Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 347 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /webnn/idlharness.https.any.html - WPT Dashboard Interop Dashboard
- /webnn/idlharness.https.any.worker.html - WPT Dashboard Interop Dashboard
// META: global=window,dedicatedworker
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js
// META: script=./resources/utils.js
// META: timeout=long
'use strict';
idl_test(
['webnn'],
['html', 'webidl', 'webgpu'],
async (idl_array) => {
if (self.GLOBAL.isWindow()) {
idl_array.add_objects({ Navigator: ['navigator'] });
} else if (self.GLOBAL.isWorker()) {
idl_array.add_objects({ WorkerNavigator: ['navigator'] });
}
idl_array.add_objects({
NavigatorML: ['navigator'],
ML: ['navigator.ml'],
MLContext: ['context'],
MLOperand: ['input', 'filter', 'output'],
MLActivation: ['relu'],
MLGraphBuilder: ['builder'],
MLGraph: ['graph']
});
self.context = await navigator.ml.createContext();
self.builder = new MLGraphBuilder(self.context);
self.input =
builder.input('input', {dataType: 'float32', dimensions: [1, 1, 5, 5]});
self.filter = builder.constant(
{dataType: 'float32', dimensions: [1, 1, 3, 3]},
new Float32Array(9).fill(1));
self.relu = builder.relu();
self.output =
builder.conv2d(input, filter, {activation: relu, inputLayout: "nchw"});
self.graph = await builder.build({output});
}
);