Is there overlap between wasi-nn and web-nn? Apologies if this has been asked before.
It would be very interesting if wasi-nn components could be backed by web-nn using a tool like JCO.
There is one key difference between the APIs: WebNN is a model builder API in which one "builds up" a graph of nodes, the ML operations to perform. wasi-nn is a model loader API in which one loads an encoded version of a model in a single step. In the model builder paradigm, the user can introspect the graph operations--low-level control. In the model loader paradigm, the model contents are essentially opaque to the user--high-level ease of use.
When wasi-nn was first proposed, we discussed this difference with the Web ML working group: at the time they were also considering enabling the model loader paradigm for WebNN. That didn't happen (though maybe at some point it still could?).
Ah OK that makes sense. While WebNN may adopt the loader paradigm, are there plans for creating a builder API for wasi?
Many of the key WebNN contributors from Intel work in our larger group so we have discussed how one might implement wasi-nn in terms of WebNN. No one has vetted this idea with implementation (so take it for the idea that it is), but it could be possible to write code to read a model in, e.g., the ONNX format and rebuild that as a WebNN graph.
Bailey Hayes said:
Ah OK that makes sense. While WebNN may adopt the loader paradigm, are there plans for creating a builder API for wasi?
I think that idea has been floated, but my sense is that the easiest thing here is to try to build an "encoded graph to WebNN graph" converter.
Convincing WebNN to adopt the loader paradigm -- lots of work and a long shot. Defining a WebNN clone in wasi-nn and implementing it in several engines -- even more work! But creating a conversion from a well-defined model encoding (e.g., ONNX, OpenVINO) to the also well-defined WebNN builder API seems... workable. Ningxin (one of the leads from our group) showed us that in some phase for a certain ML backend, WebNN already does this kind of conversion. My thought is that this converter could be compiled to a combination of WebAssembly and JS, which seems crucial for using it in JCO.
I suspect there may be certain parts of graph encodings that cannot yet be modeled in WebNN's builder API, but that is the part that would need to be vetted.
I don't have a use-case (yet) for needing this in a js runtime, but it's certainly something I'm curious about. Thank you for the info
I think it is a good idea to add support of wasi-nn in JCO at some point, via an ML framework layer such as onnx.js or tensorflow.js.
Last updated: Dec 23 2024 at 12:05 UTC