Files
wasmtime/crates/wasi-nn
Andrew Brown 558a9273e9 wasi-nn: update openvino crate, use external CI action (#4383)
* ci: replace OpenVINO installer action

To test wasi-nn, we currently use an OpenVINO backend. The Wasmtime CI
must install OpenVINO using a custom GitHub action. This CI action has
not been updated in some time and in the meantime OpenVINO (and the
OpenVINO crates) have released several new versions.
https://github.com/abrown/install-openvino-action is an external action
that we plan to keep up to date with the latest releases. This change
replaces the current CI action with that one.

* wasi-nn: upgrade openvino dependency to v0.4.1

This eliminates a `lazy_static` dependency and changes a few parameters
to pass by reference. Importantly, it enables support for the latest
versions of OpenVINO (v2022.*) in wasi-nn.

* ci: update wasi-nn script to source correct env script

* ci: really use the correct path for the env script

Also, clarify which directory OpenVINO is installed in (the symlink may
not be present).
2022-07-05 18:50:50 +00:00
..
2021-02-18 14:45:20 -08:00

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