Nanmur opened a new pull request, #20324:
URL: https://github.com/apache/tvm/pull/20324

   The Relax ONNX importer constant-folds binary operations through NumPy. For 
integer `Div`, `numpy.divide` promotes the operands to `float64`, so `int64` 
values above `2**53` lose low bits before the result is cast back to the 
integer dtype.
   
   This change handles integer constant operands directly with integer 
quotient/remainder arithmetic. NumPy floor division is adjusted by one when 
signed operands have opposite signs and a non-zero remainder, preserving ONNX's 
truncation-toward-zero behavior without passing through floating point. 
Existing tensor and `PrimExpr` paths are unchanged.
   
   The regression test covers values immediately above `2**53`, a negative 
large integer, and both signed truncation directions.
   
   Fixes #20281
   
   Tests:
   - `python -m pytest tests/python/relax/test_frontend_onnx.py -k 'test_binary 
or test_div_integer' -q` (`13 passed`)
   - `python -m ruff check python/tvm/relax/frontend/onnx/onnx_frontend.py 
tests/python/relax/test_frontend_onnx.py`
   - `python -m ruff format --check 
python/tvm/relax/frontend/onnx/onnx_frontend.py 
tests/python/relax/test_frontend_onnx.py`


-- 
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]

Reply via email to