Dynamic shape explainer - #225
Draft
theHamsta wants to merge 13 commits into
Draft
Conversation
theHamsta
force-pushed
the
dynamic-shape-explainer
branch
from
September 10, 2026 10:36
5386fb2 to
b8028a1
Compare
Contributor
|
I've updated #223 against main and added exact-result tests for
Would tests comparing the host shape result with actual CoreML outputs be useful as the next shared validation step? I can help with those. |
This was referenced Sep 13, 2026
mtavenrath
pushed a commit
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.
Summary
WIP implementation of webmachinelearning/webnn#945 basically adding the required API functions.
The
.shape/.shape_with_optionsfunction existed already before this PR and where not guarded byfeature = "dynamic-inputs. Theshapeop currently returnsVec<i64>instead of the u32 from the explainer. ORT and we used i64 internally but should probably switch to u32 from WebNN.This PR will require some kind of shape validation. Either
computeShapeValidation
make testDocumentation
make docs-backend-opsand committeddocs/development/backend-operator-support.md