[Fix][Relax][ONNX] Fix Range dtype for PrimExpr bounds#20000
Conversation
Signed-off-by: viiccwen <vicwen@apache.org>
There was a problem hiding this comment.
Code Review
This pull request updates the ONNX frontend in TVM Relax to correctly extract the data type when handling the Range operator, changing start.ty.dtype to start.ty.dtype.dtype. It also adds a new unit test, test_range_with_primexpr_limit, to verify the behavior of the Range operator when the limit is a PrimExpr. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Signed-off-by: viiccwen <vicwen@apache.org>
|
Looks like something wrong with Ruff, I add a small lint cleanup to fix it. 🤔 |
|
cc @tlopex, @guan404ming. ✨🙌 |
The ONNX
Rangeimporter uses the dtype of the start value as the output dtype forrelax.op.arange. The frontend previously passedstart.ty.dtype, which is aPrimTypewrapper rather than the underlyingDataTypeexpected byarange.This patch passes the underlying dtype with
start.ty.dtype.dtype.The regression test covers a shape-derived bound produced by
Shape -> Gather -> Range, and checks that the imported Relax IR containsR.arange(..., dtype="int64").Verification:
python -m pytest tests/python/relax/test_frontend_onnx.py::test_range_with_primexpr_limit -qpre-commit run --files python/tvm/relax/frontend/onnx/onnx_frontend.py tests/python/relax/test_frontend_onnx.pyFixes #19999.