altanh commented on a change in pull request #8597:
URL: https://github.com/apache/tvm/pull/8597#discussion_r683865198
##########
File path: tests/python/relay/test_backend_interpreter.py
##########
@@ -222,28 +218,72 @@ def test_tuple_passing():
dev = tvm.cpu()
target = tvm.target.Target("llvm")
- exec = relay.create_executor(mod=mod, device=dev, target=target)
- f = exec.evaluate(gv)
+ f = relay.create_executor(mod=mod, device=dev, target=target).evaluate(gv)
# First use a Python tuple.
out = f((10, 8))
- tvm.testing.assert_allclose(out.numpy(), np.array(10))
+ testing.assert_allclose(out.numpy(), np.array(10))
# Second use a tuple value.
value_tuple = container.tuple_object([nd.array(np.array(11)),
nd.array(np.array(12))])
out = f(value_tuple)
- tvm.testing.assert_allclose(out.numpy(), np.array(11))
+ testing.assert_allclose(out.numpy(), np.array(11))
+
+
+def test_dynamic():
+ n = 3
+ m = 2
+ x = relay.Var("x", relay.TensorType([relay.Any(), m], "float32"))
+ y = relay.Var("y", relay.TensorType([relay.Any(), m], "float32"))
+ xx = x - relay.expr.const(3.0)
+ yy = y * relay.expr.const(5.0)
+ z = relay.op.concatenate([xx, yy], axis=0)
+ mod = tvm.IRModule()
+ mod["main"] = relay.Function([x, y], z)
+ x_np = np.random.uniform(size=(n, m)).astype("float32")
+ y_np = np.random.uniform(size=(n, m)).astype("float32")
+ expected = np.concatenate([x_np - 3.0, y_np * 5.0], axis=0)
+ check_eval(None, [x_np, y_np], expected, mod)
+
+
+def test_ref_global_from_expr():
+ n = 3
+ x = relay.Var("x", relay.TensorType([n], "float32"))
+ y = relay.Var("y", relay.TensorType([n], "float32"))
+ mod = tvm.IRModule()
+ mod["add"] = relay.Function([x, y], relay.add(x, y))
+ x_np = np.random.uniform(size=(n)).astype("float32")
+ y_np = np.random.uniform(size=(n)).astype("float32")
Review comment:
```suggestion
y_np = np.random.uniform(size=(n,)).astype("float32")
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]