Skip to content

Conversation

@huningxin
Copy link
Contributor

@huningxin huningxin commented Aug 25, 2025

Only allow 1 to N rank input operand for argMin, argMax, batchNormalization, concat, cumulativeSum, gather, softmax and split operators that take 1 axis.

@fdwr and @reillyeon , PTAL.

/cc @miaobin

Fix #873


Preview | Diff

@huningxin huningxin requested a review from fdwr August 25, 2025 08:17
@huningxin huningxin changed the title Bugfix: Remove 0-D from allowed ranks for operators that take 1 axis Bugfix: Only allow 1 to N rank input for operators that take 1 axis Aug 25, 2025
Copy link
Collaborator

@fdwr fdwr left a comment

Choose a reason for hiding this comment

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

👍 TY NH.

I see gatherElements and scatterElements are already good.

@huningxin huningxin requested a review from reillyeon August 27, 2025 03:05
@huningxin huningxin merged commit 5aec997 into webmachinelearning:main Aug 29, 2025
2 checks passed
github-actions bot added a commit that referenced this pull request Aug 29, 2025
SHA: 5aec997
Reason: push, by huningxin

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 30, 2025
This CL aligns the tensor limits setting in
`WebNNContextImpl::IntersectWithBaseProperties` with spec, especially
for scalar operand limits that was fixed by spec PR [1].

The change includes:
1. argMin/Max doesn't accept scalar input and output data types except
   int32 and int64 [2]
2. batchNormalization doesn't accept scalar input [3]
3. concat doesn't accept scalar input [4]
4. conv2d/convTranspose2d only accept floating-point input data types
   [5]
5. softmax doesn't accept scalar input [6]
6. split doesn't accept scalar input [7]

Pad [8] and slice [9] support scalar input as a no-op. This CL
replaces pad or slice having scalar input with an identity operator at
MLGraphBuilder to unify the behaviors across backends.

[1]: webmachinelearning/webnn#882
[2]: https://www.w3.org/TR/webnn/#tensor-limits-argMin-argMax
[3]: https://www.w3.org/TR/webnn/#tensor-limits-batchNormalization
[4]: https://www.w3.org/TR/webnn/#tensor-limits-concat
[5]: https://www.w3.org/TR/webnn/#tensor-limits-conv2d
[6]: https://www.w3.org/TR/webnn/#tensor-limits-softmax
[7]: https://www.w3.org/TR/webnn/#tensor-limits-split
[8]: https://www.w3.org/TR/webnn/#tensor-limits-pad
[9]: https://www.w3.org/TR/webnn/#tensor-limits-slice

Change-Id: I8480cf9ef1e9e18a175677a16a553c1562a747c5
Bug: 446481989
Cq-Include-Trybots: luci.chromium.try:win11-blink-rel, mac14.arm64-blink-rel, mac14-blink-rel, mac15.arm64-blink-rel, mac15-blink-rel, linux-blink-rel
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 30, 2025
This CL aligns the tensor limits setting in
`WebNNContextImpl::IntersectWithBaseProperties` with spec, especially
for scalar operand limits that was fixed by spec PR [1].

The change includes:
1. argMin/Max doesn't accept scalar input and output data types except
   int32 and int64 [2]
2. batchNormalization doesn't accept scalar input [3]
3. concat doesn't accept scalar input [4]
4. conv2d/convTranspose2d only accept floating-point input data types
   [5]
5. softmax doesn't accept scalar input [6]
6. split doesn't accept scalar input [7]

Pad [8] and slice [9] support scalar input as a no-op. This CL
replaces pad or slice having scalar input with an identity operator at
MLGraphBuilder to unify the behaviors across backends.

[1]: webmachinelearning/webnn#882
[2]: https://www.w3.org/TR/webnn/#tensor-limits-argMin-argMax
[3]: https://www.w3.org/TR/webnn/#tensor-limits-batchNormalization
[4]: https://www.w3.org/TR/webnn/#tensor-limits-concat
[5]: https://www.w3.org/TR/webnn/#tensor-limits-conv2d
[6]: https://www.w3.org/TR/webnn/#tensor-limits-softmax
[7]: https://www.w3.org/TR/webnn/#tensor-limits-split
[8]: https://www.w3.org/TR/webnn/#tensor-limits-pad
[9]: https://www.w3.org/TR/webnn/#tensor-limits-slice

Change-Id: I8480cf9ef1e9e18a175677a16a553c1562a747c5
Bug: 446481989
Cq-Include-Trybots: luci.chromium.try:win11-blink-rel, mac14.arm64-blink-rel, mac14-blink-rel, mac15.arm64-blink-rel, mac15-blink-rel, linux-blink-rel
aarongable pushed a commit to chromium/chromium that referenced this pull request Oct 9, 2025
This CL aligns the tensor limits setting in
`WebNNContextImpl::IntersectWithBaseProperties` with spec, especially
for scalar operand limits that was fixed by spec PR [1].

The change includes:
1. argMin/Max doesn't accept scalar input and output data types except
   int32 and int64 [2]
