mbrookhart commented on a change in pull request #5766:
URL: https://github.com/apache/incubator-tvm/pull/5766#discussion_r438355902



##########
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:
       Yes, partitioning doesn't assume the graph already has type information 
in general, so it doesn't re-infer.




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to