cchung100m commented on a change in pull request #4483: [relay][op] add expand
op (from ONNX) to relay frontend
URL: https://github.com/apache/incubator-tvm/pull/4483#discussion_r358570937
##########
File path: tests/python/frontend/onnx/test_forward.py
##########
@@ -142,6 +142,43 @@ def test_reshape():
tvm.testing.assert_allclose(ref_shape, tvm_out.shape)
+def test_expand():
+
+ def _test(name, in_shap, shape, ref_shape):
+ shape_array = np.array(shape)
+ ref_node = onnx.helper.make_node('Constant',
+ inputs=[],
+ outputs=['shape'],
+ value=onnx.helper.make_tensor(name =
'const_tensor',
+ data_type =
onnx.TensorProto.INT32,
+ dims =
shape_array.shape,
+ vals =
shape_array.flatten().astype(int)))
+ expand_node = helper.make_node("Expand", ["in", "shape"], ["out"])
+
+ graph = helper.make_graph([ref_node, expand_node],
+ "expand_node",
+ inputs = [helper.make_tensor_value_info("in",
+ TensorProto.FLOAT,
list(in_shape))],
+ outputs = [helper.make_tensor_value_info("out",
+ TensorProto.FLOAT,
list(ref_shape))])
+
+ model = helper.make_model(graph, producer_name=name)
+
+ for target, ctx in ctx_list():
+ x = np.random.uniform(size=in_shape).astype('int32')
+ tvm_out = get_tvm_output(model, x, target, ctx, ref_shape,
'float32')
+
+ tvm.testing.assert_allclose(ref_shape, tvm_out.shape)
Review comment:
I think we should test the actual values instead of just their shapes.
----------------------------------------------------------------
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