Skip to content

Commit

Permalink
feat: migrate the wasi_nn_burn plugin into this repository
Browse files Browse the repository at this point in the history
Signed-off-by: vincent <vincent@secondstate.io>
  • Loading branch information
CaptainVincent committed Oct 11, 2024
1 parent 33e50e1 commit 67dc9ea
Show file tree
Hide file tree
Showing 10 changed files with 608 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[workspace]
members = [
"crates/wasi_nn_burnrs",
]
resolver = "2"

[workspace.package]
edition = "2021"
version = "0.4.0"
license = "Apache-2.0"
readme = "README.md"
repository = "https://github.com/WasmEdge/rust-plugins"
homepage = "https://github.com/WasmEdge/rust-plugins"
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# rust-plugins
WasmEdge Rust Plugins

- crates/wasi_nn_burnrs
A plugin compatible with the wasi_nn proposal, using burn.rs framework as the backend.
1 change: 1 addition & 0 deletions crates/wasi_nn_burnrs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
38 changes: 38 additions & 0 deletions crates/wasi_nn_burnrs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "wasi_nn_burnrs"
version = "0.0.1"
edition = "2021"

[lib]
name = "wasmedgePluginWasiNN"
path = "src/lib.rs"
crate-type = ["cdylib"]

[features]
default = []
squeezenet = ["squeezenet-burn"]
whisper = ["whisper-burn", "strum", "strum_macros"]

[dependencies.squeezenet-burn]
package = "squeezenet-burn"
branch = "prebuilt-feature"
git = "https://github.com/second-state/burn-rs-models.git"
features = ["weights_file"]
default-features = false
optional = true

[dependencies.whisper-burn]
package = "whisper"
branch = "dev"
git = "https://github.com/second-state/burn-rs-whisper.git"
optional = true

[dependencies]
burn = { version = "0.13.2", features = ["ndarray", "wgpu"] }
wasmedge_plugin_sdk = { git = "https://github.com/second-state/wasmedge_plugin_rust_sdk.git", features = ["standalone"] }
wasmedge-wasi-nn = "0.8.0"
lazy_static = "1.4.0"
bytemuck = "1.16.0"
cfg-if = "1.0.0"
strum = { version = "0.25.0", optional = true }
strum_macros = { version = "0.25.0", optional = true }
15 changes: 15 additions & 0 deletions crates/wasi_nn_burnrs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# WASI NN Burn

A plugin compatible with the wasi_nn proposal, using burn.rs framework as the backend.

Currently, two models have been integrated: SqueezeNet and Whisper.

The command to compile the plugin is as follows.

```bash
cargo build --features=squeezenet -p wasi_nn_burnrs

or

cargo build --features=whisper -p wasi_nn_burnrs
```
11 changes: 11 additions & 0 deletions crates/wasi_nn_burnrs/src/helper.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#[macro_export]
macro_rules! get_slice {
($memory:expr, $ptr:expr, $length:expr, $ty:ty) => {{
let raw_bytes = $memory
.data_pointer($ptr as usize, $length as usize)
.expect("Failed to get data pointer");
bytemuck::cast_slice::<u8, $ty>(raw_bytes)
}};
}

pub use get_slice;
Loading

0 comments on commit 67dc9ea

Please sign in to comment.