Skip to content

Conversation

@BruceDai
Copy link
Contributor

This PR is to fix the issue reported on https://issues.chromium.org/issues/383232123, the details of issue-383232123 as below.

Two tests cases fail on multiple platforms due to incorrect expected results when the output size is rounded up, requiring implicit zero padding:

l2Pool2d float32 4D tensor options.roundingType=ceil
l2Pool2d float32 4D tensor options.outputSizes ignores options.roundingType=floor
Both give following error for the [0, 2] output element:

assert_true: assert_array_approx_equals_ulp: test l2Pool2d float32 actual 90.6768569946289 should be
 close enough to expected 8222.29296875 by the acceptable 11 ULP distance, but they have 55254687 ULP
 distance expected true got false
The expected value of 8222 is not possible since the input elements are all < 100. The actual value of 90.677 has been confirmed correct via ORT CPU, multiple GPU implementations and manual calculation.

@fdwr @huningxin PTAL, thanks!

Copy link
Contributor

@huningxin huningxin left a comment

Choose a reason for hiding this comment

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

LGTM!

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Apr 2, 2025
This issue was introduced by incorrect implementation of l2Pool2d
operator for the case of sliding window having two valid elements in
webnn-baseline project. I've submitted a fixing PR[1] there, then got
the correct expected data for this CL.

[1]: webmachinelearning/webnn-baseline#125

Bug: 383232123
Change-Id: Icdbc0859e642b832330ae309668444a000ff280d
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
src/reduce.js Outdated
sumOfSquares = previousValue + currentValue * currentValue;
}

return (currentIndex === array.length - 1) ? Math.sqrt(sumOfSquares) : sumOfSquares;
Copy link

@fdwr fdwr Apr 4, 2025

Choose a reason for hiding this comment

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

Hmm, it's kinda complicated to figure this out, given the special cases for the first and last element. Looking at what you did for other similar cases like how you implemented reduceSumSquare and reduceLogSum, would it be simpler and more compositional to implement 2D Lebesgue pooling (y = (x1^p + x2^p + ... + xn^p) ^ (1/p)) as:

export function l2Pool2d(input, options = {}) {
  const squaredInput = pow(input, new Scalar(2));
  const pooledInput = pool2d(squaredInput, sumReducer, options);
  return pow(pooledInput, new Scalar(0.5));
}
export function reduceSumSquare(input, options = {}) {
  return reduceSum(pow(input, new Scalar(2)), options);
}

