mbaret commented on a change in pull request #5106: [Relay][MergeComposite] 
Support TupleGetItem in body of pattern
URL: https://github.com/apache/incubator-tvm/pull/5106#discussion_r398109720
 
 

 ##########
 File path: src/relay/transforms/merge_composite.cc
 ##########
 @@ -66,6 +66,31 @@ class MergeCompositeWrapper : public ExprMutator {
     return root;
   }
 
+  Expr ExtractPattern(const TupleGetItem& pattern, const Expr& root,
+      Map<std::string, Array<Expr>>* var_map, Map<Expr, Expr>* call_map) {
+    if (!root->IsInstance<TupleGetItemNode>()) {
+      return Expr();
+    }
+    auto root_node = Downcast<TupleGetItem>(root);
+    if (pattern->index != root_node->index) {
+      return Expr();
+    }
+    if (pattern->tuple->IsInstance<CallNode>() &&
+        root_node->tuple->IsInstance<CallNode>()) {
+      Expr new_arg;
+      if (call_map->find(pattern->tuple) != call_map->end()) {
+        new_arg = (*call_map)[pattern->tuple];
+      } else {
+        new_arg = ExtractPattern(Downcast<Call>(pattern->tuple),
 
 Review comment:
   Ah, I get it now, thanks.

----------------------------------------------------------------
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


With regards,
Apache Git Services

Reply via email to