0.3.0 • Published 1 year ago

as-wasi-nn v0.3.0

Weekly downloads
-
License
Apache 2.0
Repository
github
Last release
1 year ago

wasi-nn bindings for AssemblyScript

This package contains high-level AssemblyScript bindings for wasi-nn system calls. It is similar in purpose to the as-wasi bindings but this package provides optional access to a system's machine learning functionality from WebAssembly.

NOTE: These bindings are experimental (use at your own risk) and subject to upstream changes in the wasi-nn specification.

Use

  1. Add the dependency for wasi-nn to your package.json:

    "dependencies": {
      "as-wasi-nn": "0.3.0"
    }
  2. Import the objects and functions you want to use in your project:

    import { Graph, Tensor, TensorType, GraphEncoding, ExecutionTarget } from "wasi-nn";
  3. Compile your application to WebAssembly (see AssemblyScript's quick start).

  4. Run the generated WebAssembly in a runtime supporting wasi-nn, e.g. Wasmtime.

Build

To build this package from source, run npm run asbuild. Compiling your AssemblyScript application to WebAssembly is a topic best covered by AssemblyScript's quick start.

Examples

The included examples demonstrate how to use wasi-nn from an AssemblyScript program. Run them with:

npm run demo

For more information info on how to use Wasmtime to run the examples, see Wasmtime's AssemblyScript documentation. Note that the wasi-nn bindings do not perform any WASI filesystem access; this functionality is provided by the as-wasi package.

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.