cxx122 opened a new issue, #12373:
URL: https://github.com/apache/tvm/issues/12373
```
REDUCE_0 = te.reduce_axis((5, 0), name="REDUCE_0")
REDUCE_1 = te.reduce_axis((7, 0), name="REDUCE_1")
TENSOR_0 = te.placeholder([10,10,10,10], dtype="int8", name="TENSOR_0")
TENSOR_1 = te.compute([10,10], lambda
mcq,uch:te.sum(expr=TENSOR_0[REDUCE_0,mcq,uch,REDUCE_1],
axis=[REDUCE_0,REDUCE_1]), name ="TENSOR_1")
```
The args in the reduce_axis should be like (0,5), the args like (5,0) will
cause a wrong result.
### Expected behavior
An error message to point out the misuse.
### Actual behavior
```
Traceback (most recent call last):
File
"/Scuzer/src/bugs/IncorrectResult__f3f22bd7-feec-4f44-890c-2cd7d1c86814/Incorrect_bug.py",
line 48, in <module>
tvm.testing.assert_allclose(pre_list[1].numpy(),
after_list[1].numpy(),rtol=1e-5)
File "/Scuzer/tvm_cov_patch/tvm/python/tvm/testing/utils.py", line 114, in
assert_allclose
np.testing.assert_allclose(actual, desired, rtol=rtol, atol=atol,
verbose=True)
File
"/root/miniconda3/envs/py38/lib/python3.8/site-packages/numpy/testing/_private/utils.py",
line 1527, in assert_allclose
assert_array_compare(compare, actual, desired, err_msg=str(err_msg),
File
"/root/miniconda3/envs/py38/lib/python3.8/site-packages/numpy/testing/_private/utils.py",
line 840, in assert_array_compare
raise AssertionError(msg)
AssertionError:
Not equal to tolerance rtol=1e-05, atol=1e-07
Mismatched elements: 100 / 100 (100%)
Max absolute difference: 92
Max relative difference: 1.
x: array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],...
y: array([[75, 68, 41, 69, 74, 68, 66, 63, 65, 72],
[65, 67, 58, 88, 82, 74, 63, 87, 66, 66],
[71, 69, 80, 69, 52, 71, 75, 51, 69, 72],...
```
### Environment
Operating System: Ubuntu 18.04 TVM version: tag0.9.0 [d361585]
### Steps to reproduce
```
import os
import numpy as np
import tvm
from tvm import te, auto_scheduler, topi
import tvm.testing
REDUCE_0 = te.reduce_axis((0, 5), name="REDUCE_0")
REDUCE_1 = te.reduce_axis((7, 0), name="REDUCE_1")
TENSOR_0 = te.placeholder([10,10,10,10], dtype="int8", name="TENSOR_0")
TENSOR_1 = te.compute([10,10], lambda
mcq,uch:te.sum(expr=TENSOR_0[REDUCE_0,mcq,uch,REDUCE_1],
axis=[REDUCE_0,REDUCE_1]), name ="TENSOR_1")
s = te.create_schedule(TENSOR_1.op)
tensor_list = [TENSOR_0,TENSOR_1]
dev = tvm.cpu(0)
pre_list = []
after_list = []
for tensor in tensor_list:
shape = [x.value if 'value' in dir(x) and isinstance(x.value, int) else
1 for x in tensor.shape]
params = (5*np.random.uniform(size=shape)).astype(tensor.dtype)
pre_list.append(tvm.nd.array(params.copy(), dev))
after_list.append(tvm.nd.array(params.copy(), dev))
pre_mod = tvm.lower(s, tensor_list, simple_mode=True)
with tvm.transform.PassContext(opt_level=4):
f = tvm.build(pre_mod)
f(*pre_list)
# Schedule
TENSOR_1_mcq, TENSOR_1_uch, TENSOR_1_REDUCE_0, TENSOR_1_REDUCE_1 =
tuple(TENSOR_1.op.axis) + tuple(TENSOR_1.op.reduce_axis)
TENSOR_1_REDUCE_0_REDUCE_1_fused = s[TENSOR_1].fuse(TENSOR_1_REDUCE_0,
TENSOR_1_REDUCE_1)
now_mod = tvm.lower(s, tensor_list, simple_mode=True)
with tvm.transform.PassContext(opt_level=4):
f = tvm.build(now_mod)
f(*after_list)
tvm.testing.assert_allclose(pre_list[1].numpy(),
after_list[1].numpy(),rtol=1e-5)
```
--
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]