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

"The context paramter [sic] is invalid" error if Experimental Web Platform features flag is on #186

Open
anssiko opened this issue Nov 8, 2022 · 3 comments
Assignees

Comments

@anssiko
Copy link
Member

anssiko commented Nov 8, 2022

All samples at https://webmachinelearning.github.io/webnn-samples/ fail with:

The context paramter is invalid

If chrome://flags/#enable-experimental-web-platform-features is enabled.

Tested with Chrome Stable 107 and Canary 109.

@huningxin
Copy link
Contributor

The model loader API exposes the MLContext interface and it will be enabled by this flag. The webnn-polyfill should adapt to this and only polyfill the MLGraphBuilder and MLGraph interfaces.

@BruceDai , could you please take a look at this issue?

@BruceDai BruceDai self-assigned this Nov 9, 2022
@BruceDai
Copy link
Collaborator

BruceDai commented Nov 9, 2022

Yes, when testing by Chrome with enabled enable-experimental-web-platform-features flag, the following code would invoke createContext() function of ML interface from Model Load API.

const context = navigator.ml.createContext(contextOptions);

The createContext() function of Model Load API is an async function, it returns a Promise<MLContext> object, while WebNN API MLGraphBuilder constructor requires a context parameter of MLContext type, so the error was alerted.

this.builder_ = new MLGraphBuilder(context);

To fix this issue need modify code using await, @Honry PTAL, thanks.

const context = await navigator.ml.createContext(contextOptions);

while there's an issue webmachinelearning/model-loader#41 of Model Load API.

And current WebNN Polyfill API checks whether Navigator object has ML interface, if not, WebNN Polyfill API will provide it.

if (navigator.ml == null) {
  navigator.ml = new ML();
}

@Honry
Copy link
Contributor

Honry commented Nov 10, 2022

We are enabling latest async and sync APIs (PRs: #172, webmachinelearning/webnn-samples#150), which should fix this issue.

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

No branches or pull requests

4 participants