lixiaoquan commented on a change in pull request #5429:
URL: https://github.com/apache/incubator-tvm/pull/5429#discussion_r420541474



##########
File path: tests/python/relay/test_any.py
##########
@@ -138,23 +138,35 @@ def test_any_concat():
         result = ex.evaluate()(x_np, y_np)
         tvm.testing.assert_allclose(result.asnumpy(), ref)
 
-def verify_any_reshape(x_shape, newshape, x_np_shape, out_shape):
+def verify_any_reshape(x_shape, newshape, x_np_shape, out_shape, 
variable_newshape=False):
     x = relay.var('x', shape=x_shape, dtype="float32")
+    data = np.random.uniform(size=x_np_shape).astype('float32')
+    params = [x]
+    args = [data]
+
+    if variable_newshape:
+        newshape_var = relay.var('newshape', shape=(len(newshape),), 
dtype='int64')
+        params.append(newshape_var)
+        args.append(np.array(newshape, dtype='int64'))
+        newshape = newshape_var
+
     y = relay.reshape(x, newshape=newshape)
     mod = tvm.IRModule()
-    mod["main"] = relay.Function([x], y)
-    data = np.random.uniform(size=x_np_shape).astype('float32')
+    mod["main"] = relay.Function(params, y)
+
     for kind in ["debug", "vm"]:
         ex = relay.create_executor(kind, mod=mod, ctx=tvm.cpu(), target="llvm")
-        result = ex.evaluate()(data).asnumpy()
+        result = ex.evaluate()(*args).asnumpy()
         assert result.shape == out_shape
         tvm.testing.assert_allclose(result.flatten(), data.flatten())
 
 def test_any_reshape():
-    verify_any_reshape(any_dims(3), (1, -1), (2, 3, 4), (1, 24))
-    verify_any_reshape(any_dims(3), (0, -1), (2, 3, 4), (2, 12))
+    for variable_newshape in [False, True]:
+        # Variable newshape only supports that output rank is the same as 
newshape

Review comment:
       Do you mean add some dynamic shape cases to test_op_level3? Cases in 
that file use 'graph' exectuor now and test like test_arange() only supports 
constant inputs too.




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to