47 releases (15 stable)

7.0.0 Mar 20, 2023
6.0.1 Mar 8, 2023
6.0.0 Feb 20, 2023
5.0.1 Mar 8, 2023
0.25.0 Mar 16, 2021

#735 in WebAssembly

Download history 444/week @ 2022-12-08 377/week @ 2022-12-15 204/week @ 2022-12-22 130/week @ 2022-12-29 300/week @ 2023-01-05 387/week @ 2023-01-12 501/week @ 2023-01-19 406/week @ 2023-01-26 540/week @ 2023-02-02 369/week @ 2023-02-09 426/week @ 2023-02-16 320/week @ 2023-02-23 284/week @ 2023-03-02 338/week @ 2023-03-09 337/week @ 2023-03-16 397/week @ 2023-03-23

1,455 downloads per month
Used in 4 crates (3 directly)

Apache-2.0 WITH LLVM-exception

380KB
1.5K SLoC

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

Dependencies

~13–19MB
~396K SLoC