Bugfix: Allow 0-D output for gather() - #953
Merged
Merged
Conversation
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
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>
beckysiegel
pushed a commit
to chromium/chromium
that referenced
this pull request
Sep 9, 2026
This CL updates the minimum allowed rank of gather's output to 0 in required_datatypes_ranks.json by executing the script tools/generate-required-datatypes-ranks.py, per Spec change [1]. No new conformance tests are needed: the existing conformance tests and validation tests already exercise the 0-D output path. [1] Spec change: webmachinelearning/webnn#953 Change-Id: If127608d7e5cf80a402e0544169e9fa67237d66c Bug: 557288874 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8361354 Auto-Submit: Dai, Feng <feng.dai@intel.com> Reviewed-by: Hu, Ningxin <ningxin.hu@intel.com> Reviewed-by: Reilly Grant <reillyg@chromium.org> Commit-Queue: Hu, Ningxin <ningxin.hu@intel.com> Cr-Commit-Position: refs/heads/main@{#1694279}
chromium-wpt-export-bot
pushed a commit
to web-platform-tests/wpt
that referenced
this pull request
Sep 9, 2026
This CL updates the minimum allowed rank of gather's output to 0 in required_datatypes_ranks.json by executing the script tools/generate-required-datatypes-ranks.py, per Spec change [1]. No new conformance tests are needed: the existing conformance tests and validation tests already exercise the 0-D output path. [1] Spec change: webmachinelearning/webnn#953 Change-Id: If127608d7e5cf80a402e0544169e9fa67237d66c Bug: 557288874 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8361354 Auto-Submit: Dai, Feng <feng.dai@intel.com> Reviewed-by: Hu, Ningxin <ningxin.hu@intel.com> Reviewed-by: Reilly Grant <reillyg@chromium.org> Commit-Queue: Hu, Ningxin <ningxin.hu@intel.com> Cr-Commit-Position: refs/heads/main@{#1694279}
lando-worker Bot
pushed a commit
to mozilla-firefox/firefox
that referenced
this pull request
Sep 11, 2026
…tor, a=testonly Automatic update from web-platform-tests webnn: allow 0-D output for gather operator This CL updates the minimum allowed rank of gather's output to 0 in required_datatypes_ranks.json by executing the script tools/generate-required-datatypes-ranks.py, per Spec change [1]. No new conformance tests are needed: the existing conformance tests and validation tests already exercise the 0-D output path. [1] Spec change: webmachinelearning/webnn#953 Change-Id: If127608d7e5cf80a402e0544169e9fa67237d66c Bug: 557288874 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8361354 Auto-Submit: Dai, Feng <feng.dai@intel.com> Reviewed-by: Hu, Ningxin <ningxin.hu@intel.com> Reviewed-by: Reilly Grant <reillyg@chromium.org> Commit-Queue: Hu, Ningxin <ningxin.hu@intel.com> Cr-Commit-Position: refs/heads/main@{#1694279} -- wpt-commits: fadb01bc53cd4a9fac9352c977df1787425b856e wpt-pr: 62541
mtavenrath
pushed a commit
to rustnn/rustnn
that referenced
this pull request
Sep 13, 2026
Gather index normalization currently replaces dynamic dimensions with their maximum extents. The model interface and dispatch also use those maxima, preventing active-sized inputs from reaching CoreML correctly. This preserves dynamic dimensions through `gather`, `gatherElements`, and `gatherND` normalization, adds matching model shape ranges (including integer proxy outputs), and binds the active input dimensions with checked byte lengths. Dispatch now rejects oversized results instead of silently truncating them. Scalar gathers also bypassed normalization: gathering index `-1` from `[10, 20, 30]` returned `10` instead of `30`. Normalize constant and runtime scalar indices while preserving WebNN rank-zero results and CoreML's `[1]` feature boundary, consistent with [webmachinelearning/webnn#953](webmachinelearning/webnn#953). Related to [#222](#222). Dynamic behavior remains behind `dynamic-inputs`; this complements the proposed host-side shape evaluation in [#225](#225). Dynamic gathered-axis bounds, runtime reshape/slice lowering, and empty KV-cache behavior remain separate work. Validation on the M4: - Formatting and strict Clippy passed; 356 default, 364 CoreML, and 376 CoreML/dynamic Rust tests passed. - Locally compiled CoreML models returned exact values for all three gather variants over active lengths `1 -> 4 -> 2 -> 1`, including negative/out-of-range indices; constant and runtime scalar cases passed. Converter tests cover mixed dimensions, axis removal, and integer proxy metadata. - CoreML WPT: 2,461 passed, 40 skipped, and the same 20 negative-index scatter failures as clean `main` (`04fc5f4`), using [WPT `04cd4a8`](web-platform-tests/wpt@04cd4a8). The previously skipped scalar out-of-range positive gather case now passes; no expectations or snapshot changes. No newer CoreML operations or APIs are introduced. Physical iOS 18.x/watchOS 11.x validation has not been rerun for this patch.
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.
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