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 reverse operator #773

Open
huningxin opened this issue Oct 29, 2024 · 1 comment
Open

Support reverse operator #773

huningxin opened this issue Oct 29, 2024 · 1 comment

Comments

@huningxin
Copy link
Contributor

This operator reverses the order of the input tensor along specified axes. There are some pytorch models using flip operator. When they target WebNN, the flip/reverse operator get fallback to other execution providers and cause performance drop.

Frameworks' support

  • PyTorch flip
  • TensorFlow reverse
  • ONNX Slice support reverse slicing by setting step to -1

Native ML API's support

Proposal

dictionary MLReverseOptions : MLOperatorOptions {
  sequence<[EnforceRange] unsigned long> axes;
};
 
MLOperand reverse(MLOperand input, optional MLReverseOptions options = {});

Discussed with @fdwr offline, Dwayne recommended treating the axes similar to reduce operators. So if not provided at all, then all axes are reversed; but if explicitly passed as empty, then no axes are reversed.

@fdwr
Copy link
Collaborator

fdwr commented Oct 29, 2024

Signature looks good to me Ningxin. 👍

Also related:

  • StableHLO reverse
  • tosa.reverse (mlir::tosa::ReverseOp)
  • ANEURALNETWORKS_REVERSE
  • PyTorch prims rev

(historical trivia) There was actually an ONNX Reverse operator here briefly, but it was rushed before all the feedback was addressed and reverted, and then it appears Peyman never followed up with an updated version. 🤷‍♂️. (I've also thought about adding a DML_OPERATOR_REVERSE before, but didn't get to it as I didn't know a clear model that used it)

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Nov 6, 2024
This CL adds IDL and mojo definition of reverse operator according to
the spec issue [1] and implements it on DirectML backend.

[1] webmachinelearning/webnn#773

Bug: 376707210
Change-Id: I0d42b49b87ce243db9d44512e6000c7ee901077b
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 issue Nov 8, 2024
This CL adds IDL and mojo definition of reverse operator according to
the spec issue [1] and implements it on DirectML backend.

[1] webmachinelearning/webnn#773

Bug: 376707210
Change-Id: I0d42b49b87ce243db9d44512e6000c7ee901077b
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 13, 2024
This CL adds IDL and mojo definition of reverse operator according to
the spec issue [1] and implements it on DirectML backend.

[1] webmachinelearning/webnn#773

Bug: 376707210
Change-Id: I0d42b49b87ce243db9d44512e6000c7ee901077b
Cq-Include-Trybots: luci.chromium.try:win11-blink-rel, mac14.arm64-blink-rel, mac15.arm64-blink-rel, linux-blink-rel
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5979825
Commit-Queue: ningxin hu <[email protected]>
Auto-Submit: Shiyi Zou <[email protected]>
Reviewed-by: Austin Sullivan <[email protected]>
Reviewed-by: ningxin hu <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1382078}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Nov 13, 2024
This CL adds IDL and mojo definition of reverse operator according to
the spec issue [1] and implements it on DirectML backend.

[1] webmachinelearning/webnn#773

Bug: 376707210
Change-Id: I0d42b49b87ce243db9d44512e6000c7ee901077b
Cq-Include-Trybots: luci.chromium.try:win11-blink-rel, mac14.arm64-blink-rel, mac15.arm64-blink-rel, linux-blink-rel
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5979825
Commit-Queue: ningxin hu <[email protected]>
Auto-Submit: Shiyi Zou <[email protected]>
Reviewed-by: Austin Sullivan <[email protected]>
Reviewed-by: ningxin hu <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1382078}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Nov 13, 2024
This CL adds IDL and mojo definition of reverse operator according to
the spec issue [1] and implements it on DirectML backend.

[1] webmachinelearning/webnn#773

Bug: 376707210
Change-Id: I0d42b49b87ce243db9d44512e6000c7ee901077b
Cq-Include-Trybots: luci.chromium.try:win11-blink-rel, mac14.arm64-blink-rel, mac15.arm64-blink-rel, linux-blink-rel
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5979825
Commit-Queue: ningxin hu <[email protected]>
Auto-Submit: Shiyi Zou <[email protected]>
Reviewed-by: Austin Sullivan <[email protected]>
Reviewed-by: ningxin hu <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1382078}
aarongable pushed a commit to chromium/chromium that referenced this issue Nov 13, 2024
This reverts commit 0459ac1.

Reason for revert: https://ci.chromium.org/ui/p/chromium/builders/ci/mac14-arm64-rel-tests/12103/test-results?sortby=&groupby=

