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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]