You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Nick Fitzgerald a1f4b46f64 Bump Wasmtime to version 0.30.0; cranelift to 0.77.0 3 years ago
..
examples wasi-nn: use the newly-published Rust bindings for wasi-nn 4 years ago
spec@8adc5b9b3b Update wasi-nn submodule 4 years ago
src wasi-nn: refactor wasi-nn context to use multiple backends 3 years ago
Cargo.toml Bump Wasmtime to version 0.30.0; cranelift to 0.77.0 3 years ago
LICENSE Add an initial wasi-nn implementation for Wasmtime (#2208) 4 years ago
README.md Add an initial wasi-nn implementation for Wasmtime (#2208) 4 years ago
build.rs wasi-nn: turn it on by default (#2859) 4 years ago

README.md

wasmtime-wasi-nn

This crate enables support for the wasi-nn API in Wasmtime. Currently it contains an implementation of wasi-nn using OpenVINO™ but in the future it could support multiple machine learning backends. Since the wasi-nn API is expected to be an optional feature of WASI, this crate is currently separate from the wasi-common crate. This crate is experimental and its API, functionality, and location could quickly change.

Use

Use the Wasmtime APIs to instantiate a Wasm module and link in the WasiNn implementation as follows:

let wasi_nn = WasiNn::new(&store, WasiNnCtx::new()?);
wasi_nn.add_to_linker(&mut linker)?;

Build

This crate should build as usual (i.e. cargo build) but note that using an existing installation of OpenVINO™, rather than building from source, will drastically improve the build times. See the openvino crate for more information

Example

An end-to-end example demonstrating ML classification is included in examples:

  • tests/wasi-nn-rust-bindings contains ergonomic bindings for writing Rust code against the wasi-nn APIs
  • tests/classification-example contains a standalone Rust project that uses the wasi-nn APIs and is compiled to the wasm32-wasi target using the wasi-nn-rust-bindings

Run the example from the Wasmtime project directory:

ci/run-wasi-nn-example.sh