cchung100m commented on a change in pull request #5073: [Relay][Frontend][ONNX] 
operator support NonZero
URL: https://github.com/apache/incubator-tvm/pull/5073#discussion_r393634206
 
 

 ##########
 File path: tests/python/frontend/onnx/test_forward.py
 ##########
 @@ -30,6 +30,30 @@
 import scipy
 
 
+def get_tvm_output_with_vm(graph_def, input_data, target, ctx,
+                           opset=None, mode=None):
+    """ Generic function to execute and get tvm output with vm executor"""
+    if isinstance(input_data, list):
+        input_names = {}
+        shape_dict = {}
+        dtype_dict = {}
+        for i, _ in enumerate(input_data):
+            input_names[i] = graph_def.graph.input[i].name
+            shape_dict[input_names[i]] = input_data[i].shape
+            dtype_dict[input_names[i]] = input_data[i].dtype
+    else:
+        input_names = graph_def.graph.input[0].name
+        shape_dict = {input_names: input_data.shape}
+        dtype_dict = {input_names: input_data.dtype}
+
+    mod, params = relay.frontend.from_onnx(graph_def, shape_dict, opset=opset)
+
+    ex = relay.create_executor(mode, mod=mod, ctx=tvm.cpu(), target=target)
+    indata = tvm.nd.array(input_data)
+    result = ex.evaluate()(indata)
+    return result.asnumpy().transpose()
 
 Review comment:
   The output shape of argwhere is different from the one of ONNX nonzero. I 
move the transpose() to 
[here](https://github.com/apache/incubator-tvm/pull/5073/files#diff-03149f7671cff8be6734838f7707a24dR1455).

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to