Should we use PureExtern for some TVM ops?


I found that some TVM ops such as exp, floor, ceil, etc., are defined as pure intrinsic ops. For example,

However, in HalideIR, these ops are defined as pure extern ops, see

Should we change them to pure extern ops to be consistent with HalideIR? Further, this will also be compatible with HalideIR simplification pass (though we need to add TVM op signature for them).



These operators will get lowered in compiler into different extern functions. So we want to keep them as intrinsics as opposed to extern.

In terms of simplification i feel we should not do the simplification for floating pt ops anyway, mainly because LLVM will do them when necessary and we mainly need simplification for integer indices.


One problem I have now is that when I want to compute the shape of arange op, storage rewrite fails because it cannot simplify the expr due to ceil op.


Should we use pure integer arithmetics to implement ceil division instead?


But arange can take in float value for start, stop, and step.


I see what you mean. Perhaps we could overload ceil floor op to eagerly simplify float arithmetics. As in our current eager simplification of integer ones


as in


Thanks Tianqi. I can work on a PR to simplify ceil and floor.


hmm. I found that float division/add/sub are not eagerly simplified either. Therefore, operand to ceil is still an expr instead of FloatImm. But I feel that eagar simplication for all float expression might not be desired. So what should we do here? Should I change the HalideIR simplify and match intrinsic ceil op defined in TVM?


Let us simply make the add sub div arithmetic eager simplify for float. I think it is not a bad choice anyway