You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/12/16 20:50:28 UTC
[GitHub] [tvm] shingjan opened a new issue, #13634: [Bug] [GraphModule] `get_output` returned unintialized output tensor after `set_output_zero_copy`
shingjan opened a new issue, #13634:
URL: https://github.com/apache/tvm/issues/13634
The `get_output` function of `GraphModule` returned wrong, likely uninitialized output tensor after `set_output_zero_copy`
My repro
```
mod = tvm.IRModule()
params = {}
dev = tvm.cpu()
x = relay.var("x", shape=(1, 10))
y = relay.var("y", shape=(1, 10))
z = relay.add(x, y)
mod["main"] = relay.Function([x, y], z)
# need torch to do the from_dlpack trick
import torch
compiled_graph_lib = relay.build(mod, target="llvm", params=params)
gm = graph_executor.GraphModule(compiled_graph_lib["default"](dev))
x_data = torch.rand((1, 10))
y_data = torch.rand((1, 10))
z_data = torch.rand((1, 10))
z_torch = x_data + y_data
# first run
assert not np.allclose(z_data.numpy(), z_torch.numpy())
gm.set_input_zero_copy("x", tvm.nd.from_dlpack(x_data))
gm.set_input_zero_copy("y", tvm.nd.from_dlpack(y_data))
gm.set_output_zero_copy(0, tvm.nd.from_dlpack(z_data))
gm.run()
tvm.testing.assert_allclose(z_data.numpy(), z_torch.numpy())
tvm.testing.assert_allclose(gm.get_output(0).numpy(), z_torch.numpy())
```
### Expected behavior
The second assert should pass
### Actual behavior
It failed
### Environment
Latest TVM main
cc: @vinx13
--
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: commits-unsubscribe@tvm.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] lileidev commented on issue #13634: [Bug] [GraphModule] `get_output` returned unintialized output tensor after `set_output_zero_copy`
Posted by "lileidev (via GitHub)" <gi...@apache.org>.
lileidev commented on issue #13634:
URL: https://github.com/apache/tvm/issues/13634#issuecomment-1471387682
Initialize z_data to zeros. After gm.run(), z_data elements updated to expected value. gm.get_output(0) get wrong number.
`x_data = torch.rand((1, 10))
y_data = torch.rand((1, 10))
z_data = torch.zeros((1, 10))
z_torch = x_data + y_data
print("z_data: ", z_data)
# first run
assert not np.allclose(z_data.numpy(), z_torch.numpy())
gm.set_input_zero_copy("x", tvm.nd.from_dlpack(x_data))
gm.set_input_zero_copy("y", tvm.nd.from_dlpack(y_data))
gm.set_output_zero_copy(0, tvm.nd.from_dlpack(z_data))
gm.run()
print("output: ", gm.get_output(0).numpy())
print("z_data: ", z_data)
print("z_torch: ", z_torch.numpy())
testing.assert_allclose(z_data.numpy(), z_torch.numpy())
testing.assert_allclose(gm.get_output(0).numpy(), z_torch.numpy())`
Output:
z_data: tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]])
output: [[1.093013e-43 0.000000e+00 3.222986e-44 0.000000e+00 1.121039e-44
0.000000e+00 0.000000e+00 0.000000e+00 4.958032e+12 3.073468e-41]]
z_data: tensor([[1.7693, 0.9101, 1.1325, 0.7544, 0.8513, 1.2013, 1.4561, 1.1772, 0.7521,
1.4009]])
z_torch: [[1.7692755 0.910111 1.1324804 0.7543799 0.8513221 1.2012794
1.4561145 1.177244 0.75213444 1.4009231 ]]
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] lileidev commented on issue #13634: [Bug] [GraphModule] `get_output` returned unintialized output tensor after `set_output_zero_copy`
Posted by "lileidev (via GitHub)" <gi...@apache.org>.
lileidev commented on issue #13634:
URL: https://github.com/apache/tvm/issues/13634#issuecomment-1473523968
Seems that gm.set_output_zero_copy(0, tvm.nd.from_dlpack(z_data)) affected output value. If comment this line, gm.get_output(0).numpy() will get correct value.
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug] [GraphModule] `get_output` returned unintialized output tensor after `set_output_zero_copy` [tvm]
Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen closed issue #13634: [Bug] [GraphModule] `get_output` returned unintialized output tensor after `set_output_zero_copy`
URL: https://github.com/apache/tvm/issues/13634
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org