How to add floormod in relay and topi

I found TVM::FloorMod included in the most recent code, So I wanted to look for the FloorMod front-end support, but After I have registered relay and topi for FloorMod , I find that the final calculation procedure calls is llvm

llvm::Value* CodeGenLLVM::VisitExpr_(const Mod* op) {

llvm::Value* a = MakeValue(op->a);

llvm::Value* b = MakeValue(op->b);

if (op->type.is_int()) {

return builder_->CreateSRem(a, b);

} else if (op->type.is_uint()) {

return builder_->CreateURem(a, b);

} else {


return builder_->CreateFRem(a, b);



in floormod if a*b<0 floormod(a,b)=a%b+b , so where should I do this in my code , I don’t think it’s in LLVM.
sorry I just touched on TVM, so can anyone help me?

Am I making myself clear?Can anyone help me?

We have not yet added the lowering support for floormod/div. so we still need to wait a few PRs to make use of it internally

@tqchen can you please update on the status of this?

The integer floormod/div is now supported in low level codegen, so it is just a matter of exposing them to relay

Thanks for the update. @ydy are you still working on this? If not, I can pick up the work item.

I implemented a floormod a long time ago with a mod, which obviously does not conform to the code specification.if you can implement it is better.