zhiics commented on a change in pull request #5766:
URL: https://github.com/apache/incubator-tvm/pull/5766#discussion_r438322794
##########
File path: src/relay/transforms/merge_composite.cc
##########
@@ -36,17 +36,24 @@ namespace tvm {
namespace relay {
namespace merge_composite {
+Function InferType(const Function& expr) {
+ auto mod = IRModule::FromExpr(expr);
+ mod = transform::InferType()(mod);
+ return Downcast<Function>(mod->Lookup("main"));
+}
+
Expr MergeComposite(const Function& func, const Array<runtime::String>&
pattern_names,
const Array<DFPattern>& patterns, const
std::vector<PackedFunc>& checks) {
CHECK_EQ(pattern_names.size(), patterns.size());
- Expr merged_expr = func->body;
+ Function merged_func = func;
// merge the patterns one-by-one in order
for (size_t i = 0; i < patterns.size(); i++) {
Map<String, ObjectRef> attrs;
attrs.Set("Composite", pattern_names[i]);
- merged_expr = PartitionPattern(patterns[i], merged_expr, attrs, checks[i]);
+ merged_func = Downcast<Function>(PartitionPattern(patterns[i],
merged_func, attrs, checks[i]));
+ merged_func = InferType(merged_func);
Review comment:
Do we need to infer type here? The resulted function should be added the
IRModule since it is FunctionPass.
https://github.com/apache/incubator-tvm/blob/ed583092dbeb4f1b0458ad015f607f0746d61e80/src/relay/ir/transform.cc#L135
This would do type inference implicitly as module is strongly typed. Do I
miss something?
----------------------------------------------------------------
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]