viiccwen opened a new issue, #19974: URL: https://github.com/apache/tvm/issues/19974
### Expected behavior The Relax ONNX frontend should preserve ONNX integer `Div` semantics. ONNX defines integer `Div` as truncating division, rounding toward zero. This behavior should hold both for constant tensors and for shape-derived scalar values represented as Relax/TIR primitive expressions. ### Actual behavior When an ONNX `Div` has integer inputs and one input is a shape-derived `PrimExpr`, the importer can fold it through NumPy floating-point division. This produces a floating-point TIR value such as `T.float64(128.67676767)` instead of an integer value such as `T.int64(128)`. If that result is then used as a slice bound or another index value, Relax import can fail because the downstream operator expects an integer primitive expression. One failing pattern is: ```text Shape -> Gather -> Div -> Slice ``` where the `Div` result is used as the `end` argument of `Slice`. ### Environment - Component: Relax ONNX frontend - Affected file: `python/tvm/relax/frontend/onnx/onnx_frontend.py` - Reproduced with a local TVM checkout using the Python ONNX frontend tests ### Steps to reproduce Create a graph where `Shape(x)[0]` is divided by an `int64` constant and used as a `Slice` bound: ```text x: float32[386] Shape(x) -> Gather(axis=0) -> Div(3) -> Slice(x, starts=[0], ends=[Div result]) ``` The importer may fail with an error similar to: ```text relax.strided_slice requires the end argument to be a tuple of int64 PrimExpr values ... the end argument (T.float64(128.66666666666666),) has type T.Tuple(T.float64) ``` ### Triage * needs-triage * type: bug * relax * frontend: onnx -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
