Skip to content

Comments

Restrict padding options to better match backend limits#843

Merged
fdwr merged 3 commits intowebmachinelearning:mainfrom
inexorabletash:pad-constraints
May 9, 2025
Merged

Restrict padding options to better match backend limits#843
fdwr merged 3 commits intowebmachinelearning:mainfrom
inexorabletash:pad-constraints

Conversation

@inexorabletash
Copy link
Contributor

@inexorabletash inexorabletash commented Apr 29, 2025

Per discussion in the linked issues and working group, drop "symmetric" padding since it is not widely supported by backends, isn't used by notable models, and can be emulated. Also for non-constant padding, backends typically impose restrictions on the amount of padding to reasonable values based on the input size, so incorporate those limits too.

Resolves #377. Resolves #739.


Preview | Diff

Per discussion in the linked issues and working group, drop
"symmetric" padding since it is not widely supported by backends,
isn't used by notable models, and can be emulated. Also for
non-constant padding, backends typically impose restrictions on the
amount of padding to reasonable values based on the input size, so
incorporate those limits too.

Resolves #377. Resolves #739.
@inexorabletash
Copy link
Contributor Author

Notes:

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.

Thank you Joshua.

If we need to restore the edge-inclusive reflection¹, then we can easily construct it from two pad calls, just inflating by 1 replicated tensel and then using edge-exclusive reflection: pad(pad(input, [1,1,1,1...], "replicate"), paddingMinusOne, "reflect").

¹ I'm starting to refer to it as this, since "reflection" and "symmetric" alone are less clear, as I always forget which "reflection" is edge-inclusive (standard behavior for textures in graphics API's) vs which reflection is edge-exclusive (the more common one in ML).

Co-authored-by: Dwayne Robinson <[email protected]>
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.

👍

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.

Removing edge replication size restriction LGTM.

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!

@fdwr fdwr merged commit 3aa67b3 into webmachinelearning:main May 9, 2025
2 checks passed
github-actions bot added a commit that referenced this pull request May 9, 2025
SHA: 3aa67b3
Reason: push, by fdwr

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@inexorabletash inexorabletash deleted the pad-constraints branch May 9, 2025 02:47
aarongable pushed a commit to chromium/chromium that referenced this pull request May 19, 2025
This CL is to update tests align with latest WebNN API Spec change for
pad()[1] by removing one conformance test with symmetric padding mode
and adding four validation tests of restrict the padding size for
reflection model. The failure validation tests are tracked by
issue#417227410[2].

[1] webmachinelearning/webnn#843
[2] https://issues.chromium.org/issues/417227410

Bug: 416604162
Change-Id: I7a3ec7539138019c7cab78eb3cd616de3a7d630d
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/+/6529861
Reviewed-by: Reilly Grant <[email protected]>
Reviewed-by: ningxin hu <[email protected]>
Auto-Submit: Feng Dai <[email protected]>
Commit-Queue: Feng Dai <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1461938}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request May 19, 2025
This CL is to update tests align with latest WebNN API Spec change for
pad()[1] by removing one conformance test with symmetric padding mode
and adding four validation tests of restrict the padding size for
reflection model. The failure validation tests are tracked by
issue#417227410[2].

[1] webmachinelearning/webnn#843
[2] https://issues.chromium.org/issues/417227410

Bug: 416604162
Change-Id: I7a3ec7539138019c7cab78eb3cd616de3a7d630d
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/+/6529861
Reviewed-by: Reilly Grant <[email protected]>
Reviewed-by: ningxin hu <[email protected]>
Auto-Submit: Feng Dai <[email protected]>
Commit-Queue: Feng Dai <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1461938}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request May 19, 2025
This CL is to update tests align with latest WebNN API Spec change for
pad()[1] by removing one conformance test with symmetric padding mode
and adding four validation tests of restrict the padding size for
reflection model. The failure validation tests are tracked by
issue#417227410[2].

[1] webmachinelearning/webnn#843
[2] https://issues.chromium.org/issues/417227410

Bug: 416604162
Change-Id: I7a3ec7539138019c7cab78eb3cd616de3a7d630d
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/+/6529861
Reviewed-by: Reilly Grant <[email protected]>
Reviewed-by: ningxin hu <[email protected]>
Auto-Submit: Feng Dai <[email protected]>
Commit-Queue: Feng Dai <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1461938}
aarongable pushed a commit to chromium/chromium that referenced this pull request May 20, 2025
Implement the spec change [1] for removing symmetric padding mode. The
padding size restriction for reflection padding mode will be fixed in a
follow-up CL.

[1]:webmachinelearning/webnn#843

Bug: 417227410
Change-Id: If9afb745696b1b6cdae4c2f6583715b526fa4d59
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6557483
Reviewed-by: Alex Gough <[email protected]>
Commit-Queue: ningxin hu <[email protected]>
Reviewed-by: Phillis Tang <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1462516}
lando-prod-mozilla bot pushed a commit to mozilla-firefox/firefox that referenced this pull request May 22, 2025
…bNN API Spec change for pad(),

Automatic update from web-platform-tests
webnn: update tests align with latest WebNN API Spec change for pad()

This CL is to update tests align with latest WebNN API Spec change for
pad()[1] by removing one conformance test with symmetric padding mode
and adding four validation tests of restrict the padding size for
reflection model. The failure validation tests are tracked by
issue#417227410[2].

[1] webmachinelearning/webnn#843
[2] https://issues.chromium.org/issues/417227410

Bug: 416604162
Change-Id: I7a3ec7539138019c7cab78eb3cd616de3a7d630d
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/+/6529861
Reviewed-by: Reilly Grant <[email protected]>
Reviewed-by: ningxin hu <[email protected]>
Auto-Submit: Feng Dai <[email protected]>
Commit-Queue: Feng Dai <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1461938}

