dpankratz opened a new pull request #5009: [Bugfixes] Improved handling of tir 
instrinsics applied to ints. Fixed div by zero crash
URL: https://github.com/apache/incubator-tvm/pull/5009
 
 
   ## Intrinsics
   
   This PR improves the behaviour of many tir instrinsics when called with an 
integer typed argument. Previously TVM's front-end would accept a statement 
such as `tvm.tir.sqrt(tvm.tir.const(3,'int32'))` and then the llvm backend 
would fail to verify with the message:
   ```
   TVMError: LLVM module verification failed with the following errors: 
   Intrinsic has incorrect return type!
   i32 (i32)* @llvm.sqrt.i32
   ```
   This is due to many of the intrinsics being defined only for floating point 
types. 
   
   The new behaviour is to raise a Python RuntimeError for the intrinsics 
`sin,cos,atan,tan,tanh,sigmoid,log,erf,exp,sqrt,rsqrt`.
   
   For the intrinsics `round,trunc,ceil,floor,nearbyint` they simply returns 
the passed argument. For example `tvm.tir.floor(tvm.tir.const(10)) #prints 10`.
   
   ## Divide by Zero Core Dump
   
   It appears that a few cases of dividing by zero were missed causing 
const_fold to trigger a floating point exception in python. For example 
`tvm.tir.const(2) % 0
   
   I would appreciate a review!
   
   @tqchen 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to