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

Current use of execution providers is suboptimal #30

Closed
DavidGOrtega opened this issue Mar 19, 2023 · 3 comments · Fixed by #35
Closed

Current use of execution providers is suboptimal #30

DavidGOrtega opened this issue Mar 19, 2023 · 3 comments · Fixed by #35

Comments

@DavidGOrtega
Copy link
Contributor

DavidGOrtega commented Mar 19, 2023

Currently the library only operates with the WASM backend even in nodejs. However the better approach should be use node bindings in node and add the webgl EP to automatically fallback to wasm if webgl is not supported by the model.

Currenly in code:

let session = await InferenceSession.create(buffer, {
  // executionProviders: ["webgl"]
  executionProviders: ["wasm"]
});

Hack to at least improve in the web

let session;

try {
    session = await InferenceSession.create(buffer, {
        executionProviders: ['webgl', 'wasm']
    });
} catch (err) {
    session = await InferenceSession.create(buffer, {
        executionProviders: ['wasm']
    });
}

I can prepare a PR to improve the execution in node and web 😃

@DavidGOrtega
Copy link
Contributor Author

related to #22 and #20

@xenova
Copy link
Collaborator

xenova commented Mar 19, 2023

Hi! Yes, please do make a PR :) any contributions are most welcome.

I just had a question about webgl support for some of the models. When initially testing with the webgl backend, I kept getting errors saying that certain operations weren't supported. It might have been because the models are quantised (8-bit), but either way, I wasn't able to get it working reliably enough.

Do you have any suggestions?

@DavidGOrtega
Copy link
Contributor Author

Hi! Yes, please do make a PR :) any contributions are most welcome.

Good! Let's do it!

Do you have any suggestions?

m open sourcing a project called aiui that transforms a model into an app, My first support was ONNX and it also happened to me. Not every layer is supported in webgl. It will depend on the model, but at least for the supported ones the speed will be very good.

Let me check what your script is doing.

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 a pull request may close this issue.

2 participants