jwfromm 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_r344565585
##########
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:
Last one I promise, but I don't think we want to be doing try excepts here.
If tests fail its important to throw an error so it can be fixed and won't
sneak into the master branch. Did you need to add this because you were hitting
ValidationErrors?
----------------------------------------------------------------
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