masahi commented on a change in pull request #4996: [relay][external codegen]
outline and inline lifted functions for external codegen
URL: https://github.com/apache/incubator-tvm/pull/4996#discussion_r389189824
##########
File path: src/relay/pass/partition_graph.cc
##########
@@ -207,16 +211,28 @@ class Partitioner : public ExprMutator {
}
auto subgraph_func =
- FunctionNode::make(params, input, call->args[0]->checked_type_, {},
Attrs());
+ FunctionNode::make(params, input, call->checked_type_, {}, Attrs());
- Expr arg0 = call->args[0];
std::string name = compiler_attrs->compiler + "_" +
std::to_string(subgraph->id);
subgraph_func =
FunctionSetAttr(subgraph_func, attr::kExternalSymbol,
tir::StringImmNode::make(name));
subgraph_func = FunctionSetAttr(subgraph_func, attr::kPrimitive,
tvm::Integer(1));
subgraph_func = FunctionSetAttr(subgraph_func, attr::kCompiler,
tvm::tir::StringImmNode::make(compiler_attrs->compiler));
- return CallNode::make(subgraph_func, args);
+ subgraph_func = FunctionSetAttr(subgraph_func, attr::kInline,
tvm::Integer(1));
+ CHECK(!module_->ContainGlobalVar(name))
+ << "Global function " << name << " already exists";
+ // Create a global function and add it to the IRModule for the subgraph.
+ // This way we lift the functions that should be handled by external
+ // codegen to the module scope and rely the pass manager to prevent relay
Review comment:
rely on
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services