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 2021/10/11 17:45:34 UTC

[GitHub] [tvm] rkimball opened a new pull request #9248: Propagate tvm target through graph tuning setup

rkimball opened a new pull request #9248:
URL: https://github.com/apache/tvm/pull/9248


   This allows for targets other than llvm to run graph tuning.


-- 
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] comaniac commented on a change in pull request #9248: Propagate tvm target through graph tuning setup

Posted by GitBox <gi...@apache.org>.
comaniac commented on a change in pull request #9248:
URL: https://github.com/apache/tvm/pull/9248#discussion_r726491354



##########
File path: python/tvm/autotvm/graph_tuner/utils/traverse_graph.py
##########
@@ -130,8 +130,11 @@ def _traverse_expr(node):
                 call = relay.Call(node.op, params, node.attrs)
                 mod = tvm.IRModule.from_expr(relay.Function(params, call))
                 relay.backend.compile_engine.get().clear()
+                target_string = (
+                    tvm_target if " -device" in tvm_target else f"{tvm_target} -device=tracing"
+                )
                 build_thread = threading.Thread(
-                    target=relay.build, args=(mod, f"{tvm_target} -device=tracing", None, None)
+                    target=relay.build, args=(mod, target_string, None, None)

Review comment:
       It seems not correct. IIUC, we need `-device` to be `tracing` in graph tuner.




-- 
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] rkimball commented on a change in pull request #9248: Propagate tvm target through graph tuning setup

Posted by GitBox <gi...@apache.org>.
rkimball commented on a change in pull request #9248:
URL: https://github.com/apache/tvm/pull/9248#discussion_r727253356



##########
File path: tests/python/unittest/test_autotvm_graph_tuner_utils.py
##########
@@ -155,6 +158,19 @@ def test_get_out_nodes():
         )
 
 
+@pytest.mark.parametrize(
+    "target,expected",
+    [
+        pytest.param("llvm", "llvm -device=tracing"),
+        pytest.param("llvm -device=arm_cpu -arg=xxx", "llvm -device=tracing -arg=xxx"),
+        pytest.param("llvm -device=arm_cpu", "llvm -device=tracing"),
+        pytest.param("llvm -device=abc, def", "llvm -device=tracing"),

Review comment:
       The first test there checks where the device flag is at EOL which is a special case that needs to be tested.
   The second one has a space in the device flag items which is strange but I did find an example in the codebase here https://github.com/apache/tvm/blob/main/tests/python/driver/tvmc/test_tvmc_common.py#L267
   I added/changed some tests for cuda




-- 
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] rkimball commented on a change in pull request #9248: Propagate tvm target through graph tuning setup

Posted by GitBox <gi...@apache.org>.
rkimball commented on a change in pull request #9248:
URL: https://github.com/apache/tvm/pull/9248#discussion_r726459570



##########
File path: python/tvm/autotvm/graph_tuner/utils/traverse_graph.py
##########
@@ -129,7 +131,7 @@ def _traverse_expr(node):
                 mod = tvm.IRModule.from_expr(relay.Function(params, call))
                 relay.backend.compile_engine.get().clear()
                 build_thread = threading.Thread(
-                    target=relay.build, args=(mod, "llvm -device=tracing", None, None)
+                    target=relay.build, args=(mod, f"{tvm_target} -device=tracing", None, None)

Review comment:
       Good question. I will look into the code around `-device` and add some code to handle that if needed.
   




-- 
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] mbrookhart commented on pull request #9248: Propagate tvm target through graph tuning setup

Posted by GitBox <gi...@apache.org>.
mbrookhart commented on pull request #9248:
URL: https://github.com/apache/tvm/pull/9248#issuecomment-942446645


   Thanks @rkimball @comaniac 


-- 
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] mbrookhart merged pull request #9248: Propagate tvm target through graph tuning setup

Posted by GitBox <gi...@apache.org>.
mbrookhart merged pull request #9248:
URL: https://github.com/apache/tvm/pull/9248


   


-- 
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] comaniac commented on a change in pull request #9248: Propagate tvm target through graph tuning setup

Posted by GitBox <gi...@apache.org>.
comaniac commented on a change in pull request #9248:
URL: https://github.com/apache/tvm/pull/9248#discussion_r726611467



##########
File path: python/tvm/autotvm/graph_tuner/utils/traverse_graph.py
##########
@@ -130,8 +130,11 @@ def _traverse_expr(node):
                 call = relay.Call(node.op, params, node.attrs)
                 mod = tvm.IRModule.from_expr(relay.Function(params, call))
                 relay.backend.compile_engine.get().clear()
