WACS.WASI.NN.MLNet
0.2.4
dotnet add package WACS.WASI.NN.MLNet --version 0.2.4
NuGet\Install-Package WACS.WASI.NN.MLNet -Version 0.2.4
<PackageReference Include="WACS.WASI.NN.MLNet" Version="0.2.4" />
<PackageVersion Include="WACS.WASI.NN.MLNet" Version="0.2.4" />
<PackageReference Include="WACS.WASI.NN.MLNet" />
paket add WACS.WASI.NN.MLNet --version 0.2.4
#r "nuget: WACS.WASI.NN.MLNet, 0.2.4"
#:package WACS.WASI.NN.MLNet@0.2.4
#addin nuget:?package=WACS.WASI.NN.MLNet&version=0.2.4
#tool nuget:?package=WACS.WASI.NN.MLNet&version=0.2.4
WACS.WASI.NN.MLNet
ML.NET-flavored ONNX backend for WACS.WASI.NN.
Implements IBackend for graph-encoding.onnx against
Microsoft.ML.OnnxTransformer
under an MLContext lifecycle — for embedders composing wasi-nn inference with the rest
of an ML.NET pipeline (preprocessing transformers, custom predictors, IDataView /
PredictionEngine).
For raw tensor inference with no pipeline integration, prefer
WACS.WASI.NN.OnnxRuntime —
it avoids the Microsoft.ML transitive surface (~70 MB lighter).
Install
dotnet add package WACS.WASI.NN.MLNet
The package's bin ships its NuGet transitives + RID-specific native libs (via
<EnableDynamicLoading>true</EnableDynamicLoading>), so Assembly.LoadFrom resolves
everything from the LoadFromContext probe.
CLI
# After dotnet build of this project's repo:
MLNET=$(realpath Wacs.WASI/Wacs.WASI.NN/Wacs.WASI.NN.MLNet/bin/Release/net8.0/Wacs.WASI.NN.MLNet.dll)
wacs run my.component.wasm --wasip2 --bind "$MLNET" -d ./models::/models
--bind auto-pulls the WASI.NN typed surface + DI sibling onto host-packages when the
identity starts with Wacs.WASI.NN.. The Preview 2 DI scope wires the ML.NET-backed ORT
into the DI bundle's WasiNNConfiguration.Backends[ONNX].
Embedder
Interpreter / one-line:
using Wacs.Core.Runtime;
using Wacs.WASI.NN;
using Wacs.WASI.NN.MLNet;
using Wacs.WASI.NN.Types;
var runtime = new WasmRuntime();
runtime.UseWasiNN(b => b.AddBackend(GraphEncoding.ONNX, new MLNetBackend()));
What it provides
MLNetBackend : IBackend— wraps ORT underMLContext.Transforms.ApplyOnnxModel/IDataView, exposing the sameLoadGraph(builders, target)/Compute(inputs)shape as the bare ORT backend. Embedders who want the ML.NET preprocessing surface get it; the rest of WACS doesn't noticeWasiNNMLNetBindable : IBindable— parameterless adapter for--bind[assembly: WasiHostPackage]
Why ML.NET over bare ORT
Use this backend when:
- Your wasm guest is one stage in a longer ML.NET pipeline (custom transformers,
preprocessing,
IDataViewconsumers) and you want them composed in one host-side process - You're already bringing in
Microsoft.MLfor adjacent work — the marginal cost of routing wasi-nn throughMLContextis small - You want
MLContext.Log/ structured ML.NET diagnostics around the inference call
For everything else — image classification, embeddings, encoder-only LLMs, raw tensor
in / raw tensor out — bare
WACS.WASI.NN.OnnxRuntime is
lighter and simpler.
Backend choice
| Use case | Package |
|---|---|
| ONNX with ML.NET pipeline integration | WACS.WASI.NN.MLNet (this) |
| Standard ONNX inference (lighter footprint) | WACS.WASI.NN.OnnxRuntime |
| GGUF / llama.cpp generative LLMs | WACS.WASI.NN.LlamaSharp |
Documentation
docs/WASI_NN_USAGE.md— unified usage guide (CLI flags, env vars, programmatic embedding, worked examples)docs/COMPONENT_CHAINING.mdWacs.WASI/Wacs.WASI.NN/README.md— backend matrix + package layout
License
Apache-2.0
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.ML (>= 3.0.1)
- Microsoft.ML.OnnxRuntime (>= 1.20.1)
- Microsoft.ML.OnnxTransformer (>= 3.0.1)
- WACS.WASI.NN (>= 0.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.