-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[js/webnn] update API of session options for WebNN #20816
Conversation
@Honry @huningxin @egalli Please take a look and let me know if you have any concerns. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with questions, thanks much!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, this makes things very clear and fulfills all the requirements.
Thanks much @fs-eire!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for making all the API changes!
This change enables the API added in microsoft#20816 as well as moving context creation to JS.
### Description This PR enables the API added in #20816 as well as moving context creation to JS. ### Motivation and Context In order to enable I/O Binding with the upcoming [MLBuffer](webmachinelearning/webnn#542) API in the WebNN specification, we need to share the same `MLContext` across multiple sessions. This is because `MLBuffer`s are restricted to the `MLContext` where they were created. This PR enables developers to use the same `MLContext` across multiple sessions.
Description
This PR is an API-only change to address the requirements being discussed in #20729.
There are multiple ways that users may create an ORT session by specifying the session options differently.
All the code snippet below will use the variable
webnnOptions
as this:The old way (backward-compatibility)
The new way (specify with MLContext)
This should throw (because no deviceType is specified):
Interop with WebGPU
This should throw (because cannot specify both gpu device and MLContext option at the same time):