jrandolf opened PR #14921 from jrandolf:wasi-nn-named-imports to bytecodealliance:main:
This builds on #14875, so only the last commit is new here.
Components importing
wasi:nninterfaces under a label couldn't be linked with wasmtime-wasi-nn. This addsadd_named_to_linkerfor the WIT-based API, following the named-import support in wasmtime-wasi (#14275).wasmtime-wasi-nn now depends on
wasmtime-wasi(it was a dev-dependency) to share itsNamedId. That grows its dependency tree from 102 to 166 crates, so I'd appreciate a second opinion on whether that's the right way to share it.Part of #14858
<details>
<summary>LLM summary of the changes</summary>API
WasiNnNamedViewmaps aNamedIdto theWasiNnViewto use.InterfacehasNnTensor,NnGraph,NnInferenceandNnErrors.add_named_to_linkeradds every labelled import of those interfaces that the component has, askinglookupfor each one's id.Implementation
The bindings get
named_importsfor the four interfaces. Each named method looks up the context for the id and calls the existing implementation. Theconvert_errorconversion ofwasi:nn/errorstakes the id because of #14875.Dependency
wasmtime-wasimoves from dev-dependencies to dependencies, forNamedId(ausizenewtype) andWasiCtxNamedView(a one-field wrapper). It's used without default features, but its non-optional dependencies such as tokio still come along.Cargo.lockdoesn't change.Interaction with #14873
#14873 changes the signature of the
add_named_to_linkerlookup. Whichever of the two lands second needs to port this function, which is mechanical.Test
run_named_importsruns a new guest program that importswasi:nn/graphunder the labelsaandb, where each label's registry only has a graph of that name. It needs no ML backend.</details>
jrandolf commented on PR #14921:
Closing: nobody needs labelled
wasi:nnimports yet, andwasi:nnisn't part of a WASI release. Happy to revisit if someone asks.
:cross_mark: jrandolf closed without merge PR #14921.
Last updated: Oct 31 2026 at 23:03 UTC