export function reduceLogSum(input, options = {}) {
  return log(reduceSum(input, options));
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated! Please take another look, thanks!

Copy link

@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.

Yeah, much clearer (at least to me, and hopefully later generations of readers after us too 😉).

aarongable pushed a commit to chromium/chromium that referenced this pull request Apr 7, 2025
This issue was introduced by incorrect implementation of l2Pool2d
operator for the case of sliding window having two valid elements in
webnn-baseline project. I've submitted a fixing PR[1] there, then got
the correct expected data for this CL.

[1]: webmachinelearning/webnn-baseline#125

Bug: 383232123
Change-Id: Icdbc0859e642b832330ae309668444a000ff280d
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
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6415990
Reviewed-by: Austin Sullivan <asully@chromium.org>
Auto-Submit: Feng Dai <feng.dai@intel.com>
Reviewed-by: ningxin hu <ningxin.hu@intel.com>
Commit-Queue: Feng Dai <feng.dai@intel.com>
Cr-Commit-Position: refs/heads/main@{#1443301}
Copy link

@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.

Reapproving after data merge.

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Apr 7, 2025
This issue was introduced by incorrect implementation of l2Pool2d
operator for the case of sliding window having two valid elements in
webnn-baseline project. I've submitted a fixing PR[1] there, then got
the correct expected data for this CL.

[1]: webmachinelearning/webnn-baseline#125

Bug: 383232123
Change-Id: Icdbc0859e642b832330ae309668444a000ff280d
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
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6415990
Reviewed-by: Austin Sullivan <asully@chromium.org>
Auto-Submit: Feng Dai <feng.dai@intel.com>
Reviewed-by: ningxin hu <ningxin.hu@intel.com>
Commit-Queue: Feng Dai <feng.dai@intel.com>
Cr-Commit-Position: refs/heads/main@{#1443301}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Apr 7, 2025
This issue was introduced by incorrect implementation of l2Pool2d
operator for the case of sliding window having two valid elements in
webnn-baseline project. I've submitted a fixing PR[1] there, then got
the correct expected data for this CL.

[1]: webmachinelearning/webnn-baseline#125

Bug: 383232123
Change-Id: Icdbc0859e642b832330ae309668444a000ff280d
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
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6415990
Reviewed-by: Austin Sullivan <asully@chromium.org>
Auto-Submit: Feng Dai <feng.dai@intel.com>
Reviewed-by: ningxin hu <ningxin.hu@intel.com>
Commit-Queue: Feng Dai <feng.dai@intel.com>
Cr-Commit-Position: refs/heads/main@{#1443301}
@huningxin huningxin merged commit b7a6aae into webmachinelearning:main Apr 8, 2025
3 checks passed
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Apr 9, 2025
…tests, a=testonly

Automatic update from web-platform-tests
webnn: fixed wrong results for l2Pool2d tests

This issue was introduced by incorrect implementation of l2Pool2d
operator for the case of sliding window having two valid elements in
webnn-baseline project. I've submitted a fixing PR[1] there, then got
the correct expected data for this CL.

[1]: webmachinelearning/webnn-baseline#125

Bug: 383232123
Change-Id: Icdbc0859e642b832330ae309668444a000ff280d
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
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6415990
Reviewed-by: Austin Sullivan <asully@chromium.org>
Auto-Submit: Feng Dai <feng.dai@intel.com>
Reviewed-by: ningxin hu <ningxin.hu@intel.com>
Commit-Queue: Feng Dai <feng.dai@intel.com>
Cr-Commit-Position: refs/heads/main@{#1443301}

--

wpt-commits: ecd6a697f24a5f3206fa2b599c0a083a6b52df5a
wpt-pr: 51783
aosmond pushed a commit to aosmond/gecko that referenced this pull request Apr 10, 2025
…tests, a=testonly

Automatic update from web-platform-tests
webnn: fixed wrong results for l2Pool2d tests

This issue was introduced by incorrect implementation of l2Pool2d
operator for the case of sliding window having two valid elements in
webnn-baseline project. I've submitted a fixing PR[1] there, then got
the correct expected data for this CL.

[1]: webmachinelearning/webnn-baseline#125

Bug: 383232123
Change-Id: Icdbc0859e642b832330ae309668444a000ff280d
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
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6415990
Reviewed-by: Austin Sullivan <asully@chromium.org>
Auto-Submit: Feng Dai <feng.dai@intel.com>
Reviewed-by: ningxin hu <ningxin.hu@intel.com>
Commit-Queue: Feng Dai <feng.dai@intel.com>
Cr-Commit-Position: refs/heads/main@{#1443301}

--

wpt-commits: ecd6a697f24a5f3206fa2b599c0a083a6b52df5a
wpt-pr: 51783
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this pull request Apr 11, 2025
…tests, a=testonly

Automatic update from web-platform-tests
webnn: fixed wrong results for l2Pool2d tests

This issue was introduced by incorrect implementation of l2Pool2d
operator for the case of sliding window having two valid elements in
webnn-baseline project. I've submitted a fixing PR[1] there, then got
the correct expected data for this CL.

[1]: webmachinelearning/webnn-baseline#125

Bug: 383232123
Change-Id: Icdbc0859e642b832330ae309668444a000ff280d
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
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6415990
Reviewed-by: Austin Sullivan <asully@chromium.org>
Auto-Submit: Feng Dai <feng.dai@intel.com>
Reviewed-by: ningxin hu <ningxin.hu@intel.com>
Commit-Queue: Feng Dai <feng.dai@intel.com>
Cr-Commit-Position: refs/heads/main@{#1443301}

--

wpt-commits: ecd6a697f24a5f3206fa2b599c0a083a6b52df5a
wpt-pr: 51783
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Apr 16, 2025
…tests, a=testonly

Automatic update from web-platform-tests
webnn: fixed wrong results for l2Pool2d tests

This issue was introduced by incorrect implementation of l2Pool2d
operator for the case of sliding window having two valid elements in
webnn-baseline project. I've submitted a fixing PR[1] there, then got
the correct expected data for this CL.

[1]: webmachinelearning/webnn-baseline#125

Bug: 383232123
Change-Id: Icdbc0859e642b832330ae309668444a000ff280d
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
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6415990
Reviewed-by: Austin Sullivan <asullychromium.org>
Auto-Submit: Feng Dai <feng.daiintel.com>
Reviewed-by: ningxin hu <ningxin.huintel.com>
Commit-Queue: Feng Dai <feng.daiintel.com>
Cr-Commit-Position: refs/heads/main{#1443301}

--

wpt-commits: ecd6a697f24a5f3206fa2b599c0a083a6b52df5a
wpt-pr: 51783

UltraBlame original commit: 85119108de0ce6ebcd38fb09b3db8ebc926841ee
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Apr 16, 2025
…tests, a=testonly

Automatic update from web-platform-tests
webnn: fixed wrong results for l2Pool2d tests

This issue was introduced by incorrect implementation of l2Pool2d
operator for the case of sliding window having two valid elements in
webnn-baseline project. I've submitted a fixing PR[1] there, then got
the correct expected data for this CL.

[1]: webmachinelearning/webnn-baseline#125

Bug: 383232123
Change-Id: Icdbc0859e642b832330ae309668444a000ff280d
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
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6415990
Reviewed-by: Austin Sullivan <asullychromium.org>
Auto-Submit: Feng Dai <feng.daiintel.com>
Reviewed-by: ningxin hu <ningxin.huintel.com>
Commit-Queue: Feng Dai <feng.daiintel.com>
Cr-Commit-Position: refs/heads/main{#1443301}

--

wpt-commits: ecd6a697f24a5f3206fa2b599c0a083a6b52df5a
wpt-pr: 51783

UltraBlame original commit: 85119108de0ce6ebcd38fb09b3db8ebc926841ee
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Apr 16, 2025
…tests, a=testonly

Automatic update from web-platform-tests
webnn: fixed wrong results for l2Pool2d tests

This issue was introduced by incorrect implementation of l2Pool2d
operator for the case of sliding window having two valid elements in
webnn-baseline project. I've submitted a fixing PR[1] there, then got
the correct expected data for this CL.

[1]: webmachinelearning/webnn-baseline#125

Bug: 383232123
Change-Id: Icdbc0859e642b832330ae309668444a000ff280d
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
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6415990
Reviewed-by: Austin Sullivan <asullychromium.org>
Auto-Submit: Feng Dai <feng.daiintel.com>
Reviewed-by: ningxin hu <ningxin.huintel.com>
Commit-Queue: Feng Dai <feng.daiintel.com>
Cr-Commit-Position: refs/heads/main{#1443301}

--

wpt-commits: ecd6a697f24a5f3206fa2b599c0a083a6b52df5a
wpt-pr: 51783

UltraBlame original commit: 85119108de0ce6ebcd38fb09b3db8ebc926841ee
jwidar pushed a commit to jwidar/LatencyZeroGithub that referenced this pull request Sep 16, 2025
…tests, a=testonly

Automatic update from web-platform-tests
webnn: fixed wrong results for l2Pool2d tests

This issue was introduced by incorrect implementation of l2Pool2d
operator for the case of sliding window having two valid elements in
webnn-baseline project. I've submitted a fixing PR[1] there, then got
the correct expected data for this CL.

[1]: webmachinelearning/webnn-baseline#125

Bug: 383232123
Change-Id: Icdbc0859e642b832330ae309668444a000ff280d
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
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6415990
Reviewed-by: Austin Sullivan <asully@chromium.org>
Auto-Submit: Feng Dai <feng.dai@intel.com>
Reviewed-by: ningxin hu <ningxin.hu@intel.com>
Commit-Queue: Feng Dai <feng.dai@intel.com>
Cr-Commit-Position: refs/heads/main@{#1443301}

--

wpt-commits: ecd6a697f24a5f3206fa2b599c0a083a6b52df5a
wpt-pr: 51783
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.

3 participants