THINKER-ONLY opened a new pull request, #19537:
URL: https://github.com/apache/tvm/pull/19537

   This PR fixes #19532.
   
   ONNX `Slice` can produce an empty tensor when a negative step moves away 
from the end bound. For example, `starts=[0]`, `ends=[5]`, and `steps=[-1]` 
should produce a zero-length result, matching ONNX Runtime.
   
   Previously, the Relax ONNX frontend passed those bounds directly to 
`relax.strided_slice`. During legalization, TOPI rejected the range because the 
canonicalized end is greater than the begin for a negative stride.
   
   This PR normalizes statically empty constant `Slice` ranges before emitting 
`relax.strided_slice`, so Relax can represent the same zero-length result. It 
also adds a regression test for the negative-step empty result case.
   
   Testing:
   - `pytest tests/python/relax/test_frontend_onnx.py::test_slice -q`
   - `pytest tests/python/relax/test_frontend_onnx.py -k slice -q`
   - `pytest tests/python/relax/test_op_index.py 
tests/python/relax/test_transform_legalize_ops_index_linear_algebra.py -k 
strided_slice -q`
   - `pytest tests/python/relax/test_frontend_onnx.py -k "not 
test_all_reduce_funcs_axes_input and not test_topk" -q`
   - `git diff --check`
   - `python -m py_compile python/tvm/relax/frontend/onnx/onnx_frontend.py 
tests/python/relax/test_frontend_onnx.py`
   
   Note: Full `test_frontend_onnx.py -q` currently has 14 failures in 
`test_all_reduce_funcs_axes_input` and `test_topk`; the same failures reproduce 
on the cached baseline source, so they are unrelated to this patch.


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