You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/07/13 21:18:18 UTC

[GitHub] [tvm] mbs-octoml opened a new pull request, #12085: [Relay] Add RecoverVirtualDeviceMap helper

mbs-octoml opened a new pull request, #12085:
URL: https://github.com/apache/tvm/pull/12085

   Device planning is halfway through the transition to using the virtual_device_
   field on every expression node to capture device/target/etc info. In the meantime
   it is necessary to derive from a 'device aware' visitor so as to track device
   information. In Collage this is not feasible, so as a stop gap allow the map
   from expression nodes to virtual devices to be reconstructed as a stand alone
   map.
   
   This code can be removed once expr->virtual_device() is the canonical representation.
   


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

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] mbs-octoml commented on a diff in pull request #12085: [Relay] Add RecoverVirtualDeviceMap helper

Posted by GitBox <gi...@apache.org>.
mbs-octoml commented on code in PR #12085:
URL: https://github.com/apache/tvm/pull/12085#discussion_r920537111


##########
tests/python/relay/test_pass_plan_devices.py:
##########
@@ -241,6 +243,70 @@ def ref(a, b, c, d):
     exercise(input(), expected(), ref, rands((5, 7), 4))
 
 
+def test_left_add_on_cpu_via_copy_as_map():
+    metatable = {"VirtualDevice": [CPU, GPU]}
+
+    # As for test_left_add_on_cpu, but with an explicit device_copy.
+    def input():
+        return tvm.parser.parse(
+            """
+            #[version = "0.0.5"]
+            def @main(%a: Tensor[(5, 7), float32], %b: Tensor[(5, 7), float32],
+                      %c: Tensor[(5, 7), float32], %d: Tensor[(5, 7), float32]) {
+              %0 = add(%a, %b);
+              %1 = device_copy(%0, src_virtual_device=meta[VirtualDevice][0], dst_virtual_device=meta[VirtualDevice][1]);
+              %2 = add(%c, %d);
+              subtract(%1, %2)
+            }
+        """,
+            "from_string",
+            None,
+            metatable,
+        )
+
+    config = tvm.target.make_compilation_config(CTXT, TARGETS, HOST_TARGET)
+    actual_mod = relay.transform.InferType()(input())
+    actual_mod = relay.transform.PlanDevices(config)(actual_mod)
+    actual_mod = relay.transform.CapturePostDfsIndexInSpans()(actual_mod)
+
+    # Actual looks like:

Review Comment:
   It doesn't hurt though it is a repeat of the above test. (Tho I parse and structural assert not str assert...). 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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] tmoreau89 commented on pull request #12085: [Relay] Add RecoverVirtualDeviceMap helper

Posted by GitBox <gi...@apache.org>.
tmoreau89 commented on PR #12085:
URL: https://github.com/apache/tvm/pull/12085#issuecomment-1184232254

   Thanks @mbs-octoml and @areusch the PR has been merged.


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

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] areusch commented on a diff in pull request #12085: [Relay] Add RecoverVirtualDeviceMap helper

Posted by GitBox <gi...@apache.org>.
areusch commented on code in PR #12085:
URL: https://github.com/apache/tvm/pull/12085#discussion_r920535891


##########
tests/python/relay/test_pass_plan_devices.py:
##########
@@ -241,6 +243,70 @@ def ref(a, b, c, d):
     exercise(input(), expected(), ref, rands((5, 7), 4))
 
 
+def test_left_add_on_cpu_via_copy_as_map():
+    metatable = {"VirtualDevice": [CPU, GPU]}
+
+    # As for test_left_add_on_cpu, but with an explicit device_copy.
+    def input():
+        return tvm.parser.parse(
+            """
+            #[version = "0.0.5"]
+            def @main(%a: Tensor[(5, 7), float32], %b: Tensor[(5, 7), float32],
+                      %c: Tensor[(5, 7), float32], %d: Tensor[(5, 7), float32]) {
+              %0 = add(%a, %b);
+              %1 = device_copy(%0, src_virtual_device=meta[VirtualDevice][0], dst_virtual_device=meta[VirtualDevice][1]);
+              %2 = add(%c, %d);
+              subtract(%1, %2)
+            }
+        """,
+            "from_string",
+            None,
+            metatable,
+        )
+
+    config = tvm.target.make_compilation_config(CTXT, TARGETS, HOST_TARGET)
+    actual_mod = relay.transform.InferType()(input())
+    actual_mod = relay.transform.PlanDevices(config)(actual_mod)
+    actual_mod = relay.transform.CapturePostDfsIndexInSpans()(actual_mod)
+
+    # Actual looks like:

Review Comment:
   does it make sense to assert this via assert str(actual_mod) == """..."""?



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

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] tmoreau89 merged pull request #12085: [Relay] Add RecoverVirtualDeviceMap helper

Posted by GitBox <gi...@apache.org>.
tmoreau89 merged PR #12085:
URL: https://github.com/apache/tvm/pull/12085


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

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org