cchung100m commented on a change in pull request #4271: [Relay][Frontend][ONNX] 
operator support: DepthToSpace, SpaceToDepth
URL: https://github.com/apache/incubator-tvm/pull/4271#discussion_r344665963
 
 

 ##########
 File path: tests/python/frontend/onnx/test_forward.py
 ##########
 @@ -77,22 +77,27 @@ def get_tvm_output(graph_def, input_data, target, ctx, 
output_shape=None, output
         return tvm_output.asnumpy()
 
 
-def get_caffe2_output(model, x, dtype='float32'):
-    import caffe2.python.onnx.backend
-    prepared_backend = caffe2.python.onnx.backend.prepare(model)
-    W = {model.graph.input[0].name: x.astype(dtype)}
-    c2_out = prepared_backend.run(W)[0]
-    return c2_out
+def get_onnxruntime_output(model, x, dtype='float32'):
+    import onnxruntime.backend
+    rep = onnxruntime.backend.prepare(model, 'CPU')
+    x = x.astype(dtype)
+    ort_out = rep.run(x)[0]
+    return ort_out
 
 
 def verify_onnx_forward_impl(graph_file, data_shape, out_shape):
     dtype = 'float32'
     x = np.random.uniform(size=data_shape)
     model = onnx.load_model(graph_file)
-    c2_out = get_caffe2_output(model, x, dtype)
-    for target, ctx in ctx_list():
-        tvm_out = get_tvm_output(model, x, target, ctx, out_shape, dtype)
-        tvm.testing.assert_allclose(c2_out, tvm_out, rtol=1e-5, atol=1e-5)
+    try:
+        c2_out = get_onnxruntime_output(model, x, dtype)
+    except onnx.onnx_cpp2py_export.checker.ValidationError as e:
 
 Review comment:
   Hi @jwfromm 
   
   Thanks for the prompt reply.
   
   I remove the most part of try excepts but `DepthToSpace` because there is a 
strange issue here:
   
   ```
   onnx.onnx_cpp2py_export.checker.ValidationError: Unrecognized attribute: 
mode for operator DepthToSpace
   
   ==> Context: Bad node spec: input: "x" output: "y" op_type: "DepthToSpace" 
attribute { name: "blocksize" i: 2 type: INT } attribute { name: "mode" s: 
"CRD" type: STRING }
   ```
   
   I check the example from 
[onnx.operator.DepthToSpace](https://github.com/onnx/onnx/blob/master/docs/Operators.md#DepthToSpace)
 document and it has the `mode` attribute for `DepthToSpace`, therefore, I keep 
the try-catch for `DepthToSpace`, currently. 

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