Skip to content

[Fix][TOPI] Allow empty GatherElements indices - #20990

Open
DiadkoShmek wants to merge 1 commit into
apache:mainfrom
DiadkoShmek:DiadkoShmek/fix-empty-gather-elements
Open

DiadkoShmek wants to merge 1 commit into
apache:mainfrom
DiadkoShmek:DiadkoShmek/fix-empty-gather-elements

Conversation

@DiadkoShmek

Copy link
Copy Markdown

Fixes #20868.

The TOPI lowering for GatherElements rejects 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 of indices. 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 0 and -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.

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][Relax][TOPI] GatherElements rejects valid empty indices during lowering

1 participant