Skip to content

Bugfix: Allow 0-D output for gather() - #953

Merged
fdwr merged 1 commit into
webmachinelearning:mainfrom
huningxin:gather-allow-0d-output
Sep 4, 2026
Merged

Bugfix: Allow 0-D output for gather()#953
fdwr merged 1 commit into
webmachinelearning:mainfrom
huningxin:gather-allow-0d-output

Conversation

@huningxin

Copy link
Copy Markdown
Contributor

The indices operand already allows rank 0, and the output rank is rank(input) + rank(indices) - 1. So a rank-1 input gathered with scalar indices produces a rank-0 output.

The algorithm steps needed no change; they already produce an empty output shape for this case.

Fixes #946

The indices operand already allows rank 0, and the output rank is
rank(input) + rank(indices) - 1. So a rank-1 input gathered with scalar
indices legitimately produces a rank-0 output, e.g. input of shape [4]
with indices of shape [] and axis 0 yields output of shape [].

The output row of the tensor limits table set the minimum rank to 1,
which rejected that case. Relax it to allow rank 0, matching both the
indices row and gatherND()'s output row.

The algorithm steps needed no change; they already produce an empty
output shape for this case.

Fixes webmachinelearning#946
@huningxin
huningxin requested a review from fdwr September 4, 2026 22:46

@fdwr fdwr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

馃憤

@fdwr
fdwr merged commit f4a9b25 into webmachinelearning:main Sep 4, 2026
2 checks passed
github-actions Bot added a commit that referenced this pull request Sep 4, 2026
SHA: f4a9b25
Reason: push, by fdwr

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

gather should allow 0D output

2 participants