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

[WebNN EP] Support Shape op #16282

Merged
merged 3 commits into from Jun 15, 2023
Merged

[WebNN EP] Support Shape op #16282

merged 3 commits into from Jun 15, 2023

Conversation

Honry
Copy link
Contributor

@Honry Honry commented Jun 8, 2023

Since WebNN API doesn't support shape op, in the WebNN EP, we calculate the ONNX Shape node output and pass the values to a WebNN's constant + slice as workaround.

Since WebNN API doesn't support shape op, in the WebNN EP,
we calculate the ONNX Shape node output and pass the values
to a WebNN's constant as workaround.
@Honry
Copy link
Contributor Author

Honry commented Jun 8, 2023

@fdwr, @guschmue, PTAL, I use WebNN's constant op to implement the shape op.

@Honry Honry changed the title Support Shape op [WebNN EP] Support Shape op Jun 8, 2023
@guschmue
Copy link
Contributor

/azp run ONNX Runtime Web CI Pipeline

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

guschmue
guschmue previously approved these changes Jun 13, 2023
@guschmue
Copy link
Contributor

/azp run ONNX Runtime Web CI Pipeline

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

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

Thanks Wanming. I'm still thinking ideas on how to mitigate GPU readback cost, because we don't actually want to use Const+Slice followed by a bunch of tiny operators (Gather, Concat...) when the end result is just another operator like Reshape consuming that tiny shape tensor. I think we'll need a heuristic like CUDA has for small tensors to prefer those remain on the CPU EP, along with any immediate successors (until reaching an op like Reshape or Expand which consumes that small tensor and should continue on the GPU again).

Note @guschmue that if we add AddFreeDimensionOverrideByName to the JS session options (I'm really surprised these are missing), then many of those Shape operators will be constant folded out anyway, mitigating this cost. It won't help for Segment Anything because of the dynamic input (that case required static model manipulation), but it will help for Stable Diffusion.

@guschmue
Copy link
Contributor

/azp run Linux CPU CI Pipeline,Linux CPU Minimal Build E2E CI Pipeline,Linux GPU CI Pipeline,Linux GPU TensorRT CI Pipeline,Linux OpenVINO CI Pipeline,Linux QNN CI Pipeline,MacOS CI Pipeline,Windows ARM64 QNN CI Pipeline,Windows CPU CI Pipeline

@guschmue
Copy link
Contributor

/azp run Windows GPU CI Pipeline,Windows GPU TensorRT CI Pipeline,onnxruntime-binary-size-checks-ci-pipeline,orttraining-linux-ci-pipeline,orttraining-linux-gpu-ci-pipeline,orttraining-ortmodule-distributed

@azure-pipelines
Copy link

Azure Pipelines successfully started running 9 pipeline(s).

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@guschmue
Copy link
Contributor

AddFreeDimensionOverrideByName : ok, I'll add it to my todo list

@fdwr fdwr merged commit 73dad44 into microsoft:main Jun 15, 2023
64 checks passed
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.

None yet

3 participants