tvm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-tvm] trevor-m commented on a change in pull request #5106: [Relay][MergeComposite] Support TupleGetItem in body of pattern
Date Tue, 24 Mar 2020 17:33:19 GMT
trevor-m 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_r397337604
 
 

 ##########
 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:
   Thanks for reviewing!
   `pattern->tuple` can be a tuple or it can be any node with a TupleType output. In this
call it is a Call node (batch_norm) which has multiple outputs so the output is a TupleType.

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


With regards,
Apache Git Services

Mime
View raw message