ort: Support for `wasm32-unknown-unknown`
What
ONNXRuntime supports wasm targets via it’s onnxruntime for web bindings.
According to this page you can build a static lib of onnxruntime for wasm targets which you can then bundle with your C++ WebAssembly. project.
From what I understand, the wasm lib provides the same C API that regular onnxruntime provide.
Why
Supporting wasm targets will make it easy to deploy models built with ort to web browsers and wasm runtimes such as WasmTime and Wasmer.
Since wasm-runtimes are cross-platform, users can bundle their models along with pre and post processing code in a single, universal, executable module that they can then run on browsers or on any wasm-runtime.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 4
- Comments: 22 (11 by maintainers)
Commits related to this issue
- feat: support for WASM targets, closes #75 — committed to pykeio/ort by decahedron1 9 months ago
wasm32-unknown-emscriptenis now supported in v1.15.5.Seeing how requested WASM support is, I’ll keep working on solutions. It may be possible to shim the needed Emscripten APIs but that’s a lot of work and I can’t guarantee it’ll be successful.
@k2m5t2 Got a repro, the issue is rustc stable. It compiles fine with nightly, still trying to figure out what commit fixed it.
Please give it a try:
A few notes:
ort::wasm::initialize()at the very top of your program, before you use anyortAPIs.SessionBuilder::commit_from_memory_directly..ortformat models - see here for how to convert. TL;DRpython -m onnxruntime.tools.convert_onnx_models_to_ort ./my_model.onnxSessionBuilder::with_optimization_level.See also the example/test which implements the above notes.
I was actually in the middle of writing some docs about this very issue 😂
From what I can tell, compiling to
wasm32-unknown-emscriptenis very tricky. I haven’t been able to make it work either. I’d have to recommend alternative libraries that do support plain oldwasm32-unknown-unknownliketractorwonnxfor the time being.