+                target_string = (
+                    tvm_target if " -device" in tvm_target else f"{tvm_target} -device=tracing"
+                )
                 build_thread = threading.Thread(
-                    target=relay.build, args=(mod, f"{tvm_target} -device=tracing", None, None)
+                    target=relay.build, args=(mod, target_string, None, None)

Review comment:
       Gotcha. Ok then let's keep the current solution that only overrides `-device`.




-- 
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] comaniac commented on a change in pull request #9248: Propagate tvm target through graph tuning setup

Posted by GitBox <gi...@apache.org>.
comaniac commented on a change in pull request #9248:
URL: https://github.com/apache/tvm/pull/9248#discussion_r726605124



##########
File path: python/tvm/autotvm/graph_tuner/utils/traverse_graph.py
##########
@@ -130,8 +130,11 @@ def _traverse_expr(node):
                 call = relay.Call(node.op, params, node.attrs)
                 mod = tvm.IRModule.from_expr(relay.Function(params, call))
                 relay.backend.compile_engine.get().clear()
+                target_string = (
+                    tvm_target if " -device" in tvm_target else f"{tvm_target} -device=tracing"
+                )
                 build_thread = threading.Thread(
-                    target=relay.build, args=(mod, f"{tvm_target} -device=tracing", None, None)
+                    target=relay.build, args=(mod, target_string, None, None)

Review comment:
       Hmm I see. Would that be even simpler to just do something like the following if other attributes don't matter?
   ```
   f"{tvm_target.kind} -device=tracing"
   ```




-- 
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] rkimball commented on a change in pull request #9248: Propagate tvm target through graph tuning setup

Posted by GitBox <gi...@apache.org>.
rkimball commented on a change in pull request #9248:
URL: https://github.com/apache/tvm/pull/9248#discussion_r726609974



##########
File path: python/tvm/autotvm/graph_tuner/utils/traverse_graph.py
##########
@@ -130,8 +130,11 @@ def _traverse_expr(node):
                 call = relay.Call(node.op, params, node.attrs)
                 mod = tvm.IRModule.from_expr(relay.Function(params, call))
                 relay.backend.compile_engine.get().clear()
+                target_string = (
+                    tvm_target if " -device" in tvm_target else f"{tvm_target} -device=tracing"
+                )
                 build_thread = threading.Thread(
-                    target=relay.build, args=(mod, f"{tvm_target} -device=tracing", None, None)
+                    target=relay.build, args=(mod, target_string, None, None)

Review comment:
       We want this to work flags like `-libs=cudnn` for things like BoBW so I think other flags may be required to build the workload.




-- 
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] comaniac commented on a change in pull request #9248: Propagate tvm target through graph tuning setup

Posted by GitBox <gi...@apache.org>.
comaniac commented on a change in pull request #9248:
URL: https://github.com/apache/tvm/pull/9248#discussion_r727311387



##########
File path: python/tvm/autotvm/graph_tuner/utils/traverse_graph.py
##########
@@ -50,6 +51,8 @@ def expr2graph(expr, target_ops, node_dict, node_list):
         Each node will be stored as a dictionary in the format of
         {"op": str, "node": tvm.relay.expr, "inputs": [int], "types": [tvm.relay.Type],
          "name": str, "workloads": [tuple], "topi_op": [function]}
+
+    tvm_target : The TVM Target

Review comment:
       Please follow the docstring format:
   ```
   param_name: type
       Description.
   ```

##########
File path: tests/python/unittest/test_autotvm_graph_tuner_utils.py
##########
@@ -57,7 +60,7 @@ def test_has_multiple_inputs():
     target_ops = [relay.op.get("nn.conv2d")]
     node_list = []
     node_dict = {}
-    expr2graph(net, target_ops, node_dict, node_list)
+    expr2graph(net, target_ops, node_dict, node_list, tvm.target.target.Target("llvm"))

Review comment:
       nit: could be just `tvm.target.Target("llvm")`




-- 
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] comaniac commented on a change in pull request #9248: Propagate tvm target through graph tuning setup

Posted by GitBox <gi...@apache.org>.
comaniac commented on a change in pull request #9248:
URL: https://github.com/apache/tvm/pull/9248#discussion_r726605124



##########
File path: python/tvm/autotvm/graph_tuner/utils/traverse_graph.py
##########
@@ -130,8 +130,11 @@ def _traverse_expr(node):
                 call = relay.Call(node.op, params, node.attrs)
                 mod = tvm.IRModule.from_expr(relay.Function(params, call))
                 relay.backend.compile_engine.get().clear()
