coderef

WebNNLimited availability

The WebNN API constructs and executes computational graphs of neural networks by making use of the various machine learning capabilities and hardware accelerators available on the device. Also known as Web Neural Network API.

Not yet supported in all major browsers — check the table and provide a fallback.

Browser support

DesktopChrome
✕Not supportedup to 155
Current: 155
Edge
✕Not supportedup to 154
Current: 154
Firefox
✕Not supportedup to 157
Current: 157
Safari
✕Not supportedup to 27
Current: 27
MobileChrome Android
✕Not supportedup to 155
Current: 155
Firefox Android
✕Not supportedup to 157
Current: 157
Safari iOS
✕Not supportedup to 27
Current: 27

How to use

Not supported in Chrome, Edge, Firefox, Safari, Chrome Android, Firefox Android, Safari iOS. Use feature detection below and provide a fallback (or a polyfill) for those browsers.

Example

Full syntax and examples are on MDN — see the links below.

Feature detection

JS · check before using
if ("ML" in globalThis) {
  // ML is available
} else {
  // load a polyfill or use a fallback
}

Sub-features

Support for each part of the feature (103). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
ML✕✕✕✕✕✕✕
ML.createContext✕✕✕✕✕✕✕
MLContext✕✕✕✕✕✕✕
MLContext.dispatch✕✕✕✕✕✕✕
MLContext.opSupportLimits✕✕✕✕✕✕✕
MLGraph✕✕✕✕✕✕✕
MLGraphBuilder✕✕✕✕✕✕✕
MLGraphBuilder.MLGraphBuilder✕✕✕✕✕✕✕
MLGraphBuilder.abs✕✕✕✕✕✕✕
MLGraphBuilder.add✕✕✕✕✕✕✕
MLGraphBuilder.argMax✕✕✕✕✕✕✕
MLGraphBuilder.argMin✕✕✕✕✕✕✕
MLGraphBuilder.averagePool2d✕✕✕✕✕✕✕
MLGraphBuilder.batchNormalization✕✕✕✕✕✕✕
MLGraphBuilder.build✕✕✕✕✕✕✕
MLGraphBuilder.cast✕✕✕✕✕✕✕
MLGraphBuilder.ceil✕✕✕✕✕✕✕
MLGraphBuilder.clamp✕✕✕✕✕✕✕
MLGraphBuilder.concat✕✕✕✕✕✕✕
MLGraphBuilder.constant✕✕✕✕✕✕✕
Show 83 more
Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
MLGraphBuilder.conv2d✕✕✕✕✕✕✕
MLGraphBuilder.convTranspose2d✕✕✕✕✕✕✕
MLGraphBuilder.cos✕✕✕✕✕✕✕
MLGraphBuilder.cumulativeSum✕✕✕✕✕✕✕
MLGraphBuilder.dequantizeLinear✕✕✕✕✕✕✕
MLGraphBuilder.div✕✕✕✕✕✕✕
MLGraphBuilder.elu✕✕✕✕✕✕✕
MLGraphBuilder.equal✕✕✕✕✕✕✕
MLGraphBuilder.erf✕✕✕✕✕✕✕
MLGraphBuilder.exp✕✕✕✕✕✕✕
MLGraphBuilder.expand✕✕✕✕✕✕✕
MLGraphBuilder.floor✕✕✕✕✕✕✕
MLGraphBuilder.gather✕✕✕✕✕✕✕
MLGraphBuilder.gatherElements✕✕✕✕✕✕✕
MLGraphBuilder.gatherND✕✕✕✕✕✕✕
MLGraphBuilder.gemm✕✕✕✕✕✕✕
MLGraphBuilder.greater✕✕✕✕✕✕✕
MLGraphBuilder.greaterOrEqual✕✕✕✕✕✕✕
MLGraphBuilder.gru✕✕✕✕✕✕✕
MLGraphBuilder.gruCell✕✕✕✕✕✕✕
MLGraphBuilder.hardSigmoid✕✕✕✕✕✕✕
MLGraphBuilder.hardSwish✕✕✕✕✕✕✕
MLGraphBuilder.identity✕✕✕✕✕✕✕
MLGraphBuilder.input✕✕✕✕✕✕✕
MLGraphBuilder.instanceNormalization✕✕✕✕✕✕✕
MLGraphBuilder.l2Pool2d✕✕✕✕✕✕✕
MLGraphBuilder.layerNormalization✕✕✕✕✕✕✕
MLGraphBuilder.leakyRelu✕✕✕✕✕✕✕
MLGraphBuilder.lesser✕✕✕✕✕✕✕
MLGraphBuilder.lesserOrEqual✕✕✕✕✕✕✕
MLGraphBuilder.linear✕✕✕✕✕✕✕
MLGraphBuilder.log✕✕✕✕✕✕✕
MLGraphBuilder.logicalAnd✕✕✕✕✕✕✕
MLGraphBuilder.logicalNot✕✕✕✕✕✕✕
MLGraphBuilder.logicalOr✕✕✕✕✕✕✕
MLGraphBuilder.logicalXor✕✕✕✕✕✕✕
MLGraphBuilder.lstm✕✕✕✕✕✕✕
MLGraphBuilder.lstmCell✕✕✕✕✕✕✕
MLGraphBuilder.matmul✕✕✕✕✕✕✕
MLGraphBuilder.max✕✕✕✕✕✕✕
MLGraphBuilder.maxPool2d✕✕✕✕✕✕✕
MLGraphBuilder.min✕✕✕✕✕✕✕
MLGraphBuilder.mul✕✕✕✕✕✕✕
MLGraphBuilder.neg✕✕✕✕✕✕✕
MLGraphBuilder.pad✕✕✕✕✕✕✕
MLGraphBuilder.pow✕✕✕✕✕✕✕
MLGraphBuilder.prelu✕✕✕✕✕✕✕
MLGraphBuilder.quantizeLinear✕✕✕✕✕✕✕
MLGraphBuilder.reciprocal✕✕✕✕✕✕✕
MLGraphBuilder.reduceL1✕✕✕✕✕✕✕
MLGraphBuilder.reduceL2✕✕✕✕✕✕✕
MLGraphBuilder.reduceLogSum✕✕✕✕✕✕✕
MLGraphBuilder.reduceLogSumExp✕✕✕✕✕✕✕
MLGraphBuilder.reduceMax✕✕✕✕✕✕✕
MLGraphBuilder.reduceMean✕✕✕✕✕✕✕
MLGraphBuilder.reduceMin✕✕✕✕✕✕✕
MLGraphBuilder.reduceProduct✕✕✕✕✕✕✕
MLGraphBuilder.reduceSum✕✕✕✕✕✕✕
MLGraphBuilder.reduceSumSquare✕✕✕✕✕✕✕
MLGraphBuilder.relu✕✕✕✕✕✕✕
MLGraphBuilder.resample2d✕✕✕✕✕✕✕
MLGraphBuilder.reshape✕✕✕✕✕✕✕
MLGraphBuilder.scatterElements✕✕✕✕✕✕✕
MLGraphBuilder.scatterND✕✕✕✕✕✕✕
MLGraphBuilder.sigmoid✕✕✕✕✕✕✕
MLGraphBuilder.sign✕✕✕✕✕✕✕
MLGraphBuilder.sin✕✕✕✕✕✕✕
MLGraphBuilder.slice✕✕✕✕✕✕✕
MLGraphBuilder.softmax✕✕✕✕✕✕✕
MLGraphBuilder.softplus✕✕✕✕✕✕✕
MLGraphBuilder.softsign✕✕✕✕✕✕✕
MLGraphBuilder.split✕✕✕✕✕✕✕
MLGraphBuilder.sqrt✕✕✕✕✕✕✕
MLGraphBuilder.sub✕✕✕✕✕✕✕
MLGraphBuilder.tan✕✕✕✕✕✕✕
MLGraphBuilder.tanh✕✕✕✕✕✕✕
MLGraphBuilder.tile✕✕✕✕✕✕✕
MLGraphBuilder.transpose✕✕✕✕✕✕✕
MLGraphBuilder.triangular✕✕✕✕✕✕✕
MLGraphBuilder.where✕✕✕✕✕✕✕
MLOperand✕✕✕✕✕✕✕
Navigator.ml✕✕✕✕✕✕✕
WorkerNavigator.ml✕✕✕✕✕✕✕