wasi-nn: add named models (#6854)* wasi-nn: add [named models]This change adds a way to retrieve preloaded ML models (i.e., "graphs"in wasi-nn terms) from a registry. The wasi-nn specification i
wasi-nn: add named models (#6854)* wasi-nn: add [named models]This change adds a way to retrieve preloaded ML models (i.e., "graphs"in wasi-nn terms) from a registry. The wasi-nn specification includes anew function, `load_by_name`, that can be used to access these modelsmore efficiently than before; previously, a user's only option was toread/download/etc. all of the bytes of an ML model and pass them to the`load` function.[named models]: https://github.com/WebAssembly/wasi-nn/issues/36In Wasmtime's implementation of wasi-nn, we call the registry that holdsthe models a `GraphRegistry`. We include a simplistic `InMemoryRegistry`for use in the Wasmtime CLI (more on this later) but the idea is thatproduction use will involve some more complex caching and thus a newimplementation of a registry--a `Box<dyn GraphRegistry>`--passed intothe wasi-nn context. Note that, because we now must be able to `clone` agraph out of the registry and into the "used graphs" table, the OpenVINO`BackendGraph` is updated to be easier to copy around.To allow experimentation with this "preload a named model"functionality, this change also adds a new Wasmtime CLI flag: `--graph<encoding>:<host dir>`. Wasmtime CLI users can now preload a model froma directory; the directory `basename` is used as the model name. Loadingmodels from a directory is probably not desired in Wasmtime embeddingsso it is cordoned off into a separate `BackendFromDir` extension trait.* wasi-nn: add "named model" testAdd a new example crate which loads a model by name and performs imageclassification. It uses the same MobileNet model as the existing testbut a new version of the Rust bindings. The new crate is built and runwith the new CLI flag in the `ci/run-wasi-nn-example.sh` script.prtest:full* review: rename `--graph` to `--wasi-nn-graph`
show more ...