diff options
Diffstat (limited to '')
27 files changed, 8476 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webnn/META.yml b/testing/web-platform/tests/webnn/META.yml new file mode 100644 index 0000000000..3f87fc8042 --- /dev/null +++ b/testing/web-platform/tests/webnn/META.yml @@ -0,0 +1,4 @@ +spec: https://webmachinelearning.github.io/webnn/ +suggested_reviewers: + - dontcallmedom + - Honry
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/clamp.https.any.js b/testing/web-platform/tests/webnn/clamp.https.any.js new file mode 100644 index 0000000000..4cf54d1cea --- /dev/null +++ b/testing/web-platform/tests/webnn/clamp.https.any.js @@ -0,0 +1,10 @@ +// META: title=test WebNN API clamp operation +// META: global=window,dedicatedworker +// META: script=./resources/utils.js +// META: timeout=long + +'use strict'; + +// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-clamp + +testWebNNOperation('clamp', '/webnn/resources/test_data/clamp.json', buildOperationWithSingleInput);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/concat.https.any.js b/testing/web-platform/tests/webnn/concat.https.any.js new file mode 100644 index 0000000000..2c8950fe99 --- /dev/null +++ b/testing/web-platform/tests/webnn/concat.https.any.js @@ -0,0 +1,22 @@ +// META: title=test WebNN API concat operation +// META: global=window,dedicatedworker +// META: script=./resources/utils.js +// META: timeout=long + +'use strict'; + +// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-concat + +const buildConcat = (operationName, builder, resources) => { + // MLOperand concat(sequence<MLOperand> inputs, long axis); + const namedOutputOperand = {}; + const inputOperands = []; + for (let input of resources.inputs) { + inputOperands.push(builder.input(input.name, {type: input.type, dimensions: input.shape})); + } + // invoke builder.concat() + namedOutputOperand[resources.expected.name] = builder[operationName](inputOperands, resources.axis); + return namedOutputOperand; +}; + +testWebNNOperation('concat', '/webnn/resources/test_data/concat.json', buildConcat);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/idlharness.https.any.js b/testing/web-platform/tests/webnn/idlharness.https.any.js new file mode 100644 index 0000000000..6122134268 --- /dev/null +++ b/testing/web-platform/tests/webnn/idlharness.https.any.js @@ -0,0 +1,58 @@ +// META: global=window,dedicatedworker +// META: script=/resources/WebIDLParser.js +// META: script=/resources/idlharness.js +// META: script=./resources/utils.js +// META: timeout=long + +// https://webmachinelearning.github.io/webnn/ + +'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'], + MLOperator: ['relu'], + MLGraphBuilder: ['builder'], + MLGraph: ['graph'] + }); + + for (const executionType of ExecutionArray) { + const isSync = executionType === 'sync'; + if (self.GLOBAL.isWindow() && isSync) { + continue; + } + + for (const deviceType of DeviceTypeArray) { + if (isSync) { + self.context = navigator.ml.createContextSync({deviceType}); + } else { + self.context = await navigator.ml.createContext({deviceType}); + } + + self.builder = new MLGraphBuilder(self.context); + self.input = builder.input('input', {type: 'float32', dimensions: [1, 1, 5, 5]}); + self.filter = builder.constant({type: '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"}); + + if (isSync) { + self.graph = builder.buildSync({output}); + } else { + self.graph = await builder.build({output}); + } + } + } + } +); diff --git a/testing/web-platform/tests/webnn/leaky_relu.https.any.js b/testing/web-platform/tests/webnn/leaky_relu.https.any.js new file mode 100644 index 0000000000..0755f33a90 --- /dev/null +++ b/testing/web-platform/tests/webnn/leaky_relu.https.any.js @@ -0,0 +1,10 @@ +// META: title=test WebNN API leakyRelu operation +// META: global=window,dedicatedworker +// META: script=./resources/utils.js +// META: timeout=long + +'use strict'; + +// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-leakyrelu + +testWebNNOperation('leakyRelu', '/webnn/resources/test_data/leaky_relu.json', buildOperationWithSingleInput);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/relu.https.any.js b/testing/web-platform/tests/webnn/relu.https.any.js new file mode 100644 index 0000000000..19a0d986ca --- /dev/null +++ b/testing/web-platform/tests/webnn/relu.https.any.js @@ -0,0 +1,10 @@ +// META: title=test WebNN API relu operation +// META: global=window,dedicatedworker +// META: script=./resources/utils.js +// META: timeout=long + +'use strict'; + +// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-relu + +testWebNNOperation('relu', '/webnn/resources/test_data/relu.json', buildOperationWithSingleInput);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/reshape.https.any.js b/testing/web-platform/tests/webnn/reshape.https.any.js new file mode 100644 index 0000000000..40829bd1c3 --- /dev/null +++ b/testing/web-platform/tests/webnn/reshape.https.any.js @@ -0,0 +1,20 @@ +// META: title=test WebNN API reshape operation +// META: global=window,dedicatedworker +// META: script=./resources/utils.js +// META: timeout=long + +'use strict'; + +// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-reshape + +const buildReshape = (operationName, builder, resources) => { + // MLOperand reshape(MLOperand input, sequence<long> newShape); + const namedOutputOperand = {}; + const inputOperand = createSingleInputOperand(builder, resources); + // invoke builder.reshape() + namedOutputOperand[resources.expected.name] = builder[operationName](inputOperand, resources.newShape); + return namedOutputOperand; +}; + +testWebNNOperation('reshape', '/webnn/resources/test_data/reshape.json', buildReshape); + diff --git a/testing/web-platform/tests/webnn/resources/test_data/clamp.json b/testing/web-platform/tests/webnn/resources/test_data/clamp.json new file mode 100644 index 0000000000..93ab5ca0c1 --- /dev/null +++ b/testing/web-platform/tests/webnn/resources/test_data/clamp.json @@ -0,0 +1,1102 @@ +{ + "tests": [ + // default options + { + "name": "clamp float32 1D tensor default options", + "inputs": { + "x": { // use 'x' for input operand name + "shape": [24], + "data": [ + -9.817828475355284, + -6.024063916325786, + -4.072562498632983, + -6.575078191902692, + -7.7556836912181915, + 9.524681107378463, + 3.7292487446449307, + 6.4816868736447475, + -1.5374205904252634, + -7.343102426698445, + 7.880751290929794, + -2.056408790509967, + 6.34386375786449, + 5.52573787183, + 0.8433118207347725, + -8.19996033345526, + -7.786487326213716, + 9.280223823954241, + -2.31305948485121, + 9.549695091037119, + 5.788925460130297, + 5.549378312916486, + 7.409400528051194, + -2.1236145770503745 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [24], + "data": [ + -9.817828178405762, + -6.024064064025879, + -4.0725626945495605, + -6.575078010559082, + -7.755683898925781, + 9.524681091308594, + 3.7292487621307373, + 6.481687068939209, + -1.537420630455017, + -7.34310245513916, + 7.880751132965088, + -2.0564088821411133, + 6.3438639640808105, + 5.525737762451172, + 0.8433118462562561, + -8.199960708618164, + -7.786487102508545, + 9.280223846435547, + -2.3130595684051514, + 9.549695014953613, + 5.788925647735596, + 5.549378395080566, + 7.409400463104248, + -2.123614549636841 + ], + "type": "float32" + } + }, + { + "name": "clamp float32 2D tensor default options", + "inputs": { + "x": { + "shape": [4, 6], + "data": [ + -9.817828475355284, + -6.024063916325786, + -4.072562498632983, + -6.575078191902692, + -7.7556836912181915, + 9.524681107378463, + 3.7292487446449307, + 6.4816868736447475, + -1.5374205904252634, + -7.343102426698445, + 7.880751290929794, + -2.056408790509967, + 6.34386375786449, + 5.52573787183, + 0.8433118207347725, + -8.19996033345526, + -7.786487326213716, + 9.280223823954241, + -2.31305948485121, + 9.549695091037119, + 5.788925460130297, + 5.549378312916486, + 7.409400528051194, + -2.1236145770503745 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [4, 6], + "data": [ + -9.817828178405762, + -6.024064064025879, + -4.0725626945495605, + -6.575078010559082, + -7.755683898925781, + 9.524681091308594, + 3.7292487621307373, + 6.481687068939209, + -1.537420630455017, + -7.34310245513916, + 7.880751132965088, + -2.0564088821411133, + 6.3438639640808105, + 5.525737762451172, + 0.8433118462562561, + -8.199960708618164, + -7.786487102508545, + 9.280223846435547, + -2.3130595684051514, + 9.549695014953613, + 5.788925647735596, + 5.549378395080566, + 7.409400463104248, + -2.123614549636841 + ], + "type": "float32" + } + }, + { + "name": "clamp float32 3D tensor default options", + "inputs": { + "x": { + "shape": [2, 3, 4], + "data": [ + -9.817828475355284, + -6.024063916325786, + -4.072562498632983, + -6.575078191902692, + -7.7556836912181915, + 9.524681107378463, + 3.7292487446449307, + 6.4816868736447475, + -1.5374205904252634, + -7.343102426698445, + 7.880751290929794, + -2.056408790509967, + 6.34386375786449, + 5.52573787183, + 0.8433118207347725, + -8.19996033345526, + -7.786487326213716, + 9.280223823954241, + -2.31305948485121, + 9.549695091037119, + 5.788925460130297, + 5.549378312916486, + 7.409400528051194, + -2.1236145770503745 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [2, 3, 4], + "data": [ + -9.817828178405762, + -6.024064064025879, + -4.0725626945495605, + -6.575078010559082, + -7.755683898925781, + 9.524681091308594, + 3.7292487621307373, + 6.481687068939209, + -1.537420630455017, + -7.34310245513916, + 7.880751132965088, + -2.0564088821411133, + 6.3438639640808105, + 5.525737762451172, + 0.8433118462562561, + -8.199960708618164, + -7.786487102508545, + 9.280223846435547, + -2.3130595684051514, + 9.549695014953613, + 5.788925647735596, + 5.549378395080566, + 7.409400463104248, + -2.123614549636841 + ], + "type": "float32" + } + }, + { + "name": "clamp float32 4D tensor default options", + "inputs": { + "x": { + "shape": [3, 2, 2, 2], + "data": [ + -9.817828475355284, + -6.024063916325786, + -4.072562498632983, + -6.575078191902692, + -7.7556836912181915, + 9.524681107378463, + 3.7292487446449307, + 6.4816868736447475, + -1.5374205904252634, + -7.343102426698445, + 7.880751290929794, + -2.056408790509967, + 6.34386375786449, + 5.52573787183, + 0.8433118207347725, + -8.19996033345526, + -7.786487326213716, + 9.280223823954241, + -2.31305948485121, + 9.549695091037119, + 5.788925460130297, + 5.549378312916486, + 7.409400528051194, + -2.1236145770503745 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [3, 2, 2, 2], + "data": [ + -9.817828178405762, + -6.024064064025879, + -4.0725626945495605, + -6.575078010559082, + -7.755683898925781, + 9.524681091308594, + 3.7292487621307373, + 6.481687068939209, + -1.537420630455017, + -7.34310245513916, + 7.880751132965088, + -2.0564088821411133, + 6.3438639640808105, + 5.525737762451172, + 0.8433118462562561, + -8.199960708618164, + -7.786487102508545, + 9.280223846435547, + -2.3130595684051514, + 9.549695014953613, + 5.788925647735596, + 5.549378395080566, + 7.409400463104248, + -2.123614549636841 + ], + "type": "float32" + } + }, + { + "name": "clamp float32 5D tensor default options", + "inputs": { + "x": { + "shape": [4, 1, 1, 2, 3], + "data": [ + -9.817828475355284, + -6.024063916325786, + -4.072562498632983, + -6.575078191902692, + -7.7556836912181915, + 9.524681107378463, + 3.7292487446449307, + 6.4816868736447475, + -1.5374205904252634, + -7.343102426698445, + 7.880751290929794, + -2.056408790509967, + 6.34386375786449, + 5.52573787183, + 0.8433118207347725, + -8.19996033345526, + -7.786487326213716, + 9.280223823954241, + -2.31305948485121, + 9.549695091037119, + 5.788925460130297, + 5.549378312916486, + 7.409400528051194, + -2.1236145770503745 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [4, 1, 1, 2, 3], + "data": [ + -9.817828178405762, + -6.024064064025879, + -4.0725626945495605, + -6.575078010559082, + -7.755683898925781, + 9.524681091308594, + 3.7292487621307373, + 6.481687068939209, + -1.537420630455017, + -7.34310245513916, + 7.880751132965088, + -2.0564088821411133, + 6.3438639640808105, + 5.525737762451172, + 0.8433118462562561, + -8.199960708618164, + -7.786487102508545, + 9.280223846435547, + -2.3130595684051514, + 9.549695014953613, + 5.788925647735596, + 5.549378395080566, + 7.409400463104248, + -2.123614549636841 + ], + "type": "float32" + } + }, + // default options.maxValue and specified options.minValue + { + "name": "clamp float32 4D tensor default options.maxValue and specified negative options.minValue", + "inputs": { + "x": { + "shape": [2, 1, 4, 3], + "data": [ + -9.817828475355284, + -6.024063916325786, + -4.072562498632983, + -6.575078191902692, + -7.7556836912181915, + 9.524681107378463, + 3.7292487446449307, + 6.4816868736447475, + -1.5374205904252634, + -7.343102426698445, + 7.880751290929794, + -2.056408790509967, + 6.34386375786449, + 5.52573787183, + 0.8433118207347725, + -8.19996033345526, + -7.786487326213716, + 9.280223823954241, + -2.31305948485121, + 9.549695091037119, + 5.788925460130297, + 5.549378312916486, + 7.409400528051194, + -2.1236145770503745 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [2, 1, 4, 3], + "data": [ + -1, + -1, + -1, + -1, + -1, + 9.524681091308594, + 3.7292487621307373, + 6.481687068939209, + -1, + -1, + 7.880751132965088, + -1, + 6.3438639640808105, + 5.525737762451172, + 0.8433118462562561, + -1, + -1, + 9.280223846435547, + -1, + 9.549695014953613, + 5.788925647735596, + 5.549378395080566, + 7.409400463104248, + -1 + ], + "type": "float32" + }, + "options": { + "minValue": -1.0 + } + }, + { + "name": "clamp float32 3D tensor default options.maxValue and specified options.minValue=0.0", + "inputs": { + "x": { + "shape": [6, 2, 2], + "data": [ + -9.817828475355284, + -6.024063916325786, + -4.072562498632983, + -6.575078191902692, + -7.7556836912181915, + 9.524681107378463, + 3.7292487446449307, + 6.4816868736447475, + -1.5374205904252634, + -7.343102426698445, + 7.880751290929794, + -2.056408790509967, + 6.34386375786449, + 5.52573787183, + 0.8433118207347725, + -8.19996033345526, + -7.786487326213716, + 9.280223823954241, + -2.31305948485121, + 9.549695091037119, + 5.788925460130297, + 5.549378312916486, + 7.409400528051194, + -2.1236145770503745 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [6, 2, 2], + "data": [ + 0, + 0, + 0, + 0, + 0, + 9.524681091308594, + 3.7292487621307373, + 6.481687068939209, + 0, + 0, + 7.880751132965088, + 0, + 6.3438639640808105, + 5.525737762451172, + 0.8433118462562561, + 0, + 0, + 9.280223846435547, + 0, + 9.549695014953613, + 5.788925647735596, + 5.549378395080566, + 7.409400463104248, + 0 + ], + "type": "float32" + }, + "options": { + "minValue": 0.0 + } + }, + { + "name": "clamp float32 2D tensor default options.maxValue and specified positive options.minValue", + "inputs": { + "x": { + "shape": [3, 8], + "data": [ + -9.817828475355284, + -6.024063916325786, + -4.072562498632983, + -6.575078191902692, + -7.7556836912181915, + 9.524681107378463, + 3.7292487446449307, + 6.4816868736447475, + -1.5374205904252634, + -7.343102426698445, + 7.880751290929794, + -2.056408790509967, + 6.34386375786449, + 5.52573787183, + 0.8433118207347725, + -8.19996033345526, + -7.786487326213716, + 9.280223823954241, + -2.31305948485121, + 9.549695091037119, + 5.788925460130297, + 5.549378312916486, + 7.409400528051194, + -2.1236145770503745 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [3, 8], + "data": [ + 1, + 1, + 1, + 1, + 1, + 9.524681091308594, + 3.7292487621307373, + 6.481687068939209, + 1, + 1, + 7.880751132965088, + 1, + 6.3438639640808105, + 5.525737762451172, + 1, + 1, + 1, + 9.280223846435547, + 1, + 9.549695014953613, + 5.788925647735596, + 5.549378395080566, + 7.409400463104248, + 1 + ], + "type": "float32" + }, + "options": { + "minValue": 1.0 + } + }, + // default options.minValue and specified options.maxValue + { + "name": "clamp float32 5D tensor default options.minValue and specified negative options.maxValue", + "inputs": { + "x": { + "shape": [2, 2, 1, 2, 3], + "data": [ + -9.817828475355284, + -6.024063916325786, + -4.072562498632983, + -6.575078191902692, + -7.7556836912181915, + 9.524681107378463, + 3.7292487446449307, + 6.4816868736447475, + -1.5374205904252634, + -7.343102426698445, + 7.880751290929794, + -2.056408790509967, + 6.34386375786449, + 5.52573787183, + 0.8433118207347725, + -8.19996033345526, + -7.786487326213716, + 9.280223823954241, + -2.31305948485121, + 9.549695091037119, + 5.788925460130297, + 5.549378312916486, + 7.409400528051194, + -2.1236145770503745 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [2, 1, 4, 3], + "data": [ + -9.817828178405762, + -6.024064064025879, + -4.0725626945495605, + -6.575078010559082, + -7.755683898925781, + -2, + -2, + -2, + -2, + -7.34310245513916, + -2, + -2.0564088821411133, + -2, + -2, + -2, + -8.199960708618164, + -7.786487102508545, + -2, + -2.3130595684051514, + -2, + -2, + -2, + -2, + -2.123614549636841 + ], + "type": "float32" + }, + "options": { + "maxValue": -2.0 + } + }, + { + "name": "clamp float32 1D tensor default options.minValue and specified options.maxValue=0.0", + "inputs": { + "x": { + "shape": [24], + "data": [ + -9.817828475355284, + -6.024063916325786, + -4.072562498632983, + -6.575078191902692, + -7.7556836912181915, + 9.524681107378463, + 3.7292487446449307, + 6.4816868736447475, + -1.5374205904252634, + -7.343102426698445, + 7.880751290929794, + -2.056408790509967, + 6.34386375786449, + 5.52573787183, + 0.8433118207347725, + -8.19996033345526, + -7.786487326213716, + 9.280223823954241, + -2.31305948485121, + 9.549695091037119, + 5.788925460130297, + 5.549378312916486, + 7.409400528051194, + -2.1236145770503745 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [24], + "data": [ + -9.817828178405762, + -6.024064064025879, + -4.0725626945495605, + -6.575078010559082, + -7.755683898925781, + 0, + 0, + 0, + -1.537420630455017, + -7.34310245513916, + 0, + -2.0564088821411133, + 0, + 0, + 0, + -8.199960708618164, + -7.786487102508545, + 0, + -2.3130595684051514, + 0, + 0, + 0, + 0, + -2.123614549636841 + ], + "type": "float32" + }, + "options": { + "maxValue": 0.0 + } + }, + { + "name": "clamp float32 3D tensor default options.minValue and specified positive options.maxValue", + "inputs": { + "x": { + "shape": [3, 4, 2], + "data": [ + -9.817828475355284, + -6.024063916325786, + -4.072562498632983, + -6.575078191902692, + -7.7556836912181915, + 9.524681107378463, + 3.7292487446449307, + 6.4816868736447475, + -1.5374205904252634, + -7.343102426698445, + 7.880751290929794, + -2.056408790509967, + 6.34386375786449, + 5.52573787183, + 0.8433118207347725, + -8.19996033345526, + -7.786487326213716, + 9.280223823954241, + -2.31305948485121, + 9.549695091037119, + 5.788925460130297, + 5.549378312916486, + 7.409400528051194, + -2.1236145770503745 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [3, 4, 2], + "data": [ + -9.817828178405762, + -6.024064064025879, + -4.0725626945495605, + -6.575078010559082, + -7.755683898925781, + 3, + 3, + 3, + -1.537420630455017, + -7.34310245513916, + 3, + -2.0564088821411133, + 3, + 3, + 0.8433118462562561, + -8.199960708618164, + -7.786487102508545, + 3, + -2.3130595684051514, + 3, + 3, + 3, + 3, + -2.123614549636841 + ], + "type": "float32" + }, + "options": { + "maxValue": 3.0 + } + }, + // specified both options.minValue and options.maxValue + { + "name": "clamp float32 5D tensor specified both negative options.minValue and options.maxValue", + "inputs": { + "x": { + "shape": [3, 2, 1, 1, 4], + "data": [ + -9.817828475355284, + -6.024063916325786, + -4.072562498632983, + -6.575078191902692, + -7.7556836912181915, + 9.524681107378463, + 3.7292487446449307, + 6.4816868736447475, + -1.5374205904252634, + -7.343102426698445, + 7.880751290929794, + -2.056408790509967, + 6.34386375786449, + 5.52573787183, + 0.8433118207347725, + -8.19996033345526, + -7.786487326213716, + 9.280223823954241, + -2.31305948485121, + 9.549695091037119, + 5.788925460130297, + 5.549378312916486, + 7.409400528051194, + -2.1236145770503745 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [3, 2, 1, 1, 4], + "data": [ + -8, + -6.024064064025879, + -4.0725626945495605, + -6.575078010559082, + -7.755683898925781, + -1, + -1, + -1, + -1.537420630455017, + -7.34310245513916, + -1, + -2.0564088821411133, + -1, + -1, + -1, + -8, + -7.786487102508545, + -1, + -2.3130595684051514, + -1, + -1, + -1, + -1, + -2.123614549636841 + ], + "type": "float32" + }, + "options": { + "minValue": -8.0, + "maxValue": -1.0 + } + }, + { + "name": "clamp float32 4D tensor specified negative options.minValue and options.maxValue=0.0", + "inputs": { + "x": { + "shape": [1, 4, 3, 2], + "data": [ + -9.817828475355284, + -6.024063916325786, + -4.072562498632983, + -6.575078191902692, + -7.7556836912181915, + 9.524681107378463, + 3.7292487446449307, + 6.4816868736447475, + -1.5374205904252634, + -7.343102426698445, + 7.880751290929794, + -2.056408790509967, + 6.34386375786449, + 5.52573787183, + 0.8433118207347725, + -8.19996033345526, + -7.786487326213716, + 9.280223823954241, + -2.31305948485121, + 9.549695091037119, + 5.788925460130297, + 5.549378312916486, + 7.409400528051194, + -2.1236145770503745 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [1, 4, 3, 2], + "data": [ + -6, + -6, + -4.0725626945495605, + -6, + -6, + 0, + 0, + 0, + -1.537420630455017, + -6, + 0, + -2.0564088821411133, + 0, + 0, + 0, + -6, + -6, + 0, + -2.3130595684051514, + 0, + 0, + 0, + 0, + -2.123614549636841 + ], + "type": "float32" + }, + "options": { + "minValue": -6.0, + "maxValue": 0.0 + } + }, + { + "name": "clamp float32 3D tensor specified negative options.minValue and positive options.maxValue", + "inputs": { + "x": { + "shape": [2, 6, 2], + "data": [ + -9.817828475355284, + -6.024063916325786, + -4.072562498632983, + -6.575078191902692, + -7.7556836912181915, + 9.524681107378463, + 3.7292487446449307, + 6.4816868736447475, + -1.5374205904252634, + -7.343102426698445, + 7.880751290929794, + -2.056408790509967, + 6.34386375786449, + 5.52573787183, + 0.8433118207347725, + -8.19996033345526, + -7.786487326213716, + 9.280223823954241, + -2.31305948485121, + 9.549695091037119, + 5.788925460130297, + 5.549378312916486, + 7.409400528051194, + -2.1236145770503745 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [2, 6, 2], + "data": [ + -3, + -3, + -3, + -3, + -3, + 4, + 3.7292487621307373, + 4, + -1.537420630455017, + -3, + 4, + -2.0564088821411133, + 4, + 4, + 0.8433118462562561, + -3, + -3, + 4, + -2.3130595684051514, + 4, + 4, + 4, + 4, + -2.123614549636841 + ], + "type": "float32" + }, + "options": { + "minValue": -3.0, + "maxValue": 4.0 + } + }, + { + "name": "clamp float32 2D tensor specified options.minValue=0.0 and positive options.maxValue", + "inputs": { + "x": { + "shape": [6, 4], + "data": [ + -9.817828475355284, + -6.024063916325786, + -4.072562498632983, + -6.575078191902692, + -7.7556836912181915, + 9.524681107378463, + 3.7292487446449307, + 6.4816868736447475, + -1.5374205904252634, + -7.343102426698445, + 7.880751290929794, + -2.056408790509967, + 6.34386375786449, + 5.52573787183, + 0.8433118207347725, + -8.19996033345526, + -7.786487326213716, + 9.280223823954241, + -2.31305948485121, + 9.549695091037119, + 5.788925460130297, + 5.549378312916486, + 7.409400528051194, + -2.1236145770503745 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [6, 4], + "data": [ + 0, + 0, + 0, + 0, + 0, + 6, + 3.7292487621307373, + 6, + 0, + 0, + 6, + 0, + 6, + 5.525737762451172, + 0.8433118462562561, + 0, + 0, + 6, + 0, + 6, + 5.788925647735596, + 5.549378395080566, + 6, + 0 + ], + "type": "float32" + }, + "options": { + "minValue": 0.0, + "maxValue": 6.0 + } + }, + { + "name": "clamp float32 1D tensor specified both positive options.minValue and options.maxValue", + "inputs": { + "x": { + "shape": [24], + "data": [ + -9.817828475355284, + -6.024063916325786, + -4.072562498632983, + -6.575078191902692, + -7.7556836912181915, + 9.524681107378463, + 3.7292487446449307, + 6.4816868736447475, + -1.5374205904252634, + -7.343102426698445, + 7.880751290929794, + -2.056408790509967, + 6.34386375786449, + 5.52573787183, + 0.8433118207347725, + -8.19996033345526, + -7.786487326213716, + 9.280223823954241, + -2.31305948485121, + 9.549695091037119, + 5.788925460130297, + 5.549378312916486, + 7.409400528051194, + -2.1236145770503745 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [24], + "data": [ + 2, + 2, + 2, + 2, + 2, + 7, + 3.7292487621307373, + 6.481687068939209, + 2, + 2, + 7, + 2, + 6.3438639640808105, + 5.525737762451172, + 2, + 2, + 2, + 7, + 2, + 7, + 5.788925647735596, + 5.549378395080566, + 7, + 2 + ], + "type": "float32" + }, + "options": { + "minValue": 2.0, + "maxValue": 7.0 + } + } + ] +}
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/resources/test_data/concat.json b/testing/web-platform/tests/webnn/resources/test_data/concat.json new file mode 100644 index 0000000000..9ecc393f89 --- /dev/null +++ b/testing/web-platform/tests/webnn/resources/test_data/concat.json @@ -0,0 +1,1799 @@ +{ + "tests": [ + // concat 1D tensors + { + "name": "concat two float32 1D tensors of same shape along axis 0", + "inputs": [ + { + "name": "input1", + "shape": [12], + "data": [ + -0.39444134019222243, + 0.8619825316530809, + 0.3379962524218807, + -0.9906398615400507, + 0.576785657225761, + 0.3227640108329237, + -0.44735022799701873, + 0.11028251232581932, + -0.5945112749179908, + -0.40284849555754754, + -0.9531654171044694, + -0.6731740531810844 + ], + "type": "float32" + }, + { + "name": "input2", + "shape": [12], + "data": [ + 0.4918989118791477, + -0.15864110312378976, + -0.34188115459083157, + -0.9158143500894873, + -0.7206121708970712, + -0.7993468785008635, + 0.6653799854931952, + 0.03886038855553897, + 0.5182055416768865, + -0.8742016938344297, + -0.479021891130635, + 0.1211843166661235 + ], + "type": "float32" + } + ], + "axis": 0, + "expected": { + "name": "output", + "shape": [24], + "data": [ + -0.3944413363933563, + 0.861982524394989, + 0.337996244430542, + -0.990639865398407, + 0.576785683631897, + 0.32276400923728943, + -0.44735023379325867, + 0.11028251051902771, + -0.5945112705230713, + -0.402848482131958, + -0.9531654119491577, + -0.6731740236282349, + 0.49189892411231995, + -0.15864109992980957, + -0.3418811559677124, + -0.9158143401145935, + -0.7206121683120728, + -0.7993468642234802, + 0.6653800010681152, + 0.03886038810014725, + 0.5182055234909058, + -0.8742017149925232, + -0.4790218770503998, + 0.1211843192577362 + ], + "type": "float32" + } + }, + { + "name": "concat three float32 1D tensors of different 1st dimension along axis 0", + "inputs": [ + { + "name": "input1", + "shape": [4], + "data": [ + -0.39444134019222243, + 0.8619825316530809, + 0.3379962524218807, + -0.9906398615400507 + ], + "type": "float32" + }, + { + "name": "input2", + "shape": [8], + "data": [ + 0.576785657225761, + 0.3227640108329237, + -0.44735022799701873, + 0.11028251232581932, + -0.5945112749179908, + -0.40284849555754754, + -0.9531654171044694, + -0.6731740531810844 + ], + "type": "float32" + }, + { + "name": "input3", + "shape": [12], + "data": [ + 0.4918989118791477, + -0.15864110312378976, + -0.34188115459083157, + -0.9158143500894873, + -0.7206121708970712, + -0.7993468785008635, + 0.6653799854931952, + 0.03886038855553897, + 0.5182055416768865, + -0.8742016938344297, + -0.479021891130635, + 0.1211843166661235 + ], + "type": "float32" + } + ], + "axis": 0, + "expected": { + "name": "output", + "shape": [24], + "data": [ + -0.3944413363933563, + 0.861982524394989, + 0.337996244430542, + -0.990639865398407, + 0.576785683631897, + 0.32276400923728943, + -0.44735023379325867, + 0.11028251051902771, + -0.5945112705230713, + -0.402848482131958, + -0.9531654119491577, + -0.6731740236282349, + 0.49189892411231995, + -0.15864109992980957, + -0.3418811559677124, + -0.9158143401145935, + -0.7206121683120728, + -0.7993468642234802, + 0.6653800010681152, + 0.03886038810014725, + 0.5182055234909058, + -0.8742017149925232, + -0.4790218770503998, + 0.1211843192577362 + ], + "type": "float32" + } + }, + { + "name": "concat four float32 1D tensors of same 1st dimension along axis 0", + "inputs": [ + { + "name": "input1", + "shape": [6], + "data": [ + -0.39444134019222243, + 0.8619825316530809, + 0.3379962524218807, + -0.9906398615400507, + 0.576785657225761, + 0.3227640108329237 + ], + "type": "float32" + }, + { + "name": "input2", + "shape": [6], + "data": [ + -0.44735022799701873, + 0.11028251232581932, + -0.5945112749179908, + -0.40284849555754754, + -0.9531654171044694, + -0.6731740531810844 + ], + "type": "float32" + }, + { + "name": "input3", + "shape": [6], + "data": [ + 0.4918989118791477, + -0.15864110312378976, + -0.34188115459083157, + -0.9158143500894873, + -0.7206121708970712, + -0.7993468785008635 + ], + "type": "float32" + }, + { + "name": "input4", + "shape": [6], + "data": [ + 0.6653799854931952, + 0.03886038855553897, + 0.5182055416768865, + -0.8742016938344297, + -0.479021891130635, + 0.1211843166661235 + ], + "type": "float32" + } + ], + "axis": 0, + "expected": { + "name": "output", + "shape": [24], + "data": [ + -0.3944413363933563, + 0.861982524394989, + 0.337996244430542, + -0.990639865398407, + 0.576785683631897, + 0.32276400923728943, + -0.44735023379325867, + 0.11028251051902771, + -0.5945112705230713, + -0.402848482131958, + -0.9531654119491577, + -0.6731740236282349, + 0.49189892411231995, + -0.15864109992980957, + -0.3418811559677124, + -0.9158143401145935, + -0.7206121683120728, + -0.7993468642234802, + 0.6653800010681152, + 0.03886038810014725, + 0.5182055234909058, + -0.8742017149925232, + -0.4790218770503998, + 0.1211843192577362 + ], + "type": "float32" + } + }, + { + "name": "concat four float32 1D tensors of different 1st dimension along axis 0", + "inputs": [ + { + "name": "input1", + "shape": [2], + "data": [ + -0.39444134019222243, + 0.8619825316530809 + ], + "type": "float32" + }, + { + "name": "input2", + "shape": [4], + "data": [ + 0.3379962524218807, + -0.9906398615400507, + 0.576785657225761, + 0.3227640108329237 + ], + "type": "float32" + }, + { + "name": "input3", + "shape": [8], + "data": [ + -0.44735022799701873, + 0.11028251232581932, + -0.5945112749179908, + -0.40284849555754754, + -0.9531654171044694, + -0.6731740531810844, + 0.4918989118791477, + -0.15864110312378976 + ], + "type": "float32" + }, + { + "name": "input4", + "shape": [10], + "data": [ + -0.34188115459083157, + -0.9158143500894873, + -0.7206121708970712, + -0.7993468785008635, + 0.6653799854931952, + 0.03886038855553897, + 0.5182055416768865, + -0.8742016938344297, + -0.479021891130635, + 0.1211843166661235 + ], + "type": "float32" + } + ], + "axis": 0, + "expected": { + "name": "output", + "shape": [24], + "data": [ + -0.3944413363933563, + 0.861982524394989, + 0.337996244430542, + -0.990639865398407, + 0.576785683631897, + 0.32276400923728943, + -0.44735023379325867, + 0.11028251051902771, + -0.5945112705230713, + -0.402848482131958, + -0.9531654119491577, + -0.6731740236282349, + 0.49189892411231995, + -0.15864109992980957, + -0.3418811559677124, + -0.9158143401145935, + -0.7206121683120728, + -0.7993468642234802, + 0.6653800010681152, + 0.03886038810014725, + 0.5182055234909058, + -0.8742017149925232, + -0.4790218770503998, + 0.1211843192577362 + ], + "type": "float32" + } + }, + // concat 2D tensors + { + "name": "concat two float32 2D tensors of same shape along axis 0", + "inputs": [ + { + "name": "input1", + "shape": [2, 6], + "data": [ + -0.39444134019222243, + 0.8619825316530809, + 0.3379962524218807, + -0.9906398615400507, + 0.576785657225761, + 0.3227640108329237, + -0.44735022799701873, + 0.11028251232581932, + -0.5945112749179908, + -0.40284849555754754, + -0.9531654171044694, + -0.6731740531810844 + ], + "type": "float32" + }, + { + "name": "input2", + "shape": [2, 6], + "data": [ + 0.4918989118791477, + -0.15864110312378976, + -0.34188115459083157, + -0.9158143500894873, + -0.7206121708970712, + -0.7993468785008635, + 0.6653799854931952, + 0.03886038855553897, + 0.5182055416768865, + -0.8742016938344297, + -0.479021891130635, + 0.1211843166661235 + ], + "type": "float32" + } + ], + "axis": 0, + "expected": { + "name": "output", + "shape": [4, 6], + "data": [ + -0.3944413363933563, + 0.861982524394989, + 0.337996244430542, + -0.990639865398407, + 0.576785683631897, + 0.32276400923728943, + -0.44735023379325867, + 0.11028251051902771, + -0.5945112705230713, + -0.402848482131958, + -0.9531654119491577, + -0.6731740236282349, + 0.49189892411231995, + -0.15864109992980957, + -0.3418811559677124, + -0.9158143401145935, + -0.7206121683120728, + -0.7993468642234802, + 0.6653800010681152, + 0.03886038810014725, + 0.5182055234909058, + -0.8742017149925232, + -0.4790218770503998, + 0.1211843192577362 + ], + "type": "float32" + } + }, + { + "name": "concat two float32 2D tensors of same others dimensions except different 1st dimension along axis 0", + "inputs": [ + { + "name": "input1", + "shape": [1, 6], + "data": [ + -0.39444134019222243, + 0.8619825316530809, + 0.3379962524218807, + -0.9906398615400507, + 0.576785657225761, + 0.3227640108329237 + ], + "type": "float32" + }, + { + "name": "input2", + "shape": [3, 6], + "data": [ + -0.44735022799701873, + 0.11028251232581932, + -0.5945112749179908, + -0.40284849555754754, + -0.9531654171044694, + -0.6731740531810844, + 0.4918989118791477, + -0.15864110312378976, + -0.34188115459083157, + -0.9158143500894873, + -0.7206121708970712, + -0.7993468785008635, + 0.6653799854931952, + 0.03886038855553897, + 0.5182055416768865, + -0.8742016938344297, + -0.479021891130635, + 0.1211843166661235 + ], + "type": "float32" + } + ], + "axis": 0, + "expected": { + "name": "output", + "shape": [4, 6], + "data": [ + -0.3944413363933563, + 0.861982524394989, + 0.337996244430542, + -0.990639865398407, + 0.576785683631897, + 0.32276400923728943, + -0.44735023379325867, + 0.11028251051902771, + -0.5945112705230713, + -0.402848482131958, + -0.9531654119491577, + -0.6731740236282349, + 0.49189892411231995, + -0.15864109992980957, + -0.3418811559677124, + -0.9158143401145935, + -0.7206121683120728, + -0.7993468642234802, + 0.6653800010681152, + 0.03886038810014725, + 0.5182055234909058, + -0.8742017149925232, + -0.4790218770503998, + 0.1211843192577362 + ], + "type": "float32" + } + }, + { + "name": "concat four float32 2D tensors of same shape along axis 0", + "inputs": [ + { + "name": "input1", + "shape": [3, 2], + "data": [ + -0.39444134019222243, + 0.8619825316530809, + 0.3379962524218807, + -0.9906398615400507, + 0.576785657225761, + 0.3227640108329237 + ], + "type": "float32" + }, + { + "name": "input2", + "shape": [3, 2], + "data": [ + -0.44735022799701873, + 0.11028251232581932, + -0.5945112749179908, + -0.40284849555754754, + -0.9531654171044694, + -0.6731740531810844 + ], + "type": "float32" + }, + { + "name": "input3", + "shape": [3, 2], + "data": [ + 0.4918989118791477, + -0.15864110312378976, + -0.34188115459083157, + -0.9158143500894873, + -0.7206121708970712, + -0.7993468785008635 + ], + "type": "float32" + }, + { + "name": "input4", + "shape": [3, 2], + "data": [ + 0.6653799854931952, + 0.03886038855553897, + 0.5182055416768865, + -0.8742016938344297, + -0.479021891130635, + 0.1211843166661235 + ], + "type": "float32" + } + ], + "axis": 0, + "expected": { + "name": "output", + "shape": [12, 2], + "data": [ + -0.3944413363933563, + 0.861982524394989, + 0.337996244430542, + -0.990639865398407, + 0.576785683631897, + 0.32276400923728943, + -0.44735023379325867, + 0.11028251051902771, + -0.5945112705230713, + -0.402848482131958, + -0.9531654119491577, + -0.6731740236282349, + 0.49189892411231995, + -0.15864109992980957, + -0.3418811559677124, + -0.9158143401145935, + -0.7206121683120728, + -0.7993468642234802, + 0.6653800010681152, + 0.03886038810014725, + 0.5182055234909058, + -0.8742017149925232, + -0.4790218770503998, + 0.1211843192577362 + ], + "type": "float32" + } + }, + { + "name": "concat two float32 2D tensors of same others dimensions except different 2nd dimension along axis 1", + "inputs": [ + { + "name": "input1", + "shape": [2, 10], + "data": [ + -0.39444134019222243, + 0.8619825316530809, + 0.3379962524218807, + -0.9906398615400507, + 0.576785657225761, + 0.3227640108329237, + -0.44735022799701873, + 0.11028251232581932, + -0.5945112749179908, + -0.40284849555754754, + -0.9531654171044694, + -0.6731740531810844, + 0.4918989118791477, + -0.15864110312378976, + -0.34188115459083157, + -0.9158143500894873, + -0.7206121708970712, + -0.7993468785008635, + 0.6653799854931952, + 0.03886038855553897 + ], + "type": "float32" + }, + { + "name": "input2", + "shape": [2, 2], + "data": [ + 0.5182055416768865, + -0.8742016938344297, + -0.479021891130635, + 0.1211843166661235 + ], + "type": "float32" + } + ], + "axis": 1, + "expected": { + "name": "output", + "shape": [2, 12], + "data": [ + -0.3944413363933563, + 0.861982524394989, + 0.337996244430542, + -0.990639865398407, + 0.576785683631897, + 0.32276400923728943, + -0.44735023379325867, + 0.11028251051902771, + -0.5945112705230713, + -0.402848482131958, + 0.5182055234909058, + -0.8742017149925232, + -0.9531654119491577, + -0.6731740236282349, + 0.49189892411231995, + -0.15864109992980957, + -0.3418811559677124, + -0.9158143401145935, + -0.7206121683120728, + -0.7993468642234802, + 0.6653800010681152, + 0.03886038810014725, + -0.4790218770503998, + 0.1211843192577362 + ], + "type": "float32" + } + }, + { + "name": "concat three float32 2D tensors of same shape along axis 1", + "inputs": [ + { + "name": "input1", + "shape": [4, 2], + "data": [ + -0.39444134019222243, + 0.8619825316530809, + 0.3379962524218807, + -0.9906398615400507, + 0.576785657225761, + 0.3227640108329237, + -0.44735022799701873, + 0.11028251232581932 + ], + "type": "float32" + }, + { + "name": "input2", + "shape": [4, 2], + "data": [ + -0.5945112749179908, + -0.40284849555754754, + -0.9531654171044694, + -0.6731740531810844, + 0.4918989118791477, + -0.15864110312378976, + -0.34188115459083157, + -0.9158143500894873 + ], + "type": "float32" + }, + { + "name": "input3", + "shape": [4, 2], + "data": [ + -0.7206121708970712, + -0.7993468785008635, + 0.6653799854931952, + 0.03886038855553897, + 0.5182055416768865, + -0.8742016938344297, + -0.479021891130635, + 0.1211843166661235 + ], + "type": "float32" + } + ], + "axis": 1, + "expected": { + "name": "output", + "shape": [4, 6], + "data": [ + -0.3944413363933563, + 0.861982524394989, + -0.5945112705230713, + -0.402848482131958, + -0.7206121683120728, + -0.7993468642234802, + 0.337996244430542, + -0.990639865398407, + -0.9531654119491577, + -0.6731740236282349, + 0.6653800010681152, + 0.03886038810014725, + 0.576785683631897, + 0.32276400923728943, + 0.49189892411231995, + -0.15864109992980957, + 0.5182055234909058, + -0.8742017149925232, + -0.44735023379325867, + 0.11028251051902771, + -0.3418811559677124, + -0.9158143401145935, + -0.4790218770503998, + 0.1211843192577362 + ], + "type": "float32" + } + }, + { + "name": "concat four float32 2D tensors of same others dimensions except different 2nd dimension along axis 1", + "inputs": [ + { + "name": "input1", + "shape": [3, 1], + "data": [ + -0.39444134019222243, + 0.8619825316530809, + 0.3379962524218807 + ], + "type": "float32" + }, + { + "name": "input2", + "shape": [3, 2], + "data": [ + -0.9906398615400507, + 0.576785657225761, + 0.3227640108329237, + -0.44735022799701873, + 0.11028251232581932, + -0.5945112749179908 + ], + "type": "float32" + }, + { + "name": "input3", + "shape": [3, 2], + "data": [ + -0.40284849555754754, + -0.9531654171044694, + -0.6731740531810844, + 0.4918989118791477, + -0.15864110312378976, + -0.34188115459083157 + ], + "type": "float32" + }, + { + "name": "input4", + "shape": [3, 3], + "data": [ + -0.9158143500894873, + -0.7206121708970712, + -0.7993468785008635, + 0.6653799854931952, + 0.03886038855553897, + 0.5182055416768865, + -0.8742016938344297, + -0.479021891130635, + 0.1211843166661235 + ], + "type": "float32" + } + ], + "axis": 1, + "expected": { + "name": "output", + "shape": [3, 8], + "data": [ + -0.3944413363933563, + -0.990639865398407, + 0.576785683631897, + -0.402848482131958, + -0.9531654119491577, + -0.9158143401145935, + -0.7206121683120728, + -0.7993468642234802, + 0.861982524394989, + 0.32276400923728943, + -0.44735023379325867, + -0.6731740236282349, + 0.49189892411231995, + 0.6653800010681152, + 0.03886038810014725, + 0.5182055234909058, + 0.337996244430542, + 0.11028251051902771, + -0.5945112705230713, + -0.15864109992980957, + -0.3418811559677124, + -0.8742017149925232, + -0.4790218770503998, + 0.1211843192577362 + ], + "type": "float32" + } + }, + // concat 3D tensors + { + "name": "concat two float32 3D tensors of same others dimensions except different 1st dimension along axis 0", + "inputs": [ + { + "name": "input1", + "shape": [2, 1, 3], + "data": [ + -0.39444134019222243, + 0.8619825316530809, + 0.3379962524218807, + -0.9906398615400507, + 0.576785657225761, + 0.3227640108329237 + ], + "type": "float32" + }, + { + "name": "input2", + "shape": [6, 1, 3], + "data": [ + -0.44735022799701873, + 0.11028251232581932, + -0.5945112749179908, + -0.40284849555754754, + -0.9531654171044694, + -0.6731740531810844, + 0.4918989118791477, + -0.15864110312378976, + -0.34188115459083157, + -0.9158143500894873, + -0.7206121708970712, + -0.7993468785008635, + 0.6653799854931952, + 0.03886038855553897, + 0.5182055416768865, + -0.8742016938344297, + -0.479021891130635, + 0.1211843166661235 + ], + "type": "float32" + } + ], + "axis": 0, + "expected": { + "name": "output", + "shape": [8, 1, 3], + "data": [ + -0.3944413363933563, + 0.861982524394989, + 0.337996244430542, + -0.990639865398407, + 0.576785683631897, + 0.32276400923728943, + -0.44735023379325867, + 0.11028251051902771, + -0.5945112705230713, + -0.402848482131958, + -0.9531654119491577, + -0.6731740236282349, + 0.49189892411231995, + -0.15864109992980957, + -0.3418811559677124, + -0.9158143401145935, + -0.7206121683120728, + -0.7993468642234802, + 0.6653800010681152, + 0.03886038810014725, + 0.5182055234909058, + -0.8742017149925232, + -0.4790218770503998, + 0.1211843192577362 + ], + "type": "float32" + } + }, + { + "name": "concat four float32 3D tensors of same others dimensions except different 2nd dimension along axis 1", + "inputs": [ + { + "name": "input1", + "shape": [3, 1, 1], + "data": [ + -0.39444134019222243, + 0.8619825316530809, + 0.3379962524218807 + ], + "type": "float32" + }, + { + "name": "input2", + "shape": [3, 2, 1], + "data": [ + -0.9906398615400507, + 0.576785657225761, + 0.3227640108329237, + -0.44735022799701873, + 0.11028251232581932, + -0.5945112749179908 + ], + "type": "float32" + }, + { + "name": "input3", + "shape": [3, 2, 1], + "data": [ + -0.40284849555754754, + -0.9531654171044694, + -0.6731740531810844, + 0.4918989118791477, + -0.15864110312378976, + -0.34188115459083157 + ], + "type": "float32" + }, + { + "name": "input4", + "shape": [3, 3, 1], + "data": [ + -0.9158143500894873, + -0.7206121708970712, + -0.7993468785008635, + 0.6653799854931952, + 0.03886038855553897, + 0.5182055416768865, + -0.8742016938344297, + -0.479021891130635, + 0.1211843166661235 + ], + "type": "float32" + } + ], + "axis": 1, + "expected": { + "name": "output", + "shape": [3, 8, 1], + "data": [ + -0.3944413363933563, + -0.990639865398407, + 0.576785683631897, + -0.402848482131958, + -0.9531654119491577, + -0.9158143401145935, + -0.7206121683120728, + -0.7993468642234802, + 0.861982524394989, + 0.32276400923728943, + -0.44735023379325867, + -0.6731740236282349, + 0.49189892411231995, + 0.6653800010681152, + 0.03886038810014725, + 0.5182055234909058, + 0.337996244430542, + 0.11028251051902771, + -0.5945112705230713, + -0.15864109992980957, + -0.3418811559677124, + -0.8742017149925232, + -0.4790218770503998, + 0.1211843192577362 + ], + "type": "float32" + } + }, + { + "name": "concat three float32 3D tensors of same shape along axis 2", + "inputs": [ + { + "name": "input1", + "shape": [2, 2, 2], + "data": [ + -0.39444134019222243, + 0.8619825316530809, + 0.3379962524218807, + -0.9906398615400507, + 0.576785657225761, + 0.3227640108329237, + -0.44735022799701873, + 0.11028251232581932 + ], + "type": "float32" + }, + { + "name": "input2", + "shape": [2, 2, 2], + "data": [ + -0.5945112749179908, + -0.40284849555754754, + -0.9531654171044694, + -0.6731740531810844, + 0.4918989118791477, + -0.15864110312378976, + -0.34188115459083157, + -0.9158143500894873 + ], + "type": "float32" + }, + { + "name": "input3", + "shape": [2, 2, 2], + "data": [ + -0.7206121708970712, + -0.7993468785008635, + 0.6653799854931952, + 0.03886038855553897, + 0.5182055416768865, + -0.8742016938344297, + -0.479021891130635, + 0.1211843166661235 + ], + "type": "float32" + } + ], + "axis": 2, + "expected": { + "name": "output", + "shape": [2, 2, 6], + "data": [ + -0.3944413363933563, + 0.861982524394989, + -0.5945112705230713, + -0.402848482131958, + -0.7206121683120728, + -0.7993468642234802, + 0.337996244430542, + -0.990639865398407, + -0.9531654119491577, + -0.6731740236282349, + 0.6653800010681152, + 0.03886038810014725, + 0.576785683631897, + 0.32276400923728943, + 0.49189892411231995, + -0.15864109992980957, + 0.5182055234909058, + -0.8742017149925232, + -0.44735023379325867, + 0.11028251051902771, + -0.3418811559677124, + -0.9158143401145935, + -0.4790218770503998, + 0.1211843192577362 + ], + "type": "float32" + } + }, + // concat 4D tensors + { + "name": "concat two float32 4D tensors of same others dimensions except different 1st dimension along axis 0", + "inputs": [ + { + "name": "input1", + "shape": [1, 3, 1, 2], + "data": [ + -0.39444134019222243, + 0.8619825316530809, + 0.3379962524218807, + -0.9906398615400507, + 0.576785657225761, + 0.3227640108329237 + ], + "type": "float32" + }, + { + "name": "input2", + "shape": [3, 3, 1, 2], + "data": [ + -0.44735022799701873, + 0.11028251232581932, + -0.5945112749179908, + -0.40284849555754754, + -0.9531654171044694, + -0.6731740531810844, + 0.4918989118791477, + -0.15864110312378976, + -0.34188115459083157, + -0.9158143500894873, + -0.7206121708970712, + -0.7993468785008635, + 0.6653799854931952, + 0.03886038855553897, + 0.5182055416768865, + -0.8742016938344297, + -0.479021891130635, + 0.1211843166661235 + ], + "type": "float32" + } + ], + "axis": 0, + "expected": { + "name": "output", + "shape": [4, 3, 1, 2], + "data": [ + -0.3944413363933563, + 0.861982524394989, + 0.337996244430542, + -0.990639865398407, + 0.576785683631897, + 0.32276400923728943, + -0.44735023379325867, + 0.11028251051902771, + -0.5945112705230713, + -0.402848482131958, + -0.9531654119491577, + -0.6731740236282349, + 0.49189892411231995, + -0.15864109992980957, + -0.3418811559677124, + -0.9158143401145935, + -0.7206121683120728, + -0.7993468642234802, + 0.6653800010681152, + 0.03886038810014725, + 0.5182055234909058, + -0.8742017149925232, + -0.4790218770503998, + 0.1211843192577362 + ], + "type": "float32" + } + }, + { + "name": "concat three float32 4D tensors of same shape along axis 1", + "inputs": [ + { + "name": "input1", + "shape": [2, 2, 1, 2], + "data": [ + -0.39444134019222243, + 0.8619825316530809, + 0.3379962524218807, + -0.9906398615400507, + 0.576785657225761, + 0.3227640108329237, + -0.44735022799701873, + 0.11028251232581932 + ], + "type": "float32" + }, + { + "name": "input2", + "shape": [2, 2, 1, 2], + "data": [ + -0.5945112749179908, + -0.40284849555754754, + -0.9531654171044694, + -0.6731740531810844, + 0.4918989118791477, + -0.15864110312378976, + -0.34188115459083157, + -0.9158143500894873 + ], + "type": "float32" + }, + { + "name": "input3", + "shape": [2, 2, 1, 2], + "data": [ + -0.7206121708970712, + -0.7993468785008635, + 0.6653799854931952, + 0.03886038855553897, + 0.5182055416768865, + -0.8742016938344297, + -0.479021891130635, + 0.1211843166661235 + ], + "type": "float32" + } + ], + "axis": 1, + "expected": { + "name": "output", + "shape": [2, 6, 1, 2], + "data": [ + -0.3944413363933563, + 0.861982524394989, + 0.337996244430542, + -0.990639865398407, + -0.5945112705230713, + -0.402848482131958, + -0.9531654119491577, + -0.6731740236282349, + -0.7206121683120728, + -0.7993468642234802, + 0.6653800010681152, + 0.03886038810014725, + 0.576785683631897, + 0.32276400923728943, + -0.44735023379325867, + 0.11028251051902771, + 0.49189892411231995, + -0.15864109992980957, + -0.3418811559677124, + -0.9158143401145935, + 0.5182055234909058, + -0.8742017149925232, + -0.4790218770503998, + 0.1211843192577362 + ], + "type": "float32" + } + }, + { + "name": "concat three float32 4D tensors of same others dimensions except different 3rd dimension along axis 2", + "inputs": [ + { + "name": "input1", + "shape": [1, 2, 2, 1], + "data": [ + -0.39444134019222243, + 0.8619825316530809, + 0.3379962524218807, + -0.9906398615400507 + ], + "type": "float32" + }, + { + "name": "input2", + "shape": [1, 2, 8, 1], + "data": [ + 0.576785657225761, + 0.3227640108329237, + -0.44735022799701873, + 0.11028251232581932, + -0.5945112749179908, + -0.40284849555754754, + -0.9531654171044694, + -0.6731740531810844, + 0.4918989118791477, + -0.15864110312378976, + -0.34188115459083157, + -0.9158143500894873, + -0.7206121708970712, + -0.7993468785008635, + 0.6653799854931952, + 0.03886038855553897 + ], + "type": "float32" + }, + { + "name": "input3", + "shape": [1, 2, 2, 1], + "data": [ + 0.5182055416768865, + -0.8742016938344297, + -0.479021891130635, + 0.1211843166661235 + ], + "type": "float32" + } + ], + "axis": 2, + "expected": { + "name": "output", + "shape": [1, 2, 12, 1], + "data": [ + -0.3944413363933563, + 0.861982524394989, + 0.576785683631897, + 0.32276400923728943, + -0.44735023379325867, + 0.11028251051902771, + -0.5945112705230713, + -0.402848482131958, + -0.9531654119491577, + -0.6731740236282349, + 0.5182055234909058, + -0.8742017149925232, + 0.337996244430542, + -0.990639865398407, + 0.49189892411231995, + -0.15864109992980957, + -0.3418811559677124, + -0.9158143401145935, + -0.7206121683120728, + -0.7993468642234802, + 0.6653800010681152, + 0.03886038810014725, + -0.4790218770503998, + 0.1211843192577362 + ], + "type": "float32" + } + }, + { + "name": "concat four float32 4D tensors of same others dimensions except different 4th dimension along axis 3", + "inputs": [ + { + "name": "input1", + "shape": [1, 3, 1, 1], + "data": [ + -0.39444134019222243, + 0.8619825316530809, + 0.3379962524218807 + ], + "type": "float32" + }, + { + "name": "input2", + "shape": [1, 3, 1, 1], + "data": [ + -0.9906398615400507, + 0.576785657225761, + 0.3227640108329237 + ], + "type": "float32" + }, + { + "name": "input3", + "shape": [1, 3, 1, 2], + "data": [ + -0.44735022799701873, + 0.11028251232581932, + -0.5945112749179908, + -0.40284849555754754, + -0.9531654171044694, + -0.6731740531810844 + ], + "type": "float32" + }, + { + "name": "input4", + "shape": [1, 3, 1, 4], + "data": [ + 0.4918989118791477, + -0.15864110312378976, + -0.34188115459083157, + -0.9158143500894873, + -0.7206121708970712, + -0.7993468785008635, + 0.6653799854931952, + 0.03886038855553897, + 0.5182055416768865, + -0.8742016938344297, + -0.479021891130635, + 0.1211843166661235 + ], + "type": "float32" + } + ], + "axis": 3, + "expected": { + "name": "output", + "shape": [1, 3, 1, 8], + "data": [ + -0.3944413363933563, + -0.990639865398407, + -0.44735023379325867, + 0.11028251051902771, + 0.49189892411231995, + -0.15864109992980957, + -0.3418811559677124, + -0.9158143401145935, + 0.861982524394989, + 0.576785683631897, + -0.5945112705230713, + -0.402848482131958, + -0.7206121683120728, + -0.7993468642234802, + 0.6653800010681152, + 0.03886038810014725, + 0.337996244430542, + 0.32276400923728943, + -0.9531654119491577, + -0.6731740236282349, + 0.5182055234909058, + -0.8742017149925232, + -0.4790218770503998, + 0.1211843192577362 + ], + "type": "float32" + } + }, + // concat 5D tensors + { + "name": "concat four float32 5D tensors of same shape along axis 0", + "inputs": [ + { + "name": "input1", + "shape": [1, 2, 1, 1, 3], + "data": [ + -0.39444134019222243, + 0.8619825316530809, + 0.3379962524218807, + -0.9906398615400507, + 0.576785657225761, + 0.3227640108329237 + ], + "type": "float32" + }, + { + "name": "input2", + "shape": [1, 2, 1, 1, 3], + "data": [ + -0.44735022799701873, + 0.11028251232581932, + -0.5945112749179908, + -0.40284849555754754, + -0.9531654171044694, + -0.6731740531810844 + ], + "type": "float32" + }, + { + "name": "input3", + "shape": [1, 2, 1, 1, 3], + "data": [ + 0.4918989118791477, + -0.15864110312378976, + -0.34188115459083157, + -0.9158143500894873, + -0.7206121708970712, + -0.7993468785008635 + ], + "type": "float32" + }, + { + "name": "input4", + "shape":[1, 2, 1, 1, 3], + "data": [ + 0.6653799854931952, + 0.03886038855553897, + 0.5182055416768865, + -0.8742016938344297, + -0.479021891130635, + 0.1211843166661235 + ], + "type": "float32" + } + ], + "axis": 0, + "expected": { + "name": "output", + "shape": [4, 2, 1, 1, 3], + "data": [ + -0.3944413363933563, + 0.861982524394989, + 0.337996244430542, + -0.990639865398407, + 0.576785683631897, + 0.32276400923728943, + -0.44735023379325867, + 0.11028251051902771, + -0.5945112705230713, + -0.402848482131958, + -0.9531654119491577, + -0.6731740236282349, + 0.49189892411231995, + -0.15864109992980957, + -0.3418811559677124, + -0.9158143401145935, + -0.7206121683120728, + -0.7993468642234802, + 0.6653800010681152, + 0.03886038810014725, + 0.5182055234909058, + -0.8742017149925232, + -0.4790218770503998, + 0.1211843192577362 + ], + "type": "float32" + } + }, + { + "name": "concat two float32 5D tensors of same others dimensions except different 2nd dimension along axis 1", + "inputs": [ + { + "name": "input1", + "shape": [1, 2, 3, 1, 1], + "data": [ + -0.39444134019222243, + 0.8619825316530809, + 0.3379962524218807, + -0.9906398615400507, + 0.576785657225761, + 0.3227640108329237 + ], + "type": "float32" + }, + { + "name": "input2", + "shape": [1, 6, 3, 1, 1], + "data": [ + -0.44735022799701873, + 0.11028251232581932, + -0.5945112749179908, + -0.40284849555754754, + -0.9531654171044694, + -0.6731740531810844, + 0.4918989118791477, + -0.15864110312378976, + -0.34188115459083157, + -0.9158143500894873, + -0.7206121708970712, + -0.7993468785008635, + 0.6653799854931952, + 0.03886038855553897, + 0.5182055416768865, + -0.8742016938344297, + -0.479021891130635, + 0.1211843166661235 + ], + "type": "float32" + } + ], + "axis": 1, + "expected": { + "name": "output", + "shape": [1, 8, 3, 1, 1], + "data": [ + -0.3944413363933563, + 0.861982524394989, + 0.337996244430542, + -0.990639865398407, + 0.576785683631897, + 0.32276400923728943, + -0.44735023379325867, + 0.11028251051902771, + -0.5945112705230713, + -0.402848482131958, + -0.9531654119491577, + -0.6731740236282349, + 0.49189892411231995, + -0.15864109992980957, + -0.3418811559677124, + -0.9158143401145935, + -0.7206121683120728, + -0.7993468642234802, + 0.6653800010681152, + 0.03886038810014725, + 0.5182055234909058, + -0.8742017149925232, + -0.4790218770503998, + 0.1211843192577362 + ], + "type": "float32" + } + }, + { + "name": "concat three float32 5D tensors of same others dimensions except different 3rd dimension along axis 2", + "inputs": [ + { + "name": "input1", + "shape": [1, 2, 1, 1, 2], + "data": [ + -0.39444134019222243, + 0.8619825316530809, + 0.3379962524218807, + -0.9906398615400507 + ], + "type": "float32" + }, + { + "name": "input2", + "shape": [1, 2, 2, 1, 2], + "data": [ + 0.576785657225761, + 0.3227640108329237, + -0.44735022799701873, + 0.11028251232581932, + -0.5945112749179908, + -0.40284849555754754, + -0.9531654171044694, + -0.6731740531810844 + ], + "type": "float32" + }, + { + "name": "input3", + "shape": [1, 2, 3, 1, 2], + "data": [ + 0.4918989118791477, + -0.15864110312378976, + -0.34188115459083157, + -0.9158143500894873, + -0.7206121708970712, + -0.7993468785008635, + 0.6653799854931952, + 0.03886038855553897, + 0.5182055416768865, + -0.8742016938344297, + -0.479021891130635, + 0.1211843166661235 + ], + "type": "float32" + } + ], + "axis": 2, + "expected": { + "name": "output", + "shape": [1, 2, 6, 1, 2], + "data": [ + -0.3944413363933563, + 0.861982524394989, + 0.576785683631897, + 0.32276400923728943, + -0.44735023379325867, + 0.11028251051902771, + 0.49189892411231995, + -0.15864109992980957, + -0.3418811559677124, + -0.9158143401145935, + -0.7206121683120728, + -0.7993468642234802, + 0.337996244430542, + -0.990639865398407, + -0.5945112705230713, + -0.402848482131958, + -0.9531654119491577, + -0.6731740236282349, + 0.6653800010681152, + 0.03886038810014725, + 0.5182055234909058, + -0.8742017149925232, + -0.4790218770503998, + 0.1211843192577362 + ], + "type": "float32" + } + }, + { + "name": "concat two float32 5D tensors of same others dimensions except different 4th dimension along axis 3", + "inputs": [ + { + "name": "input1", + "shape": [3, 1, 1, 1, 2], + "data": [ + -0.39444134019222243, + 0.8619825316530809, + 0.3379962524218807, + -0.9906398615400507, + 0.576785657225761, + 0.3227640108329237 + ], + "type": "float32" + }, + { + "name": "input2", + "shape": [3, 1, 1, 3, 2], + "data": [ + -0.44735022799701873, + 0.11028251232581932, + -0.5945112749179908, + -0.40284849555754754, + -0.9531654171044694, + -0.6731740531810844, + 0.4918989118791477, + -0.15864110312378976, + -0.34188115459083157, + -0.9158143500894873, + -0.7206121708970712, + -0.7993468785008635, + 0.6653799854931952, + 0.03886038855553897, + 0.5182055416768865, + -0.8742016938344297, + -0.479021891130635, + 0.1211843166661235 + ], + "type": "float32" + } + ], + "axis": 3, + "expected": { + "name": "output", + "shape": [3, 1, 1, 4, 2], + "data": [ + -0.3944413363933563, + 0.861982524394989, + -0.44735023379325867, + 0.11028251051902771, + -0.5945112705230713, + -0.402848482131958, + -0.9531654119491577, + -0.6731740236282349, + 0.337996244430542, + -0.990639865398407, + 0.49189892411231995, + -0.15864109992980957, + -0.3418811559677124, + -0.9158143401145935, + -0.7206121683120728, + -0.7993468642234802, + 0.576785683631897, + 0.32276400923728943, + 0.6653800010681152, + 0.03886038810014725, + 0.5182055234909058, + -0.8742017149925232, + -0.4790218770503998, + 0.1211843192577362 + ], + "type": "float32" + } + }, + { + "name": "concat two float32 5D tensors of same others dimensions except different 5th dimension along axis 4", + "inputs": [ + { + "name": "input1", + "shape": [1, 2, 1, 1, 4], + "data": [ + -0.39444134019222243, + 0.8619825316530809, + 0.3379962524218807, + -0.9906398615400507, + 0.576785657225761, + 0.3227640108329237, + -0.44735022799701873, + 0.11028251232581932 + ], + "type": "float32" + }, + { + "name": "input2", + "shape": [1, 2, 1, 1, 8], + "data": [ + -0.5945112749179908, + -0.40284849555754754, + -0.9531654171044694, + -0.6731740531810844, + 0.4918989118791477, + -0.15864110312378976, + -0.34188115459083157, + -0.9158143500894873, + -0.7206121708970712, + -0.7993468785008635, + 0.6653799854931952, + 0.03886038855553897, + 0.5182055416768865, + -0.8742016938344297, + -0.479021891130635, + 0.1211843166661235 + ], + "type": "float32" + } + ], + "axis": 4, + "expected": { + "name": "output", + "shape": [1, 2, 1, 1, 12], + "data": [ + -0.3944413363933563, + 0.861982524394989, + 0.337996244430542, + -0.990639865398407, + -0.5945112705230713, + -0.402848482131958, + -0.9531654119491577, + -0.6731740236282349, + 0.49189892411231995, + -0.15864109992980957, + -0.3418811559677124, + -0.9158143401145935, + 0.576785683631897, + 0.32276400923728943, + -0.44735023379325867, + 0.11028251051902771, + -0.7206121683120728, + -0.7993468642234802, + 0.6653800010681152, + 0.03886038810014725, + 0.5182055234909058, + -0.8742017149925232, + -0.4790218770503998, + 0.1211843192577362 + ], + "type": "float32" + } + } + ] +}
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/resources/test_data/leaky_relu.json b/testing/web-platform/tests/webnn/resources/test_data/leaky_relu.json new file mode 100644 index 0000000000..a95a9a0cfc --- /dev/null +++ b/testing/web-platform/tests/webnn/resources/test_data/leaky_relu.json @@ -0,0 +1,542 @@ +{ + "tests": [ + { + "name": "leakyRelu float32 1D tensor default options", // default options.alpha=0.01 + "inputs": { + "x": { + "shape": [24], + "data": [ + -19.053641157857015, + 50.77590443347373, + -69.54966768567536, + -80.57432185346957, + -90.40109641580112, + 76.02884674163622, + 66.33873525494391, + -84.10186452043264, + -17.19101282693427, + -87.47624329964907, + -3.4164664941905585, + -22.7723589638245, + -2.509489125727569, + 18.933284857582677, + 98.61402761165104, + 55.33923216295767, + -33.178605382176, + -46.03901297809681, + -61.47925538549912, + 64.26514742116822, + 21.46934200700099, + -31.51468946013378, + -41.27694294131783, + -65.59528852425132 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [24], + "data": [ + -0.19053640961647034, + 50.77590560913086, + -0.695496678352356, + -0.8057432770729065, + -0.9040110111236572, + 76.02884674072266, + 66.33873748779297, + -0.8410186767578125, + -0.1719101369380951, + -0.8747624158859253, + -0.0341646634042263, + -0.2277235984802246, + -0.02509489096701145, + 18.933284759521484, + 98.61402893066406, + 55.3392333984375, + -0.33178603649139404, + -0.4603901207447052, + -0.6147925853729248, + 64.26514434814453, + 21.469341278076172, + -0.31514689326286316, + -0.4127694368362427, + -0.6559529304504395 + ], + "type": "float32" + } + }, + { + "name": "leakyRelu float32 2D tensor default options", + "inputs": { + "x": { + "shape": [4, 6], + "data": [ + -19.053641157857015, + 50.77590443347373, + -69.54966768567536, + -80.57432185346957, + -90.40109641580112, + 76.02884674163622, + 66.33873525494391, + -84.10186452043264, + -17.19101282693427, + -87.47624329964907, + -3.4164664941905585, + -22.7723589638245, + -2.509489125727569, + 18.933284857582677, + 98.61402761165104, + 55.33923216295767, + -33.178605382176, + -46.03901297809681, + -61.47925538549912, + 64.26514742116822, + 21.46934200700099, + -31.51468946013378, + -41.27694294131783, + -65.59528852425132 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [4, 6], + "data": [ + -0.19053640961647034, + 50.77590560913086, + -0.695496678352356, + -0.8057432770729065, + -0.9040110111236572, + 76.02884674072266, + 66.33873748779297, + -0.8410186767578125, + -0.1719101369380951, + -0.8747624158859253, + -0.0341646634042263, + -0.2277235984802246, + -0.02509489096701145, + 18.933284759521484, + 98.61402893066406, + 55.3392333984375, + -0.33178603649139404, + -0.4603901207447052, + -0.6147925853729248, + 64.26514434814453, + 21.469341278076172, + -0.31514689326286316, + -0.4127694368362427, + -0.6559529304504395 + ], + "type": "float32" + } + }, + { + "name": "leakyRelu float32 3D tensor default options", + "inputs": { + "x": { + "shape": [2, 3, 4], + "data": [ + -19.053641157857015, + 50.77590443347373, + -69.54966768567536, + -80.57432185346957, + -90.40109641580112, + 76.02884674163622, + 66.33873525494391, + -84.10186452043264, + -17.19101282693427, + -87.47624329964907, + -3.4164664941905585, + -22.7723589638245, + -2.509489125727569, + 18.933284857582677, + 98.61402761165104, + 55.33923216295767, + -33.178605382176, + -46.03901297809681, + -61.47925538549912, + 64.26514742116822, + 21.46934200700099, + -31.51468946013378, + -41.27694294131783, + -65.59528852425132 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [2, 3, 4], + "data": [ + -0.19053640961647034, + 50.77590560913086, + -0.695496678352356, + -0.8057432770729065, + -0.9040110111236572, + 76.02884674072266, + 66.33873748779297, + -0.8410186767578125, + -0.1719101369380951, + -0.8747624158859253, + -0.0341646634042263, + -0.2277235984802246, + -0.02509489096701145, + 18.933284759521484, + 98.61402893066406, + 55.3392333984375, + -0.33178603649139404, + -0.4603901207447052, + -0.6147925853729248, + 64.26514434814453, + 21.469341278076172, + -0.31514689326286316, + -0.4127694368362427, + -0.6559529304504395 + ], + "type": "float32" + } + }, + { + "name": "leakyRelu float32 4D tensor default options", + "inputs": { + "x": { + "shape": [1, 2, 3, 4], + "data": [ + -19.053641157857015, + 50.77590443347373, + -69.54966768567536, + -80.57432185346957, + -90.40109641580112, + 76.02884674163622, + 66.33873525494391, + -84.10186452043264, + -17.19101282693427, + -87.47624329964907, + -3.4164664941905585, + -22.7723589638245, + -2.509489125727569, + 18.933284857582677, + 98.61402761165104, + 55.33923216295767, + -33.178605382176, + -46.03901297809681, + -61.47925538549912, + 64.26514742116822, + 21.46934200700099, + -31.51468946013378, + -41.27694294131783, + -65.59528852425132 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [1, 2, 3, 4], + "data": [ + -0.19053640961647034, + 50.77590560913086, + -0.695496678352356, + -0.8057432770729065, + -0.9040110111236572, + 76.02884674072266, + 66.33873748779297, + -0.8410186767578125, + -0.1719101369380951, + -0.8747624158859253, + -0.0341646634042263, + -0.2277235984802246, + -0.02509489096701145, + 18.933284759521484, + 98.61402893066406, + 55.3392333984375, + -0.33178603649139404, + -0.4603901207447052, + -0.6147925853729248, + 64.26514434814453, + 21.469341278076172, + -0.31514689326286316, + -0.4127694368362427, + -0.6559529304504395 + ], + "type": "float32" + } + }, + { + "name": "leakyRelu float32 5D tensor default options", + "inputs": { + "x": { + "shape": [1, 2, 1, 3, 4], + "data": [ + -19.053641157857015, + 50.77590443347373, + -69.54966768567536, + -80.57432185346957, + -90.40109641580112, + 76.02884674163622, + 66.33873525494391, + -84.10186452043264, + -17.19101282693427, + -87.47624329964907, + -3.4164664941905585, + -22.7723589638245, + -2.509489125727569, + 18.933284857582677, + 98.61402761165104, + 55.33923216295767, + -33.178605382176, + -46.03901297809681, + -61.47925538549912, + 64.26514742116822, + 21.46934200700099, + -31.51468946013378, + -41.27694294131783, + -65.59528852425132 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [1, 2, 1, 3, 4], + "data": [ + -0.19053640961647034, + 50.77590560913086, + -0.695496678352356, + -0.8057432770729065, + -0.9040110111236572, + 76.02884674072266, + 66.33873748779297, + -0.8410186767578125, + -0.1719101369380951, + -0.8747624158859253, + -0.0341646634042263, + -0.2277235984802246, + -0.02509489096701145, + 18.933284759521484, + 98.61402893066406, + 55.3392333984375, + -0.33178603649139404, + -0.4603901207447052, + -0.6147925853729248, + 64.26514434814453, + 21.469341278076172, + -0.31514689326286316, + -0.4127694368362427, + -0.6559529304504395 + ], + "type": "float32" + } + }, + { + "name": "leakyRelu float32 1D tensor negative options.alpha", + "inputs": { + "x": { + "shape": [24], + "data": [ + -19.053641157857015, + 50.77590443347373, + -69.54966768567536, + -80.57432185346957, + -90.40109641580112, + 76.02884674163622, + 66.33873525494391, + -84.10186452043264, + -17.19101282693427, + -87.47624329964907, + -3.4164664941905585, + -22.7723589638245, + -2.509489125727569, + 18.933284857582677, + 98.61402761165104, + 55.33923216295767, + -33.178605382176, + -46.03901297809681, + -61.47925538549912, + 64.26514742116822, + 21.46934200700099, + -31.51468946013378, + -41.27694294131783, + -65.59528852425132 + ], + "type": "float32" + } + }, + "options": { + "alpha": -97.70109193608776 + }, + "expected": { + "name": "output", + "shape": [24], + "data": [ + 1861.5615234375, + 50.77590560913086, + 6795.07861328125, + 7872.19970703125, + 8832.2861328125, + 76.02884674072266, + 66.33873748779297, + 8216.8447265625, + 1679.580810546875, + 8546.5244140625, + 333.7925109863281, + 2224.884521484375, + 245.17982482910156, + 18.933284759521484, + 98.61402893066406, + 55.3392333984375, + 3241.5859375, + 4498.06201171875, + 6006.5908203125, + 64.26514434814453, + 21.469341278076172, + 3079.019775390625, + 4032.802490234375, + 6408.73193359375 + ], + "type": "float32" + } + }, + { + "name": "leakyRelu float32 2D tensor positive options.alpha", + "inputs": { + "x": { + "shape": [4, 6], + "data": [ + -19.053641157857015, + 50.77590443347373, + -69.54966768567536, + -80.57432185346957, + -90.40109641580112, + 76.02884674163622, + 66.33873525494391, + -84.10186452043264, + -17.19101282693427, + -87.47624329964907, + -3.4164664941905585, + -22.7723589638245, + -2.509489125727569, + 18.933284857582677, + 98.61402761165104, + 55.33923216295767, + -33.178605382176, + -46.03901297809681, + -61.47925538549912, + 64.26514742116822, + 21.46934200700099, + -31.51468946013378, + -41.27694294131783, + -65.59528852425132 + ], + "type": "float32" + } + }, + "options": { + "alpha": 35.799162942273234 + }, + "expected": { + "name": "output", + "shape": [4, 6], + "data": [ + -682.1043701171875, + 50.77590560913086, + -2489.81982421875, + -2884.493408203125, + -3236.28369140625, + 76.02884674072266, + 66.33873748779297, + -3010.776611328125, + -615.4238891601562, + -3131.576416015625, + -122.306640625, + -815.2314453125, + -89.83760833740234, + 18.933284759521484, + 98.61402893066406, + 55.3392333984375, + -1187.7662353515625, + -1648.158203125, + -2200.906005859375, + 64.26514434814453, + 21.469341278076172, + -1128.1995849609375, + -1477.6800537109375, + -2348.256591796875 + ], + "type": "float32" + } + }, + { + "name": "leakyRelu float32 5D tensor options.alpha=0.0", // relu + "inputs": { + "x": { + "shape": [1, 2, 1, 3, 4], + "data": [ + -19.053641157857015, + 50.77590443347373, + -69.54966768567536, + -80.57432185346957, + -90.40109641580112, + 76.02884674163622, + 66.33873525494391, + -84.10186452043264, + -17.19101282693427, + -87.47624329964907, + -3.4164664941905585, + -22.7723589638245, + -2.509489125727569, + 18.933284857582677, + 98.61402761165104, + 55.33923216295767, + -33.178605382176, + -46.03901297809681, + -61.47925538549912, + 64.26514742116822, + 21.46934200700099, + -31.51468946013378, + -41.27694294131783, + -65.59528852425132 + ], + "type": "float32" + } + }, + "options": { + "alpha": 0.0 + }, + "expected": { + "name": "output", + "shape": [1, 2, 1, 3, 4], + "data": [ + 0, + 50.77590560913086, + 0, + 0, + 0, + 76.02884674072266, + 66.33873748779297, + 0, + 0, + 0, + 0, + 0, + 0, + 18.933284759521484, + 98.61402893066406, + 55.3392333984375, + 0, + 0, + 0, + 64.26514434814453, + 21.469341278076172, + 0, + 0, + 0 + ], + "type": "float32" + }, + "type": "float32" + } + ] +}
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/resources/test_data/relu.json b/testing/web-platform/tests/webnn/resources/test_data/relu.json new file mode 100644 index 0000000000..b459789147 --- /dev/null +++ b/testing/web-platform/tests/webnn/resources/test_data/relu.json @@ -0,0 +1,334 @@ +{ + "tests": [ // relu input tensor of 1D to 5D with same data values + { + "name": "relu float32 1D tensor", + "inputs": { + "x": { + "shape": [24], + "data": [ + 79.04725231657116, + 2.2503608756501166, + 80.73939090529203, + 63.90392076789547, + 77.67340745512104, + -71.09157819044825, + -82.74703468427575, + -26.814426600801028, + -99.16788836397058, + -35.71083406288831, + 18.36165830990626, + -37.36091648205435, + -52.8386119809162, + -10.408374773008958, + 60.60291560236189, + -13.644198913810342, + -76.54250291031946, + -8.132338049258351, + 51.51447452437017, + -51.63370281825297, + -64.567999424324, + -5.093302411117136, + 15.354103550744384, + 90.03858807393516 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [24], + "data": [ + 79.04724884033203, + 2.2503609657287598, + 80.73938751220703, + 63.9039192199707, + 77.67340850830078, + 0, + 0, + 0, + 0, + 0, + 18.361658096313477, + 0, + 0, + 0, + 60.6029167175293, + 0, + 0, + 0, + 51.51447296142578, + 0, + 0, + 0, + 15.354103088378906, + 90.03858947753906 + ], + "type": "float32" + } + }, + { + "name": "relu float32 2D tensor", + "inputs": { + "x": { + "shape": [4, 6], + "data": [ + 79.04725231657116, + 2.2503608756501166, + 80.73939090529203, + 63.90392076789547, + 77.67340745512104, + -71.09157819044825, + -82.74703468427575, + -26.814426600801028, + -99.16788836397058, + -35.71083406288831, + 18.36165830990626, + -37.36091648205435, + -52.8386119809162, + -10.408374773008958, + 60.60291560236189, + -13.644198913810342, + -76.54250291031946, + -8.132338049258351, + 51.51447452437017, + -51.63370281825297, + -64.567999424324, + -5.093302411117136, + 15.354103550744384, + 90.03858807393516 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [4, 6], + "data": [ + 79.04724884033203, + 2.2503609657287598, + 80.73938751220703, + 63.9039192199707, + 77.67340850830078, + 0, + 0, + 0, + 0, + 0, + 18.361658096313477, + 0, + 0, + 0, + 60.6029167175293, + 0, + 0, + 0, + 51.51447296142578, + 0, + 0, + 0, + 15.354103088378906, + 90.03858947753906 + ], + "type": "float32" + } + }, + { + "name": "relu float32 3D tensor", + "inputs": { + "x": { + "shape": [2, 3, 4], + "data": [ + 79.04725231657116, + 2.2503608756501166, + 80.73939090529203, + 63.90392076789547, + 77.67340745512104, + -71.09157819044825, + -82.74703468427575, + -26.814426600801028, + -99.16788836397058, + -35.71083406288831, + 18.36165830990626, + -37.36091648205435, + -52.8386119809162, + -10.408374773008958, + 60.60291560236189, + -13.644198913810342, + -76.54250291031946, + -8.132338049258351, + 51.51447452437017, + -51.63370281825297, + -64.567999424324, + -5.093302411117136, + 15.354103550744384, + 90.03858807393516 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [2, 3, 4], + "data": [ + 79.04724884033203, + 2.2503609657287598, + 80.73938751220703, + 63.9039192199707, + 77.67340850830078, + 0, + 0, + 0, + 0, + 0, + 18.361658096313477, + 0, + 0, + 0, + 60.6029167175293, + 0, + 0, + 0, + 51.51447296142578, + 0, + 0, + 0, + 15.354103088378906, + 90.03858947753906 + ], + "type": "float32" + } + }, + { + "name": "relu float32 4D tensor", + "inputs": { + "x": { + "shape": [2, 2, 2, 3], + "data": [ + 79.04725231657116, + 2.2503608756501166, + 80.73939090529203, + 63.90392076789547, + 77.67340745512104, + -71.09157819044825, + -82.74703468427575, + -26.814426600801028, + -99.16788836397058, + -35.71083406288831, + 18.36165830990626, + -37.36091648205435, + -52.8386119809162, + -10.408374773008958, + 60.60291560236189, + -13.644198913810342, + -76.54250291031946, + -8.132338049258351, + 51.51447452437017, + -51.63370281825297, + -64.567999424324, + -5.093302411117136, + 15.354103550744384, + 90.03858807393516 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 79.04724884033203, + 2.2503609657287598, + 80.73938751220703, + 63.9039192199707, + 77.67340850830078, + 0, + 0, + 0, + 0, + 0, + 18.361658096313477, + 0, + 0, + 0, + 60.6029167175293, + 0, + 0, + 0, + 51.51447296142578, + 0, + 0, + 0, + 15.354103088378906, + 90.03858947753906 + ], + "type": "float32" + } + }, + { + "name": "relu float32 5D tensor", + "inputs": { + "x": { + "shape": [2, 1, 4, 1, 3], + "data": [ + 79.04725231657116, + 2.2503608756501166, + 80.73939090529203, + 63.90392076789547, + 77.67340745512104, + -71.09157819044825, + -82.74703468427575, + -26.814426600801028, + -99.16788836397058, + -35.71083406288831, + 18.36165830990626, + -37.36091648205435, + -52.8386119809162, + -10.408374773008958, + 60.60291560236189, + -13.644198913810342, + -76.54250291031946, + -8.132338049258351, + 51.51447452437017, + -51.63370281825297, + -64.567999424324, + -5.093302411117136, + 15.354103550744384, + 90.03858807393516 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [2, 1, 4, 1, 3], + "data": [ + 79.04724884033203, + 2.2503609657287598, + 80.73938751220703, + 63.9039192199707, + 77.67340850830078, + 0, + 0, + 0, + 0, + 0, + 18.361658096313477, + 0, + 0, + 0, + 60.6029167175293, + 0, + 0, + 0, + 51.51447296142578, + 0, + 0, + 0, + 15.354103088378906, + 90.03858947753906 + ], + "type": "float32" + } + } + ] +}
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/resources/test_data/reshape.json b/testing/web-platform/tests/webnn/resources/test_data/reshape.json new file mode 100644 index 0000000000..f04b7b1dbe --- /dev/null +++ b/testing/web-platform/tests/webnn/resources/test_data/reshape.json @@ -0,0 +1,406 @@ +{ + "tests": [ + { + "name": "reshape float32 tensor to a new shape (reorder all dimensions)", + "inputs": { + "input": { + "shape": [2, 3, 4], + "data": [ + -30.056147250771076, + 99.5694232746736, + 88.04620115823073, + -91.87507576772606, + -23.797235323955633, + -91.28665022600151, + -63.15204449663816, + 12.066952464893262, + -96.1172904235943, + -44.77365489782947, + -80.08650883940432, + -64.4375694650447, + 27.641954235862485, + -96.86306613475395, + 83.68347403572196, + 50.599484132010815, + -20.187656772788642, + -1.3904608012750117, + -96.9360325497362, + 65.34144119048645, + 34.835993949837274, + 62.01485845563673, + -2.8698414892852355, + 27.903749097190158 + ], + "type": "float32" + } + }, + "newShape": [4, 2, 3], + "expected": { + "name": "output", + "shape": [4, 2, 3], + "data": [ + -30.0561466217041, + 99.56941986083984, + 88.04620361328125, + -91.87507629394531, + -23.7972354888916, + -91.28665161132812, + -63.15204620361328, + 12.0669527053833, + -96.1172866821289, + -44.77365493774414, + -80.08650970458984, + -64.43756866455078, + 27.64195442199707, + -96.86306762695312, + 83.6834716796875, + 50.599483489990234, + -20.18765640258789, + -1.3904608488082886, + -96.93603515625, + 65.34143829345703, + 34.835994720458984, + 62.01485824584961, + -2.8698415756225586, + 27.903749465942383 + ], + "type": "float32" + } + }, + { + "name": "reshape float32 tensor to a new shape (reduce dimensions)", + "inputs": { + "input": { + "shape": [4, 1, 1, 1, 6], + "data": [ + -30.056147250771076, + 99.5694232746736, + 88.04620115823073, + -91.87507576772606, + -23.797235323955633, + -91.28665022600151, + -63.15204449663816, + 12.066952464893262, + -96.1172904235943, + -44.77365489782947, + -80.08650883940432, + -64.4375694650447, + 27.641954235862485, + -96.86306613475395, + 83.68347403572196, + 50.599484132010815, + -20.187656772788642, + -1.3904608012750117, + -96.9360325497362, + 65.34144119048645, + 34.835993949837274, + 62.01485845563673, + -2.8698414892852355, + 27.903749097190158 + ], + "type": "float32" + } + }, + "newShape": [4, 1, 1, 6], + "expected": { + "name": "output", + "shape": [4, 1, 1, 6], + "data": [ + -30.0561466217041, + 99.56941986083984, + 88.04620361328125, + -91.87507629394531, + -23.7972354888916, + -91.28665161132812, + -63.15204620361328, + 12.0669527053833, + -96.1172866821289, + -44.77365493774414, + -80.08650970458984, + -64.43756866455078, + 27.64195442199707, + -96.86306762695312, + 83.6834716796875, + 50.599483489990234, + -20.18765640258789, + -1.3904608488082886, + -96.93603515625, + 65.34143829345703, + 34.835994720458984, + 62.01485824584961, + -2.8698415756225586, + 27.903749465942383 + ], + "type": "float32" + } + }, + { + "name": "reshape float32 tensor to a new shape (extend dimensions)", + "inputs": { + "input": { + "shape": [2, 2, 2, 3], + "data": [ + -30.056147250771076, + 99.5694232746736, + 88.04620115823073, + -91.87507576772606, + -23.797235323955633, + -91.28665022600151, + -63.15204449663816, + 12.066952464893262, + -96.1172904235943, + -44.77365489782947, + -80.08650883940432, + -64.4375694650447, + 27.641954235862485, + -96.86306613475395, + 83.68347403572196, + 50.599484132010815, + -20.187656772788642, + -1.3904608012750117, + -96.9360325497362, + 65.34144119048645, + 34.835993949837274, + 62.01485845563673, + -2.8698414892852355, + 27.903749097190158 + ], + "type": "float32" + } + }, + "newShape": [2, 2, 2, 3, 1], + "expected": { + "name": "output", + "shape": [2, 2, 2, 3, 1], + "data": [ + -30.0561466217041, + 99.56941986083984, + 88.04620361328125, + -91.87507629394531, + -23.7972354888916, + -91.28665161132812, + -63.15204620361328, + 12.0669527053833, + -96.1172866821289, + -44.77365493774414, + -80.08650970458984, + -64.43756866455078, + 27.64195442199707, + -96.86306762695312, + 83.6834716796875, + 50.599483489990234, + -20.18765640258789, + -1.3904608488082886, + -96.93603515625, + 65.34143829345703, + 34.835994720458984, + 62.01485824584961, + -2.8698415756225586, + 27.903749465942383 + ], + "type": "float32" + } + }, + { + "name": "reshape float32 tensor to a new shape (one dimension being the special value -1)", + "inputs": { + "input": { + "shape": [3, 2, 2, 2], + "data": [ + -30.056147250771076, + 99.5694232746736, + 88.04620115823073, + -91.87507576772606, + -23.797235323955633, + -91.28665022600151, + -63.15204449663816, + 12.066952464893262, + -96.1172904235943, + -44.77365489782947, + -80.08650883940432, + -64.4375694650447, + 27.641954235862485, + -96.86306613475395, + 83.68347403572196, + 50.599484132010815, + -20.187656772788642, + -1.3904608012750117, + -96.9360325497362, + 65.34144119048645, + 34.835993949837274, + 62.01485845563673, + -2.8698414892852355, + 27.903749097190158 + ], + "type": "float32" + } + }, + "newShape": [4, -1, 3, 1], + "expected": { + "name": "output", + "shape": [4, 2, 3, 1], + "data": [ + -30.0561466217041, + 99.56941986083984, + 88.04620361328125, + -91.87507629394531, + -23.7972354888916, + -91.28665161132812, + -63.15204620361328, + 12.0669527053833, + -96.1172866821289, + -44.77365493774414, + -80.08650970458984, + -64.43756866455078, + 27.64195442199707, + -96.86306762695312, + 83.6834716796875, + 50.599483489990234, + -20.18765640258789, + -1.3904608488082886, + -96.93603515625, + 65.34143829345703, + 34.835994720458984, + 62.01485824584961, + -2.8698415756225586, + 27.903749465942383 + ], + "type": "float32" + } + }, + { + "name": "reshape float32 tensor to 1D tensor", + "inputs": { + "input": { + "shape": [3, 2, 2, 2], + "data": [ + -30.056147250771076, + 99.5694232746736, + 88.04620115823073, + -91.87507576772606, + -23.797235323955633, + -91.28665022600151, + -63.15204449663816, + 12.066952464893262, + -96.1172904235943, + -44.77365489782947, + -80.08650883940432, + -64.4375694650447, + 27.641954235862485, + -96.86306613475395, + 83.68347403572196, + 50.599484132010815, + -20.187656772788642, + -1.3904608012750117, + -96.9360325497362, + 65.34144119048645, + 34.835993949837274, + 62.01485845563673, + -2.8698414892852355, + 27.903749097190158 + ], + "type": "float32" + } + }, + "newShape": [24], + "expected": { + "name": "output", + "shape": [24], + "data": [ + -30.0561466217041, + 99.56941986083984, + 88.04620361328125, + -91.87507629394531, + -23.7972354888916, + -91.28665161132812, + -63.15204620361328, + 12.0669527053833, + -96.1172866821289, + -44.77365493774414, + -80.08650970458984, + -64.43756866455078, + 27.64195442199707, + -96.86306762695312, + 83.6834716796875, + 50.599483489990234, + -20.18765640258789, + -1.3904608488082886, + -96.93603515625, + 65.34143829345703, + 34.835994720458984, + 62.01485824584961, + -2.8698415756225586, + 27.903749465942383 + ], + "type": "float32" + } + }, + { + "name": "reshape float32 tensor to 1D tensor newShape=[-1]", + "inputs": { + "input": { + "shape": [3, 2, 2, 2], + "data": [ + -30.056147250771076, + 99.5694232746736, + 88.04620115823073, + -91.87507576772606, + -23.797235323955633, + -91.28665022600151, + -63.15204449663816, + 12.066952464893262, + -96.1172904235943, + -44.77365489782947, + -80.08650883940432, + -64.4375694650447, + 27.641954235862485, + -96.86306613475395, + 83.68347403572196, + 50.599484132010815, + -20.187656772788642, + -1.3904608012750117, + -96.9360325497362, + 65.34144119048645, + 34.835993949837274, + 62.01485845563673, + -2.8698414892852355, + 27.903749097190158 + ], + "type": "float32" + } + }, + "newShape": [-1], + "expected": { + "name": "output", + "shape": [24], + "data": [ + -30.0561466217041, + 99.56941986083984, + 88.04620361328125, + -91.87507629394531, + -23.7972354888916, + -91.28665161132812, + -63.15204620361328, + 12.0669527053833, + -96.1172866821289, + -44.77365493774414, + -80.08650970458984, + -64.43756866455078, + 27.64195442199707, + -96.86306762695312, + 83.6834716796875, + 50.599483489990234, + -20.18765640258789, + -1.3904608488082886, + -96.93603515625, + 65.34143829345703, + 34.835994720458984, + 62.01485824584961, + -2.8698415756225586, + 27.903749465942383 + ], + "type": "float32" + } + } + ] +}
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/resources/test_data/sigmoid.json b/testing/web-platform/tests/webnn/resources/test_data/sigmoid.json new file mode 100644 index 0000000000..c233336321 --- /dev/null +++ b/testing/web-platform/tests/webnn/resources/test_data/sigmoid.json @@ -0,0 +1,334 @@ +{ + "tests": [ + { + "name": "sigmoid float32 1D tensor", + "inputs": { + "x": { + "shape": [24], + "data": [ + -0.3769951326450487, + -0.6848450678710742, + -5.98887201399973, + 4.431885748123033, + -0.9386848809986663, + 4.591195578857441, + -2.5067027776293456, + 1.5669522849917055, + -2.596473257404651, + -3.647293770068697, + 2.6785236795981433, + -3.105160168372808, + 2.258501824714781, + -0.2865157795154527, + 4.640436413897461, + 1.0606156163391969, + -3.536252613252593, + 0.44104409560934066, + 4.79146007344656, + 2.0745488579530846, + 0.8354471082395971, + -5.433595857448718, + -4.184835816765236, + -2.484982429169702 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [24], + "data": [ + 0.4068518280982971, + 0.33518078923225403, + 0.0025002227630466223, + 0.9882476925849915, + 0.28116607666015625, + 0.9899610877037048, + 0.07538963109254837, + 0.8273487091064453, + 0.0693657398223877, + 0.02539960853755474, + 0.9357474446296692, + 0.04289489984512329, + 0.9053813815116882, + 0.42885708808898926, + 0.9904388189315796, + 0.7428081631660461, + 0.0282981526106596, + 0.6085078120231628, + 0.9917680025100708, + 0.8884047269821167, + 0.6975054740905762, + 0.004348373040556908, + 0.014996387995779514, + 0.07691769301891327 + ], + "type": "float32" + } + }, + { + "name": "sigmoid float32 2D tensor", + "inputs": { + "x": { + "shape": [4, 6], + "data": [ + -0.3769951326450487, + -0.6848450678710742, + -5.98887201399973, + 4.431885748123033, + -0.9386848809986663, + 4.591195578857441, + -2.5067027776293456, + 1.5669522849917055, + -2.596473257404651, + -3.647293770068697, + 2.6785236795981433, + -3.105160168372808, + 2.258501824714781, + -0.2865157795154527, + 4.640436413897461, + 1.0606156163391969, + -3.536252613252593, + 0.44104409560934066, + 4.79146007344656, + 2.0745488579530846, + 0.8354471082395971, + -5.433595857448718, + -4.184835816765236, + -2.484982429169702 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [4, 6], + "data": [ + 0.4068518280982971, + 0.33518078923225403, + 0.0025002227630466223, + 0.9882476925849915, + 0.28116607666015625, + 0.9899610877037048, + 0.07538963109254837, + 0.8273487091064453, + 0.0693657398223877, + 0.02539960853755474, + 0.9357474446296692, + 0.04289489984512329, + 0.9053813815116882, + 0.42885708808898926, + 0.9904388189315796, + 0.7428081631660461, + 0.0282981526106596, + 0.6085078120231628, + 0.9917680025100708, + 0.8884047269821167, + 0.6975054740905762, + 0.004348373040556908, + 0.014996387995779514, + 0.07691769301891327 + ], + "type": "float32" + } + }, + { + "name": "sigmoid float32 3D tensor", + "inputs": { + "x": { + "shape": [2, 3, 4], + "data": [ + -0.3769951326450487, + -0.6848450678710742, + -5.98887201399973, + 4.431885748123033, + -0.9386848809986663, + 4.591195578857441, + -2.5067027776293456, + 1.5669522849917055, + -2.596473257404651, + -3.647293770068697, + 2.6785236795981433, + -3.105160168372808, + 2.258501824714781, + -0.2865157795154527, + 4.640436413897461, + 1.0606156163391969, + -3.536252613252593, + 0.44104409560934066, + 4.79146007344656, + 2.0745488579530846, + 0.8354471082395971, + -5.433595857448718, + -4.184835816765236, + -2.484982429169702 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [2, 3, 4], + "data": [ + 0.4068518280982971, + 0.33518078923225403, + 0.0025002227630466223, + 0.9882476925849915, + 0.28116607666015625, + 0.9899610877037048, + 0.07538963109254837, + 0.8273487091064453, + 0.0693657398223877, + 0.02539960853755474, + 0.9357474446296692, + 0.04289489984512329, + 0.9053813815116882, + 0.42885708808898926, + 0.9904388189315796, + 0.7428081631660461, + 0.0282981526106596, + 0.6085078120231628, + 0.9917680025100708, + 0.8884047269821167, + 0.6975054740905762, + 0.004348373040556908, + 0.014996387995779514, + 0.07691769301891327 + ], + "type": "float32" + } + }, + { + "name": "sigmoid float32 4D tensor", + "inputs": { + "x": { + "shape": [2, 2, 2, 3], + "data": [ + -0.3769951326450487, + -0.6848450678710742, + -5.98887201399973, + 4.431885748123033, + -0.9386848809986663, + 4.591195578857441, + -2.5067027776293456, + 1.5669522849917055, + -2.596473257404651, + -3.647293770068697, + 2.6785236795981433, + -3.105160168372808, + 2.258501824714781, + -0.2865157795154527, + 4.640436413897461, + 1.0606156163391969, + -3.536252613252593, + 0.44104409560934066, + 4.79146007344656, + 2.0745488579530846, + 0.8354471082395971, + -5.433595857448718, + -4.184835816765236, + -2.484982429169702 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 0.4068518280982971, + 0.33518078923225403, + 0.0025002227630466223, + 0.9882476925849915, + 0.28116607666015625, + 0.9899610877037048, + 0.07538963109254837, + 0.8273487091064453, + 0.0693657398223877, + 0.02539960853755474, + 0.9357474446296692, + 0.04289489984512329, + 0.9053813815116882, + 0.42885708808898926, + 0.9904388189315796, + 0.7428081631660461, + 0.0282981526106596, + 0.6085078120231628, + 0.9917680025100708, + 0.8884047269821167, + 0.6975054740905762, + 0.004348373040556908, + 0.014996387995779514, + 0.07691769301891327 + ], + "type": "float32" + } + }, + { + "name": "sigmoid float32 5D tensor", + "inputs": { + "x": { + "shape": [2, 1, 4, 1, 3], + "data": [ + -0.3769951326450487, + -0.6848450678710742, + -5.98887201399973, + 4.431885748123033, + -0.9386848809986663, + 4.591195578857441, + -2.5067027776293456, + 1.5669522849917055, + -2.596473257404651, + -3.647293770068697, + 2.6785236795981433, + -3.105160168372808, + 2.258501824714781, + -0.2865157795154527, + 4.640436413897461, + 1.0606156163391969, + -3.536252613252593, + 0.44104409560934066, + 4.79146007344656, + 2.0745488579530846, + 0.8354471082395971, + -5.433595857448718, + -4.184835816765236, + -2.484982429169702 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [2, 1, 4, 1, 3], + "data": [ + 0.4068518280982971, + 0.33518078923225403, + 0.0025002227630466223, + 0.9882476925849915, + 0.28116607666015625, + 0.9899610877037048, + 0.07538963109254837, + 0.8273487091064453, + 0.0693657398223877, + 0.02539960853755474, + 0.9357474446296692, + 0.04289489984512329, + 0.9053813815116882, + 0.42885708808898926, + 0.9904388189315796, + 0.7428081631660461, + 0.0282981526106596, + 0.6085078120231628, + 0.9917680025100708, + 0.8884047269821167, + 0.6975054740905762, + 0.004348373040556908, + 0.014996387995779514, + 0.07691769301891327 + ], + "type": "float32" + } + } + ] +}
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/resources/test_data/slice.json b/testing/web-platform/tests/webnn/resources/test_data/slice.json new file mode 100644 index 0000000000..926351cee7 --- /dev/null +++ b/testing/web-platform/tests/webnn/resources/test_data/slice.json @@ -0,0 +1,772 @@ +{ + "tests": [ + { + "name": "slice float32 1D tensor default axes options", + "inputs": { + "input": { + "shape": [24], + "data": [ + 28.846251144212147, + 97.9541470229301, + -68.15961736262523, + 14.978987588557175, + 90.23090084798065, + 76.59095547712559, + -24.556316258204532, + 79.58749302462488, + 65.21375982234204, + 57.43970862960305, + 74.41775256222849, + -4.513182026141791, + 0.5424534704526991, + 80.44634130202977, + 28.327650022124686, + 74.0261938866893, + -74.54558964005362, + -27.30604081001799, + -70.4277433212161, + 59.82631931755259, + -58.46095416849133, + 79.80571087632629, + -9.857854207596304, + 42.66519880465225 + ], + "type": "float32" + } + }, + "starts": [12], + "sizes": [12], + "expected": { + "name": "output", + "shape": [12], + "data": [ + 0.5424534678459167, + 80.44634246826172, + 28.32765007019043, + 74.02619171142578, + -74.54559326171875, + -27.306041717529297, + -70.42774200439453, + 59.82632064819336, + -58.46095275878906, + 79.80570983886719, + -9.857853889465332, + 42.665199279785156 + ], + "type": "float32" + } + }, + { + "name": "slice float32 2D tensor default axes options", + "inputs": { + "input": { + "shape": [4, 6], + "data": [ + 28.846251144212147, + 97.9541470229301, + -68.15961736262523, + 14.978987588557175, + 90.23090084798065, + 76.59095547712559, + -24.556316258204532, + 79.58749302462488, + 65.21375982234204, + 57.43970862960305, + 74.41775256222849, + -4.513182026141791, + 0.5424534704526991, + 80.44634130202977, + 28.327650022124686, + 74.0261938866893, + -74.54558964005362, + -27.30604081001799, + -70.4277433212161, + 59.82631931755259, + -58.46095416849133, + 79.80571087632629, + -9.857854207596304, + 42.66519880465225 + ], + "type": "float32" + } + }, + "starts": [2, 2], + "sizes": [2, 4], + "expected": { + "name": "output", + "shape": [2, 4], + "data": [ + 28.32765007019043, + 74.02619171142578, + -74.54559326171875, + -27.306041717529297, + -58.46095275878906, + 79.80570983886719, + -9.857853889465332, + 42.665199279785156 + ], + "type": "float32" + } + }, + { + "name": "slice float32 3D tensor default axes options", + "inputs": { + "input": { + "shape": [4, 3, 2], + "data": [ + 28.846251144212147, + 97.9541470229301, + -68.15961736262523, + 14.978987588557175, + 90.23090084798065, + 76.59095547712559, + -24.556316258204532, + 79.58749302462488, + 65.21375982234204, + 57.43970862960305, + 74.41775256222849, + -4.513182026141791, + 0.5424534704526991, + 80.44634130202977, + 28.327650022124686, + 74.0261938866893, + -74.54558964005362, + -27.30604081001799, + -70.4277433212161, + 59.82631931755259, + -58.46095416849133, + 79.80571087632629, + -9.857854207596304, + 42.66519880465225 + ], + "type": "float32" + } + }, + "starts": [1, 1, 1], + "sizes": [3, 2, 1], + "expected": { + "name": "output", + "shape": [3, 2, 1], + "data": [ + 57.4397087097168, + -4.513182163238525, + 74.02619171142578, + -27.306041717529297, + 79.80570983886719, + 42.665199279785156 + ], + "type": "float32" + } + }, + { + "name": "slice float32 4D tensor default axes options", + "inputs": { + "input": { + "shape": [2, 2, 3, 2], + "data": [ + 28.846251144212147, + 97.9541470229301, + -68.15961736262523, + 14.978987588557175, + 90.23090084798065, + 76.59095547712559, + -24.556316258204532, + 79.58749302462488, + 65.21375982234204, + 57.43970862960305, + 74.41775256222849, + -4.513182026141791, + 0.5424534704526991, + 80.44634130202977, + 28.327650022124686, + 74.0261938866893, + -74.54558964005362, + -27.30604081001799, + -70.4277433212161, + 59.82631931755259, + -58.46095416849133, + 79.80571087632629, + -9.857854207596304, + 42.66519880465225 + ], + "type": "float32" + } + }, + "starts": [1, 0, 2, 1], + "sizes": [1, 2, 1, 1], + "expected": { + "name": "output", + "shape": [1, 2, 1, 1], + "data": [ + -27.306041717529297, + 42.665199279785156 + ], + "type": "float32" + } + }, + { + "name": "slice float32 5D tensor default axes options", + "inputs": { + "input": { + "shape": [2, 2, 3, 2, 1], + "data": [ + 28.846251144212147, + 97.9541470229301, + -68.15961736262523, + 14.978987588557175, + 90.23090084798065, + 76.59095547712559, + -24.556316258204532, + 79.58749302462488, + 65.21375982234204, + 57.43970862960305, + 74.41775256222849, + -4.513182026141791, + 0.5424534704526991, + 80.44634130202977, + 28.327650022124686, + 74.0261938866893, + -74.54558964005362, + -27.30604081001799, + -70.4277433212161, + 59.82631931755259, + -58.46095416849133, + 79.80571087632629, + -9.857854207596304, + 42.66519880465225 + ], + "type": "float32" + } + }, + "starts": [1, 0, 2, 1, 0], + "sizes": [1, 2, 1, 1, 1], + "expected": { + "name": "output", + "shape": [1, 2, 1, 1, 1], + "data": [ + -27.306041717529297, + 42.665199279785156 + ], + "type": "float32" + } + }, + { + "name": "slice float32 3D tensor negative starts", + "inputs": { + "input": { + "shape": [4, 3, 2], + "data": [ + 28.846251144212147, + 97.9541470229301, + -68.15961736262523, + 14.978987588557175, + 90.23090084798065, + 76.59095547712559, + -24.556316258204532, + 79.58749302462488, + 65.21375982234204, + 57.43970862960305, + 74.41775256222849, + -4.513182026141791, + 0.5424534704526991, + 80.44634130202977, + 28.327650022124686, + 74.0261938866893, + -74.54558964005362, + -27.30604081001799, + -70.4277433212161, + 59.82631931755259, + -58.46095416849133, + 79.80571087632629, + -9.857854207596304, + 42.66519880465225 + ], + "type": "float32" + } + }, + "starts": [-3, -2, -1], // [-3, -2, -1] is equal to [1, 1, 1] + "sizes": [3, 2, 1], + "expected": { + "name": "output", + "shape": [3, 2, 1], + "data": [ + 57.4397087097168, + -4.513182163238525, + 74.02619171142578, + -27.306041717529297, + 79.80570983886719, + 42.665199279785156 + ], + "type": "float32" + } + }, + { + "name": "slice float32 4D tensor negative starts", + "inputs": { + "input": { + "shape": [2, 2, 3, 2], + "data": [ + 28.846251144212147, + 97.9541470229301, + -68.15961736262523, + 14.978987588557175, + 90.23090084798065, + 76.59095547712559, + -24.556316258204532, + 79.58749302462488, + 65.21375982234204, + 57.43970862960305, + 74.41775256222849, + -4.513182026141791, + 0.5424534704526991, + 80.44634130202977, + 28.327650022124686, + 74.0261938866893, + -74.54558964005362, + -27.30604081001799, + -70.4277433212161, + 59.82631931755259, + -58.46095416849133, + 79.80571087632629, + -9.857854207596304, + 42.66519880465225 + ], + "type": "float32" + } + }, + "starts": [-1, -2, -1, -1], // [-1, -2, -1, -1] is equal to [1, 0, 2, 1] + "sizes": [1, 2, 1, 1], + "expected": { + "name": "output", + "shape": [1, 2, 1, 1], + "data": [ + -27.306041717529297, + 42.665199279785156 + ], + "type": "float32" + } + }, + { + "name": "slice float32 4D tensor sizes having special value of -1", + "inputs": { + "input": { + "shape": [2, 2, 3, 2], + "data": [ + 28.846251144212147, + 97.9541470229301, + -68.15961736262523, + 14.978987588557175, + 90.23090084798065, + 76.59095547712559, + -24.556316258204532, + 79.58749302462488, + 65.21375982234204, + 57.43970862960305, + 74.41775256222849, + -4.513182026141791, + 0.5424534704526991, + 80.44634130202977, + 28.327650022124686, + 74.0261938866893, + -74.54558964005362, + -27.30604081001799, + -70.4277433212161, + 59.82631931755259, + -58.46095416849133, + 79.80571087632629, + -9.857854207596304, + 42.66519880465225 + ], + "type": "float32" + } + }, + "starts": [1, 0, 2, 1], + "sizes": [1, -1, 1, -1], // [1, -1, 1, -1] is equal to [1, 2, 1, 1] + "expected": { + "name": "output", + "shape": [1, 2, 1, 1], + "data": [ + -27.306041717529297, + 42.665199279785156 + ], + "type": "float32" + } + }, + { + "name": "slice float32 5D tensor sizes having special value of -1", + "inputs": { + "input": { + "shape": [2, 2, 3, 2, 1], + "data": [ + 28.846251144212147, + 97.9541470229301, + -68.15961736262523, + 14.978987588557175, + 90.23090084798065, + 76.59095547712559, + -24.556316258204532, + 79.58749302462488, + 65.21375982234204, + 57.43970862960305, + 74.41775256222849, + -4.513182026141791, + 0.5424534704526991, + 80.44634130202977, + 28.327650022124686, + 74.0261938866893, + -74.54558964005362, + -27.30604081001799, + -70.4277433212161, + 59.82631931755259, + -58.46095416849133, + 79.80571087632629, + -9.857854207596304, + 42.66519880465225 + ], + "type": "float32" + } + }, + "starts": [1, 0, 2, 1, 0], + "sizes": [-1, 2, -1, 1, -1], // [-1, 2, -1, 1, -1] is equal to [1, 2, 1, 1, 1] + "expected": { + "name": "output", + "shape": [1, 2, 1, 1, 1], + "data": [ + -27.306041717529297, + 42.665199279785156 + ], + "type": "float32" + } + }, + { + "name": "slice float32 1D tensor options.axes=[0]", + "inputs": { + "input": { + "shape": [24], + "data": [ + 28.846251144212147, + 97.9541470229301, + -68.15961736262523, + 14.978987588557175, + 90.23090084798065, + 76.59095547712559, + -24.556316258204532, + 79.58749302462488, + 65.21375982234204, + 57.43970862960305, + 74.41775256222849, + -4.513182026141791, + 0.5424534704526991, + 80.44634130202977, + 28.327650022124686, + 74.0261938866893, + -74.54558964005362, + -27.30604081001799, + -70.4277433212161, + 59.82631931755259, + -58.46095416849133, + 79.80571087632629, + -9.857854207596304, + 42.66519880465225 + ], + "type": "float32" + } + }, + "starts": [12], + "sizes": [12], + "options": { + "axes": [0] + }, + "expected": { + "name": "output", + "shape": [12], + "data": [ + 0.5424534678459167, + 80.44634246826172, + 28.32765007019043, + 74.02619171142578, + -74.54559326171875, + -27.306041717529297, + -70.42774200439453, + 59.82632064819336, + -58.46095275878906, + 79.80570983886719, + -9.857853889465332, + 42.665199279785156 + ], + "type": "float32" + } + }, + { + "name": "slice float32 2D tensor positive options.axes=[1]", + "inputs": { + "input": { + "shape": [4, 6], + "data": [ + 28.846251144212147, + 97.9541470229301, + -68.15961736262523, + 14.978987588557175, + 90.23090084798065, + 76.59095547712559, + -24.556316258204532, + 79.58749302462488, + 65.21375982234204, + 57.43970862960305, + 74.41775256222849, + -4.513182026141791, + 0.5424534704526991, + 80.44634130202977, + 28.327650022124686, + 74.0261938866893, + -74.54558964005362, + -27.30604081001799, + -70.4277433212161, + 59.82631931755259, + -58.46095416849133, + 79.80571087632629, + -9.857854207596304, + 42.66519880465225 + ], + "type": "float32" + } + }, + "starts": [2], + "sizes": [4], + "options": { + "axes": [1] + }, + "expected": { + "name": "output", + "shape": [4, 4], + "data": [ + -68.15961456298828, + 14.978987693786621, + 90.23090362548828, + 76.59095764160156, + 65.21376037597656, + 57.4397087097168, + 74.41775512695312, + -4.513182163238525, + 28.32765007019043, + 74.02619171142578, + -74.54559326171875, + -27.306041717529297, + -58.46095275878906, + 79.80570983886719, + -9.857853889465332, + 42.665199279785156 + ], + "type": "float32" + } + }, + { + "name": "slice float32 3D tensor positive options.axes=[1, 2]", + "inputs": { + "input": { + "shape": [4, 3, 2], + "data": [ + 28.846251144212147, + 97.9541470229301, + -68.15961736262523, + 14.978987588557175, + 90.23090084798065, + 76.59095547712559, + -24.556316258204532, + 79.58749302462488, + 65.21375982234204, + 57.43970862960305, + 74.41775256222849, + -4.513182026141791, + 0.5424534704526991, + 80.44634130202977, + 28.327650022124686, + 74.0261938866893, + -74.54558964005362, + -27.30604081001799, + -70.4277433212161, + 59.82631931755259, + -58.46095416849133, + 79.80571087632629, + -9.857854207596304, + 42.66519880465225 + ], + "type": "float32" + } + }, + "starts": [1, 1], + "sizes": [2, 1], + "options": { + "axes": [1, 2] + }, + "expected": { + "name": "output", + "shape": [4, 2, 1], + "data": [ + 14.978987693786621, + 76.59095764160156, + 57.4397087097168, + -4.513182163238525, + 74.02619171142578, + -27.306041717529297, + 79.80570983886719, + 42.665199279785156 + ], + "type": "float32" + } + }, + { + "name": "slice float32 4D tensor positive options.axes=[0, 2, 3]", + "inputs": { + "input": { + "shape": [2, 2, 3, 2], + "data": [ + 28.846251144212147, + 97.9541470229301, + -68.15961736262523, + 14.978987588557175, + 90.23090084798065, + 76.59095547712559, + -24.556316258204532, + 79.58749302462488, + 65.21375982234204, + 57.43970862960305, + 74.41775256222849, + -4.513182026141791, + 0.5424534704526991, + 80.44634130202977, + 28.327650022124686, + 74.0261938866893, + -74.54558964005362, + -27.30604081001799, + -70.4277433212161, + 59.82631931755259, + -58.46095416849133, + 79.80571087632629, + -9.857854207596304, + 42.66519880465225 + ], + "type": "float32" + } + }, + "options": { + "axes": [0, 2, 3] + }, + "starts": [1, 2, 1], + "sizes": [1, 1, 1], + "expected": { + "name": "output", + "shape": [1, 2, 1, 1], + "data": [ + -27.306041717529297, + 42.665199279785156 + ], + "type": "float32" + } + }, + { + "name": "slice float32 3D tensor negative options.axes=[-2, -1]", + "inputs": { + "input": { + "shape": [4, 3, 2], + "data": [ + 28.846251144212147, + 97.9541470229301, + -68.15961736262523, + 14.978987588557175, + 90.23090084798065, + 76.59095547712559, + -24.556316258204532, + 79.58749302462488, + 65.21375982234204, + 57.43970862960305, + 74.41775256222849, + -4.513182026141791, + 0.5424534704526991, + 80.44634130202977, + 28.327650022124686, + 74.0261938866893, + -74.54558964005362, + -27.30604081001799, + -70.4277433212161, + 59.82631931755259, + -58.46095416849133, + 79.80571087632629, + -9.857854207596304, + 42.66519880465225 + ], + "type": "float32" + } + }, + "starts": [1, 1], + "sizes": [2, 1], + "options": { + "axes": [-2, -1] // [-2, -1] is equal to [1, 2] + }, + "expected": { + "name": "output", + "shape": [4, 2, 1], + "data": [ + 14.978987693786621, + 76.59095764160156, + 57.4397087097168, + -4.513182163238525, + 74.02619171142578, + -27.306041717529297, + 79.80570983886719, + 42.665199279785156 + ], + "type": "float32" + } + }, + { + "name": "slice float32 4D tensor negative options.axes=[-4, -2, -1]", + "inputs": { + "input": { + "shape": [2, 2, 3, 2], + "data": [ + 28.846251144212147, + 97.9541470229301, + -68.15961736262523, + 14.978987588557175, + 90.23090084798065, + 76.59095547712559, + -24.556316258204532, + 79.58749302462488, + 65.21375982234204, + 57.43970862960305, + 74.41775256222849, + -4.513182026141791, + 0.5424534704526991, + 80.44634130202977, + 28.327650022124686, + 74.0261938866893, + -74.54558964005362, + -27.30604081001799, + -70.4277433212161, + 59.82631931755259, + -58.46095416849133, + 79.80571087632629, + -9.857854207596304, + 42.66519880465225 + ], + "type": "float32" + } + }, + "options": { + "axes": [-4, -2, -1] // [-4, -2, -1] is equal to [0, 2, 3] + }, + "starts": [1, 2, 1], + "sizes": [1, 1, 1], + "expected": { + "name": "output", + "shape": [1, 2, 1, 1], + "data": [ + -27.306041717529297, + 42.665199279785156 + ], + "type": "float32" + } + } + ] +}
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/resources/test_data/softmax.json b/testing/web-platform/tests/webnn/resources/test_data/softmax.json new file mode 100644 index 0000000000..b19ce40591 --- /dev/null +++ b/testing/web-platform/tests/webnn/resources/test_data/softmax.json @@ -0,0 +1,70 @@ +{ + "tests": [ + { + "name": "softmax float32 2D tensor", + "inputs": { + "x": { + "shape": [4, 6], + "data": [ + -9.602943250149636, + 5.353947088147631, + 4.982506021190005, + -1.8709681620943286, + 2.275207739606868, + -1.9403444022539098, + 1.8985638253724968, + 1.7877445512108103, + -7.243864108734894, + 7.827657028853274, + -2.4196847673132726, + -8.018804523844905, + -3.1493873901132474, + 7.674345195428224, + -5.183967275728079, + -7.301743057626533, + -7.121610082852072, + -8.29701166999875, + -5.77890866334104, + -9.76213424697228, + 7.332167409724249, + 3.9077721241449215, + -5.2970783047100545, + 5.0440509491607965 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [4, 6], + "data": [ + 1.8385014755040174e-7, + 0.575650691986084, + 0.3970489799976349, + 0.0004191970219835639, + 0.026489850133657455, + 0.0003911005624104291, + 0.00264744833111763, + 0.00236973213031888, + 2.833488679243601e-7, + 0.9949471354484558, + 0.00003527247827150859, + 1.3054766156983533e-7, + 0.000019920609702239744, + 0.9999766945838928, + 0.0000026043292109534377, + 3.1329790317613515e-7, + 3.7513549955292547e-7, + 1.1580249292819644e-7, + 0.0000017836379129221314, + 3.322107744452296e-8, + 0.8818095922470093, + 0.028719622641801834, + 0.000002887773234760971, + 0.08946608752012253 + ], + "type": "float32" + } + } + ] +}
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/resources/test_data/split.json b/testing/web-platform/tests/webnn/resources/test_data/split.json new file mode 100644 index 0000000000..33a0704576 --- /dev/null +++ b/testing/web-platform/tests/webnn/resources/test_data/split.json @@ -0,0 +1,818 @@ +{ + "tests": [ + { + "name": "split float32 1D tensor number splits default options", + "inputs": { + "input": { + "shape": [24], + "data": [ + -64.52057192772567, + -84.60513454654502, + -67.9928282139549, + -23.446074622313745, + -85.64383132426956, + 46.877522730892906, + -68.11224159891194, + 75.99607609082298, + -61.05668616435924, + -90.92643605408041, + 53.916621140775476, + 84.16269171442175, + -95.57494716023527, + -52.40757884637803, + -29.007187148127983, + 71.65495730084652, + 50.663572707062656, + 21.364581604631596, + -27.127241457105228, + 65.1489516233315, + -30.406812651567833, + -6.818390152438795, + 46.67362179020569, + -21.12453802903387 + ], + "type": "float32" + } + }, + "splits": 3, + "expected": [ + { + "name": "output1", + "shape": [8], + "data": [ + -64.52056884765625, + -84.60513305664062, + -67.99282836914062, + -23.446075439453125, + -85.64382934570312, + 46.87752151489258, + -68.11224365234375, + 75.99607849121094 + ], + "type": "float32" + }, + { + "name": "output2", + "shape": [8], + "data": [ + -61.05668640136719, + -90.92643737792969, + 53.916622161865234, + 84.16268920898438, + -95.57494354248047, + -52.40757751464844, + -29.007186889648438, + 71.65496063232422 + ], + "type": "float32" + }, + { + "name": "output3", + "shape": [8], + "data": [ + 50.66357421875, + 21.364582061767578, + -27.127241134643555, + 65.1489486694336, + -30.40681266784668, + -6.818390369415283, + 46.673622131347656, + -21.12453842163086 + ], + "type": "float32" + } + ] + }, + { + "name": "split float32 2D tensor number splits default options", + "inputs": { + "input": { + "shape": [8, 3], + "data": [ + -64.52057192772567, + -84.60513454654502, + -67.9928282139549, + -23.446074622313745, + -85.64383132426956, + 46.877522730892906, + -68.11224159891194, + 75.99607609082298, + -61.05668616435924, + -90.92643605408041, + 53.916621140775476, + 84.16269171442175, + -95.57494716023527, + -52.40757884637803, + -29.007187148127983, + 71.65495730084652, + 50.663572707062656, + 21.364581604631596, + -27.127241457105228, + 65.1489516233315, + -30.406812651567833, + -6.818390152438795, + 46.67362179020569, + -21.12453802903387 + ], + "type": "float32" + } + }, + "splits": 2, + "expected": [ + { + "name": "output1", + "shape": [4, 3], + "data": [ + -64.52056884765625, + -84.60513305664062, + -67.99282836914062, + -23.446075439453125, + -85.64382934570312, + 46.87752151489258, + -68.11224365234375, + 75.99607849121094, + -61.05668640136719, + -90.92643737792969, + 53.916622161865234, + 84.16268920898438 + ], + "type": "float32" + }, + { + "name": "output2", + "shape": [4, 3], + "data": [ + -95.57494354248047, + -52.40757751464844, + -29.007186889648438, + 71.65496063232422, + 50.66357421875, + 21.364582061767578, + -27.127241134643555, + 65.1489486694336, + -30.40681266784668, + -6.818390369415283, + 46.673622131347656, + -21.12453842163086 + ], + "type": "float32" + } + ] + }, + { + "name": "split float32 3D tensor number splits default options", + "inputs": { + "input": { + "shape": [4, 3, 2], + "data": [ + -64.52057192772567, + -84.60513454654502, + -67.9928282139549, + -23.446074622313745, + -85.64383132426956, + 46.877522730892906, + -68.11224159891194, + 75.99607609082298, + -61.05668616435924, + -90.92643605408041, + 53.916621140775476, + 84.16269171442175, + -95.57494716023527, + -52.40757884637803, + -29.007187148127983, + 71.65495730084652, + 50.663572707062656, + 21.364581604631596, + -27.127241457105228, + 65.1489516233315, + -30.406812651567833, + -6.818390152438795, + 46.67362179020569, + -21.12453802903387 + ], + "type": "float32" + } + }, + "splits": 2, + "expected": [ + { + "name": "output1", + "shape": [2, 3, 2], + "data": [ + -64.52056884765625, + -84.60513305664062, + -67.99282836914062, + -23.446075439453125, + -85.64382934570312, + 46.87752151489258, + -68.11224365234375, + 75.99607849121094, + -61.05668640136719, + -90.92643737792969, + 53.916622161865234, + 84.16268920898438 + ], + "type": "float32" + }, + { + "name": "output2", + "shape": [2, 3, 2], + "data": [ + -95.57494354248047, + -52.40757751464844, + -29.007186889648438, + 71.65496063232422, + 50.66357421875, + 21.364582061767578, + -27.127241134643555, + 65.1489486694336, + -30.40681266784668, + -6.818390369415283, + 46.673622131347656, + -21.12453842163086 + ], + "type": "float32" + } + ] + }, + { + "name": "split float32 4D tensor number splits default options", + "inputs": { + "input": { + "shape": [12, 1, 1, 2], + "data": [ + -64.52057192772567, + -84.60513454654502, + -67.9928282139549, + -23.446074622313745, + -85.64383132426956, + 46.877522730892906, + -68.11224159891194, + 75.99607609082298, + -61.05668616435924, + -90.92643605408041, + 53.916621140775476, + 84.16269171442175, + -95.57494716023527, + -52.40757884637803, + -29.007187148127983, + 71.65495730084652, + 50.663572707062656, + 21.364581604631596, + -27.127241457105228, + 65.1489516233315, + -30.406812651567833, + -6.818390152438795, + 46.67362179020569, + -21.12453802903387 + ], + "type": "float32" + } + }, + "splits": 4, + "expected": [ + { + "name": "output1", + "shape": [3, 1, 1, 2], + "data": [ + -64.52056884765625, + -84.60513305664062, + -67.99282836914062, + -23.446075439453125, + -85.64382934570312, + 46.87752151489258 + ], + "type": "float32" + }, + { + "name": "output2", + "shape": [3, 1, 1, 2], + "data": [ + -68.11224365234375, + 75.99607849121094, + -61.05668640136719, + -90.92643737792969, + 53.916622161865234, + 84.16268920898438 + ], + "type": "float32" + }, + { + "name": "output3", + "shape": [3, 1, 1, 2], + "data": [ + -95.57494354248047, + -52.40757751464844, + -29.007186889648438, + 71.65496063232422, + 50.66357421875, + 21.364582061767578 + ], + "type": "float32" + }, + { + "name": "output4", + "shape": [3, 1, 1, 2], + "data": [ + -27.127241134643555, + 65.1489486694336, + -30.40681266784668, + -6.818390369415283, + 46.673622131347656, + -21.12453842163086 + ], + "type": "float32" + } + ] + }, + { + "name": "split float32 5D tensor number splits default options", + "inputs": { + "input": { + "shape": [6, 1, 1, 2, 2], + "data": [ + -64.52057192772567, + -84.60513454654502, + -67.9928282139549, + -23.446074622313745, + -85.64383132426956, + 46.877522730892906, + -68.11224159891194, + 75.99607609082298, + -61.05668616435924, + -90.92643605408041, + 53.916621140775476, + 84.16269171442175, + -95.57494716023527, + -52.40757884637803, + -29.007187148127983, + 71.65495730084652, + 50.663572707062656, + 21.364581604631596, + -27.127241457105228, + 65.1489516233315, + -30.406812651567833, + -6.818390152438795, + 46.67362179020569, + -21.12453802903387 + ], + "type": "float32" + } + }, + "splits": 2, + "expected": [ + { + "name": "output1", + "shape": [3, 1, 1, 2, 2], + "data": [ + -64.52056884765625, + -84.60513305664062, + -67.99282836914062, + -23.446075439453125, + -85.64382934570312, + 46.87752151489258, + -68.11224365234375, + 75.99607849121094, + -61.05668640136719, + -90.92643737792969, + 53.916622161865234, + 84.16268920898438 + ], + "type": "float32" + }, + { + "name": "output2", + "shape": [3, 1, 1, 2, 2], + "data": [ + -95.57494354248047, + -52.40757751464844, + -29.007186889648438, + 71.65496063232422, + 50.66357421875, + 21.364582061767578, + -27.127241134643555, + 65.1489486694336, + -30.40681266784668, + -6.818390369415283, + 46.673622131347656, + -21.12453842163086 + ], + "type": "float32" + } + ] + }, + { + "name": "split float32 4D tensor array splits default options", + "inputs": { + "input": { + "shape": [12, 1, 1, 2], + "data": [ + -64.52057192772567, + -84.60513454654502, + -67.9928282139549, + -23.446074622313745, + -85.64383132426956, + 46.877522730892906, + -68.11224159891194, + 75.99607609082298, + -61.05668616435924, + -90.92643605408041, + 53.916621140775476, + 84.16269171442175, + -95.57494716023527, + -52.40757884637803, + -29.007187148127983, + 71.65495730084652, + 50.663572707062656, + 21.364581604631596, + -27.127241457105228, + 65.1489516233315, + -30.406812651567833, + -6.818390152438795, + 46.67362179020569, + -21.12453802903387 + ], + "type": "float32" + } + }, + "splits": [3, 3, 3, 3], + "expected": [ + { + "name": "output1", + "shape": [3, 1, 1, 2], + "data": [ + -64.52056884765625, + -84.60513305664062, + -67.99282836914062, + -23.446075439453125, + -85.64382934570312, + 46.87752151489258 + ], + "type": "float32" + }, + { + "name": "output2", + "shape": [3, 1, 1, 2], + "data": [ + -68.11224365234375, + 75.99607849121094, + -61.05668640136719, + -90.92643737792969, + 53.916622161865234, + 84.16268920898438 + ], + "type": "float32" + }, + { + "name": "output3", + "shape": [3, 1, 1, 2], + "data": [ + -95.57494354248047, + -52.40757751464844, + -29.007186889648438, + 71.65496063232422, + 50.66357421875, + 21.364582061767578 + ], + "type": "float32" + }, + { + "name": "output4", + "shape": [3, 1, 1, 2], + "data": [ + -27.127241134643555, + 65.1489486694336, + -30.40681266784668, + -6.818390369415283, + 46.673622131347656, + -21.12453842163086 + ], + "type": "float32" + } + ] + }, + { + "name": "split float32 4D tensor number splits options.axis", + "inputs": { + "input": { + "shape": [12, 1, 1, 2], + "data": [ + -64.52057192772567, + -84.60513454654502, + -67.9928282139549, + -23.446074622313745, + -85.64383132426956, + 46.877522730892906, + -68.11224159891194, + 75.99607609082298, + -61.05668616435924, + -90.92643605408041, + 53.916621140775476, + 84.16269171442175, + -95.57494716023527, + -52.40757884637803, + -29.007187148127983, + 71.65495730084652, + 50.663572707062656, + 21.364581604631596, + -27.127241457105228, + 65.1489516233315, + -30.406812651567833, + -6.818390152438795, + 46.67362179020569, + -21.12453802903387 + ], + "type": "float32" + } + }, + "splits": 3, + "options": { + "axis": 0 + }, + "expected": [ + { + "name": "output1", + "shape": [4, 1, 1, 2], + "data": [ + -64.52056884765625, + -84.60513305664062, + -67.99282836914062, + -23.446075439453125, + -85.64382934570312, + 46.87752151489258, + -68.11224365234375, + 75.99607849121094 + ], + "type": "float32" + }, + { + "name": "output2", + "shape": [4, 1, 1, 2], + "data": [ + -61.05668640136719, + -90.92643737792969, + 53.916622161865234, + 84.16268920898438, + -95.57494354248047, + -52.40757751464844, + -29.007186889648438, + 71.65496063232422 + ], + "type": "float32" + }, + { + "name": "output3", + "shape": [4, 1, 1, 2], + "data": [ + 50.66357421875, + 21.364582061767578, + -27.127241134643555, + 65.1489486694336, + -30.40681266784668, + -6.818390369415283, + 46.673622131347656, + -21.12453842163086 + ], + "type": "float32" + } + ] + }, + { + "name": "split float32 4D tensor number splits negative options.axis", + "inputs": { + "input": { + "shape": [1, 1, 12, 2], + "data": [ + -64.52057192772567, + -84.60513454654502, + -67.9928282139549, + -23.446074622313745, + -85.64383132426956, + 46.877522730892906, + -68.11224159891194, + 75.99607609082298, + -61.05668616435924, + -90.92643605408041, + 53.916621140775476, + 84.16269171442175, + -95.57494716023527, + -52.40757884637803, + -29.007187148127983, + 71.65495730084652, + 50.663572707062656, + 21.364581604631596, + -27.127241457105228, + 65.1489516233315, + -30.406812651567833, + -6.818390152438795, + 46.67362179020569, + -21.12453802903387 + ], + "type": "float32" + } + }, + "splits": 2, + "options": { + "axis": -2 + }, + "expected": [ + { + "name": "output1", + "shape": [1, 1, 6, 2], + "data": [ + -64.52056884765625, + -84.60513305664062, + -67.99282836914062, + -23.446075439453125, + -85.64382934570312, + 46.87752151489258, + -68.11224365234375, + 75.99607849121094, + -61.05668640136719, + -90.92643737792969, + 53.916622161865234, + 84.16268920898438 + ], + "type": "float32" + }, + { + "name": "output2", + "shape": [1, 1, 6, 2], + "data": [ + -95.57494354248047, + -52.40757751464844, + -29.007186889648438, + 71.65496063232422, + 50.66357421875, + 21.364582061767578, + -27.127241134643555, + 65.1489486694336, + -30.40681266784668, + -6.818390369415283, + 46.673622131347656, + -21.12453842163086 + ], + "type": "float32" + } + ] + }, + { + "name": "split float32 5D tensor array splits options.axis", + "inputs": { + "input": { + "shape": [1, 1, 6, 2, 2], + "data": [ + -64.52057192772567, + -84.60513454654502, + -67.9928282139549, + -23.446074622313745, + -85.64383132426956, + 46.877522730892906, + -68.11224159891194, + 75.99607609082298, + -61.05668616435924, + -90.92643605408041, + 53.916621140775476, + 84.16269171442175, + -95.57494716023527, + -52.40757884637803, + -29.007187148127983, + 71.65495730084652, + 50.663572707062656, + 21.364581604631596, + -27.127241457105228, + 65.1489516233315, + -30.406812651567833, + -6.818390152438795, + 46.67362179020569, + -21.12453802903387 + ], + "type": "float32" + } + }, + "splits": [3, 3], + "options": { + "axis": 2 + }, + "expected": [ + { + "name": "output1", + "shape": [1, 1, 3, 2, 2], + "data": [ + -64.52056884765625, + -84.60513305664062, + -67.99282836914062, + -23.446075439453125, + -85.64382934570312, + 46.87752151489258, + -68.11224365234375, + 75.99607849121094, + -61.05668640136719, + -90.92643737792969, + 53.916622161865234, + 84.16268920898438 + ], + "type": "float32" + }, + { + "name": "output2", + "shape": [1, 1, 3, 2, 2], + "data": [ + -95.57494354248047, + -52.40757751464844, + -29.007186889648438, + 71.65496063232422, + 50.66357421875, + 21.364582061767578, + -27.127241134643555, + 65.1489486694336, + -30.40681266784668, + -6.818390369415283, + 46.673622131347656, + -21.12453842163086 + ], + "type": "float32" + } + ] + }, + { + "name": "split float32 5D tensor array splits negative options.axis", + "inputs": { + "input": { + "shape": [6, 1, 1, 2, 2], + "data": [ + -64.52057192772567, + -84.60513454654502, + -67.9928282139549, + -23.446074622313745, + -85.64383132426956, + 46.877522730892906, + -68.11224159891194, + 75.99607609082298, + -61.05668616435924, + -90.92643605408041, + 53.916621140775476, + 84.16269171442175, + -95.57494716023527, + -52.40757884637803, + -29.007187148127983, + 71.65495730084652, + 50.663572707062656, + 21.364581604631596, + -27.127241457105228, + 65.1489516233315, + -30.406812651567833, + -6.818390152438795, + 46.67362179020569, + -21.12453802903387 + ], + "type": "float32" + } + }, + "splits": [2, 4], + "options": { + "axis": -5 + }, + "expected": [ + { + "name": "output1", + "shape": [2, 1, 1, 2, 2], + "data": [ + -64.52056884765625, + -84.60513305664062, + -67.99282836914062, + -23.446075439453125, + -85.64382934570312, + 46.87752151489258, + -68.11224365234375, + 75.99607849121094 + ], + "type": "float32" + }, + { + "name": "output2", + "shape": [4, 1, 1, 2, 2], + "data": [ + -61.05668640136719, + -90.92643737792969, + 53.916622161865234, + 84.16268920898438, + -95.57494354248047, + -52.40757751464844, + -29.007186889648438, + 71.65496063232422, + 50.66357421875, + 21.364582061767578, + -27.127241134643555, + 65.1489486694336, + -30.40681266784668, + -6.818390369415283, + 46.673622131347656, + -21.12453842163086 + ], + "type": "float32" + } + ] + } + ] +}
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/resources/test_data/squeeze.json b/testing/web-platform/tests/webnn/resources/test_data/squeeze.json new file mode 100644 index 0000000000..88890fe870 --- /dev/null +++ b/testing/web-platform/tests/webnn/resources/test_data/squeeze.json @@ -0,0 +1,696 @@ +{ + "tests": [ + { + "name": "squeeze float32 2D tensor by eliminating one dimension default options", + "inputs": { + "input": { + "shape": [1, 24], + "data": [ + 1.1293665986622017, + -93.29325783541842, + -19.999887095191227, + 41.119214363429876, + 92.69352298075461, + -41.51937878962313, + -56.75228730395734, + 11.148093991767155, + 5.57540042674151, + 15.709176425437747, + 62.550443705517665, + -5.299276370816216, + -18.61525168224469, + -66.94721623021692, + 94.97520289870027, + -21.94004801967297, + 30.047636856615554, + 13.805134987122344, + -45.08670702769, + 76.90356276507339, + 46.96974979938284, + -86.58127045567055, + 31.645846897982068, + -67.96637618240129 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [24], + "data": [ + 1.1293666362762451, + -93.29325866699219, + -19.999887466430664, + 41.11921310424805, + 92.69351959228516, + -41.519378662109375, + -56.752288818359375, + 11.148094177246094, + 5.575400352478027, + 15.709176063537598, + 62.550445556640625, + -5.299276351928711, + -18.615251541137695, + -66.94721984863281, + 94.97520446777344, + -21.940048217773438, + 30.047636032104492, + 13.805134773254395, + -45.086708068847656, + 76.903564453125, + 46.969749450683594, + -86.58126831054688, + 31.64584732055664, + -67.96637725830078 + ], + "type": "float32" + } + }, + { + "name": "squeeze float32 3D tensor by eliminating one dimension default options", + "inputs": { + "input": { + "shape": [4, 1, 6], + "data": [ + 1.1293665986622017, + -93.29325783541842, + -19.999887095191227, + 41.119214363429876, + 92.69352298075461, + -41.51937878962313, + -56.75228730395734, + 11.148093991767155, + 5.57540042674151, + 15.709176425437747, + 62.550443705517665, + -5.299276370816216, + -18.61525168224469, + -66.94721623021692, + 94.97520289870027, + -21.94004801967297, + 30.047636856615554, + 13.805134987122344, + -45.08670702769, + 76.90356276507339, + 46.96974979938284, + -86.58127045567055, + 31.645846897982068, + -67.96637618240129 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [4, 6], + "data": [ + 1.1293666362762451, + -93.29325866699219, + -19.999887466430664, + 41.11921310424805, + 92.69351959228516, + -41.519378662109375, + -56.752288818359375, + 11.148094177246094, + 5.575400352478027, + 15.709176063537598, + 62.550445556640625, + -5.299276351928711, + -18.615251541137695, + -66.94721984863281, + 94.97520446777344, + -21.940048217773438, + 30.047636032104492, + 13.805134773254395, + -45.086708068847656, + 76.903564453125, + 46.969749450683594, + -86.58126831054688, + 31.64584732055664, + -67.96637725830078 + ], + "type": "float32" + } + }, + { + "name": "squeeze float32 3D tensor by eliminating two dimensions default options", + "inputs": { + "input": { + "shape": [1, 24, 1], + "data": [ + 1.1293665986622017, + -93.29325783541842, + -19.999887095191227, + 41.119214363429876, + 92.69352298075461, + -41.51937878962313, + -56.75228730395734, + 11.148093991767155, + 5.57540042674151, + 15.709176425437747, + 62.550443705517665, + -5.299276370816216, + -18.61525168224469, + -66.94721623021692, + 94.97520289870027, + -21.94004801967297, + 30.047636856615554, + 13.805134987122344, + -45.08670702769, + 76.90356276507339, + 46.96974979938284, + -86.58127045567055, + 31.645846897982068, + -67.96637618240129 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [24], + "data": [ + 1.1293666362762451, + -93.29325866699219, + -19.999887466430664, + 41.11921310424805, + 92.69351959228516, + -41.519378662109375, + -56.752288818359375, + 11.148094177246094, + 5.575400352478027, + 15.709176063537598, + 62.550445556640625, + -5.299276351928711, + -18.615251541137695, + -66.94721984863281, + 94.97520446777344, + -21.940048217773438, + 30.047636032104492, + 13.805134773254395, + -45.086708068847656, + 76.903564453125, + 46.969749450683594, + -86.58126831054688, + 31.64584732055664, + -67.96637725830078 + ], + "type": "float32" + } + }, + { + "name": "squeeze float32 4D tensor by eliminating two dimensions default options", + "inputs": { + "input": { + "shape": [1, 4, 1, 6], + "data": [ + 1.1293665986622017, + -93.29325783541842, + -19.999887095191227, + 41.119214363429876, + 92.69352298075461, + -41.51937878962313, + -56.75228730395734, + 11.148093991767155, + 5.57540042674151, + 15.709176425437747, + 62.550443705517665, + -5.299276370816216, + -18.61525168224469, + -66.94721623021692, + 94.97520289870027, + -21.94004801967297, + 30.047636856615554, + 13.805134987122344, + -45.08670702769, + 76.90356276507339, + 46.96974979938284, + -86.58127045567055, + 31.645846897982068, + -67.96637618240129 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [4, 6], + "data": [ + 1.1293666362762451, + -93.29325866699219, + -19.999887466430664, + 41.11921310424805, + 92.69351959228516, + -41.519378662109375, + -56.752288818359375, + 11.148094177246094, + 5.575400352478027, + 15.709176063537598, + 62.550445556640625, + -5.299276351928711, + -18.615251541137695, + -66.94721984863281, + 94.97520446777344, + -21.940048217773438, + 30.047636032104492, + 13.805134773254395, + -45.086708068847656, + 76.903564453125, + 46.969749450683594, + -86.58126831054688, + 31.64584732055664, + -67.96637725830078 + ], + "type": "float32" + } + }, + { + "name": "squeeze float32 4D tensor by eliminating all dimensions default options", + "inputs": { + "input": { + "shape": [1, 1, 1, 1], + "data": [ + 19.404981030500302 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "data": 19.40498161315918, + "type": "float32" + } + }, + { + "name": "squeeze float32 5D tensor by eliminating four dimensions default options", + "inputs": { + "input": { + "shape": [1, 1, 1, 24, 1], + "data": [ + 1.1293665986622017, + -93.29325783541842, + -19.999887095191227, + 41.119214363429876, + 92.69352298075461, + -41.51937878962313, + -56.75228730395734, + 11.148093991767155, + 5.57540042674151, + 15.709176425437747, + 62.550443705517665, + -5.299276370816216, + -18.61525168224469, + -66.94721623021692, + 94.97520289870027, + -21.94004801967297, + 30.047636856615554, + 13.805134987122344, + -45.08670702769, + 76.90356276507339, + 46.96974979938284, + -86.58127045567055, + 31.645846897982068, + -67.96637618240129 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [24], + "data": [ + 1.1293666362762451, + -93.29325866699219, + -19.999887466430664, + 41.11921310424805, + 92.69351959228516, + -41.519378662109375, + -56.752288818359375, + 11.148094177246094, + 5.575400352478027, + 15.709176063537598, + 62.550445556640625, + -5.299276351928711, + -18.615251541137695, + -66.94721984863281, + 94.97520446777344, + -21.940048217773438, + 30.047636032104492, + 13.805134773254395, + -45.086708068847656, + 76.903564453125, + 46.969749450683594, + -86.58126831054688, + 31.64584732055664, + -67.96637725830078 + ], + "type": "float32" + } + }, + { + "name": "squeeze float32 2D tensor by eliminating one dimension options.axes", + "inputs": { + "input": { + "shape": [1, 24], + "data": [ + 1.1293665986622017, + -93.29325783541842, + -19.999887095191227, + 41.119214363429876, + 92.69352298075461, + -41.51937878962313, + -56.75228730395734, + 11.148093991767155, + 5.57540042674151, + 15.709176425437747, + 62.550443705517665, + -5.299276370816216, + -18.61525168224469, + -66.94721623021692, + 94.97520289870027, + -21.94004801967297, + 30.047636856615554, + 13.805134987122344, + -45.08670702769, + 76.90356276507339, + 46.96974979938284, + -86.58127045567055, + 31.645846897982068, + -67.96637618240129 + ], + "type": "float32" + } + }, + "options": { + "axes": [0] + }, + "expected": { + "name": "output", + "shape": [24], + "data": [ + 1.1293666362762451, + -93.29325866699219, + -19.999887466430664, + 41.11921310424805, + 92.69351959228516, + -41.519378662109375, + -56.752288818359375, + 11.148094177246094, + 5.575400352478027, + 15.709176063537598, + 62.550445556640625, + -5.299276351928711, + -18.615251541137695, + -66.94721984863281, + 94.97520446777344, + -21.940048217773438, + 30.047636032104492, + 13.805134773254395, + -45.086708068847656, + 76.903564453125, + 46.969749450683594, + -86.58126831054688, + 31.64584732055664, + -67.96637725830078 + ], + "type": "float32" + } + }, + { + "name": "squeeze float32 3D tensor by eliminating two dimensions options.axes", + "inputs": { + "input": { + "shape": [24, 1, 1], + "data": [ + 1.1293665986622017, + -93.29325783541842, + -19.999887095191227, + 41.119214363429876, + 92.69352298075461, + -41.51937878962313, + -56.75228730395734, + 11.148093991767155, + 5.57540042674151, + 15.709176425437747, + 62.550443705517665, + -5.299276370816216, + -18.61525168224469, + -66.94721623021692, + 94.97520289870027, + -21.94004801967297, + 30.047636856615554, + 13.805134987122344, + -45.08670702769, + 76.90356276507339, + 46.96974979938284, + -86.58127045567055, + 31.645846897982068, + -67.96637618240129 + ], + "type": "float32" + } + }, + "options": { + "axes": [1, 2] + }, + "expected": { + "name": "output", + "shape": [24], + "data": [ + 1.1293666362762451, + -93.29325866699219, + -19.999887466430664, + 41.11921310424805, + 92.69351959228516, + -41.519378662109375, + -56.752288818359375, + 11.148094177246094, + 5.575400352478027, + 15.709176063537598, + 62.550445556640625, + -5.299276351928711, + -18.615251541137695, + -66.94721984863281, + 94.97520446777344, + -21.940048217773438, + 30.047636032104492, + 13.805134773254395, + -45.086708068847656, + 76.903564453125, + 46.969749450683594, + -86.58126831054688, + 31.64584732055664, + -67.96637725830078 + ], + "type": "float32" + } + }, + { + "name": "squeeze float32 4D tensor by eliminating two dimensions options.axes", + "inputs": { + "input": { + "shape": [1, 4, 6, 1], + "data": [ + 1.1293665986622017, + -93.29325783541842, + -19.999887095191227, + 41.119214363429876, + 92.69352298075461, + -41.51937878962313, + -56.75228730395734, + 11.148093991767155, + 5.57540042674151, + 15.709176425437747, + 62.550443705517665, + -5.299276370816216, + -18.61525168224469, + -66.94721623021692, + 94.97520289870027, + -21.94004801967297, + 30.047636856615554, + 13.805134987122344, + -45.08670702769, + 76.90356276507339, + 46.96974979938284, + -86.58127045567055, + 31.645846897982068, + -67.96637618240129 + ], + "type": "float32" + } + }, + "options": { + "axes": [0, 3] + }, + "expected": { + "name": "output", + "shape": [4, 6], + "data": [ + 1.1293666362762451, + -93.29325866699219, + -19.999887466430664, + 41.11921310424805, + 92.69351959228516, + -41.519378662109375, + -56.752288818359375, + 11.148094177246094, + 5.575400352478027, + 15.709176063537598, + 62.550445556640625, + -5.299276351928711, + -18.615251541137695, + -66.94721984863281, + 94.97520446777344, + -21.940048217773438, + 30.047636032104492, + 13.805134773254395, + -45.086708068847656, + 76.903564453125, + 46.969749450683594, + -86.58126831054688, + 31.64584732055664, + -67.96637725830078 + ], + "type": "float32" + } + }, + { + "name": "squeeze float32 5D tensor by eliminating two dimensions options.axes", + "inputs": { + "input": { + "shape": [2, 1, 1, 12, 1], + "data": [ + 1.1293665986622017, + -93.29325783541842, + -19.999887095191227, + 41.119214363429876, + 92.69352298075461, + -41.51937878962313, + -56.75228730395734, + 11.148093991767155, + 5.57540042674151, + 15.709176425437747, + 62.550443705517665, + -5.299276370816216, + -18.61525168224469, + -66.94721623021692, + 94.97520289870027, + -21.94004801967297, + 30.047636856615554, + 13.805134987122344, + -45.08670702769, + 76.90356276507339, + 46.96974979938284, + -86.58127045567055, + 31.645846897982068, + -67.96637618240129 + ], + "type": "float32" + } + }, + "options": { + "axes": [1, 2] + }, + "expected": { + "name": "output", + "shape": [2, 12, 1], + "data": [ + 1.1293666362762451, + -93.29325866699219, + -19.999887466430664, + 41.11921310424805, + 92.69351959228516, + -41.519378662109375, + -56.752288818359375, + 11.148094177246094, + 5.575400352478027, + 15.709176063537598, + 62.550445556640625, + -5.299276351928711, + -18.615251541137695, + -66.94721984863281, + 94.97520446777344, + -21.940048217773438, + 30.047636032104492, + 13.805134773254395, + -45.086708068847656, + 76.903564453125, + 46.969749450683594, + -86.58126831054688, + 31.64584732055664, + -67.96637725830078 + ], + "type": "float32" + } + }, + { + "name": "squeeze float32 5D tensor by eliminating four dimensions options.axes", + "inputs": { + "input": { + "shape": [1, 1, 1, 24, 1], + "data": [ + 1.1293665986622017, + -93.29325783541842, + -19.999887095191227, + 41.119214363429876, + 92.69352298075461, + -41.51937878962313, + -56.75228730395734, + 11.148093991767155, + 5.57540042674151, + 15.709176425437747, + 62.550443705517665, + -5.299276370816216, + -18.61525168224469, + -66.94721623021692, + 94.97520289870027, + -21.94004801967297, + 30.047636856615554, + 13.805134987122344, + -45.08670702769, + 76.90356276507339, + 46.96974979938284, + -86.58127045567055, + 31.645846897982068, + -67.96637618240129 + ], + "type": "float32" + } + }, + "options": { + "axes": [0, 1, 2, 4] + }, + "expected": { + "name": "output", + "shape": [24], + "data": [ + 1.1293666362762451, + -93.29325866699219, + -19.999887466430664, + 41.11921310424805, + 92.69351959228516, + -41.519378662109375, + -56.752288818359375, + 11.148094177246094, + 5.575400352478027, + 15.709176063537598, + 62.550445556640625, + -5.299276351928711, + -18.615251541137695, + -66.94721984863281, + 94.97520446777344, + -21.940048217773438, + 30.047636032104492, + 13.805134773254395, + -45.086708068847656, + 76.903564453125, + 46.969749450683594, + -86.58126831054688, + 31.64584732055664, + -67.96637725830078 + ], + "type": "float32" + } + } + ] +}
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/resources/test_data/tanh.json b/testing/web-platform/tests/webnn/resources/test_data/tanh.json new file mode 100644 index 0000000000..9e13b62472 --- /dev/null +++ b/testing/web-platform/tests/webnn/resources/test_data/tanh.json @@ -0,0 +1,334 @@ +{ + "tests": [ + { + "name": "tanh float32 1D tensor", + "inputs": { + "x": { + "shape": [24], + "data": [ + 5.47352732138576, + -1.1535596038683664, + 0.4074455820170506, + 1.8297704953674545, + 2.8690003001236537, + -4.570195171586943, + 4.146744465978713, + -4.0659342722666105, + -3.712847102459686, + 0.9077175268859179, + -0.11083049583219662, + 5.955096345162751, + 1.7831856867406417, + 4.023128342782897, + 5.587857512324163, + -5.280654174784587, + 1.4147950164785632, + -5.707717050109768, + -1.4439182665473629, + -1.9129082844854288, + 2.7495969049667437, + -0.7420240173058836, + 4.856568111647942, + -0.7563357776241926 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [24], + "data": [ + 0.9999647736549377, + -0.8189298510551453, + 0.38630160689353943, + 0.9498035907745361, + 0.9935782551765442, + -0.9997855424880981, + 0.9994998574256897, + -0.9994121193885803, + -0.9988092184066772, + 0.7200349569320679, + -0.1103789210319519, + 0.9999865293502808, + 0.945036768913269, + 0.9993596076965332, + 0.9999719858169556, + -0.9999482035636902, + 0.8885080814361572, + -0.9999779462814331, + -0.894483745098114, + -0.9573289752006531, + 0.9918531775474548, + -0.6303664445877075, + 0.9998790621757507, + -0.6389135718345642 + ], + "type": "float32" + } + }, + { + "name": "tanh float32 2D tensor", + "inputs": { + "x": { + "shape": [4, 6], + "data": [ + 5.47352732138576, + -1.1535596038683664, + 0.4074455820170506, + 1.8297704953674545, + 2.8690003001236537, + -4.570195171586943, + 4.146744465978713, + -4.0659342722666105, + -3.712847102459686, + 0.9077175268859179, + -0.11083049583219662, + 5.955096345162751, + 1.7831856867406417, + 4.023128342782897, + 5.587857512324163, + -5.280654174784587, + 1.4147950164785632, + -5.707717050109768, + -1.4439182665473629, + -1.9129082844854288, + 2.7495969049667437, + -0.7420240173058836, + 4.856568111647942, + -0.7563357776241926 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [4, 6], + "data": [ + 0.9999647736549377, + -0.8189298510551453, + 0.38630160689353943, + 0.9498035907745361, + 0.9935782551765442, + -0.9997855424880981, + 0.9994998574256897, + -0.9994121193885803, + -0.9988092184066772, + 0.7200349569320679, + -0.1103789210319519, + 0.9999865293502808, + 0.945036768913269, + 0.9993596076965332, + 0.9999719858169556, + -0.9999482035636902, + 0.8885080814361572, + -0.9999779462814331, + -0.894483745098114, + -0.9573289752006531, + 0.9918531775474548, + -0.6303664445877075, + 0.9998790621757507, + -0.6389135718345642 + ], + "type": "float32" + } + }, + { + "name": "tanh float32 3D tensor", + "inputs": { + "x": { + "shape": [2, 3, 4], + "data": [ + 5.47352732138576, + -1.1535596038683664, + 0.4074455820170506, + 1.8297704953674545, + 2.8690003001236537, + -4.570195171586943, + 4.146744465978713, + -4.0659342722666105, + -3.712847102459686, + 0.9077175268859179, + -0.11083049583219662, + 5.955096345162751, + 1.7831856867406417, + 4.023128342782897, + 5.587857512324163, + -5.280654174784587, + 1.4147950164785632, + -5.707717050109768, + -1.4439182665473629, + -1.9129082844854288, + 2.7495969049667437, + -0.7420240173058836, + 4.856568111647942, + -0.7563357776241926 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [2, 3, 4], + "data": [ + 0.9999647736549377, + -0.8189298510551453, + 0.38630160689353943, + 0.9498035907745361, + 0.9935782551765442, + -0.9997855424880981, + 0.9994998574256897, + -0.9994121193885803, + -0.9988092184066772, + 0.7200349569320679, + -0.1103789210319519, + 0.9999865293502808, + 0.945036768913269, + 0.9993596076965332, + 0.9999719858169556, + -0.9999482035636902, + 0.8885080814361572, + -0.9999779462814331, + -0.894483745098114, + -0.9573289752006531, + 0.9918531775474548, + -0.6303664445877075, + 0.9998790621757507, + -0.6389135718345642 + ], + "type": "float32" + } + }, + { + "name": "tanh float32 4D tensor", + "inputs": { + "x": { + "shape": [2, 2, 2, 3], + "data": [ + 5.47352732138576, + -1.1535596038683664, + 0.4074455820170506, + 1.8297704953674545, + 2.8690003001236537, + -4.570195171586943, + 4.146744465978713, + -4.0659342722666105, + -3.712847102459686, + 0.9077175268859179, + -0.11083049583219662, + 5.955096345162751, + 1.7831856867406417, + 4.023128342782897, + 5.587857512324163, + -5.280654174784587, + 1.4147950164785632, + -5.707717050109768, + -1.4439182665473629, + -1.9129082844854288, + 2.7495969049667437, + -0.7420240173058836, + 4.856568111647942, + -0.7563357776241926 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 0.9999647736549377, + -0.8189298510551453, + 0.38630160689353943, + 0.9498035907745361, + 0.9935782551765442, + -0.9997855424880981, + 0.9994998574256897, + -0.9994121193885803, + -0.9988092184066772, + 0.7200349569320679, + -0.1103789210319519, + 0.9999865293502808, + 0.945036768913269, + 0.9993596076965332, + 0.9999719858169556, + -0.9999482035636902, + 0.8885080814361572, + -0.9999779462814331, + -0.894483745098114, + -0.9573289752006531, + 0.9918531775474548, + -0.6303664445877075, + 0.9998790621757507, + -0.6389135718345642 + ], + "type": "float32" + } + }, + { + "name": "tanh float32 5D tensor", + "inputs": { + "x": { + "shape": [2, 1, 4, 1, 3], + "data": [ + 5.47352732138576, + -1.1535596038683664, + 0.4074455820170506, + 1.8297704953674545, + 2.8690003001236537, + -4.570195171586943, + 4.146744465978713, + -4.0659342722666105, + -3.712847102459686, + 0.9077175268859179, + -0.11083049583219662, + 5.955096345162751, + 1.7831856867406417, + 4.023128342782897, + 5.587857512324163, + -5.280654174784587, + 1.4147950164785632, + -5.707717050109768, + -1.4439182665473629, + -1.9129082844854288, + 2.7495969049667437, + -0.7420240173058836, + 4.856568111647942, + -0.7563357776241926 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [2, 1, 4, 1, 3], + "data": [ + 0.9999647736549377, + -0.8189298510551453, + 0.38630160689353943, + 0.9498035907745361, + 0.9935782551765442, + -0.9997855424880981, + 0.9994998574256897, + -0.9994121193885803, + -0.9988092184066772, + 0.7200349569320679, + -0.1103789210319519, + 0.9999865293502808, + 0.945036768913269, + 0.9993596076965332, + 0.9999719858169556, + -0.9999482035636902, + 0.8885080814361572, + -0.9999779462814331, + -0.894483745098114, + -0.9573289752006531, + 0.9918531775474548, + -0.6303664445877075, + 0.9998790621757507, + -0.6389135718345642 + ], + "type": "float32" + } + } + ] +}
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/resources/test_data/transpose.json b/testing/web-platform/tests/webnn/resources/test_data/transpose.json new file mode 100644 index 0000000000..03092031d9 --- /dev/null +++ b/testing/web-platform/tests/webnn/resources/test_data/transpose.json @@ -0,0 +1,679 @@ +{ + "tests": [ + { + "name": "transpose float32 1D tensor default options", + "inputs": { + "input": { + "shape": [24], + "data": [ + -45.67443169971317, + 53.45924798828125, + -60.118491676622114, + 38.08174802652866, + 78.64247328659363, + -69.2532431989057, + 1.843458570865181, + 92.81028097440239, + 56.10007526080264, + 77.05838267016932, + 57.46807874077655, + -84.74308916696364, + 46.38539267170415, + -84.89764374240352, + 56.70438712681607, + -25.69514467758806, + 5.622173913750174, + -25.6628149156966, + 99.46284660658401, + -87.58919988335086, + -65.37790624507953, + -66.00990219021253, + 38.46682821671709, + 2.1999381880991393 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [24], + "data": [ + -45.67443084716797, + 53.45924758911133, + -60.118492126464844, + 38.081748962402344, + 78.64247131347656, + -69.25324249267578, + 1.8434585332870483, + 92.8102798461914, + 56.100074768066406, + 77.05838012695312, + 57.46807861328125, + -84.74308776855469, + 46.38539123535156, + -84.89764404296875, + 56.70438766479492, + -25.695144653320312, + 5.62217378616333, + -25.66281509399414, + 99.46284484863281, + -87.58920288085938, + -65.3779067993164, + -66.00990295410156, + 38.466827392578125, + 2.1999382972717285 + ], + "type": "float32" + } + }, + { + "name": "transpose float32 2D tensor default options", + "inputs": { + "input": { + "shape": [4, 6], + "data": [ + -45.67443169971317, + 53.45924798828125, + -60.118491676622114, + 38.08174802652866, + 78.64247328659363, + -69.2532431989057, + 1.843458570865181, + 92.81028097440239, + 56.10007526080264, + 77.05838267016932, + 57.46807874077655, + -84.74308916696364, + 46.38539267170415, + -84.89764374240352, + 56.70438712681607, + -25.69514467758806, + 5.622173913750174, + -25.6628149156966, + 99.46284660658401, + -87.58919988335086, + -65.37790624507953, + -66.00990219021253, + 38.46682821671709, + 2.1999381880991393 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [6, 4], + "data": [ + -45.67443084716797, + 1.8434585332870483, + 46.38539123535156, + 99.46284484863281, + 53.45924758911133, + 92.8102798461914, + -84.89764404296875, + -87.58920288085938, + -60.118492126464844, + 56.100074768066406, + 56.70438766479492, + -65.3779067993164, + 38.081748962402344, + 77.05838012695312, + -25.695144653320312, + -66.00990295410156, + 78.64247131347656, + 57.46807861328125, + 5.62217378616333, + 38.466827392578125, + -69.25324249267578, + -84.74308776855469, + -25.66281509399414, + 2.1999382972717285 + ], + "type": "float32" + } + }, + { + "name": "transpose float32 3D tensor default options", + "inputs": { + "input": { + "shape": [2, 3, 4], + "data": [ + -45.67443169971317, + 53.45924798828125, + -60.118491676622114, + 38.08174802652866, + 78.64247328659363, + -69.2532431989057, + 1.843458570865181, + 92.81028097440239, + 56.10007526080264, + 77.05838267016932, + 57.46807874077655, + -84.74308916696364, + 46.38539267170415, + -84.89764374240352, + 56.70438712681607, + -25.69514467758806, + 5.622173913750174, + -25.6628149156966, + 99.46284660658401, + -87.58919988335086, + -65.37790624507953, + -66.00990219021253, + 38.46682821671709, + 2.1999381880991393 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [4, 3, 2], + "data": [ + -45.67443084716797, + 46.38539123535156, + 78.64247131347656, + 5.62217378616333, + 56.100074768066406, + -65.3779067993164, + 53.45924758911133, + -84.89764404296875, + -69.25324249267578, + -25.66281509399414, + 77.05838012695312, + -66.00990295410156, + -60.118492126464844, + 56.70438766479492, + 1.8434585332870483, + 99.46284484863281, + 57.46807861328125, + 38.466827392578125, + 38.081748962402344, + -25.695144653320312, + 92.8102798461914, + -87.58920288085938, + -84.74308776855469, + 2.1999382972717285 + ], + "type": "float32" + } + }, + { + "name": "transpose float32 4D tensor default options", + "inputs": { + "input": { + "shape": [1, 2, 3, 4], + "data": [ + -45.67443169971317, + 53.45924798828125, + -60.118491676622114, + 38.08174802652866, + 78.64247328659363, + -69.2532431989057, + 1.843458570865181, + 92.81028097440239, + 56.10007526080264, + 77.05838267016932, + 57.46807874077655, + -84.74308916696364, + 46.38539267170415, + -84.89764374240352, + 56.70438712681607, + -25.69514467758806, + 5.622173913750174, + -25.6628149156966, + 99.46284660658401, + -87.58919988335086, + -65.37790624507953, + -66.00990219021253, + 38.46682821671709, + 2.1999381880991393 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [4, 3, 2, 1], + "data": [ + -45.67443084716797, + 46.38539123535156, + 78.64247131347656, + 5.62217378616333, + 56.100074768066406, + -65.3779067993164, + 53.45924758911133, + -84.89764404296875, + -69.25324249267578, + -25.66281509399414, + 77.05838012695312, + -66.00990295410156, + -60.118492126464844, + 56.70438766479492, + 1.8434585332870483, + 99.46284484863281, + 57.46807861328125, + 38.466827392578125, + 38.081748962402344, + -25.695144653320312, + 92.8102798461914, + -87.58920288085938, + -84.74308776855469, + 2.1999382972717285 + ], + "type": "float32" + } + }, + { + "name": "transpose float32 5D tensor default options", + "inputs": { + "input": { + "shape": [1, 2, 1, 3, 4], + "data": [ + -45.67443169971317, + 53.45924798828125, + -60.118491676622114, + 38.08174802652866, + 78.64247328659363, + -69.2532431989057, + 1.843458570865181, + 92.81028097440239, + 56.10007526080264, + 77.05838267016932, + 57.46807874077655, + -84.74308916696364, + 46.38539267170415, + -84.89764374240352, + 56.70438712681607, + -25.69514467758806, + 5.622173913750174, + -25.6628149156966, + 99.46284660658401, + -87.58919988335086, + -65.37790624507953, + -66.00990219021253, + 38.46682821671709, + 2.1999381880991393 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [4, 3, 1, 2, 1], + "data": [ + -45.67443084716797, + 46.38539123535156, + 78.64247131347656, + 5.62217378616333, + 56.100074768066406, + -65.3779067993164, + 53.45924758911133, + -84.89764404296875, + -69.25324249267578, + -25.66281509399414, + 77.05838012695312, + -66.00990295410156, + -60.118492126464844, + 56.70438766479492, + 1.8434585332870483, + 99.46284484863281, + 57.46807861328125, + 38.466827392578125, + 38.081748962402344, + -25.695144653320312, + 92.8102798461914, + -87.58920288085938, + -84.74308776855469, + 2.1999382972717285 + ], + "type": "float32" + } + }, + { + "name": "transpose float32 1D tensor options.permutation", + "inputs": { + "input": { + "shape": [24], + "data": [ + -45.67443169971317, + 53.45924798828125, + -60.118491676622114, + 38.08174802652866, + 78.64247328659363, + -69.2532431989057, + 1.843458570865181, + 92.81028097440239, + 56.10007526080264, + 77.05838267016932, + 57.46807874077655, + -84.74308916696364, + 46.38539267170415, + -84.89764374240352, + 56.70438712681607, + -25.69514467758806, + 5.622173913750174, + -25.6628149156966, + 99.46284660658401, + -87.58919988335086, + -65.37790624507953, + -66.00990219021253, + 38.46682821671709, + 2.1999381880991393 + ], + "type": "float32" + } + }, + "options": { + "permutation": [0] + }, + "expected": { + "name": "output", + "shape": [24], + "data": [ + -45.67443084716797, + 53.45924758911133, + -60.118492126464844, + 38.081748962402344, + 78.64247131347656, + -69.25324249267578, + 1.8434585332870483, + 92.8102798461914, + 56.100074768066406, + 77.05838012695312, + 57.46807861328125, + -84.74308776855469, + 46.38539123535156, + -84.89764404296875, + 56.70438766479492, + -25.695144653320312, + 5.62217378616333, + -25.66281509399414, + 99.46284484863281, + -87.58920288085938, + -65.3779067993164, + -66.00990295410156, + 38.466827392578125, + 2.1999382972717285 + ], + "type": "float32" + } + }, + { + "name": "transpose float32 2D tensor options.permutation", + "inputs": { + "input": { + "shape": [4, 6], + "data": [ + -45.67443169971317, + 53.45924798828125, + -60.118491676622114, + 38.08174802652866, + 78.64247328659363, + -69.2532431989057, + 1.843458570865181, + 92.81028097440239, + 56.10007526080264, + 77.05838267016932, + 57.46807874077655, + -84.74308916696364, + 46.38539267170415, + -84.89764374240352, + 56.70438712681607, + -25.69514467758806, + 5.622173913750174, + -25.6628149156966, + 99.46284660658401, + -87.58919988335086, + -65.37790624507953, + -66.00990219021253, + 38.46682821671709, + 2.1999381880991393 + ], + "type": "float32" + } + }, + "options": { + "permutation": [1, 0] + }, + "expected": { + "name": "output", + "shape": [6, 4], + "data": [ + -45.67443084716797, + 1.8434585332870483, + 46.38539123535156, + 99.46284484863281, + 53.45924758911133, + 92.8102798461914, + -84.89764404296875, + -87.58920288085938, + -60.118492126464844, + 56.100074768066406, + 56.70438766479492, + -65.3779067993164, + 38.081748962402344, + 77.05838012695312, + -25.695144653320312, + -66.00990295410156, + 78.64247131347656, + 57.46807861328125, + 5.62217378616333, + 38.466827392578125, + -69.25324249267578, + -84.74308776855469, + -25.66281509399414, + 2.1999382972717285 + ], + "type": "float32" + } + }, + { + "name": "transpose float32 3D tensor options.permutation", + "inputs": { + "input": { + "shape": [2, 3, 4], + "data": [ + -45.67443169971317, + 53.45924798828125, + -60.118491676622114, + 38.08174802652866, + 78.64247328659363, + -69.2532431989057, + 1.843458570865181, + 92.81028097440239, + 56.10007526080264, + 77.05838267016932, + 57.46807874077655, + -84.74308916696364, + 46.38539267170415, + -84.89764374240352, + 56.70438712681607, + -25.69514467758806, + 5.622173913750174, + -25.6628149156966, + 99.46284660658401, + -87.58919988335086, + -65.37790624507953, + -66.00990219021253, + 38.46682821671709, + 2.1999381880991393 + ], + "type": "float32" + } + }, + "options": { + "permutation": [2, 0, 1] + }, + "expected": { + "name": "output", + "shape": [4, 2, 3], + "data": [ + -45.67443084716797, + 78.64247131347656, + 56.100074768066406, + 46.38539123535156, + 5.62217378616333, + -65.3779067993164, + 53.45924758911133, + -69.25324249267578, + 77.05838012695312, + -84.89764404296875, + -25.66281509399414, + -66.00990295410156, + -60.118492126464844, + 1.8434585332870483, + 57.46807861328125, + 56.70438766479492, + 99.46284484863281, + 38.466827392578125, + 38.081748962402344, + 92.8102798461914, + -84.74308776855469, + -25.695144653320312, + -87.58920288085938, + 2.1999382972717285 + ], + "type": "float32" + } + }, + { + "name": "transpose float32 4D tensor options.permutation", + "inputs": { + "input": { + "shape": [1, 2, 3, 4], + "data": [ + -45.67443169971317, + 53.45924798828125, + -60.118491676622114, + 38.08174802652866, + 78.64247328659363, + -69.2532431989057, + 1.843458570865181, + 92.81028097440239, + 56.10007526080264, + 77.05838267016932, + 57.46807874077655, + -84.74308916696364, + 46.38539267170415, + -84.89764374240352, + 56.70438712681607, + -25.69514467758806, + 5.622173913750174, + -25.6628149156966, + 99.46284660658401, + -87.58919988335086, + -65.37790624507953, + -66.00990219021253, + 38.46682821671709, + 2.1999381880991393 + ], + "type": "float32" + } + }, + "options": { + "permutation": [2, 3, 0, 1] + }, + "expected": { + "name": "output", + "shape": [3, 4, 1, 2], + "data": [ + -45.67443084716797, + 46.38539123535156, + 53.45924758911133, + -84.89764404296875, + -60.118492126464844, + 56.70438766479492, + 38.081748962402344, + -25.695144653320312, + 78.64247131347656, + 5.62217378616333, + -69.25324249267578, + -25.66281509399414, + 1.8434585332870483, + 99.46284484863281, + 92.8102798461914, + -87.58920288085938, + 56.100074768066406, + -65.3779067993164, + 77.05838012695312, + -66.00990295410156, + 57.46807861328125, + 38.466827392578125, + -84.74308776855469, + 2.1999382972717285 + ], + "type": "float32" + } + }, + { + "name": "transpose float32 5D tensor options.permutation", + "inputs": { + "input": { + "shape": [1, 2, 1, 3, 4], + "data": [ + -45.67443169971317, + 53.45924798828125, + -60.118491676622114, + 38.08174802652866, + 78.64247328659363, + -69.2532431989057, + 1.843458570865181, + 92.81028097440239, + 56.10007526080264, + 77.05838267016932, + 57.46807874077655, + -84.74308916696364, + 46.38539267170415, + -84.89764374240352, + 56.70438712681607, + -25.69514467758806, + 5.622173913750174, + -25.6628149156966, + 99.46284660658401, + -87.58919988335086, + -65.37790624507953, + -66.00990219021253, + 38.46682821671709, + 2.1999381880991393 + ], + "type": "float32" + } + }, + "options": { + "permutation": [1, 3, 0, 4, 2] + }, + "expected": { + "name": "output", + "shape": [2, 3, 1, 4, 1], + "data": [ + -45.67443084716797, + 53.45924758911133, + -60.118492126464844, + 38.081748962402344, + 78.64247131347656, + -69.25324249267578, + 1.8434585332870483, + 92.8102798461914, + 56.100074768066406, + 77.05838012695312, + 57.46807861328125, + -84.74308776855469, + 46.38539123535156, + -84.89764404296875, + 56.70438766479492, + -25.695144653320312, + 5.62217378616333, + -25.66281509399414, + 99.46284484863281, + -87.58920288085938, + -65.3779067993164, + -66.00990295410156, + 38.466827392578125, + 2.1999382972717285 + ], + "type": "float32" + } + } + ] +}
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/resources/utils.js b/testing/web-platform/tests/webnn/resources/utils.js new file mode 100644 index 0000000000..f11ce7c6e0 --- /dev/null +++ b/testing/web-platform/tests/webnn/resources/utils.js @@ -0,0 +1,363 @@ +'use strict'; + +const ExecutionArray = ['sync', 'async']; + +// https://webmachinelearning.github.io/webnn/#enumdef-mldevicetype +const DeviceTypeArray = ['cpu', 'gpu']; + +// https://webmachinelearning.github.io/webnn/#enumdef-mloperandtype +const TypedArrayDict = { + float32: Float32Array, + int32: Int32Array, + uint32: Uint32Array, + int8: Int8Array, + uint8: Uint8Array, +}; + +const sizeOfShape = (array) => { + return array.reduce((accumulator, currentValue) => accumulator * currentValue, 1); +}; + +/** + * Get JSON resources from specified test resources file. + * @param {String} file - A test resources file path + * @returns {Object} Test resources + */ +const loadResources = (file) => { + const loadJSON = () => { + let xmlhttp = new XMLHttpRequest(); + xmlhttp.open("GET", file, false); + xmlhttp.overrideMimeType("application/json"); + xmlhttp.send(); + if (xmlhttp.status == 200 && xmlhttp.readyState == 4) { + return xmlhttp.responseText; + } else { + throw new Error(`Failed to load ${file}`); + } + }; + + const json = loadJSON(); + return JSON.parse(json.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m, g) => g ? "" : m)); +}; + +/** + * Get exptected data and data type from given resources with output name. + * @param {Array} resources - An array of expected resources + * @param {String} outputName - An output name + * @returns {Array.<[Number[], String]>} An array of expected data array and data type + */ +const getExpectedDataAndType = (resources, outputName) => { + let ret; + for (let subResources of resources) { + if (subResources.name === outputName) { + ret = [subResources.data, subResources.type]; + break; + } + } + if (ret === undefined) { + throw new Error(`Failed to get expected data sources and type by ${outputName}`); + } + return ret; +}; + +/** + * Get ULP tolerance of softmax operation. + * @param {Object} resources - Resources used for building a graph + * @returns {Number} A tolerance number + */ +const getSoftmaxPrecisionTolerance = (resources) => { + // Compute the softmax values of the 2-D input tensor along axis 1. + const inputShape = resources.inputs[Object.keys(resources.inputs)[0]].shape; + const tolerance = inputShape[1] * 3 + 3; + return tolerance; +}; + +// Refer to precision metrics on https://github.com/webmachinelearning/webnn/issues/265#issuecomment-1256242643 +const PrecisionMetrics = { + clamp: {ULP: {float32: 0, float16: 0}}, + concat: {ULP: {float32: 0, float16: 0}}, + leakyRelu: {ULP: {float32: 1, float16: 1}}, + relu: {ULP: {float32: 0, float16: 0}}, + reshape: {ULP: {float32: 0, float16: 0}}, + sigmoid: {ULP: {float32: 32+2, float16: 3}}, // float32 (leaving a few ULP for roundoff) + slice: {ULP: {float32: 0, float16: 0}}, + softmax: {ULP: {float32: getSoftmaxPrecisionTolerance, float16: getSoftmaxPrecisionTolerance}}, + split: {ULP: {float32: 0, float16: 0}}, + squeeze: {ULP: {float32: 0, float16: 0}}, + tanh: {ATOL: {float32: 1/1024, float16: 1/512}}, + transpose: {ULP: {float32: 0, float16: 0}}, +}; + +/** + * Get precison tolerance value. + * @param {String} operationName - An operation name + * @param {String} metricType - Value: 'ULP', 'ATOL' + * @param {String} precisionType - A precision type string, like "float32", "float16", + * more types, please see: + * https://webmachinelearning.github.io/webnn/#enumdef-mloperandtype + * @returns {Number} A tolerance number + */ +const getPrecisonTolerance = (operationName, metricType, precisionType) => { + let tolerance = PrecisionMetrics[operationName][metricType][precisionType]; + // If the tolerance is dynamic, then evaluate the function to get the value. + if (tolerance instanceof Function) { + tolerance = tolerance(resources, operationName); + } + return tolerance; +}; + +/** + * Get bitwise of the given value. + * @param {Number} value + * @param {String} dataType - A data type string, like "float32", "float16", + * more types, please see: + * https://webmachinelearning.github.io/webnn/#enumdef-mloperandtype + * @return {Number} A 64-bit signed integer. + */ +const getBitwise = (value, dataType) => { + const buffer = new ArrayBuffer(8); + const int64Array = new BigInt64Array(buffer); + int64Array[0] = value < 0 ? ~BigInt(0) : BigInt(0); + let typedArray; + if (dataType === "float32") { + typedArray = new Float32Array(buffer); + } else { + throw new AssertionError(`Data type ${dataType} is not supported`); + } + typedArray[0] = value; + return int64Array[0]; +}; + +/** + * Assert that each array property in ``actual`` is a number being close enough to the corresponding + * property in ``expected`` by the acceptable ULP distance ``nulp`` with given ``dataType`` data type. + * + * @param {Array} actual - Array of test values. + * @param {Array} expected - Array of values expected to be close to the values in ``actual``. + * @param {Number} nulp - A BigInt value indicates acceptable ULP distance. + * @param {String} dataType - A data type string, value: "float32", + * more types, please see: + * https://webmachinelearning.github.io/webnn/#enumdef-mloperandtype + * @param {String} description - Description of the condition being tested. + */ +const assert_array_approx_equals_ulp = (actual, expected, nulp, dataType, description) => { + /* + * Test if two primitive arrays are equal within acceptable ULP distance + */ + assert_true(actual.length === expected.length, + `assert_array_approx_equals_ulp: ${description} lengths differ, expected ${expected.length} but got ${actual.length}`); + let actualBitwise, expectedBitwise, distance; + for (let i = 0; i < actual.length; i++) { + actualBitwise = getBitwise(actual[i], dataType); + expectedBitwise = getBitwise(expected[i], dataType); + distance = actualBitwise - expectedBitwise; + distance = distance >= 0 ? distance : -distance; + assert_true(distance <= nulp, + `assert_array_approx_equals_ulp: ${description} actual ${actual[i]} should be close enough to expected ${expected[i]} by the acceptable ${nulp} ULP distance, but they have ${distance} ULP distance`); + } +}; + +/** + * Assert actual results with expected results. + * @param {String} operationName - An operation name + * @param {(Number[]|Number)} actual + * @param {(Number[]|Number)} expected + * @param {Number} tolerance + * @param {String} operandType - An operand type string, value: "float32", + * more types, please see: + * https://webmachinelearning.github.io/webnn/#enumdef-mloperandtype + * @param {String} metricType - Value: 'ULP', 'ATOL' + */ +const doAssert = (operationName, actual, expected, tolerance, operandType, metricType) => { + const description = `test ${operationName} ${operandType}`; + if (typeof expected === 'number') { + // for checking a scalar output by matmul 1D x 1D + expected = [expected]; + actual = [actual]; + } + if (metricType === 'ULP') { + assert_array_approx_equals_ulp(actual, expected, tolerance, operandType, description); + } else if (metricType === 'ATOL') { + assert_array_approx_equals(actual, expected, tolerance, description); + } +}; + +/** + * Check computed results with expected data. + * @param {String} operationName - An operation name + * @param {Object.<String, MLOperand>} namedOutputOperands + * @param {Object.<MLNamedArrayBufferViews>} outputs - The resources of required outputs + * @param {Object} resources - Resources used for building a graph + */ +const checkResults = (operationName, namedOutputOperands, outputs, resources) => { + const metricType = Object.keys(PrecisionMetrics[operationName])[0]; + const expected = resources.expected; + let tolerance; + let operandType; + let outputData; + let expectedData; + if (Array.isArray(expected)) { + // the outputs of split() or gru() is a sequence + for (let operandName in namedOutputOperands) { + outputData = outputs[operandName]; + // for some operations which may have multi outputs of different types + [expectedData, operandType] = getExpectedDataAndType(expected, operandName); + tolerance = getPrecisonTolerance(operationName, metricType, operandType); + doAssert(operationName, outputData, expectedData, tolerance, operandType, metricType) + } + } else { + outputData = outputs[expected.name]; + expectedData = expected.data; + operandType = expected.type; + tolerance = getPrecisonTolerance(operationName, metricType, operandType); + doAssert(operationName, outputData, expectedData, tolerance, operandType, metricType) + } +}; + +/** + * Create single input operands for a graph. + * @param {MLGraphBuilder} builder - A ML graph builder + * @param {Object} resources - Resources used for building a graph + * @param {String} [inputOperandName] - An inputOperand name + * @returns {MLOperand} An input operand + */ +const createSingleInputOperand = (builder, resources, inputOperandName) => { + inputOperandName = inputOperandName ? inputOperandName : Object.keys(resources.inputs)[0]; + const inputResources = resources.inputs[inputOperandName]; + return builder.input(inputOperandName, {type: inputResources.type, dimensions: inputResources.shape}); +}; + +/** + * Build an operation which has a single input. + * @param {String} operationName - An operation name + * @param {MLGraphBuilder} builder - A ML graph builder + * @param {Object} resources - Resources used for building a graph + * @returns {MLNamedOperands} + */ +const buildOperationWithSingleInput = (operationName, builder, resources) => { + const namedOutputOperand = {}; + const inputOperand = createSingleInputOperand(builder, resources); + const outputOperand = resources.options ? + builder[operationName](inputOperand, resources.options) : builder[operationName](inputOperand); + namedOutputOperand[resources.expected.name] = outputOperand; + return namedOutputOperand; +}; + +/** + * Build a graph. + * @param {String} operationName - An operation name + * @param {MLGraphBuilder} builder - A ML graph builder + * @param {Object} resources - Resources used for building a graph + * @param {Function} buildFunc - A build function for an operation + * @returns [namedOperands, inputs, outputs] + */ +const buildGraph = (operationName, builder, resources, buildFunc) => { + const namedOperands = buildFunc(operationName, builder, resources); + let inputs = {}; + if (Array.isArray(resources.inputs)) { + // the inputs of concat() is a sequence + for (let subInput of resources.inputs) { + inputs[subInput.name] = new TypedArrayDict[subInput.type](subInput.data); + } + } else { + for (let inputName in resources.inputs) { + const subTestByName = resources.inputs[inputName]; + inputs[inputName] = new TypedArrayDict[subTestByName.type](subTestByName.data); + } + } + let outputs = {}; + if (Array.isArray(resources.expected)) { + // the outputs of split() or gru() is a sequence + for (let i = 0; i < resources.expected.length; i++) { + const subExpected = resources.expected[i]; + outputs[subExpected.name] = new TypedArrayDict[subExpected.type](sizeOfShape(subExpected.shape)); + } + } else { + // matmul 1D with 1D produces a scalar which doesn't have its shape + const shape = resources.expected.shape ? resources.expected.shape : [1]; + outputs[resources.expected.name] = new TypedArrayDict[resources.expected.type](sizeOfShape(shape)); + } + return [namedOperands, inputs, outputs]; +}; + +/** + * Build a graph, synchronously compile graph and execute, then check computed results. + * @param {String} operationName - An operation name + * @param {MLContext} context - A ML context + * @param {MLGraphBuilder} builder - A ML graph builder + * @param {Object} resources - Resources used for building a graph + * @param {Function} buildFunc - A build function for an operation + */ +const runSync = (operationName, context, builder, resources, buildFunc) => { + // build a graph + const [namedOutputOperands, inputs, outputs] = buildGraph(operationName, builder, resources, buildFunc); + // synchronously compile the graph up to the output operand + const graph = builder.buildSync(namedOutputOperands); + // synchronously execute the compiled graph. + context.computeSync(graph, inputs, outputs); + checkResults(operationName, namedOutputOperands, outputs, resources); +}; + +/** + * Build a graph, asynchronously compile graph and execute, then check computed results. + * @param {String} operationName - An operation name + * @param {MLContext} context - A ML context + * @param {MLGraphBuilder} builder - A ML graph builder + * @param {Object} resources - Resources used for building a graph + * @param {Function} buildFunc - A build function for an operation + */ +const run = async (operationName, context, builder, resources, buildFunc) => { + // build a graph + const [namedOutputOperands, inputs, outputs] = buildGraph(operationName, builder, resources, buildFunc); + // asynchronously compile the graph up to the output operand + const graph = await builder.build(namedOutputOperands); + // asynchronously execute the compiled graph + await context.compute(graph, inputs, outputs); + checkResults(operationName, namedOutputOperands, outputs, resources); +}; + +/** + * Run WebNN operation tests. + * @param {String} operationName - An operation name + * @param {String} file - A test resources file path + * @param {Function} buildFunc - A build function for an operation + */ +const testWebNNOperation = (operationName, file, buildFunc) => { + const resources = loadResources(file); + const tests = resources.tests; + ExecutionArray.forEach(executionType => { + const isSync = executionType === 'sync'; + if (self.GLOBAL.isWindow() && isSync) { + return; + } + let context; + let builder; + if (isSync) { + // test sync + DeviceTypeArray.forEach(deviceType => { + setup(() => { + context = navigator.ml.createContextSync({deviceType}); + builder = new MLGraphBuilder(context); + }); + for (const subTest of tests) { + test(() => { + runSync(operationName, context, builder, subTest, buildFunc); + }, `${subTest.name} / ${deviceType} / ${executionType}`); + } + }); + } else { + // test async + DeviceTypeArray.forEach(deviceType => { + promise_setup(async () => { + context = await navigator.ml.createContext({deviceType}); + builder = new MLGraphBuilder(context); + }); + for (const subTest of tests) { + promise_test(async () => { + await run(operationName, context, builder, subTest, buildFunc); + }, `${subTest.name} / ${deviceType} / ${executionType}`); + } + }); + } + }); +};
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/sigmoid.https.any.js b/testing/web-platform/tests/webnn/sigmoid.https.any.js new file mode 100644 index 0000000000..cb22b6eca1 --- /dev/null +++ b/testing/web-platform/tests/webnn/sigmoid.https.any.js @@ -0,0 +1,10 @@ +// META: title=test WebNN API sigmoid operation +// META: global=window,dedicatedworker +// META: script=./resources/utils.js +// META: timeout=long + +'use strict'; + +// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-sigmoid + +testWebNNOperation('sigmoid', '/webnn/resources/test_data/sigmoid.json', buildOperationWithSingleInput);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/slice.https.any.js b/testing/web-platform/tests/webnn/slice.https.any.js new file mode 100644 index 0000000000..8cbcf057c9 --- /dev/null +++ b/testing/web-platform/tests/webnn/slice.https.any.js @@ -0,0 +1,19 @@ +// META: title=test WebNN API slice operation +// META: global=window,dedicatedworker +// META: script=./resources/utils.js +// META: timeout=long + +'use strict'; + +// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-slice + +const buildSlice = (operationName, builder, resources) => { + // MLOperand slice(MLOperand input, sequence<long> starts, sequence<long> sizes, optional MLSliceOptions options = {}); + const namedOutputOperand = {}; + const inputOperand = createSingleInputOperand(builder, resources); + // invoke builder.slice() + namedOutputOperand[resources.expected.name] = builder[operationName](inputOperand, resources.starts, resources.sizes, resources.options); + return namedOutputOperand; +}; + +testWebNNOperation('slice', '/webnn/resources/test_data/slice.json', buildSlice);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/softmax.https.any.js b/testing/web-platform/tests/webnn/softmax.https.any.js new file mode 100644 index 0000000000..91afc28385 --- /dev/null +++ b/testing/web-platform/tests/webnn/softmax.https.any.js @@ -0,0 +1,10 @@ +// META: title=test WebNN API softmax operation +// META: global=window,dedicatedworker +// META: script=./resources/utils.js +// META: timeout=long + +'use strict'; + +// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-softmax + +testWebNNOperation('softmax', '/webnn/resources/test_data/softmax.json', buildOperationWithSingleInput);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/split.https.any.js b/testing/web-platform/tests/webnn/split.https.any.js new file mode 100644 index 0000000000..54314d7b7f --- /dev/null +++ b/testing/web-platform/tests/webnn/split.https.any.js @@ -0,0 +1,24 @@ +// META: title=test WebNN API split operation +// META: global=window,dedicatedworker +// META: script=./resources/utils.js +// META: timeout=long + +'use strict'; + +// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-split + +const buildSplit = (operationName, builder, resources) => { + // sequence<MLOperand> split(MLOperand input, + // (unsigned long or sequence<unsigned long>) splits, + // optional MLSplitOptions options = {}); + const namedOutputOperand = {}; + const inputOperand = createSingleInputOperand(builder, resources); + // invoke builder.split() + const outputOperands = builder[operationName](inputOperand, resources.splits, resources.options); + resources.expected.forEach((resourceDict, index) => { + namedOutputOperand[resourceDict.name] = outputOperands[index]; + }); + return namedOutputOperand; +}; + +testWebNNOperation('split', '/webnn/resources/test_data/split.json', buildSplit);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/squeeze.https.any.js b/testing/web-platform/tests/webnn/squeeze.https.any.js new file mode 100644 index 0000000000..5e042f34bd --- /dev/null +++ b/testing/web-platform/tests/webnn/squeeze.https.any.js @@ -0,0 +1,10 @@ +// META: title=test WebNN API squeeze operation +// META: global=window,dedicatedworker +// META: script=./resources/utils.js +// META: timeout=long + +'use strict'; + +// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-squeeze + +testWebNNOperation('squeeze', '/webnn/resources/test_data/squeeze.json', buildOperationWithSingleInput);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/tanh.https.any.js b/testing/web-platform/tests/webnn/tanh.https.any.js new file mode 100644 index 0000000000..603f0930cf --- /dev/null +++ b/testing/web-platform/tests/webnn/tanh.https.any.js @@ -0,0 +1,10 @@ +// META: title=test WebNN API tanh operation +// META: global=window,dedicatedworker +// META: script=./resources/utils.js +// META: timeout=long + +'use strict'; + +// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-tanh + +testWebNNOperation('tanh', '/webnn/resources/test_data/tanh.json', buildOperationWithSingleInput);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/transpose.https.any.js b/testing/web-platform/tests/webnn/transpose.https.any.js new file mode 100644 index 0000000000..d1303f52ac --- /dev/null +++ b/testing/web-platform/tests/webnn/transpose.https.any.js @@ -0,0 +1,10 @@ +// META: title=test WebNN API transpose operation +// META: global=window,dedicatedworker +// META: script=./resources/utils.js +// META: timeout=long + +'use strict'; + +// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-transpose + +testWebNNOperation('transpose', '/webnn/resources/test_data/transpose.json', buildOperationWithSingleInput);
\ No newline at end of file |