Repository navigation
[Fix][TOPI] Allow empty GatherElements indices - #20990
Open
DiadkoShmek wants to merge 1 commit into
Open
DiadkoShmek wants to merge 1 commit into
DiadkoShmek wants to merge 1 commit into
Conversation
An empty index tensor defines an empty output and requires no data loads. Accept a zero extent on the gather axis and exercise LLVM lowering with empty and nonempty inputs.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #20868.
The TOPI lowering for
GatherElementsrejects a statically known zero extent on the selected axis, so a valid ONNX graph can fail to compile for LLVM. The output shape is the shape ofindices. An empty index tensor has no output elements and therefore no index loads to perform.Allow zero for this axis and compare the signed extent directly, to reject negative constant extents explicitly. Add LLVM VM regressions for axes
0and-1, for an empty input on the gather axis, and for two controls (an empty non-gather dimension and nonempty indices). These tests pass concrete shapes to the importer to isolate TOPI lowering from ONNX shape parsing.On locally built
23a6dbe710dfcd445a090af1c49c8d7e8a57fb10, three new cases failed at the extent assertion and both controls passed. On the rebuilt patch, all five cases passed with exact NumPy output shape, dtype, and values. ONNX Runtime 1.29.0 independently matched NumPy on all five inputs. The ONNX gather selection passed 38 tests, and the two Relax manipulation test modules passed 172 tests with 2 skipped.AI assistance (Codex) was used for the patch, tests, and verification. Thanks to @Yuhx141 for the report and the minimal ONNX graph.