Skip to content

[Fix][Relax][Frontend][ONNX] Support Shape outputs as Gather indices - #20179

Merged
tlopex merged 1 commit into
apache:mainfrom
Gunse11er:fix-20176-gather-shape-indices
Aug 28, 2026
Merged

tlopex merged 1 commit into
apache:mainfrom
Gunse11er:fix-20176-gather-shape-indices

Conversation

@Gunse11er

Copy link
Copy Markdown
Contributor

The Relax ONNX frontend preserves Shape outputs as ShapeExpr values. Gather assumed its indices operand always had a tensor type and accessed its dtype, which raised an AttributeError when a Shape output was used as indices.

Materialize ShapeExpr indices as int64 tensors before the existing dtype and negative-index handling. Add an execution test that compares the imported model against ONNX Runtime.

Fixes #20176.

The Relax ONNX frontend preserves Shape outputs as ShapeExpr values. Gather assumed its indices operand always had a tensor type and accessed its dtype, which raised an AttributeError when a Shape output was used as indices.

Materialize ShapeExpr indices as int64 tensors before the existing dtype and negative-index handling. Add an execution test that compares the imported model against ONNX Runtime.

Fixes apache#20176.

@cchung100m cchung100m left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks to @Gunse11er 😄

@tlopex tlopex left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tlopex
tlopex merged commit c985542 into apache:main Aug 28, 2026
8 checks passed
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][ONNX] Gather import fails when indices come from Shape

3 participants