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



##########
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:
       List of targets serves for the different purpose. List of target allows 
us to have a whole picture during the annotation. We can determine which target 
an op should be annotated by considering the region size, for example. As a 
result, I personally prefer to have a list of targets instead of multiple runs 
if we could. However, given the scenario you provided, which two targets 
require different graphs, it seems inevitable.




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