mbaret commented on a change in pull request #6655:
URL: https://github.com/apache/incubator-tvm/pull/6655#discussion_r504073541



##########
File path: tests/python/relay/test_pass_annotate_target.py
##########
@@ -327,6 +327,42 @@ def after():
     assert tvm.ir.structural_equal(expected, result)
 
 
+def test_tuple_two_targets():
+    """Tests whether the TupleNode is promoted to previously annotatated 
operation or is excluded."""
+    target_relu = "relu_target"
+    target_maximum = "maximum_target"
+    target_default = "default"
+
+    @tvm.ir.register_op_attr("nn.relu", "target." + target_relu)
+    def relu(attrs, args):  # pylint: disable=unused-variable
+        return True
+
+    @tvm.ir.register_op_attr("maximum", "target." + target_maximum)
+    def maximum(attrs, args):  # pylint: disable=unused-variable
+        return True
+
+    def before():
+        a = relay.var("a", shape=(10, 5))
+        b = relay.var("b", shape=(10, 5))
+        r = relay.nn.relu(b)
+        t1 = relay.Tuple((r, r))
+        r2 = relay.nn.relu(t1)
+        m = relay.maximum(a, b)
+        t2 = relay.Tuple((m, r2))
+        f = relay.Function([a, b], t2)
+        return tvm.IRModule.from_expr(f)
+
+    for default_tuples, parts in [(True, 3), (False, 2)]:
+        result = before()
+        result = transform.AnnotateTarget([target_relu], 
default_tuples)(result)
+        result = transform.AnnotateTarget([target_maximum], True)(result)

Review comment:
       Yeah, it's just confusing that we have two different ways to achieve the 
same result. Given multiple runs are supported, it seems like we don't need to 
complexity of supporting a list of targets.




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