Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Relax] Fix fuseOps via pattern #17160

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix fuseops via pattern
  • Loading branch information
Hzfengsy committed Jul 16, 2024
commit 35cf40d2bf261ef13736b86634be6cf460b4f10b
15 changes: 10 additions & 5 deletions src/relax/transform/fuse_ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,12 @@ class CompositeFunctionAnnotator : public ExprMutator {
IRModule Run() {
auto mod = builder_->GetContextIRModule();
for (const auto& gv : mod->GetGlobalVars()) {
const auto& base_func = mod->Lookup(gv);
auto it = mod->functions.find(gv);
// Note that the fusion pass may have already removed the function.
if (it == mod->functions.end()) {
continue;
}
const auto& base_func = (*it).second;
if (const auto* func = base_func.as<FunctionNode>()) {
if (func->GetAttr<String>(attr::kComposite).defined() ||
func->GetAttr<String>(attr::kCodegen).defined()) {
Expand Down Expand Up @@ -1399,7 +1404,7 @@ Pass FuseOps(int fuse_opt_level) {
};
return CreateModulePass(/*pass_function=*/pass_func, //
/*opt_level=*/0, //
/*pass_name=*/"FuseOps", //
/*name=*/"FuseOps", //
/*required=*/{});
}

Expand All @@ -1412,9 +1417,9 @@ Pass FuseOpsByPattern(const tvm::Array<FusionPattern>& patterns, bool bind_const
return relax::FuseOpsByPattern(patterns, m, bind_constants, annotate_codegen,
entry_function_names);
};
return CreateModulePass(/*pass_function=*/pass_func, //
/*opt_level=*/0, //
/*pass_name=*/"FuseOpsByPattern", //
return CreateModulePass(/*pass_function=*/pass_func, //
/*opt_level=*/0, //
/*name=*/"FuseOpsByPattern", //
/*required=*/{});
}

Expand Down
Loading