+                target_string = (
+                    tvm_target if " -device" in tvm_target else f"{tvm_target} -device=tracing"
+                )
                 build_thread = threading.Thread(
-                    target=relay.build, args=(mod, f"{tvm_target} -device=tracing", None, None)
+                    target=relay.build, args=(mod, target_string, None, None)

Review comment:
       Hmm I see. Would that be even simpler to just do something like the following?
   ```
   f"{tvm_target.kind} -device=tracing"
   ```




-- 
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] rkimball commented on a change in pull request #9248: Propagate tvm target through graph tuning setup

Posted by GitBox <gi...@apache.org>.
rkimball commented on a change in pull request #9248:
URL: https://github.com/apache/tvm/pull/9248#discussion_r726550394



##########
File path: python/tvm/autotvm/graph_tuner/utils/traverse_graph.py
##########
@@ -130,8 +130,11 @@ def _traverse_expr(node):
                 call = relay.Call(node.op, params, node.attrs)
                 mod = tvm.IRModule.from_expr(relay.Function(params, call))
                 relay.backend.compile_engine.get().clear()
+                target_string = (
+                    tvm_target if " -device" in tvm_target else f"{tvm_target} -device=tracing"
+                )
                 build_thread = threading.Thread(
-                    target=relay.build, args=(mod, f"{tvm_target} -device=tracing", None, None)
+                    target=relay.build, args=(mod, target_string, None, None)

Review comment:
       Should I remove `-device=XXX` from tvm_target and then append `-device=tracking`?




-- 
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] comaniac commented on a change in pull request #9248: Propagate tvm target through graph tuning setup

Posted by GitBox <gi...@apache.org>.
comaniac commented on a change in pull request #9248:
URL: https://github.com/apache/tvm/pull/9248#discussion_r726562287



##########
File path: python/tvm/autotvm/graph_tuner/utils/traverse_graph.py
##########
@@ -130,8 +130,11 @@ def _traverse_expr(node):
                 call = relay.Call(node.op, params, node.attrs)
                 mod = tvm.IRModule.from_expr(relay.Function(params, call))
                 relay.backend.compile_engine.get().clear()
+                target_string = (
+                    tvm_target if " -device" in tvm_target else f"{tvm_target} -device=tracing"
+                )
                 build_thread = threading.Thread(
-                    target=relay.build, args=(mod, f"{tvm_target} -device=tracing", None, None)
+                    target=relay.build, args=(mod, target_string, None, None)

Review comment:
       I don't know if that would work to be honest. IIUC, graph tuner currently was only used for x86 CPUs, which targets don't have `-device` at all.




-- 
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] rkimball commented on a change in pull request #9248: Propagate tvm target through graph tuning setup

Posted by GitBox <gi...@apache.org>.
rkimball commented on a change in pull request #9248:
URL: https://github.com/apache/tvm/pull/9248#discussion_r726566056



##########
File path: python/tvm/autotvm/graph_tuner/utils/traverse_graph.py
##########
@@ -130,8 +130,11 @@ def _traverse_expr(node):
                 call = relay.Call(node.op, params, node.attrs)
                 mod = tvm.IRModule.from_expr(relay.Function(params, call))
                 relay.backend.compile_engine.get().clear()
+                target_string = (
+                    tvm_target if " -device" in tvm_target else f"{tvm_target} -device=tracing"
+                )
                 build_thread = threading.Thread(
-                    target=relay.build, args=(mod, f"{tvm_target} -device=tracing", None, None)
+                    target=relay.build, args=(mod, target_string, None, None)

Review comment:
       I found this in traverse_graph.py. tracing is only used trace the calls to topi, not for building anything so replacing the device with `tracing` here should be fine.
   I did test this with cuda and it no longer crashes and completes successfully and the model runs.
   ```
   # Utilize tracing target to fetch workload with topo-order.
   # Since we only need workload, dummy target can be used to
   # create task.
   ```
   I'm going to remove any `device=XXX` here and replace it with `-device=tracing`. This is just for this function.
   




-- 
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] rkimball commented on a change in pull request #9248: Propagate tvm target through graph tuning setup

Posted by GitBox <gi...@apache.org>.
rkimball commented on a change in pull request #9248:
URL: https://github.com/apache/tvm/pull/9248#discussion_r726566056



