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 2020/09/29 09:42:42 UTC
[GitHub] [incubator-tvm] XIAO-XIA opened a new issue #6588: [Relay][BUG] nn.dense accuracy error
XIAO-XIA opened a new issue #6588:
URL: https://github.com/apache/incubator-tvm/issues/6588
The output of relay op nn.dense seems not so accurate when working on some specific input shapes.
`data_shape = (8, 512), weight_shape = (128, 512)`
### Reproduce
```python
import numpy as np
import tvm
from tvm import relay
import tvm.testing
@tvm.testing.uses_gpu
def test_dense():
for dtype in ["float32"]:
x = relay.var("x", shape=(8, 512), dtype=dtype)
w = relay.var("w", shape=(128, 512), dtype=dtype)
z = relay.nn.dense(x, w)
# Check result.
func = relay.Function([x, w], z)
x_data = np.random.rand(8, 512).astype(dtype)
w_data = np.random.rand(128, 512).astype(dtype)
ref_res = np.dot(x_data, w_data.T)
for target, ctx in tvm.testing.enabled_targets():
intrp1 = relay.create_executor("graph", ctx=ctx, target=target)
intrp2 = relay.create_executor("debug", ctx=ctx, target=target)
op_res1 = intrp1.evaluate(func)(x_data, w_data)
tvm.testing.assert_allclose(op_res1.asnumpy(), ref_res, rtol=1e-5)
op_res2 = intrp2.evaluate(func)(x_data, w_data)
tvm.testing.assert_allclose(op_res2.asnumpy(), ref_res, rtol=1e-5)
if __name__ == "__main__":
test_dense()
```
and the output message is like below:
```
Traceback (most recent call last):
File "../test/test_ops/tvm_dense/dense.py", line 30, in <module>
test_dense()
File "../test/test_ops/tvm_dense/dense.py", line 27, in test_dense
tvm.testing.assert_allclose(op_res2.asnumpy(), ref_res, rtol=1e-5)
File "/home/ubuntu/Document/meta-project/meta/3rdparty/tvm/python/tvm/testing.py", line 77, in assert_allclose
np.testing.assert_allclose(actual, desired, rtol=rtol, atol=atol, verbose=True)
File "/home/ubuntu/anaconda3/envs/mnm-dev/lib/python3.7/site-packages/numpy/testing/_private/utils.py", line 1533, in assert_allclose
verbose=verbose, header=header, equal_nan=equal_nan)
File "/home/ubuntu/anaconda3/envs/mnm-dev/lib/python3.7/site-packages/numpy/testing/_private/utils.py", line 846, in assert_array_compare
raise AssertionError(msg)
AssertionError:
Not equal to tolerance rtol=1e-05, atol=1e-07
Mismatched elements: 570 / 1024 (55.7%)
Max absolute difference: 0.00658417
Max relative difference: 5.3529722e-05
x: array([[129.66075 , 128.89937 , 124.70353 , ..., 125.022705, 128.74326 ,
141.4742 ],
[131.87158 , 126.299194, 122.57687 , ..., 124.902275, 127.8332 ,...
y: array([[129.66115 , 128.89871 , 124.70149 , ..., 125.02127 , 128.74138 ,
141.47542 ],
[131.87265 , 126.301506, 122.579765, ..., 124.90285 , 127.83549 ,...
```
Can @yzhliu @hzfan have a look. Thanks!
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-tvm] tqchen commented on issue #6588: [Relay][BUG] nn.dense accuracy error
Posted by GitBox <gi...@apache.org>.
tqchen commented on issue #6588:
URL: https://github.com/apache/incubator-tvm/issues/6588#issuecomment-702199691
This seems to relates to the way a reduction order is formed(rfactor) and the current schedule dense. Would be useful to directly invoke the topi schedule and take a look at the generated CUDA code to see what is going on and if there is something that needs to be fixed.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org