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 2022/08/24 08:54:41 UTC

[GitHub] [tvm] cxx122 opened a new issue, #12569: [Bug] no divide by zero report while te.floordiv(a, b-b)

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

   ```
   TENSOR_0 = te.placeholder([], dtype="int8", name="TENSOR_0")
   TENSOR_1 = te.placeholder([], dtype="int8", name="TENSOR_1")
   TENSOR_2 = te.compute([5], lambda fcc:te.floordiv(TENSOR_1, TENSOR_0-TENSOR_0), name ="TENSOR_2")
   ```
   ### Expected behavior
   
   Check failed: pb->value != 0 (0 vs. 0) : Divide by zero
   
   ### Actual behavior
   
   
   
   ### Numpy behavior
   
   ![image](https://user-images.githubusercontent.com/52519147/186374488-0951f8c9-c018-4e3d-abcc-1a8bede00cc1.png)
   
   ### 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([], dtype="int8", name="TENSOR_0")
   TENSOR_1 = te.placeholder([], dtype="int8", name="TENSOR_1")
   TENSOR_2 = te.compute([5], lambda fcc:te.floordiv(TENSOR_1, TENSOR_0-TENSOR_0), 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)+1).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=0):
       f = tvm.build(pre_mod)
   f(*pre_list)
   ```
   


-- 
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.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] ganler commented on issue #12569: [Bug] no divide by zero report while te.floordiv(a, b-b)

Posted by GitBox <gi...@apache.org>.
ganler commented on issue #12569:
URL: https://github.com/apache/tvm/issues/12569#issuecomment-1234675379

   If that's the case, that seems we need to check the generated code. Because normally if the generated code remains the semantic of div by zero, it should raise a floating-point exception.


-- 
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] cxx122 commented on issue #12569: [Bug] no divide by zero report while te.floordiv(a, b-b)

Posted by GitBox <gi...@apache.org>.
cxx122 commented on issue #12569:
URL: https://github.com/apache/tvm/issues/12569#issuecomment-1235054211

   > If that's the case, that seems we need to check the generated code. Because normally if the generated code remains the semantic of div by zero, it should raise a floating-point exception.
   
   Here is the generated code I got from this program, seems to be a problem with T_subtract().
   ```
   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_2: Buffer(TENSOR_2_2: Pointer(int8), int8, [5], []),
                TENSOR_0: Buffer(TENSOR_0_2: Pointer(int8), int8, [], []),
                TENSOR_1: Buffer(TENSOR_1_2: Pointer(int8), int8, [], [])}
     buffer_map = {TENSOR_0_1: TENSOR_0, TENSOR_1_1: TENSOR_1, TENSOR_2_1: TENSOR_2} {
     allocate(T_subtract: Pointer(global int8), int8, [1]), storage_scope = global {
       T_subtract[0] = ((int8*)TENSOR_0_2[0] - (int8*)TENSOR_0_2[0])
       for (fcc: int32, 0, 5) {
         TENSOR_2_2[fcc] = floordiv((int8*)TENSOR_1_2[0], (int8*)T_subtract[0])
       }
     }
   }
   ```


-- 
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] cxx122 closed issue #12569: [Bug] no divide by zero report while te.floordiv(a, b-b)

Posted by GitBox <gi...@apache.org>.
cxx122 closed issue #12569: [Bug] no divide by zero report while te.floordiv(a, b-b)
URL: https://github.com/apache/tvm/issues/12569


-- 
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] wzh99 commented on issue #12569: [Bug] no divide by zero report while te.floordiv(a, b-b)

Posted by GitBox <gi...@apache.org>.
wzh99 commented on issue #12569:
URL: https://github.com/apache/tvm/issues/12569#issuecomment-1314637714

   @cxx122 This bug is caused by a mistake in constant folding. It is fixed by #13348. 


-- 
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] ganler commented on issue #12569: [Bug] no divide by zero report while te.floordiv(a, b-b)

Posted by GitBox <gi...@apache.org>.
ganler commented on issue #12569:
URL: https://github.com/apache/tvm/issues/12569#issuecomment-1234673820

   @cxx122 Thanks! So the symptom is, given a div by zero formula, which normally we should throw an DivByZero exception, in tvm, it silently returns a result (which is might be wrong)? 


-- 
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