Original change's description:
> webnn: implement reverse operator
>
> This CL adds IDL and mojo definition of reverse operator according to
> the spec issue [1] and implements it on DirectML backend.
>
> [1] webmachinelearning/webnn#773
>
> Bug: 376707210
> Change-Id: I0d42b49b87ce243db9d44512e6000c7ee901077b
> Cq-Include-Trybots: luci.chromium.try:win11-blink-rel, mac14.arm64-blink-rel, mac15.arm64-blink-rel, linux-blink-rel
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5979825
> Commit-Queue: ningxin hu <[email protected]>
> Auto-Submit: Shiyi Zou <[email protected]>
> Reviewed-by: Austin Sullivan <[email protected]>
> Reviewed-by: ningxin hu <[email protected]>
> Cr-Commit-Position: refs/heads/main@{#1382078}

Bug: 376707210
Change-Id: Ie7ddada84b0e196d70da5cc42fab2c4ba2b0a13a
Cq-Include-Trybots: luci.chromium.try:win11-blink-rel, mac14.arm64-blink-rel, mac15.arm64-blink-rel, linux-blink-rel
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6013929
Commit-Queue: Rubber Stamper <[email protected]>
Bot-Commit: Rubber Stamper <[email protected]>
Reviewed-by: Yoichi Osato <[email protected]>
Owners-Override: Yoichi Osato <[email protected]>
Auto-Submit: Yoichi Osato <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1382142}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Nov 13, 2024
This reverts commit 0459ac1a9b94c1dd3e11410f7fb74f0a8e2ddeaf.

Reason for revert: https://ci.chromium.org/ui/p/chromium/builders/ci/mac14-arm64-rel-tests/12103/test-results?sortby=&groupby=

Original change's description:
> webnn: implement reverse operator
>
> This CL adds IDL and mojo definition of reverse operator according to
> the spec issue [1] and implements it on DirectML backend.
>
> [1] webmachinelearning/webnn#773
>
> Bug: 376707210
> Change-Id: I0d42b49b87ce243db9d44512e6000c7ee901077b
> Cq-Include-Trybots: luci.chromium.try:win11-blink-rel, mac14.arm64-blink-rel, mac15.arm64-blink-rel, linux-blink-rel
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5979825
> Commit-Queue: ningxin hu <[email protected]>
> Auto-Submit: Shiyi Zou <[email protected]>
> Reviewed-by: Austin Sullivan <[email protected]>
> Reviewed-by: ningxin hu <[email protected]>
> Cr-Commit-Position: refs/heads/main@{#1382078}

Bug: 376707210
Change-Id: Ie7ddada84b0e196d70da5cc42fab2c4ba2b0a13a
Cq-Include-Trybots: luci.chromium.try:win11-blink-rel, mac14.arm64-blink-rel, mac15.arm64-blink-rel, linux-blink-rel
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6013929
Commit-Queue: Rubber Stamper <[email protected]>
Bot-Commit: Rubber Stamper <[email protected]>
Reviewed-by: Yoichi Osato <[email protected]>
Owners-Override: Yoichi Osato <[email protected]>
Auto-Submit: Yoichi Osato <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1382142}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Nov 13, 2024
This reverts commit 0459ac1a9b94c1dd3e11410f7fb74f0a8e2ddeaf.

Reason for revert: https://ci.chromium.org/ui/p/chromium/builders/ci/mac14-arm64-rel-tests/12103/test-results?sortby=&groupby=

Original change's description:
> webnn: implement reverse operator
>
> This CL adds IDL and mojo definition of reverse operator according to
> the spec issue [1] and implements it on DirectML backend.
>
> [1] webmachinelearning/webnn#773
>
> Bug: 376707210
> Change-Id: I0d42b49b87ce243db9d44512e6000c7ee901077b
> Cq-Include-Trybots: luci.chromium.try:win11-blink-rel, mac14.arm64-blink-rel, mac15.arm64-blink-rel, linux-blink-rel
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5979825
> Commit-Queue: ningxin hu <[email protected]>
> Auto-Submit: Shiyi Zou <[email protected]>
> Reviewed-by: Austin Sullivan <[email protected]>
> Reviewed-by: ningxin hu <[email protected]>
> Cr-Commit-Position: refs/heads/main@{#1382078}

Bug: 376707210
Change-Id: Ie7ddada84b0e196d70da5cc42fab2c4ba2b0a13a
Cq-Include-Trybots: luci.chromium.try:win11-blink-rel, mac14.arm64-blink-rel, mac15.arm64-blink-rel, linux-blink-rel
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6013929
Commit-Queue: Rubber Stamper <[email protected]>
Bot-Commit: Rubber Stamper <[email protected]>
Reviewed-by: Yoichi Osato <[email protected]>
Owners-Override: Yoichi Osato <[email protected]>
Auto-Submit: Yoichi Osato <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1382142}
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

3 participants