| // GENERATED CONTENT - DO NOT EDIT |
| // Content was automatically extracted by Reffy into webref |
| // (https://github.com/w3c/webref) |
| // Source: Web Neural Network API (https://webmachinelearning.github.io/webnn/) |
| |
| interface mixin NavigatorML { |
| [SecureContext, SameObject] readonly attribute ML ml; |
| }; |
| Navigator includes NavigatorML; |
| WorkerNavigator includes NavigatorML; |
| |
| enum MLDeviceType { |
| "cpu", |
| "gpu" |
| }; |
| |
| enum MLPowerPreference { |
| "default", |
| "high-performance", |
| "low-power" |
| }; |
| |
| dictionary MLContextOptions { |
| MLDeviceType deviceType = "cpu"; |
| MLPowerPreference powerPreference = "default"; |
| }; |
| |
| [SecureContext, Exposed=(Window, DedicatedWorker)] |
| interface ML { |
| Promise<MLContext> createContext(optional MLContextOptions options = {}); |
| Promise<MLContext> createContext(GPUDevice gpuDevice); |
| |
| [Exposed=(DedicatedWorker)] |
| MLContext createContextSync(optional MLContextOptions options = {}); |
| [Exposed=(DedicatedWorker)] |
| MLContext createContextSync(GPUDevice gpuDevice); |
| }; |
| |
| [SecureContext, Exposed=(Window, DedicatedWorker)] |
| interface MLActivation { |
| }; |
| |
| typedef (GPUBuffer or GPUTexture) MLGPUResource; |
| |
| typedef record<DOMString, MLGPUResource> MLNamedGPUResources; |
| |
| [SecureContext, Exposed=(Window, DedicatedWorker)] |
| interface MLCommandEncoder {}; |
| |
| partial interface MLCommandEncoder { |
| undefined initializeGraph(MLGraph graph); |
| }; |
| |
| partial interface MLCommandEncoder { |
| undefined dispatch(MLGraph graph, MLNamedGPUResources inputs, MLNamedGPUResources outputs); |
| }; |
| |
| partial interface MLCommandEncoder { |
| GPUCommandBuffer finish(optional GPUCommandBufferDescriptor descriptor = {}); |
| }; |
| |
| typedef record<DOMString, ArrayBufferView> MLNamedArrayBufferViews; |
| |
| [SecureContext, Exposed=(Window, DedicatedWorker)] |
| interface MLContext {}; |
| |
| partial interface MLContext { |
| [Exposed=(DedicatedWorker)] |
| undefined computeSync( |
| MLGraph graph, MLNamedArrayBufferViews inputs, MLNamedArrayBufferViews outputs); |
| }; |
| |
| dictionary MLComputeResult { |
| MLNamedArrayBufferViews inputs; |
| MLNamedArrayBufferViews outputs; |
| }; |
| |
| partial interface MLContext { |
| Promise<MLComputeResult> compute( |
| MLGraph graph, MLNamedArrayBufferViews inputs, MLNamedArrayBufferViews outputs); |
| }; |
| |
| partial interface MLContext { |
| MLCommandEncoder createCommandEncoder(); |
| }; |
| |
| [SecureContext, Exposed=(Window, DedicatedWorker)] |
| interface MLGraph {}; |
| |
| typedef record<DOMString, MLOperand> MLNamedOperands; |
| |
| dictionary MLBufferResourceView { |
| required GPUBuffer resource; |
| unsigned long long offset = 0; |
| unsigned long long size; |
| }; |
| |
| typedef (ArrayBufferView or MLBufferResourceView) MLBufferView; |
| |
| [SecureContext, Exposed=(Window, DedicatedWorker)] |
| interface MLGraphBuilder { |
| // Construct the graph builder from the context. |
| constructor(MLContext context); |
| |
| // Create an operand for a graph input. |
| MLOperand input(DOMString name, MLOperandDescriptor descriptor); |
| |
| // Create an operand for a graph constant. |
| MLOperand constant(MLOperandDescriptor descriptor, MLBufferView bufferView); |
| |
| // Create a single-value operand from the specified number of the specified type. |
| MLOperand constant(double value, optional MLOperandDataType type = "float32"); |
| |
| // Compile the graph up to the specified output operands asynchronously. |
| Promise<MLGraph> build(MLNamedOperands outputs); |
| |
| // Compile the graph up to the specified output operands synchronously. |
| [Exposed=(DedicatedWorker)] |
| MLGraph buildSync(MLNamedOperands outputs); |
| }; |
| |
| dictionary MLArgMinMaxOptions { |
| sequence<unsigned long> axes = null; |
| boolean keepDimensions = false; |
| boolean selectLastIndex = false; |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand argMin(MLOperand input, optional MLArgMinMaxOptions options = {}); |
| MLOperand argMax(MLOperand input, optional MLArgMinMaxOptions options = {}); |
| }; |
| |
| dictionary MLBatchNormalizationOptions { |
| MLOperand scale; |
| MLOperand bias; |
| unsigned long axis = 1; |
| float epsilon = 1e-5; |
| MLActivation activation; |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand batchNormalization(MLOperand input, MLOperand mean, MLOperand variance, |
| optional MLBatchNormalizationOptions options = {}); |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand cast(MLOperand input, MLOperandDataType type); |
| }; |
| |
| dictionary MLClampOptions { |
| float minValue; |
| float maxValue; |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand clamp(MLOperand input, optional MLClampOptions options = {}); |
| MLActivation clamp(optional MLClampOptions options = {}); |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand concat(sequence<MLOperand> inputs, unsigned long axis); |
| }; |
| |
| enum MLConv2dFilterOperandLayout { |
| "oihw", |
| "hwio", |
| "ohwi", |
| "ihwo" |
| }; |
| |
| enum MLAutoPad { |
| "explicit", |
| "same-upper", |
| "same-lower" |
| }; |
| |
| dictionary MLConv2dOptions { |
| sequence<unsigned long> padding; |
| sequence<unsigned long> strides; |
| sequence<unsigned long> dilations; |
| MLAutoPad autoPad = "explicit"; |
| unsigned long groups = 1; |
| MLInputOperandLayout inputLayout = "nchw"; |
| MLConv2dFilterOperandLayout filterLayout = "oihw"; |
| MLOperand bias; |
| MLActivation activation; |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand conv2d(MLOperand input, MLOperand filter, optional MLConv2dOptions options = {}); |
| }; |
| |
| enum MLConvTranspose2dFilterOperandLayout { |
| "iohw", |
| "hwoi", |
| "ohwi" |
| }; |
| |
| dictionary MLConvTranspose2dOptions { |
| sequence<unsigned long> padding; |
| sequence<unsigned long> strides; |
| sequence<unsigned long> dilations; |
| sequence<unsigned long> outputPadding; |
| sequence<unsigned long> outputSizes; |
| MLAutoPad autoPad = "explicit"; |
| unsigned long groups = 1; |
| MLInputOperandLayout inputLayout = "nchw"; |
| MLConvTranspose2dFilterOperandLayout filterLayout = "iohw"; |
| MLOperand bias; |
| MLActivation activation; |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand convTranspose2d(MLOperand input, MLOperand filter, |
| optional MLConvTranspose2dOptions options = {}); |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand add(MLOperand a, MLOperand b); |
| MLOperand sub(MLOperand a, MLOperand b); |
| MLOperand mul(MLOperand a, MLOperand b); |
| MLOperand div(MLOperand a, MLOperand b); |
| MLOperand max(MLOperand a, MLOperand b); |
| MLOperand min(MLOperand a, MLOperand b); |
| MLOperand pow(MLOperand a, MLOperand b); |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand equal(MLOperand a, MLOperand b); |
| MLOperand greater(MLOperand a, MLOperand b); |
| MLOperand greaterOrEqual(MLOperand a, MLOperand b); |
| MLOperand lesser(MLOperand a, MLOperand b); |
| MLOperand lesserOrEqual(MLOperand a, MLOperand b); |
| MLOperand not(MLOperand a); |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand abs(MLOperand input); |
| MLOperand ceil(MLOperand input); |
| MLOperand cos(MLOperand input); |
| MLOperand erf(MLOperand input); |
| MLOperand exp(MLOperand input); |
| MLOperand floor(MLOperand input); |
| MLOperand identity(MLOperand input); |
| MLOperand log(MLOperand input); |
| MLOperand neg(MLOperand input); |
| MLOperand reciprocal(MLOperand input); |
| MLOperand sin(MLOperand input); |
| MLOperand sqrt(MLOperand input); |
| MLOperand tan(MLOperand input); |
| }; |
| |
| dictionary MLEluOptions { |
| float alpha = 1; |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand elu(MLOperand input, optional MLEluOptions options = {}); |
| MLActivation elu(optional MLEluOptions options = {}); |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand expand(MLOperand input, sequence<unsigned long> newShape); |
| }; |
| |
| dictionary MLGatherOptions { |
| unsigned long axis = 0; |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand gather(MLOperand input, MLOperand indices, optional MLGatherOptions options = {}); |
| }; |
| |
| dictionary MLGemmOptions { |
| MLOperand c; |
| float alpha = 1.0; |
| float beta = 1.0; |
| boolean aTranspose = false; |
| boolean bTranspose = false; |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand gemm(MLOperand a, MLOperand b, optional MLGemmOptions options = {}); |
| }; |
| |
| enum MLGruWeightLayout { |
| "zrn", // update-reset-new gate ordering |
| "rzn" // reset-update-new gate ordering |
| }; |
| |
| enum MLRecurrentNetworkDirection { |
| "forward", |
| "backward", |
| "both" |
| }; |
| |
| dictionary MLGruOptions { |
| MLOperand bias; |
| MLOperand recurrentBias; |
| MLOperand initialHiddenState; |
| boolean resetAfter = true; |
| boolean returnSequence = false; |
| MLRecurrentNetworkDirection direction = "forward"; |
| MLGruWeightLayout layout = "zrn"; |
| sequence<MLActivation> activations; |
| }; |
| |
| partial interface MLGraphBuilder { |
| sequence<MLOperand> gru(MLOperand input, MLOperand weight, MLOperand recurrentWeight, |
| unsigned long steps, unsigned long hiddenSize, |
| optional MLGruOptions options = {}); |
| }; |
| |
| dictionary MLGruCellOptions { |
| MLOperand bias; |
| MLOperand recurrentBias; |
| boolean resetAfter = true; |
| MLGruWeightLayout layout = "zrn"; |
| sequence<MLActivation> activations; |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand gruCell(MLOperand input, MLOperand weight, MLOperand recurrentWeight, |
| MLOperand hiddenState, unsigned long hiddenSize, |
| optional MLGruCellOptions options = {}); |
| }; |
| |
| dictionary MLHardSigmoidOptions { |
| float alpha = 0.2; |
| float beta = 0.5; |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand hardSigmoid(MLOperand input, optional MLHardSigmoidOptions options = {}); |
| MLActivation hardSigmoid(optional MLHardSigmoidOptions options = {}); |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand hardSwish(MLOperand input); |
| MLActivation hardSwish(); |
| }; |
| |
| dictionary MLInstanceNormalizationOptions { |
| MLOperand scale; |
| MLOperand bias; |
| float epsilon = 1e-5; |
| MLInputOperandLayout layout = "nchw"; |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand instanceNormalization(MLOperand input, |
| optional MLInstanceNormalizationOptions options = {}); |
| }; |
| |
| dictionary MLLayerNormalizationOptions { |
| MLOperand scale; |
| MLOperand bias; |
| sequence<unsigned long> axes; |
| float epsilon = 1e-5; |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand layerNormalization(MLOperand input, optional MLLayerNormalizationOptions options = {}); |
| }; |
| |
| dictionary MLLeakyReluOptions { |
| float alpha = 0.01; |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand leakyRelu(MLOperand input, optional MLLeakyReluOptions options = {}); |
| MLActivation leakyRelu(optional MLLeakyReluOptions options = {}); |
| }; |
| |
| dictionary MLLinearOptions { |
| float alpha = 1; |
| float beta = 0; |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand linear(MLOperand input, optional MLLinearOptions options = {}); |
| MLActivation linear(optional MLLinearOptions options = {}); |
| }; |
| |
| enum MLLstmWeightLayout { |
| "iofg", // input-output-forget-cell gate ordering |
| "ifgo" // input-forget-cell-output gate ordering |
| }; |
| |
| dictionary MLLstmOptions { |
| MLOperand bias; |
| MLOperand recurrentBias; |
| MLOperand peepholeWeight; |
| MLOperand initialHiddenState; |
| MLOperand initialCellState; |
| boolean returnSequence = false; |
| MLRecurrentNetworkDirection direction = "forward"; |
| MLLstmWeightLayout layout = "iofg"; |
| sequence<MLActivation> activations; |
| }; |
| |
| partial interface MLGraphBuilder { |
| sequence<MLOperand> lstm(MLOperand input, MLOperand weight, MLOperand recurrentWeight, |
| unsigned long steps, unsigned long hiddenSize, |
| optional MLLstmOptions options = {}); |
| }; |
| |
| dictionary MLLstmCellOptions { |
| MLOperand bias; |
| MLOperand recurrentBias; |
| MLOperand peepholeWeight; |
| MLLstmWeightLayout layout = "iofg"; |
| sequence<MLActivation> activations; |
| }; |
| |
| partial interface MLGraphBuilder { |
| sequence<MLOperand> lstmCell(MLOperand input, MLOperand weight, MLOperand recurrentWeight, |
| MLOperand hiddenState, MLOperand cellState, unsigned long hiddenSize, |
| optional MLLstmCellOptions options = {}); |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand matmul(MLOperand a, MLOperand b); |
| }; |
| |
| enum MLPaddingMode { |
| "constant", |
| "edge", |
| "reflection", |
| "symmetric" |
| }; |
| |
| dictionary MLPadOptions { |
| MLPaddingMode mode = "constant"; |
| float value = 0; |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand pad(MLOperand input, |
| sequence<unsigned long> beginningPadding, |
| sequence<unsigned long> endingPadding, |
| optional MLPadOptions options = {}); |
| }; |
| |
| enum MLRoundingType { |
| "floor", |
| "ceil" |
| }; |
| |
| dictionary MLPool2dOptions { |
| sequence<unsigned long> windowDimensions; |
| sequence<unsigned long> padding; |
| sequence<unsigned long> strides; |
| sequence<unsigned long> dilations; |
| MLAutoPad autoPad = "explicit"; |
| MLInputOperandLayout layout = "nchw"; |
| MLRoundingType roundingType = "floor"; |
| sequence<unsigned long> outputSizes; |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand averagePool2d(MLOperand input, optional MLPool2dOptions options = {}); |
| MLOperand l2Pool2d(MLOperand input, optional MLPool2dOptions options = {}); |
| MLOperand maxPool2d(MLOperand input, optional MLPool2dOptions options = {}); |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand prelu(MLOperand input, MLOperand slope); |
| }; |
| |
| dictionary MLReduceOptions { |
| sequence<unsigned long> axes = null; |
| boolean keepDimensions = false; |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand reduceL1(MLOperand input, optional MLReduceOptions options = {}); |
| MLOperand reduceL2(MLOperand input, optional MLReduceOptions options = {}); |
| MLOperand reduceLogSum(MLOperand input, optional MLReduceOptions options = {}); |
| MLOperand reduceLogSumExp(MLOperand input, optional MLReduceOptions options = {}); |
| MLOperand reduceMax(MLOperand input, optional MLReduceOptions options = {}); |
| MLOperand reduceMean(MLOperand input, optional MLReduceOptions options = {}); |
| MLOperand reduceMin(MLOperand input, optional MLReduceOptions options = {}); |
| MLOperand reduceProduct(MLOperand input, optional MLReduceOptions options = {}); |
| MLOperand reduceSum(MLOperand input, optional MLReduceOptions options = {}); |
| MLOperand reduceSumSquare(MLOperand input, optional MLReduceOptions options = {}); |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand relu(MLOperand input); |
| MLActivation relu(); |
| }; |
| |
| enum MLInterpolationMode { |
| "nearest-neighbor", |
| "linear" |
| }; |
| |
| dictionary MLResample2dOptions { |
| MLInterpolationMode mode = "nearest-neighbor"; |
| sequence<float> scales; |
| sequence<unsigned long> sizes; |
| sequence<unsigned long> axes; |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand resample2d(MLOperand input, optional MLResample2dOptions options = {}); |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand reshape(MLOperand input, sequence<unsigned long> newShape); |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand sigmoid(MLOperand input); |
| MLActivation sigmoid(); |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand slice(MLOperand input, sequence<unsigned long> starts, sequence<unsigned long> sizes); |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand softmax(MLOperand input); |
| MLActivation softmax(); |
| }; |
| |
| dictionary MLSoftplusOptions { |
| float steepness = 1; |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand softplus(MLOperand input, optional MLSoftplusOptions options = {}); |
| MLActivation softplus(optional MLSoftplusOptions options = {}); |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand softsign(MLOperand input); |
| MLActivation softsign(); |
| }; |
| |
| dictionary MLSplitOptions { |
| unsigned long axis = 0; |
| }; |
| |
| partial interface MLGraphBuilder { |
| sequence<MLOperand> split(MLOperand input, |
| (unsigned long or sequence<unsigned long>) splits, |
| optional MLSplitOptions options = {}); |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand tanh(MLOperand input); |
| MLActivation tanh(); |
| }; |
| |
| dictionary MLTransposeOptions { |
| sequence<unsigned long> permutation; |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand transpose(MLOperand input, optional MLTransposeOptions options = {}); |
| }; |
| |
| dictionary MLTriangularOptions { |
| boolean upper = true; |
| long diagonal = 0; |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand triangular(MLOperand input, optional MLTriangularOptions options = {}); |
| }; |
| |
| partial interface MLGraphBuilder { |
| MLOperand where(MLOperand condition, MLOperand input, MLOperand other); |
| }; |
| |
| [SecureContext, Exposed=(Window, DedicatedWorker)] |
| interface MLOperand {}; |
| |
| partial interface MLOperand { |
| MLOperandDataType dataType(); |
| }; |
| |
| partial interface MLOperand { |
| sequence<unsigned long> shape(); |
| }; |
| |
| enum MLInputOperandLayout { |
| "nchw", |
| "nhwc" |
| }; |
| |
| enum MLOperandDataType { |
| "float32", |
| "float16", |
| "int32", |
| "uint32", |
| "int64", |
| "uint64", |
| "int8", |
| "uint8" |
| }; |
| |
| dictionary MLOperandDescriptor { |
| // The operand type. |
| required MLOperandDataType dataType; |
| |
| // The dimensions field is only required for tensor operands. |
| sequence<unsigned long> dimensions; |
| }; |