v147 · origin trial · machine learning

WebNN

A low-level web API that exposes the platform's native machine-learning acceleration — CPU vector instructions, NPUs, GPUs — to web apps. Frameworks like ONNX Runtime Web and TensorFlow.js can target WebNN to run inference at native speed without shipping their own runtime.

Heads up Origin trial. Surface is large; expect framework integration to mediate most usage.

concepts

  1. Adapter Probe

    Lists the WebNN contexts (CPU, GPU, NPU) available in your browser and the device types each one is bound to. Useful for picking a target before you spin up a graph.

  2. Tensor arithmetic

    Build a tiny matmul → add → relu graph in MLGraphBuilder, compile, and run. The same building blocks every WebNN frontend generates — visible end-to-end with editable inputs.

  3. Linear Regression Demo

    Build a WebNN computation graph evaluating y = w·x + b across a range of inputs. Adjust weight, bias, and input range — the graph executes via MLGraphBuilder and results are plotted on a live chart.

  4. Neural Network Visualizer

    Visual drag-and-drop builder for neural networks using WebNN. Place input, dense, relu, sigmoid, softmax, and output nodes on a canvas, connect them, then compile with MLGraphBuilder and run inference. Output activations are coloured by magnitude. Presets: XOR, MNIST-like, regression.

  5. Compatibility Lab

    Probes navigator.ml, MLContext, MLGraphBuilder, and device-type availability. Runs a live navigator.ml.createContext() call and compiles a minimal add graph, reporting which backend was selected. Provides the WASM + WebGPU fallback detection chain for non-WebNN environments.

why it exists

Today, in-browser ML inference goes through TF.js or ONNX Runtime Web, both of which ship their own runtime (often via WebGPU shaders or WASM SIMD). That works, but it means the app pays for a generic runtime instead of using the silicon the device actually has — laptop NPUs, mobile DSPs, server-class GPUs. WebNN gives the browser a unified API that maps onto whichever ML accelerator is available. Frameworks delegate to WebNN; WebNN delegates to whichever native runtime fits.

references

implementation reference

Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