diff --git a/python/tvm/relay/backend/interpreter.py b/python/tvm/relay/backend/interpreter.py index 7a70a6e45e17..e927df22b201 100644 --- a/python/tvm/relay/backend/interpreter.py +++ b/python/tvm/relay/backend/interpreter.py @@ -95,7 +95,7 @@ def __init__(self, value): def _arg_to_ast(arg): if isinstance(arg, TensorValue): - return Constant(arg.data.copyto(_nd.cpu(0))) + return Constant(arg.data.copyto(nd.cpu(0))) elif isinstance(arg, np.ndarray): return Constant(nd.array(arg)) elif isinstance(arg, Constant): diff --git a/tests/python/relay/test_backend_interpreter.py b/tests/python/relay/test_backend_interpreter.py index 801b3068eff0..773af1f9fe0e 100644 --- a/tests/python/relay/test_backend_interpreter.py +++ b/tests/python/relay/test_backend_interpreter.py @@ -2,7 +2,7 @@ import tvm import tvm.testing from tvm import relay -from tvm.relay.backend.interpreter import Value, TupleValue +from tvm.relay.backend.interpreter import Value, TupleValue, TensorValue from tvm.relay.scope_builder import ScopeBuilder from tvm.relay import testing, create_executor @@ -135,6 +135,11 @@ def test_binds(): tvm.testing.assert_allclose(xx + xx, res) +def test_tensor_value(): + x = relay.var("x", shape=(1, 10)) + xx = np.ones((1, 10)).astype("float32") + check_eval(relay.Function([x], x), [TensorValue(xx)], xx) + def test_kwargs_params(): x = relay.var("x", shape=(1, 10)) y = relay.var("y", shape=(1, 10)) @@ -159,3 +164,4 @@ def test_kwargs_params(): test_binds() test_kwargs_params() test_ref() + test_tensor_value()