cxx122 opened a new issue, #12383:
URL: https://github.com/apache/tvm/issues/12383
```
TENSOR_0 = te.placeholder([8], dtype="uint32", name="TENSOR_0")
TENSOR_1 = te.compute([8], lambda jcn:te.min_value("uint32"), name
="TENSOR_1")
TENSOR_2 = te.compute([8,8], lambda zce,mcw:TENSOR_1[zce]-TENSOR_0[zce],
name ="TENSOR_2")
```
The result will be different when the dtype is "uint32" or "uint64" except
"uint16", and the shape of tensor needs to be higher or equal to 7.
### Actual behavior
```
AssertionError:
Not equal to tolerance rtol=1e-05, atol=1e-07
Mismatched elements: 8 / 64 (12.5%)
Max absolute difference: 4294967295
Max relative difference: inf
x: array([[ 0, 0, 0, 0, 0,
0, 0, 0],
[ 0, 0, 0, 0, 0,...
y: 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],...
```
tensor_0:
`[0 3 2 0 4 0 2 0]`
tensor_2 pre mod:
```
@main = primfn(TENSOR_0_1: handle, TENSOR_1_1: handle, TENSOR_2_1: handle)
-> ()
attr = {"from_legacy_te_schedule": True, "global_symbol": "main",
"tir.noalias": True}
buffers = {TENSOR_0: Buffer(TENSOR_0_2: Pointer(uint32), uint32, [8], []),
TENSOR_1: Buffer(TENSOR_1_2: Pointer(uint32), uint32, [8], []),
TENSOR_2: Buffer(TENSOR_2_2: Pointer(uint32), uint32, [64], [])}
buffer_map = {TENSOR_0_1: TENSOR_0, TENSOR_1_1: TENSOR_1, TENSOR_2_1:
TENSOR_2}
preflattened_buffer_map = {TENSOR_0_1: TENSOR_0_3: Buffer(TENSOR_0_2,
uint32, [8], []), TENSOR_1_1: TENSOR_1_3: Buffer(TENSOR_1_2, uint32, [8], []),
TENSOR_2_1: TENSOR_2_3: Buffer(TENSOR_2_2, uint32, [8, 8], [])} {
for (jcn: int32, 0, 8) {
TENSOR_1[jcn] = 0u32
}
for (zce: int32, 0, 8) {
for (mcw: int32, 0, 8) {
TENSOR_2[((zce*8) + mcw)] = (TENSOR_1[zce] - TENSOR_0[zce])
}
}
}
```
tensor_2 pre result:
```
[[ 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
0 0]
[ 0 0 0 0 0 0
0 0]
[ 0 0 0 0 0 0
0 0]
[4294967294 4294967294 4294967294 4294967294 4294967294 4294967294
4294967294 4294967294]
[ 0 0 0 0 0 0
0 0]]
```
tensor_2 after mod:
```
@main = primfn(TENSOR_0_1: handle, TENSOR_1_1: handle, TENSOR_2_1: handle)
-> ()
attr = {"from_legacy_te_schedule": True, "global_symbol": "main",
"tir.noalias": True}
buffers = {TENSOR_0: Buffer(TENSOR_0_2: Pointer(uint32), uint32, [8], []),
TENSOR_1: Buffer(TENSOR_1_2: Pointer(uint32), uint32, [8], []),
TENSOR_2: Buffer(TENSOR_2_2: Pointer(uint32), uint32, [64], [])}
buffer_map = {TENSOR_0_1: TENSOR_0, TENSOR_1_1: TENSOR_1, TENSOR_2_1:
TENSOR_2}
preflattened_buffer_map = {TENSOR_0_1: TENSOR_0_3: Buffer(TENSOR_0_2,
uint32, [8], []), TENSOR_1_1: TENSOR_1_3: Buffer(TENSOR_1_2, uint32, [8], []),
TENSOR_2_1: TENSOR_2_3: Buffer(TENSOR_2_2, uint32, [8, 8], [])} {
for (zce: int32, 0, 8) {
TENSOR_1[zce] = 0u32
for (mcw: int32, 0, 8) {
TENSOR_2[((zce*8) + mcw)] = (TENSOR_1[zce] - TENSOR_0[zce])
}
}
}
```
tensor_2 after result:
```
[[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 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 0 0 0 0]]
```
### 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
TENSOR_0 = te.placeholder([8], dtype="uint32", name="TENSOR_0")
TENSOR_1 = te.compute([8], lambda jcn:te.min_value("uint32"), name
="TENSOR_1")
TENSOR_2 = te.compute([8,8], lambda zce,mcw:TENSOR_1[zce]-TENSOR_0[zce],
name ="TENSOR_2")
s = te.create_schedule(TENSOR_2.op)
tensor_list = [TENSOR_0,TENSOR_1,TENSOR_2]
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)
print(pre_list[0])
print(pre_list[2])
# Schedule
TENSOR_2_zce, TENSOR_2_mcw = tuple(TENSOR_2.op.axis) +
tuple(TENSOR_2.op.reduce_axis)
s[TENSOR_1].compute_at(s[TENSOR_2], TENSOR_2_zce)
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)
print(after_list[2])
print(pre_mod)
print(now_mod)
tvm.testing.assert_allclose(pre_list[2].numpy(),
after_list[2].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]