Division and FloorDiv documentation


#1

Hi everyone, I’m new to TVM and I was looking for mathematically precise documentation on the new FloorDiv and related ops (including regular division) introduced as part of this issue:

https://github.com/dmlc/tvm/issues/3977

I can see division listed here:

https://docs.tvm.ai/langref/relay_op.html

but it doesn’t list FloorDiv and similar ops, and it doesn’t show the math, which is important since there are several different ways of doing division (which is why FloorDiv exists). How do I get background information on this? Maybe I’m just looking in the wrong place?


#2

Relay is the high level IR that we use for computational graph level. At the moment the relay level divide operator redirections to the c-semantics division.

We support both C semantics division and FloorDiv in the low level IR and FloorDiv is primarily used for index calculations and simplifications. You can find low level IR ast nodes in here https://docs.tvm.ai/api/python/dev.html#module-tvm.expr

I agree that it makes sense for us to document the division semantics of high level graph IR explicitly as well. cc @jroesch


#3

Cool. Specific things I wonder about are around what happens on signed overflow as in INT_MAX / -1, integer division by zero and negative divisor or dividend.