2. batchNormalization doesn't accept scalar input [3]
3. concat doesn't accept scalar input [4]
4. conv2d/convTranspose2d only accept floating-point input data types
   [5]
5. softmax doesn't accept scalar input [6]
6. split doesn't accept scalar input [7]

Pad [8] and slice [9] support scalar input as a no-op. This CL
replaces pad or slice having scalar input with an identity operator at
MLGraphBuilder to unify the behaviors across backends.

[1]: webmachinelearning/webnn#882
[2]: https://www.w3.org/TR/webnn/#tensor-limits-argMin-argMax
[3]: https://www.w3.org/TR/webnn/#tensor-limits-batchNormalization
[4]: https://www.w3.org/TR/webnn/#tensor-limits-concat
[5]: https://www.w3.org/TR/webnn/#tensor-limits-conv2d
[6]: https://www.w3.org/TR/webnn/#tensor-limits-softmax
[7]: https://www.w3.org/TR/webnn/#tensor-limits-split
[8]: https://www.w3.org/TR/webnn/#tensor-limits-pad
[9]: https://www.w3.org/TR/webnn/#tensor-limits-slice

Change-Id: I8480cf9ef1e9e18a175677a16a553c1562a747c5
Bug: 446481989
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6972256
Commit-Queue: ningxin hu <ningxin.hu@intel.com>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1527306}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Oct 9, 2025
This CL aligns the tensor limits setting in
`WebNNContextImpl::IntersectWithBaseProperties` with spec, especially
for scalar operand limits that was fixed by spec PR [1].

The change includes:
1. argMin/Max doesn't accept scalar input and output data types except
   int32 and int64 [2]
2. batchNormalization doesn't accept scalar input [3]
3. concat doesn't accept scalar input [4]
4. conv2d/convTranspose2d only accept floating-point input data types
   [5]
5. softmax doesn't accept scalar input [6]
6. split doesn't accept scalar input [7]

Pad [8] and slice [9] support scalar input as a no-op. This CL
replaces pad or slice having scalar input with an identity operator at
MLGraphBuilder to unify the behaviors across backends.

[1]: webmachinelearning/webnn#882
[2]: https://www.w3.org/TR/webnn/#tensor-limits-argMin-argMax
[3]: https://www.w3.org/TR/webnn/#tensor-limits-batchNormalization
[4]: https://www.w3.org/TR/webnn/#tensor-limits-concat
[5]: https://www.w3.org/TR/webnn/#tensor-limits-conv2d
[6]: https://www.w3.org/TR/webnn/#tensor-limits-softmax
[7]: https://www.w3.org/TR/webnn/#tensor-limits-split
[8]: https://www.w3.org/TR/webnn/#tensor-limits-pad
[9]: https://www.w3.org/TR/webnn/#tensor-limits-slice

Change-Id: I8480cf9ef1e9e18a175677a16a553c1562a747c5
Bug: 446481989
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6972256
Commit-Queue: ningxin hu <ningxin.hu@intel.com>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1527306}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Oct 9, 2025
This CL aligns the tensor limits setting in
`WebNNContextImpl::IntersectWithBaseProperties` with spec, especially
for scalar operand limits that was fixed by spec PR [1].

The change includes:
1. argMin/Max doesn't accept scalar input and output data types except
   int32 and int64 [2]
2. batchNormalization doesn't accept scalar input [3]
3. concat doesn't accept scalar input [4]
4. conv2d/convTranspose2d only accept floating-point input data types
   [5]
5. softmax doesn't accept scalar input [6]
6. split doesn't accept scalar input [7]

Pad [8] and slice [9] support scalar input as a no-op. This CL
replaces pad or slice having scalar input with an identity operator at
MLGraphBuilder to unify the behaviors across backends.

[1]: webmachinelearning/webnn#882
[2]: https://www.w3.org/TR/webnn/#tensor-limits-argMin-argMax
[3]: https://www.w3.org/TR/webnn/#tensor-limits-batchNormalization
[4]: https://www.w3.org/TR/webnn/#tensor-limits-concat
[5]: https://www.w3.org/TR/webnn/#tensor-limits-conv2d
[6]: https://www.w3.org/TR/webnn/#tensor-limits-softmax
[7]: https://www.w3.org/TR/webnn/#tensor-limits-split
[8]: https://www.w3.org/TR/webnn/#tensor-limits-pad
[9]: https://www.w3.org/TR/webnn/#tensor-limits-slice

Change-Id: I8480cf9ef1e9e18a175677a16a553c1562a747c5
Bug: 446481989
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6972256
Commit-Queue: ningxin hu <ningxin.hu@intel.com>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1527306}
lando-prod-mozilla bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Oct 20, 2025
…n with spec, a=testonly

Automatic update from web-platform-tests
WebNN: Align tensor limits implementation with spec

This CL aligns the tensor limits setting in
`WebNNContextImpl::IntersectWithBaseProperties` with spec, especially
for scalar operand limits that was fixed by spec PR [1].

The change includes:
1. argMin/Max doesn't accept scalar input and output data types except
   int32 and int64 [2]
