Conversation
5386fb2 to
b8028a1
Compare
|
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. |
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.
Hi! I'm currently having a look whether we can have a symbolic shape inference to implement the dynamic shape explainer. This would have the advantage that
The idea would basically be to propagate expressions dependent on MLDimension::dynamic("some_string") through the network until the outputs. Whenever I'm encountering a DynamicXXX op, I plan to trace back the shape input to The alternative would be to do a concrete shape CPU interpreter on We know from Chromium that the CPU interpreter approach works (at least for implementing WebNN where runtime compilation is expected). I'm curious whether my symbolic approach would work also. I'm developing this as a separate crate though that we could use it for dev tooling if it is not a good fit for WebNN itself. A big gap we have right now is that when we fail with shape inference (e.g. dynamic shapes or gap in implementation for static shapes), we are setting the shape to empty vec which has the ambiguity that it can mean "Unknown" shape or scalar shape. A symbolic inference could allow us to never have "unknown" shape. Alternatively, we should make To add symbolic shape inference incrementally and optionally, I would extend our internal |
Extracted from rustnn#225
Extracted from rustnn#225
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