Skip to content

[Fix][Relax] Return one-dimensional inverse indices from unique - #21131

Open
tandede wants to merge 1 commit into
apache:mainfrom
tandede:fix/unique-flat-inverse
Open

tandede wants to merge 1 commit into
apache:mainfrom
tandede:fix/unique-flat-inverse

Conversation

@tandede

@tandede tandede commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

NumPy 2 can return inverse indices with the shape of the input when axis=None. Relax infers a one-dimensional tensor, so an ONNX Unique model requesting inverse indices fails at runtime for multidimensional input.

Flatten the inverse indices before remapping them for unsorted output. Re-enable the four existing ONNX cases that cover both sort modes and three or four outputs.

All 32 ONNX Unique cases passed with NumPy 1.26.4 and 2.5.3. The 13 Relax set operator tests also passed with NumPy 2.5.3.

Fixes #21126.

OpenAI Codex helped prepare and test this change.

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] relax.op.unique(return_inverse=True) returns an input-shaped inverse for N-D input when axis is None

1 participant