Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support strides option for slice operator #772

Open
huningxin opened this issue Oct 25, 2024 · 3 comments
Open

Support strides option for slice operator #772

huningxin opened this issue Oct 25, 2024 · 3 comments

Comments

@huningxin
Copy link
Contributor

huningxin commented Oct 25, 2024

This is a separate issue of previous discussion #369 (comment) focusing on steps/strides support (proposed by @fdwr, thanks!).

A stride of slice operator indicates how many elements to advance when copying within the input tensor along a dimension. It is widely supported. However, today's WebNN slice operator only support stride 1. We observed there are real models using slice with stride > 1. When targeting those model to WebNN, the slice op has fallback to other execution provider and causes performance drop.

Frameworks' support

Native ML API's support

Proposal

dictionary MLSliceOptions : MLOperatorOptions {
  sequence<[EnforceRange] unsigned long> strides;
};

MLOperand slice(MLOperand input,
                sequence<[EnforceRange] unsigned long> starts,
                sequence<[EnforceRange] unsigned long> sizes,
                optional MLSliceOptions options = {});

Revision History:
10/29/2004: only support positive strides.

@a-sully
Copy link
Contributor

a-sully commented Oct 28, 2024

Seems reasonable to me 👍

@huningxin
Copy link
Contributor Author

Discussed with @fdwr offline, the negative strides may have ambiguities due to starting index. A separate reverse operator is proposed in #773. I'd update the proposal to support the positive strides as the starter.

@fdwr
Copy link
Collaborator

fdwr commented Oct 29, 2024

I'd update the proposal to support the positive strides as the starter.

Alrighty. Yeah, I can draw a diagram later illustrating the ambiguities related to negative strides, but positive strides are very clear.

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Nov 6, 2024
To fix the spec issue:
webmachinelearning/webnn#772

Bug: 376071284
Change-Id: I51dec37ce9a606941be3810ef0fd7b9e66edfef2
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 issue Nov 6, 2024
To fix the spec issue:
webmachinelearning/webnn#772

Bug: 376071284
Change-Id: I51dec37ce9a606941be3810ef0fd7b9e66edfef2
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/+/5975313
Commit-Queue: Shiyi Zou <shiyi.zou@intel.com>
Reviewed-by: ningxin hu <ningxin.hu@intel.com>
Auto-Submit: Shiyi Zou <shiyi.zou@intel.com>
Reviewed-by: Alex Gough <ajgo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1378794}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Nov 6, 2024
To fix the spec issue:
webmachinelearning/webnn#772

Bug: 376071284
Change-Id: I51dec37ce9a606941be3810ef0fd7b9e66edfef2
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/+/5975313
Commit-Queue: Shiyi Zou <shiyi.zou@intel.com>
Reviewed-by: ningxin hu <ningxin.hu@intel.com>
Auto-Submit: Shiyi Zou <shiyi.zou@intel.com>
Reviewed-by: Alex Gough <ajgo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1378794}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Nov 6, 2024
To fix the spec issue:
webmachinelearning/webnn#772

Bug: 376071284
Change-Id: I51dec37ce9a606941be3810ef0fd7b9e66edfef2
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/+/5975313
Commit-Queue: Shiyi Zou <shiyi.zou@intel.com>
Reviewed-by: ningxin hu <ningxin.hu@intel.com>
Auto-Submit: Shiyi Zou <shiyi.zou@intel.com>
Reviewed-by: Alex Gough <ajgo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1378794}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Nov 7, 2024
…r, a=testonly

Automatic update from web-platform-tests
webnn: support strides for slice operator

To fix the spec issue:
webmachinelearning/webnn#772

Bug: 376071284
Change-Id: I51dec37ce9a606941be3810ef0fd7b9e66edfef2
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/+/5975313
Commit-Queue: Shiyi Zou <shiyi.zou@intel.com>
Reviewed-by: ningxin hu <ningxin.hu@intel.com>
Auto-Submit: Shiyi Zou <shiyi.zou@intel.com>
Reviewed-by: Alex Gough <ajgo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1378794}

--

wpt-commits: d584e9246e5cf3e7c4a4d011ba46a3dc51ea9c5b
wpt-pr: 48995
ErichDonGubler pushed a commit to erichdongubler-mozilla/firefox that referenced this issue Nov 9, 2024
…r, a=testonly

Automatic update from web-platform-tests
webnn: support strides for slice operator

To fix the spec issue:
webmachinelearning/webnn#772

Bug: 376071284
Change-Id: I51dec37ce9a606941be3810ef0fd7b9e66edfef2
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/+/5975313
Commit-Queue: Shiyi Zou <shiyi.zou@intel.com>
Reviewed-by: ningxin hu <ningxin.hu@intel.com>
Auto-Submit: Shiyi Zou <shiyi.zou@intel.com>
Reviewed-by: Alex Gough <ajgo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1378794}

--

wpt-commits: d584e9246e5cf3e7c4a4d011ba46a3dc51ea9c5b
wpt-pr: 48995
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this issue Nov 16, 2024
…r, a=testonly

Automatic update from web-platform-tests
webnn: support strides for slice operator

To fix the spec issue:
webmachinelearning/webnn#772

Bug: 376071284
Change-Id: I51dec37ce9a606941be3810ef0fd7b9e66edfef2
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/+/5975313
Commit-Queue: Shiyi Zou <shiyi.zou@intel.com>
Reviewed-by: ningxin hu <ningxin.hu@intel.com>
Auto-Submit: Shiyi Zou <shiyi.zou@intel.com>
Reviewed-by: Alex Gough <ajgo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1378794}

--

wpt-commits: d584e9246e5cf3e7c4a4d011ba46a3dc51ea9c5b
wpt-pr: 48995
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants