Add an initial wasi-nn implementation for Wasmtime (#2208)

* Add an initial wasi-nn implementation for Wasmtime

This change adds a crate, `wasmtime-wasi-nn`, that uses `wiggle` to expose the current state of the wasi-nn API and `openvino` to implement the exposed functions. It includes an end-to-end test demonstrating how to do classification using wasi-nn:
 - `crates/wasi-nn/tests/classification-example` contains Rust code that is compiled to the `wasm32-wasi` target and run with a Wasmtime embedding that exposes the wasi-nn calls
 - the example uses Rust bindings for wasi-nn contained in `crates/wasi-nn/tests/wasi-nn-rust-bindings`; this crate contains code generated by `witx-bindgen` and eventually should be its own standalone crate

* Test wasi-nn as a CI step

This change adds:
 - a GitHub action for installing OpenVINO
 - a script, `ci/run-wasi-nn-example.sh`, to run the classification example
This commit is contained in:
Andrew Brown
2020-11-16 10:54:00 -08:00
committed by GitHub
parent 61a0bcbdc6
commit a61f068c64
33 changed files with 1554 additions and 1 deletions

View File

@@ -51,6 +51,7 @@ jobs:
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: -Dbroken_intra_doc_links
OPENVINO_SKIP_LINKING: 1
steps:
- uses: actions/checkout@v2
with:
@@ -252,6 +253,7 @@ jobs:
--all \
--exclude lightbeam \
--exclude wasmtime-lightbeam \
--exclude wasmtime-wasi-nn \
--exclude peepmatic \
--exclude peepmatic-automata \
--exclude peepmatic-fuzzing \
@@ -304,6 +306,23 @@ jobs:
CARGO_VERSION: "+nightly"
RUST_BACKTRACE: 1
# Build and test the wasi-nn module.
test_wasi_nn:
name: Test wasi-nn module
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: ./.github/actions/install-rust
with:
toolchain: nightly-2020-08-25
- run: rustup target add wasm32-wasi
- uses: ./.github/actions/install-openvino
- run: ./ci/run-wasi-nn-example.sh
env:
RUST_BACKTRACE: 1
# Verify that cranelift's code generation is deterministic
meta_determinist_check:
name: Meta deterministic check
@@ -411,6 +430,7 @@ jobs:
--all \
--exclude lightbeam \
--exclude wasmtime-lightbeam \
--exclude wasmtime-wasi-nn \
--exclude peepmatic \
--exclude peepmatic-automata \
--exclude peepmatic-fuzzing \