"Unresolved intrinsic floor with return type int32"


Hi guys,
I am trying to implement a custom operator in TVM which needs to convert a float Expr to an int Expr as the output shape.

inline Tensor custom_op(const Expr &a, const Expr &b, std::string name = "tensor", std::string tag = kElementWise) {
  Array<Expr> oshape;
  Expr num = tvm::floor(a / b);
  oshape.push_back(tvm::cast(Int(32), num););
  return compute(oshape, [&](const Array<Var>& indices) { return xxx; }, name, tag);

When compiling the operator like tvm.build(s, [A], 'cuda', name="custom_op"), the program crashed with the below error message:

tvm._ffi.base.TVMError: [16:25:47] /xxx/tvm/src/codegen/codegen_c.cc:556: Unresolved intrinsic floor with return type int32

I guess the error is related to the code where I tried to compute the output shape. Can anyone help with this problem ?


tvm.floor accept float. Could you check the type of a / b?


Thanks, simply cast a/b to Float(32) solves the problem !


This PR aims to solve this problem. It adds eager simplification for floating values as well.