cxx122 opened a new issue, #12380:
URL: https://github.com/apache/tvm/issues/12380

   ```
   TENSOR_0 = te.placeholder([3,3,3], dtype="float16", name="TENSOR_0")
   TENSOR_1 = te.compute([3,3,3,3], lambda 
dck,zch,vci,wcs:TENSOR_0[wcs,vci,dck]*te.sqrt(TENSOR_0[wcs,wcs,zch]), name 
="TENSOR_1")
   ```
   ```
   TENSOR_0 = te.placeholder([3,3,3], dtype="float16", name="TENSOR_0")
   TENSOR_1 = te.compute([3,3,3,3], lambda 
dck,zch,vci,wcs:TENSOR_0[wcs,vci,dck]*te.cos(TENSOR_0[wcs,wcs,zch]), name 
="TENSOR_1")
   ```
   When changing the shape num of the tensor higher or equal to 3, it will 
cause an inconsistency after using fuse.
   
   ### Actual behavior
   cos:
   ```
   AssertionError: 
   Not equal to tolerance rtol=1e-05, atol=1e-07
   
   Mismatched elements: 12 / 81 (14.8%)
   Max absolute difference: 0.007812
   Max relative difference: 0.000825
    x: array([[[[ 3.8   ,  5.203 ,  2.787 ],
            [ 5.234 , 10.79  ,  2.96  ],
            [ 1.436 ,  9.68  ,  0.3608]],...
    y: array([[[[ 3.8   ,  5.203 ,  2.787 ],
            [ 5.234 , 10.79  ,  2.96  ],
            [ 1.436 ,  9.68  ,  0.3608]],...
   ```
   sqrt:
   ```
   AssertionError: 
   Not equal to tolerance rtol=1e-05, atol=1e-07
   
   Mismatched elements: 16 / 81 (19.8%)
   Max absolute difference: 0.007812
   Max relative difference: 0.0009217
    x: array([[[[6.320e+00, 1.156e+00, 9.766e+00],
            [4.926e+00, 1.188e+00, 2.744e-01],
            [2.333e-02, 4.898e+00, 1.105e+01]],...
    y: array([[[[6.3203e+00, 1.1562e+00, 9.7656e+00],
            [4.9258e+00, 1.1885e+00, 2.7441e-01],
            [2.3331e-02, 4.8984e+00, 1.1047e+01]],...
   ```
   
   
   ### 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
   
   # Your TE program
   TENSOR_0 = te.placeholder([3,3,3], dtype="float16", name="TENSOR_0")
   TENSOR_1 = te.compute([3,3,3,3], lambda 
dck,zch,vci,wcs:TENSOR_0[wcs,vci,dck]*te.sqrt(TENSOR_0[wcs,wcs,zch]), 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_dck, TENSOR_1_zch, TENSOR_1_vci, TENSOR_1_wcs = 
tuple(TENSOR_1.op.axis) + tuple(TENSOR_1.op.reduce_axis)
   TENSOR_1_dck_zch_fused_vci_fused = s[TENSOR_1].fuse(TENSOR_1_dck, 
TENSOR_1_zch, TENSOR_1_vci)
   
   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]

Reply via email to