tkclimb commented on a change in pull request #4483: [WIP][relay][op] add 
expand op (from ONNX) to relay frontend
URL: https://github.com/apache/incubator-tvm/pull/4483#discussion_r356373570
 
 

 ##########
 File path: tests/python/frontend/onnx/test_forward.py
 ##########
 @@ -142,6 +142,37 @@ def test_reshape():
     tvm.testing.assert_allclose(ref_shape, tvm_out.shape)
 
 
+def test_expand():
+    in_shape = (1, 3, 1, 4)
+    shape = (4, 3, 3, 4)
+    ref_shape = (4, 3, 3, 4)
+
+    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='expand_test')
+
+    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 just directory ran `python tests/python/frontend/onnx/test_forward.py`  
then it failed. it seems it's not proper way to do the test so, I'm checking 
the procedure and run.

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