--

wpt-commits: 2a5ceec5c242259bafaab3091625ae2d5af89d9a
wpt-pr: 52629

Differential Revision: https://phabricator.services.mozilla.com/D250693
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request May 22, 2025
…bNN API Spec change for pad(),

Automatic update from web-platform-tests
webnn: update tests align with latest WebNN API Spec change for pad()

This CL is to update tests align with latest WebNN API Spec change for
pad()[1] by removing one conformance test with symmetric padding mode
and adding four validation tests of restrict the padding size for
reflection model. The failure validation tests are tracked by
issue#417227410[2].

[1] webmachinelearning/webnn#843
[2] https://issues.chromium.org/issues/417227410

Bug: 416604162
Change-Id: I7a3ec7539138019c7cab78eb3cd616de3a7d630d
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/+/6529861
Reviewed-by: Reilly Grant <[email protected]>
Reviewed-by: ningxin hu <[email protected]>
Auto-Submit: Feng Dai <[email protected]>
Commit-Queue: Feng Dai <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1461938}

--

wpt-commits: 2a5ceec5c242259bafaab3091625ae2d5af89d9a
wpt-pr: 52629

Differential Revision: https://phabricator.services.mozilla.com/D250693
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request May 28, 2025
…bNN API Spec change for pad(),

Automatic update from web-platform-tests
webnn: update tests align with latest WebNN API Spec change for pad()

This CL is to update tests align with latest WebNN API Spec change for
pad()[1] by removing one conformance test with symmetric padding mode
and adding four validation tests of restrict the padding size for
reflection model. The failure validation tests are tracked by
issue#417227410[2].

[1] webmachinelearning/webnn#843
[2] https://issues.chromium.org/issues/417227410

Bug: 416604162
Change-Id: I7a3ec7539138019c7cab78eb3cd616de3a7d630d
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/+/6529861
Reviewed-by: Reilly Grant <reillygchromium.org>
Reviewed-by: ningxin hu <ningxin.huintel.com>
Auto-Submit: Feng Dai <feng.daiintel.com>
Commit-Queue: Feng Dai <feng.daiintel.com>
Cr-Commit-Position: refs/heads/main{#1461938}

--

wpt-commits: 2a5ceec5c242259bafaab3091625ae2d5af89d9a
wpt-pr: 52629

Differential Revision: https://phabricator.services.mozilla.com/D250693

UltraBlame original commit: 1f32789a126993b3a7254926412f6c3e5d15b8a6
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request May 28, 2025
…bNN API Spec change for pad(),

Automatic update from web-platform-tests
webnn: update tests align with latest WebNN API Spec change for pad()

This CL is to update tests align with latest WebNN API Spec change for
pad()[1] by removing one conformance test with symmetric padding mode
and adding four validation tests of restrict the padding size for
reflection model. The failure validation tests are tracked by
issue#417227410[2].

[1] webmachinelearning/webnn#843
[2] https://issues.chromium.org/issues/417227410

Bug: 416604162
Change-Id: I7a3ec7539138019c7cab78eb3cd616de3a7d630d
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/+/6529861
Reviewed-by: Reilly Grant <reillygchromium.org>
Reviewed-by: ningxin hu <ningxin.huintel.com>
Auto-Submit: Feng Dai <feng.daiintel.com>
Commit-Queue: Feng Dai <feng.daiintel.com>
Cr-Commit-Position: refs/heads/main{#1461938}

--

wpt-commits: 2a5ceec5c242259bafaab3091625ae2d5af89d9a
wpt-pr: 52629

Differential Revision: https://phabricator.services.mozilla.com/D250693

UltraBlame original commit: 1f32789a126993b3a7254926412f6c3e5d15b8a6
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request May 28, 2025
…bNN API Spec change for pad(),

Automatic update from web-platform-tests
webnn: update tests align with latest WebNN API Spec change for pad()

This CL is to update tests align with latest WebNN API Spec change for
pad()[1] by removing one conformance test with symmetric padding mode
and adding four validation tests of restrict the padding size for
reflection model. The failure validation tests are tracked by
issue#417227410[2].

[1] webmachinelearning/webnn#843
[2] https://issues.chromium.org/issues/417227410

Bug: 416604162
Change-Id: I7a3ec7539138019c7cab78eb3cd616de3a7d630d
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/+/6529861
Reviewed-by: Reilly Grant <reillygchromium.org>
Reviewed-by: ningxin hu <ningxin.huintel.com>
Auto-Submit: Feng Dai <feng.daiintel.com>
Commit-Queue: Feng Dai <feng.daiintel.com>
Cr-Commit-Position: refs/heads/main{#1461938}

--

wpt-commits: 2a5ceec5c242259bafaab3091625ae2d5af89d9a
wpt-pr: 52629

Differential Revision: https://phabricator.services.mozilla.com/D250693

UltraBlame original commit: 1f32789a126993b3a7254926412f6c3e5d15b8a6
aarongable pushed a commit to chromium/chromium that referenced this pull request May 29, 2025
This CL implements the padding size restriction for reflection padding
mode that was introduced by WebNN spec change [1].

With this CL, the WPT tests for validating reflection padding size
restriction [2] now can pass. This CL also rebaselines the WPT test
results.

[1]: webmachinelearning/webnn#843
[2]: https://chromium-review.googlesource.com/c/chromium/src/+/6529861

Bug: 417227410
Change-Id: I4600f7624179f6058828f165221c063db112b182
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6586298
Reviewed-by: Phillis Tang <[email protected]>
Commit-Queue: ningxin hu <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1466903}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants