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 NPU for SSD MobileNetV1 example #228

Merged

Conversation

huningxin
Copy link
Contributor

This change converts the float32 weigths to float16 at loading time. And it uses WebNN cast operator to convert float32 inputs to float16 before compute and convert float16 outputs back to float32 after compute.

/cc @mingmingtasd @ibelem

This change converts the float32 weigths to float16 at loading time. And
it uses WebNN cast operator to convert float32 inputs to float16 before
compute and convert float16 outputs back to float32 after compute.
@huningxin huningxin requested a review from Honry May 5, 2024 03:27
Copy link
Collaborator

@Honry Honry left a comment

Choose a reason for hiding this comment

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

@huningxin, thanks for the PR! Good idea to cast the float 32 to float 16 directly for NPU, maybe we can support fp16 in other samples like this if there's no precision issue.

common/utils.js Show resolved Hide resolved
Copy link
Collaborator

@Honry Honry left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@Honry Honry merged commit 555aeab into webmachinelearning:master May 6, 2024
0 of 3 checks passed
Honry pushed a commit to Honry/webnn-samples that referenced this pull request May 15, 2024
* Support NPU for SSD MobileNetV1 example

This change converts the float32 weigths to float16 at loading time. And
it uses WebNN cast operator to convert float32 inputs to float16 before
compute and convert float16 outputs back to float32 after compute.

* Fix lint error
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.

2 participants