This package contains high-level Rust bindings for [wasi-nn] system calls. It is similar in purpose to the [WASI bindings] but this package provides optional access to a system's machine learning functionality from WebAssembly.
NOTE: These bindings are experimental (use at your own risk) and subject to upstream changes in the wasi-nn specification.
Depend on this crate in your Cargo.toml
:
toml
[dependencies]
wasi-nn = "0.2.1"
Use the wasi-nn APIs in your application, for example: ```rust use wasi_nn;
unsafe { wasinn::load( &[&xml.intobytes(), &weights], wasinn::GRAPHENCODINGOPENVINO, wasinn::EXECUTIONTARGETCPU, ) .unwrap() } ```
Compile the application to WebAssembly:
shell script
cargo build --target=wasm32-wasi
Run the generated WebAssembly in a runtime supporting [wasi-nn], e.g. [Wasmtime].
To build this crate from source, use: cargo build
.
This crate contains code (src/generated.rs
) generated by
witx-bindgen
. To
regenerate this code, run witx-bindgen
against the wasi-nn
WITX
file:
shell script
.../crates/witx-bindgen$ cargo run .../wasi-nn/phases/ephemeral/witx/wasi_ephemeral_nn.witx
The [examples] demonstrate how to use wasi-nn from a Rust program.
This project is licensed under the Apache 2.0 license. See [LICENSE] for more details.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.