onnxrt
OCaml bindings to ONNX Runtime Web for browser-based ML inference via js_of_ocaml.
Supports WebAssembly (CPU) and WebGPU (GPU) execution providers, typed tensors, and session management. Models are loaded from .onnx files and run asynchronously using Lwt.
Examples
- Tensor addition — minimal example of creating tensors and running a model
- Sentiment analysis — text classification using a transformer model
API
The main entry points are:
Onnxrt.Session— load models and run inferenceOnnxrt.Tensor— create and inspect typed tensorsOnnxrt.Env— configure execution providers (WASM threads, WebGPU, SIMD)