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 2021/11/04 20:13:33 UTC
[GitHub] [tvm] jrfonseca opened a new issue #9448: [Bug]
jrfonseca opened a new issue #9448:
URL: https://github.com/apache/tvm/issues/9448
@tqchen, I was trying v0.8 but noticed a regression in `reshape` when used with `set_input_zero_copy`. I bisected the rergession to commit b2c4f1c2cbd4c4b7ac27ac853dbad7c489784444.
Here's a basic test case:
```python
import sys
import os
import tvm.relay
import tvm.contrib
import numpy as np
shape = (1, 512, 1, 1)
newshape = (1, 512)
x = tvm.relay.var("x", shape=shape, dtype='float32')
y = tvm.relay.reshape(x, newshape=newshape)
func = tvm.relay.Function([x], y)
mod = tvm.IRModule()
mod['main'] = func
sys.stderr.write(func.astext() + '\n')
targetName = 'llvm'
target = tvm.target.Target(targetName)
params = {}
lib = tvm.relay.build(mod, target, params=params)
X = np.arange(512, dtype=np.float32).reshape(shape)
expectedY = X.reshape(newshape)
try:
dev = tvm.device(targetName, 0)
except AttributeError:
dev = tvm.context(targetName, 0)
m = lib["default"](dev)
try:
gmod = tvm.contrib.graph_executor.GraphModule(m)
except AttributeError:
gmod = tvm.contrib.graph_runtime.GraphModule(m)
X = tvm.nd.array(X)
if int(os.environ.get('WORKAROUND', '0')) == 0:
# This fails...
m["set_input_zero_copy"]("x", X)
else:
# ... but this always works.
m["set_input"]("x", X)
gmod.run()
Y = gmod.get_output(0).asnumpy()
np.testing.assert_equal(Y, expectedY)
```
### Expected behavior
Test should run successfully.
### Actual behavior
```
#[version = "0.0.5"]
fn (%x: Tensor[(1, 512, 1, 1), float32]) {
reshape(%x, newshape=[1, 512])
}
Traceback (most recent call last):
File "test_reshape.py", line 49, in <module>
np.testing.assert_equal(Y, expectedY)
File "/usr/lib/python3/dist-packages/numpy/testing/_private/utils.py", line 360, in assert_equal
return assert_array_equal(actual, desired, err_msg, verbose)
File "/usr/lib/python3/dist-packages/numpy/testing/_private/utils.py", line 917, in assert_array_equal
assert_array_compare(operator.__eq__, x, y, err_msg=err_msg,
File "/usr/lib/python3/dist-packages/numpy/testing/_private/utils.py", line 841, in assert_array_compare
raise AssertionError(msg)
AssertionError:
Arrays are not equal
Mismatch: 100%
Max absolute difference: 511.
Max relative difference: 1.
x: array([[ 2.444030e-38, 0.000000e+00, 1.401298e-45, 0.000000e+00,
-2.232557e-19, 4.567392e-41, 3.643376e-44, 0.000000e+00,
-2.258280e-19, 4.567392e-41, 6.586103e-44, 0.000000e+00,...
y: array([[ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.,
11., 12., 13., 14., 15., 16., 17., 18., 19., 20., 21.,
22., 23., 24., 25., 26., 27., 28., 29., 30., 31., 32.,...
```
### Environment
Ubuntu 20.04.3 LTS
### Steps to reproduce
See script above.
--
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] jrfonseca edited a comment on issue #9448: [Bug] GraphExecutor set_input_zero_copy introduces accuracy error when used with reshape
Posted by GitBox <gi...@apache.org>.
jrfonseca edited a comment on issue #9448:
URL: https://github.com/apache/tvm/issues/9448#issuecomment-964271367
_accuracy error_ is an understatement. It gives complete garbage numbers!
--
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] jrfonseca commented on issue #9448: [Bug] GraphExecutor set_input_zero_copy introduces accuracy error when used with reshape
Posted by GitBox <gi...@apache.org>.
jrfonseca commented on issue #9448:
URL: https://github.com/apache/tvm/issues/9448#issuecomment-964271367
`accuracy error` is an understatement. It gives complete garbage numbers!
--
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] jrfonseca commented on issue #9448: [Bug]
Posted by GitBox <gi...@apache.org>.
jrfonseca commented on issue #9448:
URL: https://github.com/apache/tvm/issues/9448#issuecomment-961385288
Just to give some more context, I admit this is not a common scenario, but it was exercised when running some tests for ONNX's [Reshape](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Reshape) operator, with a single node.
--
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] jrfonseca commented on issue #9448: [Bug]
Posted by GitBox <gi...@apache.org>.
jrfonseca commented on issue #9448:
URL: https://github.com/apache/tvm/issues/9448#issuecomment-961385288
Just to give some more context, I admit this is not a common scenario, but it was exercised when running some tests for ONNX's [Reshape](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Reshape) operator, with a single node.
--
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] jrfonseca commented on issue #9448: [Bug]
Posted by GitBox <gi...@apache.org>.
jrfonseca commented on issue #9448:
URL: https://github.com/apache/tvm/issues/9448#issuecomment-961385288
Just to give some more context, I admit this is not a common scenario, but it was exercised when running some tests for ONNX's [Reshape](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Reshape) operator, with a single node.
--
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