##########
File path: python/tvm/autotvm/graph_tuner/utils/traverse_graph.py
##########
@@ -130,8 +130,11 @@ def _traverse_expr(node):
                 call = relay.Call(node.op, params, node.attrs)
                 mod = tvm.IRModule.from_expr(relay.Function(params, call))
                 relay.backend.compile_engine.get().clear()
+                target_string = (
+                    tvm_target if " -device" in tvm_target else f"{tvm_target} -device=tracing"
+                )
                 build_thread = threading.Thread(
-                    target=relay.build, args=(mod, f"{tvm_target} -device=tracing", None, None)
+                    target=relay.build, args=(mod, target_string, None, None)

Review comment:
       I found this in traverse_graph.py. tracing is only used trace the calls to topi, not for building anything so replacing the device with `tracing` here should be fine.
   I did test this with cuda and it no longer crashes and completes successfully and the model runs.
   ```
   # Utilize tracing target to fetch workload with topo-order.
   # Since we only need workload, dummy target can be used to
   # create task.
   ```




-- 
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] rkimball commented on a change in pull request #9248: Propagate tvm target through graph tuning setup

Posted by GitBox <gi...@apache.org>.
rkimball commented on a change in pull request #9248:
URL: https://github.com/apache/tvm/pull/9248#discussion_r726475382



##########
File path: python/tvm/autotvm/graph_tuner/utils/traverse_graph.py
##########
@@ -129,7 +131,7 @@ def _traverse_expr(node):
                 mod = tvm.IRModule.from_expr(relay.Function(params, call))
                 relay.backend.compile_engine.get().clear()
                 build_thread = threading.Thread(
-                    target=relay.build, args=(mod, "llvm -device=tracing", None, None)
+                    target=relay.build, args=(mod, f"{tvm_target} -device=tracing", None, None)

Review comment:
       Since there should only be one `device` I added a check so it is not appended if already present.
   




-- 
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] mbrookhart commented on pull request #9248: Propagate tvm target through graph tuning setup

Posted by GitBox <gi...@apache.org>.
mbrookhart commented on pull request #9248:
URL: https://github.com/apache/tvm/pull/9248#issuecomment-942446645


   Thanks @rkimball @comaniac 


-- 
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] comaniac commented on a change in pull request #9248: Propagate tvm target through graph tuning setup

Posted by GitBox <gi...@apache.org>.
comaniac commented on a change in pull request #9248:
URL: https://github.com/apache/tvm/pull/9248#discussion_r726455535



##########
File path: python/tvm/autotvm/graph_tuner/utils/traverse_graph.py
##########
@@ -129,7 +131,7 @@ def _traverse_expr(node):
                 mod = tvm.IRModule.from_expr(relay.Function(params, call))
                 relay.backend.compile_engine.get().clear()
                 build_thread = threading.Thread(
-                    target=relay.build, args=(mod, "llvm -device=tracing", None, None)
+                    target=relay.build, args=(mod, f"{tvm_target} -device=tracing", None, None)

Review comment:
       Is it possible to have duplicated `-device` if `tvm_target` already specifies one?




-- 
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] rkimball commented on a change in pull request #9248: Propagate tvm target through graph tuning setup

Posted by GitBox <gi...@apache.org>.
rkimball commented on a change in pull request #9248:
URL: https://github.com/apache/tvm/pull/9248#discussion_r727253356



##########
File path: tests/python/unittest/test_autotvm_graph_tuner_utils.py
##########
@@ -155,6 +158,19 @@ def test_get_out_nodes():
         )
 
 