2. batchNormalization doesn't accept scalar input [3]
3. concat doesn't accept scalar input [4]
4. conv2d/convTranspose2d only accept floating-point input data types
   [5]
5. softmax doesn't accept scalar input [6]
6. split doesn't accept scalar input [7]

Pad [8] and slice [9] support scalar input as a no-op. This CL
replaces pad or slice having scalar input with an identity operator at
MLGraphBuilder to unify the behaviors across backends.

[1]: webmachinelearning/webnn#882
[2]: https://www.w3.org/TR/webnn/#tensor-limits-argMin-argMax
[3]: https://www.w3.org/TR/webnn/#tensor-limits-batchNormalization
[4]: https://www.w3.org/TR/webnn/#tensor-limits-concat
[5]: https://www.w3.org/TR/webnn/#tensor-limits-conv2d
[6]: https://www.w3.org/TR/webnn/#tensor-limits-softmax
[7]: https://www.w3.org/TR/webnn/#tensor-limits-split
[8]: https://www.w3.org/TR/webnn/#tensor-limits-pad
[9]: https://www.w3.org/TR/webnn/#tensor-limits-slice

Change-Id: I8480cf9ef1e9e18a175677a16a553c1562a747c5
Bug: 446481989
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6972256
Commit-Queue: ningxin hu <ningxin.hu@intel.com>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1527306}

--

wpt-commits: a460ea73b9d67a705401622c6a7f8c0088b6a036
wpt-pr: 55147
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this pull request Oct 25, 2025
…n with spec, a=testonly

Automatic update from web-platform-tests
WebNN: Align tensor limits implementation with spec

This CL aligns the tensor limits setting in
`WebNNContextImpl::IntersectWithBaseProperties` with spec, especially
for scalar operand limits that was fixed by spec PR [1].

The change includes:
1. argMin/Max doesn't accept scalar input and output data types except
   int32 and int64 [2]
2. batchNormalization doesn't accept scalar input [3]
3. concat doesn't accept scalar input [4]
4. conv2d/convTranspose2d only accept floating-point input data types
   [5]
5. softmax doesn't accept scalar input [6]
6. split doesn't accept scalar input [7]

Pad [8] and slice [9] support scalar input as a no-op. This CL
replaces pad or slice having scalar input with an identity operator at
MLGraphBuilder to unify the behaviors across backends.

[1]: webmachinelearning/webnn#882
[2]: https://www.w3.org/TR/webnn/#tensor-limits-argMin-argMax
[3]: https://www.w3.org/TR/webnn/#tensor-limits-batchNormalization
[4]: https://www.w3.org/TR/webnn/#tensor-limits-concat
[5]: https://www.w3.org/TR/webnn/#tensor-limits-conv2d
[6]: https://www.w3.org/TR/webnn/#tensor-limits-softmax
[7]: https://www.w3.org/TR/webnn/#tensor-limits-split
[8]: https://www.w3.org/TR/webnn/#tensor-limits-pad
[9]: https://www.w3.org/TR/webnn/#tensor-limits-slice

Change-Id: I8480cf9ef1e9e18a175677a16a553c1562a747c5
Bug: 446481989
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6972256
Commit-Queue: ningxin hu <ningxin.hu@intel.com>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1527306}

--

wpt-commits: a460ea73b9d67a705401622c6a7f8c0088b6a036
wpt-pr: 55147
mertcanaltin pushed a commit to mertcanaltin/wpt that referenced this pull request Oct 26, 2025
This CL aligns the tensor limits setting in
`WebNNContextImpl::IntersectWithBaseProperties` with spec, especially
for scalar operand limits that was fixed by spec PR [1].

The change includes:
1. argMin/Max doesn't accept scalar input and output data types except
   int32 and int64 [2]
2. batchNormalization doesn't accept scalar input [3]
3. concat doesn't accept scalar input [4]
4. conv2d/convTranspose2d only accept floating-point input data types
   [5]
5. softmax doesn't accept scalar input [6]
6. split doesn't accept scalar input [7]

Pad [8] and slice [9] support scalar input as a no-op. This CL
replaces pad or slice having scalar input with an identity operator at
MLGraphBuilder to unify the behaviors across backends.

[1]: webmachinelearning/webnn#882
[2]: https://www.w3.org/TR/webnn/#tensor-limits-argMin-argMax
[3]: https://www.w3.org/TR/webnn/#tensor-limits-batchNormalization
[4]: https://www.w3.org/TR/webnn/#tensor-limits-concat
[5]: https://www.w3.org/TR/webnn/#tensor-limits-conv2d
[6]: https://www.w3.org/TR/webnn/#tensor-limits-softmax
[7]: https://www.w3.org/TR/webnn/#tensor-limits-split
[8]: https://www.w3.org/TR/webnn/#tensor-limits-pad
[9]: https://www.w3.org/TR/webnn/#tensor-limits-slice

Change-Id: I8480cf9ef1e9e18a175677a16a553c1562a747c5
Bug: 446481989
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6972256
Commit-Queue: ningxin hu <ningxin.hu@intel.com>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1527306}
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.

Clarify 0D tensor (rank of 0) support for axis-dependent operations

3 participants