diff options
Diffstat (limited to 'tests/wpt/tests/webnn/conformance_tests/expand.https.any.js')
-rw-r--r-- | tests/wpt/tests/webnn/conformance_tests/expand.https.any.js | 622 |
1 files changed, 617 insertions, 5 deletions
diff --git a/tests/wpt/tests/webnn/conformance_tests/expand.https.any.js b/tests/wpt/tests/webnn/conformance_tests/expand.https.any.js index 2304cf9e9c9..821c9b83ec2 100644 --- a/tests/wpt/tests/webnn/conformance_tests/expand.https.any.js +++ b/tests/wpt/tests/webnn/conformance_tests/expand.https.any.js @@ -16,11 +16,8 @@ // MLOperand input, sequence<[EnforceRange] unsigned long> newShape); -const getExpandPrecisionTolerance = (graphResources) => { - const toleranceValueDict = {float32: 0, float16: 0}; - const expectedDataType = - getExpectedDataTypeOfSingleOutput(graphResources.expectedOutputs); - return {metricType: 'ULP', value: toleranceValueDict[expectedDataType]}; +const getExpandPrecisionTolerance = () => { + return {metricType: 'ULP', value: 0}; }; const expandTests = [ @@ -718,6 +715,621 @@ const expandTests = [ } } } + }, + + // float16 tests + { + 'name': 'expand float16 0D scalar to 1D', + 'graph': { + 'inputs': { + 'expandInput': { + 'data': [-6.4609375], + 'descriptor': {shape: [], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'expand', + 'arguments': [{'input': 'expandInput'}, {'newShape': [24]}], + 'outputs': 'expandOutput' + }], + 'expectedOutputs': { + 'expandOutput': { + 'data': [ + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375 + ], + 'descriptor': {shape: [24], dataType: 'float16'} + } + } + } + }, + { + 'name': 'expand float16 0D scalar to 2D', + 'graph': { + 'inputs': { + 'expandInput': { + 'data': [-6.4609375], + 'descriptor': {shape: [], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'expand', + 'arguments': [{'input': 'expandInput'}, {'newShape': [4, 6]}], + 'outputs': 'expandOutput' + }], + 'expectedOutputs': { + 'expandOutput': { + 'data': [ + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375 + ], + 'descriptor': {shape: [4, 6], dataType: 'float16'} + } + } + } + }, + { + 'name': 'expand float16 0D scalar to 3D', + 'graph': { + 'inputs': { + 'expandInput': { + 'data': [-6.4609375], + 'descriptor': {shape: [], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'expand', + 'arguments': [{'input': 'expandInput'}, {'newShape': [2, 3, 4]}], + 'outputs': 'expandOutput' + }], + 'expectedOutputs': { + 'expandOutput': { + 'data': [ + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375 + ], + 'descriptor': {shape: [2, 3, 4], dataType: 'float16'} + } + } + } + }, + { + 'name': 'expand float16 0D scalar to 4D', + 'graph': { + 'inputs': { + 'expandInput': { + 'data': [-6.4609375], + 'descriptor': {shape: [], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'expand', + 'arguments': [{'input': 'expandInput'}, {'newShape': [2, 2, 2, 3]}], + 'outputs': 'expandOutput' + }], + 'expectedOutputs': { + 'expandOutput': { + 'data': [ + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375 + ], + 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} + } + } + } + }, + { + 'name': 'expand float16 0D scalar to 5D', + 'graph': { + 'inputs': { + 'expandInput': { + 'data': [-6.4609375], + 'descriptor': {shape: [], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'expand', + 'arguments': [{'input': 'expandInput'}, {'newShape': [2, 2, 3, 1, 2]}], + 'outputs': 'expandOutput' + }], + 'expectedOutputs': { + 'expandOutput': { + 'data': [ + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375 + ], + 'descriptor': {shape: [2, 2, 3, 1, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': 'expand float16 1D constant tensor to 1D', + 'graph': { + 'inputs': { + 'expandInput': { + 'data': [-6.4609375], + 'descriptor': {shape: [1], dataType: 'float16'}, + 'constant': true + } + }, + 'operators': [{ + 'name': 'expand', + 'arguments': [{'input': 'expandInput'}, {'newShape': [24]}], + 'outputs': 'expandOutput' + }], + 'expectedOutputs': { + 'expandOutput': { + 'data': [ + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375 + ], + 'descriptor': {shape: [24], dataType: 'float16'} + } + } + } + }, + { + 'name': 'expand float16 1D tensor to 1D', + 'graph': { + 'inputs': { + 'expandInput': { + 'data': [-6.4609375], + 'descriptor': {shape: [1], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'expand', + 'arguments': [{'input': 'expandInput'}, {'newShape': [24]}], + 'outputs': 'expandOutput' + }], + 'expectedOutputs': { + 'expandOutput': { + 'data': [ + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375 + ], + 'descriptor': {shape: [24], dataType: 'float16'} + } + } + } + }, + { + 'name': 'expand float16 1D tensor to 2D', + 'graph': { + 'inputs': { + 'expandInput': { + 'data': [-6.4609375], + 'descriptor': {shape: [1], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'expand', + 'arguments': [{'input': 'expandInput'}, {'newShape': [4, 6]}], + 'outputs': 'expandOutput' + }], + 'expectedOutputs': { + 'expandOutput': { + 'data': [ + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375 + ], + 'descriptor': {shape: [4, 6], dataType: 'float16'} + } + } + } + }, + { + 'name': 'expand float16 1D tensor to 3D', + 'graph': { + 'inputs': { + 'expandInput': { + 'data': [-6.4609375], + 'descriptor': {shape: [1], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'expand', + 'arguments': [{'input': 'expandInput'}, {'newShape': [2, 3, 4]}], + 'outputs': 'expandOutput' + }], + 'expectedOutputs': { + 'expandOutput': { + 'data': [ + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375 + ], + 'descriptor': {shape: [2, 3, 4], dataType: 'float16'} + } + } + } + }, + { + 'name': 'expand float16 1D tensor to 4D', + 'graph': { + 'inputs': { + 'expandInput': { + 'data': [-6.4609375], + 'descriptor': {shape: [1], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'expand', + 'arguments': [{'input': 'expandInput'}, {'newShape': [2, 2, 2, 3]}], + 'outputs': 'expandOutput' + }], + 'expectedOutputs': { + 'expandOutput': { + 'data': [ + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375 + ], + 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} + } + } + } + }, + { + 'name': 'expand float16 1D tensor to 5D', + 'graph': { + 'inputs': { + 'expandInput': { + 'data': [-6.4609375], + 'descriptor': {shape: [1], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'expand', + 'arguments': [{'input': 'expandInput'}, {'newShape': [2, 2, 3, 1, 2]}], + 'outputs': 'expandOutput' + }], + 'expectedOutputs': { + 'expandOutput': { + 'data': [ + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375 + ], + 'descriptor': {shape: [2, 2, 3, 1, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': 'expand float16 2D tensor to 2D (1st dimension)', + 'graph': { + 'inputs': { + 'expandInput': { + 'data': + [10.8984375, -29.390625, -73.75, 22.453125, -97.5625, -76.9375], + 'descriptor': {shape: [1, 6], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'expand', + 'arguments': [{'input': 'expandInput'}, {'newShape': [4, 6]}], + 'outputs': 'expandOutput' + }], + 'expectedOutputs': { + 'expandOutput': { + 'data': [ + 10.8984375, -29.390625, -73.75, 22.453125, -97.5625, -76.9375, + 10.8984375, -29.390625, -73.75, 22.453125, -97.5625, -76.9375, + 10.8984375, -29.390625, -73.75, 22.453125, -97.5625, -76.9375, + 10.8984375, -29.390625, -73.75, 22.453125, -97.5625, -76.9375 + ], + 'descriptor': {shape: [4, 6], dataType: 'float16'} + } + } + } + }, + { + 'name': 'expand float16 2D tensor to 2D (2nd dimension)', + 'graph': { + 'inputs': { + 'expandInput': { + 'data': [4.96484375, 66.125, 75.3125, 50], + 'descriptor': {shape: [4, 1], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'expand', + 'arguments': [{'input': 'expandInput'}, {'newShape': [4, 6]}], + 'outputs': 'expandOutput' + }], + 'expectedOutputs': { + 'expandOutput': { + 'data': [ + 4.96484375, 4.96484375, 4.96484375, 4.96484375, 4.96484375, + 4.96484375, 66.125, 66.125, 66.125, 66.125, + 66.125, 66.125, 75.3125, 75.3125, 75.3125, + 75.3125, 75.3125, 75.3125, 50, 50, + 50, 50, 50, 50 + ], + 'descriptor': {shape: [4, 6], dataType: 'float16'} + } + } + } + }, + { + 'name': 'expand float16 2D tensor to 2D (all dimensions)', + 'graph': { + 'inputs': { + 'expandInput': { + 'data': [-6.4609375], + 'descriptor': {shape: [1, 1], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'expand', + 'arguments': [{'input': 'expandInput'}, {'newShape': [4, 6]}], + 'outputs': 'expandOutput' + }], + 'expectedOutputs': { + 'expandOutput': { + 'data': [ + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375 + ], + 'descriptor': {shape: [4, 6], dataType: 'float16'} + } + } + } + }, + { + 'name': 'expand float16 2D tensor to 3D', + 'graph': { + 'inputs': { + 'expandInput': { + 'data': [4.96484375, 66.125, 75.3125, 50], + 'descriptor': {shape: [4, 1], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'expand', + 'arguments': [{'input': 'expandInput'}, {'newShape': [2, 4, 3]}], + 'outputs': 'expandOutput' + }], + 'expectedOutputs': { + 'expandOutput': { + 'data': [ + 4.96484375, 4.96484375, 4.96484375, 66.125, 66.125, 66.125, + 75.3125, 75.3125, 75.3125, 50, 50, 50, + 4.96484375, 4.96484375, 4.96484375, 66.125, 66.125, 66.125, + 75.3125, 75.3125, 75.3125, 50, 50, 50 + ], + 'descriptor': {shape: [2, 4, 3], dataType: 'float16'} + } + } + } + }, + { + 'name': 'expand float16 2D tensor to 4D', + 'graph': { + 'inputs': { + 'expandInput': { + 'data': + [10.8984375, -29.390625, -73.75, 22.453125, -97.5625, -76.9375], + 'descriptor': {shape: [1, 6], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'expand', + 'arguments': [{'input': 'expandInput'}, {'newShape': [2, 1, 2, 6]}], + 'outputs': 'expandOutput' + }], + 'expectedOutputs': { + 'expandOutput': { + 'data': [ + 10.8984375, -29.390625, -73.75, 22.453125, -97.5625, -76.9375, + 10.8984375, -29.390625, -73.75, 22.453125, -97.5625, -76.9375, + 10.8984375, -29.390625, -73.75, 22.453125, -97.5625, -76.9375, + 10.8984375, -29.390625, -73.75, 22.453125, -97.5625, -76.9375 + ], + 'descriptor': {shape: [2, 1, 2, 6], dataType: 'float16'} + } + } + } + }, + { + 'name': 'expand float16 2D tensor to 5D', + 'graph': { + 'inputs': { + 'expandInput': { + 'data': [-6.4609375], + 'descriptor': {shape: [1, 1], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'expand', + 'arguments': [{'input': 'expandInput'}, {'newShape': [2, 1, 3, 2, 2]}], + 'outputs': 'expandOutput' + }], + 'expectedOutputs': { + 'expandOutput': { + 'data': [ + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375, -6.4609375, + -6.4609375, -6.4609375, -6.4609375, -6.4609375 + ], + 'descriptor': {shape: [2, 1, 3, 2, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': 'expand float16 3D tensor to 3D', + 'graph': { + 'inputs': { + 'expandInput': { + 'data': [21.6875, -72.8125], + 'descriptor': {shape: [1, 2, 1], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'expand', + 'arguments': [{'input': 'expandInput'}, {'newShape': [2, 2, 6]}], + 'outputs': 'expandOutput' + }], + 'expectedOutputs': { + 'expandOutput': { + 'data': [ + 21.6875, 21.6875, 21.6875, 21.6875, 21.6875, 21.6875, + -72.8125, -72.8125, -72.8125, -72.8125, -72.8125, -72.8125, + 21.6875, 21.6875, 21.6875, 21.6875, 21.6875, 21.6875, + -72.8125, -72.8125, -72.8125, -72.8125, -72.8125, -72.8125 + ], + 'descriptor': {shape: [2, 2, 6], dataType: 'float16'} + } + } + } + }, + { + 'name': 'expand float16 3D tensor to 4D', + 'graph': { + 'inputs': { + 'expandInput': { + 'data': [21.6875, -72.8125], + 'descriptor': {shape: [1, 2, 1], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'expand', + 'arguments': [{'input': 'expandInput'}, {'newShape': [2, 2, 2, 3]}], + 'outputs': 'expandOutput' + }], + 'expectedOutputs': { + 'expandOutput': { + 'data': [ + 21.6875, 21.6875, 21.6875, -72.8125, -72.8125, -72.8125, + 21.6875, 21.6875, 21.6875, -72.8125, -72.8125, -72.8125, + 21.6875, 21.6875, 21.6875, -72.8125, -72.8125, -72.8125, + 21.6875, 21.6875, 21.6875, -72.8125, -72.8125, -72.8125 + ], + 'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'} + } + } + } + }, + { + 'name': 'expand float16 3D tensor to 5D', + 'graph': { + 'inputs': { + 'expandInput': { + 'data': [21.6875, -72.8125], + 'descriptor': {shape: [1, 2, 1], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'expand', + 'arguments': [{'input': 'expandInput'}, {'newShape': [2, 1, 2, 2, 3]}], + 'outputs': 'expandOutput' + }], + 'expectedOutputs': { + 'expandOutput': { + 'data': [ + 21.6875, 21.6875, 21.6875, -72.8125, -72.8125, -72.8125, + 21.6875, 21.6875, 21.6875, -72.8125, -72.8125, -72.8125, + 21.6875, 21.6875, 21.6875, -72.8125, -72.8125, -72.8125, + 21.6875, 21.6875, 21.6875, -72.8125, -72.8125, -72.8125 + ], + 'descriptor': {shape: [2, 1, 2, 2, 3], dataType: 'float16'} + } + } + } + }, + { + 'name': 'expand float16 4D tensor to 4D', + 'graph': { + 'inputs': { + 'expandInput': { + 'data': [12.796875, -26.546875], + 'descriptor': {shape: [2, 1, 1, 1], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'expand', + 'arguments': [{'input': 'expandInput'}, {'newShape': [2, 3, 2, 2]}], + 'outputs': 'expandOutput' + }], + 'expectedOutputs': { + 'expandOutput': { + 'data': [ + 12.796875, 12.796875, 12.796875, 12.796875, 12.796875, + 12.796875, 12.796875, 12.796875, 12.796875, 12.796875, + 12.796875, 12.796875, -26.546875, -26.546875, -26.546875, + -26.546875, -26.546875, -26.546875, -26.546875, -26.546875, + -26.546875, -26.546875, -26.546875, -26.546875 + ], + 'descriptor': {shape: [2, 3, 2, 2], dataType: 'float16'} + } + } + } + }, + { + 'name': 'expand float16 4D tensor to 5D', + 'graph': { + 'inputs': { + 'expandInput': { + 'data': [12.796875, -26.546875], + 'descriptor': {shape: [2, 1, 1, 1], dataType: 'float16'} + } + }, + 'operators': [{ + 'name': 'expand', + 'arguments': [{'input': 'expandInput'}, {'newShape': [2, 2, 3, 1, 2]}], + 'outputs': 'expandOutput' + }], + 'expectedOutputs': { + 'expandOutput': { + 'data': [ + 12.796875, 12.796875, 12.796875, 12.796875, 12.796875, + 12.796875, -26.546875, -26.546875, -26.546875, -26.546875, + -26.546875, -26.546875, 12.796875, 12.796875, 12.796875, + 12.796875, 12.796875, 12.796875, -26.546875, -26.546875, + -26.546875, -26.546875, -26.546875, -26.546875 + ], + 'descriptor': {shape: [2, 2, 3, 1, 2], dataType: 'float16'} + } + } + } } ]; |