-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
[Web] How to use JSEP and WebGPU in static library (missing jsepAlloc or jsepInit) #23072
Comments
JSEP does not work in ONNX Runtime WebAssembly static lib, because it depends on the inter-op between JS and C++ specifically defined for the JavaScript library. We are currently working on a C++ implemented WebGPU EP, which is technically able to work in wasm static lib. It is still being worked on. |
Thanks! |
Is there an alternative, for example if I use webgpu without JSEP? But this involves another component called "dawn" |
if you are building C++ targeting web (wasm), then your application should not depend the native implementation of dawn. instead, you should use the dawn's fork of Emscripten in order to compile the code that uses WebGPU API. However, as I explained above, we've not get to there yet. We will work on it but since that involves quite code and build script changes it may take a while. |
Thanks for the clear explanation @fs-eire, do you happen to have a rough estimate of when this is expected to be completed? |
it's about 3-4 months or so |
Looking forward for WebGPU being available as execution runner in the Emscripten environment! May I ask how is it possible that WebGPU is already available in PS: My running assumption is that |
Is this available now? #23364 (comment) |
Please track #23697 |
Describe the issue
Hello,
I have C++ code that uses the ONNXRuntime CXX API which I compile against static onnxruntime wasm (
--build_wasm_static_lib
- full build commands are shown at the bottom). I link against the static lib in my CMakeLists.txt file like so:When building with onnxruntime only using simd, my code works fine. When building with webgpu support through jsep
and using the js execution provider in the C++ code:
This is the javascript webworker code which imports the wasm module:
I get an error when using my code, saying
Module.jsepAlloc is not a function
. This is printed by my wasm module in the Chrome developer console:I believe it's because I'm using the static lib which is missing the
jsepInit
step we find in the fileort-wasm-simd.jsep.mjs
is built with the non-static--build_wasm
. I have also read this guide https://gist.github.com/fs-eire/a55b2c7e10a6864b9602c279b8b75dceI tried to include
pre-jsep.js
in my link flags:It's probably missing other ts or js files. Any advice? @fs-eire sorry to ping you directly but you seem to be the WebGPU/JSEP implementor
Build commands:
Simd no webgpu:
Webgpu jsep:
To reproduce
Write custom C++ code using ORT CXX API, build onnxruntime WASM static lib with jsep and webgpu support, you might get a
Module.jsepAlloc is not a function
Urgency
No response
ONNX Runtime Installation
Built from Source
ONNX Runtime Version or Commit ID
deee480
Execution Provider
'webgpu' (WebGPU)
The text was updated successfully, but these errors were encountered: