* Use stable Rust on CI to test the x64 backend This commit leverages the newly-released 1.51.0 compiler to test the new backend on Windows and Linux with a stable compiler instead of a nightly compiler. This isolates the nightly build to just the nightly documentation generation and fuzzing, both of which rely on nightly for the best results right now. * Use updated stable in book build job * Run rustfmt for new stable * Silence new warnings for wasi-nn * Allow some dead code in the x64 backend Looks like new rustc is better about emitting some dead-code warnings * Update rust in peepmatic job * Fix a test in the pooling allocator * Remove `package.metdata.docs.rs` temporarily Needs resolution of https://github.com/rust-lang/cargo/pull/9300 first * Fix a warning in a wasi-nn example
wasi-nn Rust Bindings
This crate contains API bindings for wasi-nn system calls in Rust. It is similar in purpose to the wasi bindings but this crate provides access to the optional neural network functionality from WebAssembly.
Note
: These bindings are experimental (use at your own risk) and subject to upstream changes in the wasi-nn specification.
Note
: In the future this crate may be (should be) moved to its own repository, like the wasi bindings.
Use
Depend on this crate in your Cargo.toml:
[dependencies]
wasi-nn = "0.1.0"
Use the wasi-nn APIs in your application:
use wasi_nn;
unsafe {
wasi_nn::load(
&[&xml.into_bytes(), &weights],
wasi_nn::GRAPH_ENCODING_OPENVINO,
wasi_nn::EXECUTION_TARGET_CPU,
)
.unwrap()
}
Compile the application to WebAssembly:
cargo build --target=wasm32-wasi
Run the generated Wasm in a runtime supporting wasi-nn. Currently Wasmtime has experimental support using the Wasmtime APIs; see main.rs for an example of how this is accomplished.
Generation
This crate contains code (src/generated.rs) generated by
witx-bindgen.
To regenerate this code, run witx-bindgen against the wasi-nn WITX file:
.../crates/witx-bindgen$ cargo run .../wasi-nn/phases/ephemeral/witx/wasi_ephemeral_nn.witx
License
This project is licensed under the Apache 2.0 license. See LICENSE for more details.
Contribution
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.