WebAssembly / wasi-nn

Neural Network proposal for WASI
429 stars 34 forks source link

Add example to README #23

Open abrown opened 2 years ago

abrown commented 2 years ago

The README includes a placeholder for an example walking through the API. Ideally, the example would include all of the calls in some language (e.g., Rust) to demonstrate how to perform something like image classification using the wasi-nn API. Optionally, this could leverage some of the wit-bindgen tooling since the specification is now WIT-based.

abrown commented 2 years ago

cc: @brianjjones

yamt commented 2 years ago

i happened to search examples yesterday. what i've found are: https://github.com/fermyon/wasi-experimental-toolkit/tree/main/tests/modules/nn-demo (wit) https://github.com/bytecodealliance/wasmtime/tree/main/crates/wasi-nn/examples/classification-example (witx)

abrown commented 2 years ago

That first one only does a load and we need to walk through the entire API. Would you like to take a stab at adapting the second one to WIT?

yamt commented 2 years ago

That first one only does a load and we need to walk through the entire API. Would you like to take a stab at adapting the second one to WIT?

i agree it's better to migrate the latter one to wit. my understanding is it's mainly about migrating wasi-nn, which is https://github.com/bytecodealliance/wasi-nn/tree/main/rust. is it right?

yamt commented 2 years ago

Optionally, this could leverage some of the wit-bindgen tooling since the specification is not WIT-based.

do you mean s/not/now/ ?

yamt commented 2 years ago

That first one only does a load and we need to walk through the entire API. Would you like to take a stab at adapting the second one to WIT?

my attempt https://github.com/bytecodealliance/wasmtime/pull/4451

abrown commented 2 years ago

i agree it's better to migrate the latter one to wit. my understanding is it's mainly about migrating wasi-nn, which is https://github.com/bytecodealliance/wasi-nn/tree/main/rust. is it right?

Well, there's work to be done in Wasmtime as you saw in that PR but there is also work to be done in the bindings (e.g., Rust, as you point out). I think @bjorn3's suggestion to use the wit-bindgen macros is reasonable (for reference, see https://github.com/bytecodealliance/wasi-nn/issues/64).