+@pytest.mark.parametrize(
+    "target,expected",
+    [
+        pytest.param("llvm", "llvm -device=tracing"),
+        pytest.param("llvm -device=arm_cpu -arg=xxx", "llvm -device=tracing -arg=xxx"),
+        pytest.param("llvm -device=arm_cpu", "llvm -device=tracing"),
+        pytest.param("llvm -device=abc, def", "llvm -device=tracing"),

Review comment:
       The first test there checks where the device flag is at EOL which is a special case that needs to be tested.
   The second one has a space in the device flag items which is strange but I did find an example in the codebase here https://github.com/apache/tvm/blob/main/tests/python/driver/tvmc/test_tvmc_common.py#L267
   I added/changed some tests for cuda




-- 
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] comaniac commented on a change in pull request #9248: Propagate tvm target through graph tuning setup

Posted by GitBox <gi...@apache.org>.
comaniac commented on a change in pull request #9248:
URL: https://github.com/apache/tvm/pull/9248#discussion_r726611923



##########
File path: python/tvm/autotvm/graph_tuner/utils/traverse_graph.py
##########
@@ -50,6 +51,8 @@ def expr2graph(expr, target_ops, node_dict, node_list):
         Each node will be stored as a dictionary in the format of
         {"op": str, "node": tvm.relay.expr, "inputs": [int], "types": [tvm.relay.Type],
          "name": str, "workloads": [tuple], "topi_op": [function]}
+
+    tvm_target : The TVM Target

Review comment:
       ```suggestion
       tvm_target : tvm.target
           The TVM target object.
   ```
   Also please double check the target type. Based on `base_graph_tuner.py:L134`, it seems to me that this is always a target object instead of a target string.

##########
File path: tests/python/unittest/test_autotvm_graph_tuner_utils.py
##########
@@ -57,7 +60,7 @@ def test_has_multiple_inputs():
     target_ops = [relay.op.get("nn.conv2d")]
     node_list = []
     node_dict = {}
-    expr2graph(net, target_ops, node_dict, node_list)
+    expr2graph(net, target_ops, node_dict, node_list, "llvm")

Review comment:
       Be careful about the target type.

##########
File path: python/tvm/autotvm/graph_tuner/utils/traverse_graph.py
##########
@@ -77,7 +80,16 @@ def _infer_type(node):
     return entry if isinstance(node, relay.Function) else entry.body
 
 
-def _expr2graph_impl(expr, target_ops, node_dict, node_list):
+def _replace_device_with_tracing(target):
+    """This is to replace -device=XXX with -device=tracing in the tvm_target string.
+    It is a stand-along function for testability"""

Review comment:
       1. Write down more explanations in our discussion, including why we need to override and why it is safe.
   2. Add parameter and return type.

##########
File path: tests/python/unittest/test_autotvm_graph_tuner_utils.py
##########
@@ -155,6 +158,19 @@ def test_get_out_nodes():
         )
 
 
+@pytest.mark.parametrize(
+    "target,expected",
+    [
+        pytest.param("llvm", "llvm -device=tracing"),
+        pytest.param("llvm -device=arm_cpu -arg=xxx", "llvm -device=tracing -arg=xxx"),
+        pytest.param("llvm -device=arm_cpu", "llvm -device=tracing"),
+        pytest.param("llvm -device=abc, def", "llvm -device=tracing"),

Review comment:
       I don't think we need these 2. Instead, could we add a case for cuda?

##########
File path: python/tvm/autotvm/graph_tuner/utils/traverse_graph.py
##########
@@ -77,7 +80,16 @@ def _infer_type(node):
     return entry if isinstance(node, relay.Function) else entry.body
 
 
-def _expr2graph_impl(expr, target_ops, node_dict, node_list):
+def _replace_device_with_tracing(target):
+    """This is to replace -device=XXX with -device=tracing in the tvm_target string.
+    It is a stand-along function for testability"""
+    if "-device" in target:
+        return re.sub("-device=[^\\-$]+", "-device=tracing ", target).strip(" ")
+    else:
+        return target + " -device=tracing"

Review comment:
       Note that the input target is an object, not a string.
   ```python
   if "device" in target.attrs:
     return re.sub("-device=[^\\-$]+", "-device=tracing ", str(target)).strip(" ")
   else:
     return ("%s -device=tracing" % str(target)).strip(" ")
   ```




-- 
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] comaniac commented on a change in pull request #9248: Propagate tvm target through graph tuning setup

Posted by GitBox <gi...@apache.org>.
comaniac commented on a change in pull request #9248:
URL: https://github.com/apache/tvm/pull/9248#discussion_r727311387



##########
File path: python/tvm/autotvm/graph_tuner/utils/traverse_graph.py
##########
@@ -50,6 +51,8 @@ def expr2graph(expr, target_ops, node_dict, node_list):
         Each node will be stored as a dictionary in the format of
         {"op": str, "node": tvm.relay.expr, "inputs": [int], "types": [tvm.relay.Type],
          "name": str, "workloads": [tuple], "topi_op": [function]}
+
+    tvm_target : The TVM Target

Review comment:
       Please follow the docstring format:
   ```
   param_name: type
       Description.
   ```

##########
File path: tests/python/unittest/test_autotvm_graph_tuner_utils.py
##########
@@ -57,7 +60,7 @@ def test_has_multiple_inputs():
     target_ops = [relay.op.get("nn.conv2d")]
     node_list = []
     node_dict = {}
-    expr2graph(net, target_ops, node_dict, node_list)
+    expr2graph(net, target_ops, node_dict, node_list, tvm.target.target.Target("llvm"))

Review comment:
       nit: could be just `tvm.target.Target("llvm")`




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