[Solved] Cannot use `sqrt`, 'exp', etc. in TIR

I was trying to build a TIR with operators like tir.exp, but it says “Check failed: (f) is false: Cannot find intrinsic declaration, possible type mismatch: llvm.exp”. However, I do found that TVM has modeled such operators for LLVM (https://github.com/apache/tvm/blob/main/src/target/llvm/intrin_rule_llvm.cc#L40). Can anyone help with this? Many thanks.

To reproduce

from tvm import tir
import tvm

a = tir.Var('a', dtype='int32') # [Solved Thx to @masahi] type should be float

# some simple tir function
f = tir.PrimFunc([a], tir.Evaluate(tir.ret(tir.exp(a))))

# compile the function
tvm.build(f)
"""
---------------------------------------------------------------
An error occurred during the execution of TVM.
For more information, please see: https://tvm.apache.org/docs/errors.html
---------------------------------------------------------------
  Check failed: (f) is false: Cannot find intrinsic declaration, possible type mismatch: llvm.exp
"""

Maybe a is not floating point?

1 Like

@masahi Thank you. You are right. I should apply a casting node to work this around.