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_r343821615
##########
File path: tests/python/frontend/onnx/test_forward.py
##########
@@ -142,6 +142,123 @@ def test_reshape():
tvm.testing.assert_allclose(ref_shape, tvm_out.shape)
+def verify_depth_to_space(indata, outdata, mode="DCR"):
+ node = onnx.helper.make_node('DepthToSpace',
+ inputs=['x'],
+ outputs=['y'],
+ blocksize=2,
+ mode=mode)
+
+ graph = helper.make_graph([node],
+ "depth_to_space_test",
+ inputs=[helper.make_tensor_value_info("x",
TensorProto.FLOAT, list(indata.shape))],
+ outputs=[helper.make_tensor_value_info("y",
TensorProto.FLOAT, list(outdata.shape))])
+ model = helper.make_model(graph, producer_name='depth_to_space_test')
+
+ for target, ctx in ctx_list():
+ tvm_out = get_tvm_output(model, [indata], target, ctx, outdata.shape,
'float32')
+
+ tvm.testing.assert_allclose(outdata, tvm_out)
+
+
+def test_depth_to_space():
+ # CRD mode
+ # (1, 8, 2, 3) input tensor
+ x = np.array([[[[0., 1., 2.],
Review comment:
I'm not a big fan of using hardcoded test tensors like this. Would it be
possible to just generate a random numpy tensor for test data? Although numpy
doesn't have its own depth to space or space to depth operators, you could
consider using `get_caffe2_output` on the Onnx model to test against.
----------------------------------------------------------------
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