From fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:14:29 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- .../webnn/resources/test_data/average_pool2d.json | 335 ------ .../tests/webnn/resources/test_data/constant.json | 754 +++++++++++++ .../tests/webnn/resources/test_data/conv2d.json | 351 ------ .../resources/test_data/conv_transpose2d.json | 547 --------- .../tests/webnn/resources/test_data/l2_pool2d.json | 1174 ++++++++++++++++++++ .../webnn/resources/test_data/max_pool2d.json | 335 ------ .../webnn/resources/test_data/resample2d.json | 527 +++++++++ .../webnn/resources/test_data/triangular.json | 1101 ++++++++++++++++++ .../web-platform/tests/webnn/resources/utils.js | 172 ++- .../tests/webnn/resources/utils_validation.js | 359 ++++++ 10 files changed, 4028 insertions(+), 1627 deletions(-) create mode 100644 testing/web-platform/tests/webnn/resources/test_data/constant.json create mode 100644 testing/web-platform/tests/webnn/resources/test_data/l2_pool2d.json create mode 100644 testing/web-platform/tests/webnn/resources/test_data/resample2d.json create mode 100644 testing/web-platform/tests/webnn/resources/test_data/triangular.json create mode 100644 testing/web-platform/tests/webnn/resources/utils_validation.js (limited to 'testing/web-platform/tests/webnn/resources') diff --git a/testing/web-platform/tests/webnn/resources/test_data/average_pool2d.json b/testing/web-platform/tests/webnn/resources/test_data/average_pool2d.json index 5a9f4e28b1..3d0c432273 100644 --- a/testing/web-platform/tests/webnn/resources/test_data/average_pool2d.json +++ b/testing/web-platform/tests/webnn/resources/test_data/average_pool2d.json @@ -533,340 +533,6 @@ "type": "float32" } }, - { - "name": "averagePool2d float32 4D tensor options.autoPad=explicit", - "inputs": { - "input": { - "shape": [1, 2, 5, 5], - "data": [ - 22.975555502750634, - 78.15438048012338, - 9.68611138116071, - 51.29803808129347, - 32.19308601456918, - 87.65037289600019, - 87.25082191311348, - 39.49793996935087, - 80.09963591169489, - 10.220142557736978, - 52.60270021646585, - 1.4128639882603933, - 11.954064466077474, - 85.0007506374375, - 64.7837446465813, - 88.03128735720126, - 11.333851214909307, - 70.61659435728073, - 84.90442561999888, - 79.06688041781518, - 7.328724951604215, - 35.97796581186121, - 10.17730631094398, - 1.4140757517112412, - 78.10038172113374, - 91.59549689157087, - 65.64701225681809, - 55.14215004436653, - 18.432438840756184, - 49.34624267439973, - 15.648024969290454, - 68.02723372727797, - 20.342549040418124, - 26.72794900604616, - 64.87446829774323, - 46.56714896227794, - 79.57832937136276, - 4.338463748959498, - 38.18383968382213, - 45.253981324455175, - 80.9717996657439, - 67.58124910163149, - 6.026499585657263, - 29.77881349289366, - 58.58993337807239, - 2.2384984647495054, - 14.505490166700486, - 68.72449589246624, - 76.45657404642184, - 23.53263275794233 - ], - "type": "float32" - } - }, - "options": { - "padding": [1, 0, 0, 1], - "autoPad": "explicit" - }, - "expected": { - "name": "output", - "shape": [1, 2, 2, 2], - "data": [ - 52.43666076660156, - 49.84208297729492, - 47.26926803588867, - 46.15715408325195, - 46.63268280029297, - 43.616947174072266, - 44.72445297241211, - 44.05451583862305 - ], - "type": "float32" - } - }, - { - "name": "averagePool2d float32 4D tensor options.autoPad=same-upper", - "inputs": { - "input": { - "shape": [1, 2, 4, 4], - "data": [ - 18.669797402066955, - 95.74087629574039, - 24.142204556566483, - 51.13168108230512, - 32.59428648032041, - 36.33802591707573, - 27.143744148346705, - 61.289996123672566, - 0.728295383811961, - 60.81457168719891, - 95.0135160845949, - 65.57073366405261, - 24.878494968304032, - 54.664386232007665, - 26.61406921126077, - 52.134243150024886, - 12.628756510724926, - 83.86613668699508, - 10.754655927067148, - 14.330409913484088, - 29.797547470611676, - 4.38582170135331, - 3.052249580313382, - 22.562494369151654, - 6.22880691096237, - 84.28155043844244, - 11.095604502619949, - 43.65773966541213, - 20.380576521492454, - 94.70740415350079, - 29.785210365576088, - 49.15286022732512 - ], - "type": "float32" - } - }, - "options": { - "windowDimensions": [3, 3], - "strides": [2, 2], - "autoPad": "same-upper" - }, - "expected": { - "name": "output", - "shape": [1, 2, 2, 2], - "data": [ - 43.46503448486328, - 54.04864501953125, - 43.78555679321289, - 59.8331413269043, - 27.34345817565918, - 17.575525283813477, - 41.079856872558594, - 33.422855377197266 - ], - "type": "float32" - } - }, - { - "name": "averagePool2d float32 4D tensor options.autoPad=same-lower", - "inputs": { - "input": { - "shape": [1, 2, 4, 4], - "data": [ - 18.669797402066955, - 95.74087629574039, - 24.142204556566483, - 51.13168108230512, - 32.59428648032041, - 36.33802591707573, - 27.143744148346705, - 61.289996123672566, - 0.728295383811961, - 60.81457168719891, - 95.0135160845949, - 65.57073366405261, - 24.878494968304032, - 54.664386232007665, - 26.61406921126077, - 52.134243150024886, - 12.628756510724926, - 83.86613668699508, - 10.754655927067148, - 14.330409913484088, - 29.797547470611676, - 4.38582170135331, - 3.052249580313382, - 22.562494369151654, - 6.22880691096237, - 84.28155043844244, - 11.095604502619949, - 43.65773966541213, - 20.380576521492454, - 94.70740415350079, - 29.785210365576088, - 49.15286022732512 - ], - "type": "float32" - } - }, - "options": { - "windowDimensions": [3, 3], - "strides": [2, 2], - "autoPad": "same-lower" - }, - "expected": { - "name": "output", - "shape": [1, 2, 2, 2], - "data": [ - 45.83574676513672, - 49.297752380371094, - 35.00300979614258, - 53.28703308105469, - 32.6695671081543, - 23.158628463745117, - 39.963619232177734, - 38.075660705566406 - ], - "type": "float32" - } - }, - { - "name": "averagePool2d float32 4D tensor options.autoPad=same-upper ignores options.padding", - "inputs": { - "input": { - "shape": [1, 2, 4, 4], - "data": [ - 18.669797402066955, - 95.74087629574039, - 24.142204556566483, - 51.13168108230512, - 32.59428648032041, - 36.33802591707573, - 27.143744148346705, - 61.289996123672566, - 0.728295383811961, - 60.81457168719891, - 95.0135160845949, - 65.57073366405261, - 24.878494968304032, - 54.664386232007665, - 26.61406921126077, - 52.134243150024886, - 12.628756510724926, - 83.86613668699508, - 10.754655927067148, - 14.330409913484088, - 29.797547470611676, - 4.38582170135331, - 3.052249580313382, - 22.562494369151654, - 6.22880691096237, - 84.28155043844244, - 11.095604502619949, - 43.65773966541213, - 20.380576521492454, - 94.70740415350079, - 29.785210365576088, - 49.15286022732512 - ], - "type": "float32" - } - }, - "options": { - "windowDimensions": [3, 3], - "padding": [2, 2, 2, 2], - "strides": [2, 2], - "autoPad": "same-upper" - }, - "expected": { - "name": "output", - "shape": [1, 2, 2, 2], - "data": [ - 43.46503448486328, - 54.04864501953125, - 43.78555679321289, - 59.8331413269043, - 27.34345817565918, - 17.575525283813477, - 41.079856872558594, - 33.422855377197266 - ], - "type": "float32" - } - }, - { - "name": "averagePool2d float32 4D tensor options.autoPad=same-lower ignores options.padding", - "inputs": { - "input": { - "shape": [1, 2, 4, 4], - "data": [ - 18.669797402066955, - 95.74087629574039, - 24.142204556566483, - 51.13168108230512, - 32.59428648032041, - 36.33802591707573, - 27.143744148346705, - 61.289996123672566, - 0.728295383811961, - 60.81457168719891, - 95.0135160845949, - 65.57073366405261, - 24.878494968304032, - 54.664386232007665, - 26.61406921126077, - 52.134243150024886, - 12.628756510724926, - 83.86613668699508, - 10.754655927067148, - 14.330409913484088, - 29.797547470611676, - 4.38582170135331, - 3.052249580313382, - 22.562494369151654, - 6.22880691096237, - 84.28155043844244, - 11.095604502619949, - 43.65773966541213, - 20.380576521492454, - 94.70740415350079, - 29.785210365576088, - 49.15286022732512 - ], - "type": "float32" - } - }, - "options": { - "windowDimensions": [3, 3], - "padding": [2, 2, 2, 2], - "strides": [2, 2], - "autoPad": "same-lower" - }, - "expected": { - "name": "output", - "shape": [1, 2, 2, 2], - "data": [ - 45.83574676513672, - 49.297752380371094, - 35.00300979614258, - 53.28703308105469, - 32.6695671081543, - 23.158628463745117, - 39.963619232177734, - 38.075660705566406 - ], - "type": "float32" - } - }, { "name": "averagePool2d float32 4D tensor options.layout=nchw", "inputs": { @@ -1650,7 +1316,6 @@ "options": { "windowDimensions": [3, 3], "padding": [1, 0, 0, 1], - "autoPad": "explicit", "strides": [2, 2], "layout": "nhwc" }, diff --git a/testing/web-platform/tests/webnn/resources/test_data/constant.json b/testing/web-platform/tests/webnn/resources/test_data/constant.json new file mode 100644 index 0000000000..06fe0a7a95 --- /dev/null +++ b/testing/web-platform/tests/webnn/resources/test_data/constant.json @@ -0,0 +1,754 @@ +{ + "tests": [ + { + "name": "constant float32 0D tensor of default float32 type", + "inputs": { + "start": { + "data": 0.22992068529129028, + "type": "float32" + }, + "step": { + "data": 0.7537541389465332, + "type": "float32" + } + }, + "outputShape": [], + "expected": { + "name": "output", + "shape": [], + "data": [ + 0.22992068529129028 + ], + "type": "float32" + } + }, + { + "name": "constant float32 1D tensor of default float32 type", + "inputs": { + "start": { + "data": 0.22992068529129028, + "type": "float32" + }, + "step": { + "data": 0.7537541389465332, + "type": "float32" + } + }, + "outputShape": [24], + "expected": { + "name": "output", + "shape": [24], + "data": [ + 0.22992068529129028, + 0.9836748242378235, + 1.737428903579712, + 2.491183042526245, + 3.2449371814727783, + 3.9986913204193115, + 4.752445697784424, + 5.506199836730957, + 6.25995397567749, + 7.013708114624023, + 7.767462253570557, + 8.52121639251709, + 9.274970054626465, + 10.028724670410156, + 10.782478332519531, + 11.536232948303223, + 12.289986610412598, + 13.043741226196289, + 13.797494888305664, + 14.551249504089355, + 15.30500316619873, + 16.058757781982422, + 16.812511444091797, + 17.566265106201172 + ], + "type": "float32" + } + }, + { + "name": "constant float32 2D tensor of default float32 type", + "inputs": { + "start": { + "data": 0.22992068529129028, + "type": "float32" + }, + "step": { + "data": 0.7537541389465332, + "type": "float32" + } + }, + "outputShape": [4, 6], + "expected": { + "name": "output", + "shape": [4, 6], + "data": [ + 0.22992068529129028, + 0.9836748242378235, + 1.737428903579712, + 2.491183042526245, + 3.2449371814727783, + 3.9986913204193115, + 4.752445697784424, + 5.506199836730957, + 6.25995397567749, + 7.013708114624023, + 7.767462253570557, + 8.52121639251709, + 9.274970054626465, + 10.028724670410156, + 10.782478332519531, + 11.536232948303223, + 12.289986610412598, + 13.043741226196289, + 13.797494888305664, + 14.551249504089355, + 15.30500316619873, + 16.058757781982422, + 16.812511444091797, + 17.566265106201172 + ], + "type": "float32" + } + }, + { + "name": "constant float32 3D tensor of default float32 type", + "inputs": { + "start": { + "data": 0.22992068529129028, + "type": "float32" + }, + "step": { + "data": 0.7537541389465332, + "type": "float32" + } + }, + "outputShape": [2, 3, 4], + "expected": { + "name": "output", + "shape": [2, 3, 4], + "data": [ + 0.22992068529129028, + 0.9836748242378235, + 1.737428903579712, + 2.491183042526245, + 3.2449371814727783, + 3.9986913204193115, + 4.752445697784424, + 5.506199836730957, + 6.25995397567749, + 7.013708114624023, + 7.767462253570557, + 8.52121639251709, + 9.274970054626465, + 10.028724670410156, + 10.782478332519531, + 11.536232948303223, + 12.289986610412598, + 13.043741226196289, + 13.797494888305664, + 14.551249504089355, + 15.30500316619873, + 16.058757781982422, + 16.812511444091797, + 17.566265106201172 + ], + "type": "float32" + } + }, + { + "name": "constant float32 4D tensor of default float32 type", + "inputs": { + "start": { + "data": 0.22992068529129028, + "type": "float32" + }, + "step": { + "data": 0.7537541389465332, + "type": "float32" + } + }, + "outputShape": [2, 2, 2, 3], + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 0.22992068529129028, + 0.9836748242378235, + 1.737428903579712, + 2.491183042526245, + 3.2449371814727783, + 3.9986913204193115, + 4.752445697784424, + 5.506199836730957, + 6.25995397567749, + 7.013708114624023, + 7.767462253570557, + 8.52121639251709, + 9.274970054626465, + 10.028724670410156, + 10.782478332519531, + 11.536232948303223, + 12.289986610412598, + 13.043741226196289, + 13.797494888305664, + 14.551249504089355, + 15.30500316619873, + 16.058757781982422, + 16.812511444091797, + 17.566265106201172 + ], + "type": "float32" + } + }, + { + "name": "constant float32 4D tensor of default float32 type step > 0", + "inputs": { + "start": { + "data": 0.22992068529129028, + "type": "float32" + }, + "step": { + "data": 0.7615746259689331, + "type": "float32" + } + }, + "outputShape": [2, 2, 2, 3], + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 0.22992068529129028, + 0.9914953112602234, + 1.7530698776245117, + 2.5146446228027344, + 3.276219129562378, + 4.0377936363220215, + 4.799368381500244, + 5.560943126678467, + 6.3225178718566895, + 7.084092140197754, + 7.845666885375977, + 8.6072416305542, + 9.368816375732422, + 10.130391120910645, + 10.891965866088867, + 11.653539657592773, + 12.415114402770996, + 13.176689147949219, + 13.938263893127441, + 14.699838638305664, + 15.461413383483887, + 16.22298812866211, + 16.984561920166016, + 17.746137619018555 + ], + "type": "float32" + } + }, + { + "name": "constant float32 4D tensor of default float32 type step = 0", + "inputs": { + "start": { + "data": 0.22992068529129028, + "type": "float32" + }, + "step": { + "data": 0, + "type": "float32" + } + }, + "outputShape": [2, 2, 2, 3], + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 0.22992068529129028, + 0.22992068529129028, + 0.22992068529129028, + 0.22992068529129028, + 0.22992068529129028, + 0.22992068529129028, + 0.22992068529129028, + 0.22992068529129028, + 0.22992068529129028, + 0.22992068529129028, + 0.22992068529129028, + 0.22992068529129028, + 0.22992068529129028, + 0.22992068529129028, + 0.22992068529129028, + 0.22992068529129028, + 0.22992068529129028, + 0.22992068529129028, + 0.22992068529129028, + 0.22992068529129028, + 0.22992068529129028, + 0.22992068529129028, + 0.22992068529129028, + 0.22992068529129028 + ], + "type": "float32" + } + }, + { + "name": "constant float32 4D tensor of default float32 type step < 0", + "inputs": { + "start": { + "data": 0.22992068529129028, + "type": "float32" + }, + "step": { + "data": -0.6248052716255188, + "type": "float32" + } + }, + "outputShape": [2, 2, 2, 3], + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 0.22992068529129028, + -0.3948845863342285, + -1.0196897983551025, + -1.6444951295852661, + -2.2693004608154297, + -2.8941056728363037, + -3.5189108848571777, + -4.143716335296631, + -4.768521308898926, + -5.393326759338379, + -6.018132209777832, + -6.642937183380127, + -7.26774263381958, + -7.892547607421875, + -8.517353057861328, + -9.142158508300781, + -9.766963958740234, + -10.391769409179688, + -11.016573905944824, + -11.641379356384277, + -12.26618480682373, + -12.890990257263184, + -13.515795707702637, + -14.140600204467773 + ], + "type": "float32" + } + }, + { + "name": "constant float32 5D tensor of default float32 type", + "inputs": { + "start": { + "data": 0.22992068529129028, + "type": "float32" + }, + "step": { + "data": 0.7537541389465332, + "type": "float32" + } + }, + "outputShape": [2, 1, 4, 1, 3], + "expected": { + "name": "output", + "shape": [2, 1, 4, 1, 3], + "data": [ + 0.22992068529129028, + 0.9836748242378235, + 1.737428903579712, + 2.491183042526245, + 3.2449371814727783, + 3.9986913204193115, + 4.752445697784424, + 5.506199836730957, + 6.25995397567749, + 7.013708114624023, + 7.767462253570557, + 8.52121639251709, + 9.274970054626465, + 10.028724670410156, + 10.782478332519531, + 11.536232948303223, + 12.289986610412598, + 13.043741226196289, + 13.797494888305664, + 14.551249504089355, + 15.30500316619873, + 16.058757781982422, + 16.812511444091797, + 17.566265106201172 + ], + "type": "float32" + } + }, + { + "name": "constant float32 4D tensor of explict float32 type", + "inputs": { + "start": { + "data": 0.22992068529129028, + "type": "float32" + }, + "step": { + "data": 0.7537541389465332, + "type": "float32" + } + }, + "outputShape": [2, 2, 2, 3], + "type": "float32", + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 0.22992068529129028, + 0.9836748242378235, + 1.737428903579712, + 2.491183042526245, + 3.2449371814727783, + 3.9986913204193115, + 4.752445697784424, + 5.506199836730957, + 6.25995397567749, + 7.013708114624023, + 7.767462253570557, + 8.52121639251709, + 9.274970054626465, + 10.028724670410156, + 10.782478332519531, + 11.536232948303223, + 12.289986610412598, + 13.043741226196289, + 13.797494888305664, + 14.551249504089355, + 15.30500316619873, + 16.058757781982422, + 16.812511444091797, + 17.566265106201172 + ], + "type": "float32" + } + }, + { + "name": "constant float32 4D tensor of float16 type", + "inputs": { + "start": { + "data": 0.22992068529129028, + "type": "float32" + }, + "step": { + "data": 0.7537541389465332, + "type": "float32" + } + }, + "outputShape": [2, 2, 2, 3], + "type": "float16", + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 0.22998046875, + 0.98388671875, + 1.7373046875, + 2.490234375, + 3.244140625, + 3.998046875, + 4.75390625, + 5.5078125, + 6.26171875, + 7.015625, + 7.765625, + 8.5234375, + 9.2734375, + 10.03125, + 10.78125, + 11.5390625, + 12.2890625, + 13.046875, + 13.796875, + 14.5546875, + 15.3046875, + 16.0625, + 16.8125, + 17.5625 + ], + "type": "float16" + } + }, + { + "name": "constant float32 4D tensor of int32 type", + "inputs": { + "start": { + "data": 7, + "type": "float32" + }, + "step": { + "data": 1, + "type": "float32" + } + }, + "outputShape": [2, 2, 2, 3], + "type": "int32", + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30 + ], + "type": "int32" + } + }, + { + "name": "constant float32 4D tensor of uint32 type", + "inputs": { + "start": { + "data": 7, + "type": "float32" + }, + "step": { + "data": 1, + "type": "float32" + } + }, + "outputShape": [2, 2, 2, 3], + "type": "uint32", + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30 + ], + "type": "uint32" + } + }, + { + "name": "constant float32 4D tensor of int64 type", + "inputs": { + "start": { + "data": 7, + "type": "float32" + }, + "step": { + "data": 1, + "type": "float32" + } + }, + "outputShape": [2, 2, 2, 3], + "type": "int64", + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + "7", + "8", + "9", + "10", + "11", + "12", + "13", + "14", + "15", + "16", + "17", + "18", + "19", + "20", + "21", + "22", + "23", + "24", + "25", + "26", + "27", + "28", + "29", + "30" + ], + "type": "int64" + } + }, + { + "name": "constant float32 4D tensor of int8 type step > 0", + "inputs": { + "start": { + "data": -9, + "type": "float32" + }, + "step": { + "data": 1, + "type": "float32" + } + }, + "outputShape": [2, 2, 2, 3], + "type": "int8", + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + -9, + -8, + -7, + -6, + -5, + -4, + -3, + -2, + -1, + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14 + ], + "type": "int8" + } + }, + { + "name": "constant float32 4D tensor of int8 type step < 0", + "inputs": { + "start": { + "data": 7, + "type": "float32" + }, + "step": { + "data": -2, + "type": "float32" + } + }, + "outputShape": [2, 2, 2, 3], + "type": "int8", + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 7, + 5, + 3, + 1, + -1, + -3, + -5, + -7, + -9, + -11, + -13, + -15, + -17, + -19, + -21, + -23, + -25, + -27, + -29, + -31, + -33, + -35, + -37, + -39 + ], + "type": "int8" + } + }, + { + "name": "constant float32 4D tensor of uint8 type", + "inputs": { + "start": { + "data": 7, + "type": "float32" + }, + "step": { + "data": 1, + "type": "float32" + } + }, + "outputShape": [2, 2, 2, 3], + "type": "uint8", + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30 + ], + "type": "uint8" + } + } + ] +} \ No newline at end of file diff --git a/testing/web-platform/tests/webnn/resources/test_data/conv2d.json b/testing/web-platform/tests/webnn/resources/test_data/conv2d.json index 5f8cd814a9..13e6b17242 100644 --- a/testing/web-platform/tests/webnn/resources/test_data/conv2d.json +++ b/testing/web-platform/tests/webnn/resources/test_data/conv2d.json @@ -420,356 +420,6 @@ "type": "float32" } }, - { - "name": "conv2d float32 4D input and filter tensors options.padding and options.autoPad='explicit'", - "inputs": { - "input": { - "shape": [1, 1, 5, 5], - "data": [ - 0.6124474607869732, - 0.8857858599952035, - 0.13667134799354397, - 0.564529098909835, - 0.8965171985225997, - 0.36792828664768873, - 0.6811466319147079, - 0.04795110047019757, - 0.33355462154327986, - 0.19882695924603588, - 0.4116714070095846, - 0.07934240242135737, - 0.42724633975875426, - 0.5358005687699703, - 0.5910805999797129, - 0.2841543363273238, - 0.414725865128835, - 0.026906268886554896, - 0.3621256577250671, - 0.9945681862504354, - 0.07184549434969778, - 0.1220437231354885, - 0.8422137325421886, - 0.4537501021068471, - 0.2152944303497728 - ], - "type": "float32" - }, - "filter": { - "shape": [1, 1, 3, 3], - "data": [ - 0.3804761331189006, - 0.5280312082437455, - 0.2194703660873738, - 0.3668976886827289, - 0.33974137307686836, - 0.42000596251782674, - 0.38050310131155185, - 0.19443586243810795, - 0.5686976617292392 - ], - "type": "float32", - "constant": true - } - }, - "options": { - "padding": [1, 1, 1, 1], - "autoPad": "explicit" - }, - "expected": { - "name": "output", - "shape": [1, 1, 5, 5], - "data": [ - 1.0390141010284424, - 0.882753312587738, - 1.0667248964309692, - 0.8146538734436035, - 0.6772860884666443, - 1.0540467500686646, - 1.5323282480239868, - 1.3573521375656128, - 1.3641656637191772, - 1.1969101428985596, - 0.8080586791038513, - 1.071682333946228, - 1.1259644031524658, - 1.4713115692138672, - 0.960464596748352, - 0.5888903141021729, - 1.078782320022583, - 1.155018925666809, - 1.656954288482666, - 1.2012416124343872, - 0.3167303800582886, - 0.7545653581619263, - 0.7729666829109192, - 0.9733180403709412, - 0.9025675058364868 - ], - "type": "float32" - } - }, - { - "name": "conv2d float32 4D input and filter tensors options.autoPad='same-upper'", - "inputs": { - "input": { - "shape": [1, 1, 4, 4], - "data": [ - 0.9371488026117993, - 0.4742464662522563, - 0.6571340852996714, - 0.8399660616881559, - 0.3286228380482863, - 0.09911389391233816, - 0.008774675079729732, - 0.49592297038960576, - 0.6906991955372042, - 0.40363236211387643, - 0.08385655421112803, - 0.7818648489403492, - 0.7862677667715321, - 0.8178903833064657, - 0.9872956148300345, - 0.1289262831549154 - ], - "type": "float32" - }, - "filter": { - "shape": [1, 1, 3, 3], - "data": [ - 0.3804761331189006, - 0.5280312082437455, - 0.2194703660873738, - 0.3668976886827289, - 0.33974137307686836, - 0.42000596251782674, - 0.38050310131155185, - 0.19443586243810795, - 0.5686976617292392 - ], - "type": "float32", - "constant": true - } - }, - "options": { - "strides": [2, 2], - "autoPad": "same-upper" - }, - "expected": { - "name": "output", - "shape": [1, 1, 2, 2], - "data": [ - 1.298113465309143, - 1.0491873025894165, - 1.475350260734558, - 0.8507925271987915 - ], - "type": "float32" - } - }, - { - "name": "conv2d float32 4D input and filter tensors options.autoPad='same-upper' ignores options.padding", - "inputs": { - "input": { - "shape": [1, 1, 4, 4], - "data": [ - 0.9371488026117993, - 0.4742464662522563, - 0.6571340852996714, - 0.8399660616881559, - 0.3286228380482863, - 0.09911389391233816, - 0.008774675079729732, - 0.49592297038960576, - 0.6906991955372042, - 0.40363236211387643, - 0.08385655421112803, - 0.7818648489403492, - 0.7862677667715321, - 0.8178903833064657, - 0.9872956148300345, - 0.1289262831549154 - ], - "type": "float32" - }, - "filter": { - "shape": [1, 1, 3, 3], - "data": [ - 0.3804761331189006, - 0.5280312082437455, - 0.2194703660873738, - 0.3668976886827289, - 0.33974137307686836, - 0.42000596251782674, - 0.38050310131155185, - 0.19443586243810795, - 0.5686976617292392 - ], - "type": "float32", - "constant": true - } - }, - "options": { - "padding": [1, 2, 1, 2], - "strides": [2, 2], - "autoPad": "same-upper" - }, - "expected": { - "name": "output", - "shape": [1, 1, 2, 2], - "data": [ - 1.298113465309143, - 1.0491873025894165, - 1.475350260734558, - 0.8507925271987915 - ], - "type": "float32" - } - }, - { - "name": "conv2d float32 4D input and filter tensors options.autoPad='same-lower'", - "inputs": { - "input": { - "shape": [1, 1, 5, 5], - "data": [ - 0.6124474607869732, - 0.8857858599952035, - 0.13667134799354397, - 0.564529098909835, - 0.8965171985225997, - 0.36792828664768873, - 0.6811466319147079, - 0.04795110047019757, - 0.33355462154327986, - 0.19882695924603588, - 0.4116714070095846, - 0.07934240242135737, - 0.42724633975875426, - 0.5358005687699703, - 0.5910805999797129, - 0.2841543363273238, - 0.414725865128835, - 0.026906268886554896, - 0.3621256577250671, - 0.9945681862504354, - 0.07184549434969778, - 0.1220437231354885, - 0.8422137325421886, - 0.4537501021068471, - 0.2152944303497728 - ], - "type": "float32" - }, - "filter": { - "shape": [1, 1, 3, 3], - "data": [ - 0.3804761331189006, - 0.5280312082437455, - 0.2194703660873738, - 0.3668976886827289, - 0.33974137307686836, - 0.42000596251782674, - 0.38050310131155185, - 0.19443586243810795, - 0.5686976617292392 - ], - "type": "float32", - "constant": true - } - }, - "options": { - "strides": [2, 2], - "autoPad": "same-lower" - }, - "expected": { - "name": "output", - "shape": [1, 1, 3, 3], - "data": [ - 1.0390141010284424, - 1.0667248964309692, - 0.6772860884666443, - 0.8080586791038513, - 1.1259644031524658, - 0.960464596748352, - 0.3167303800582886, - 0.7729666829109192, - 0.9025675058364868 - ], - "type": "float32" - } - }, - { - "name": "conv2d float32 4D input and filter tensors options.autoPad='same-lower' ignores options.padding", - "inputs": { - "input": { - "shape": [1, 1, 5, 5], - "data": [ - 0.6124474607869732, - 0.8857858599952035, - 0.13667134799354397, - 0.564529098909835, - 0.8965171985225997, - 0.36792828664768873, - 0.6811466319147079, - 0.04795110047019757, - 0.33355462154327986, - 0.19882695924603588, - 0.4116714070095846, - 0.07934240242135737, - 0.42724633975875426, - 0.5358005687699703, - 0.5910805999797129, - 0.2841543363273238, - 0.414725865128835, - 0.026906268886554896, - 0.3621256577250671, - 0.9945681862504354, - 0.07184549434969778, - 0.1220437231354885, - 0.8422137325421886, - 0.4537501021068471, - 0.2152944303497728 - ], - "type": "float32" - }, - "filter": { - "shape": [1, 1, 3, 3], - "data": [ - 0.3804761331189006, - 0.5280312082437455, - 0.2194703660873738, - 0.3668976886827289, - 0.33974137307686836, - 0.42000596251782674, - 0.38050310131155185, - 0.19443586243810795, - 0.5686976617292392 - ], - "type": "float32", - "constant": true - } - }, - "options": { - "padding": [1, 2, 1, 2], - "strides": [2, 2], - "autoPad": "same-lower" - }, - "expected": { - "name": "output", - "shape": [1, 1, 3, 3], - "data": [ - 1.0390141010284424, - 1.0667248964309692, - 0.6772860884666443, - 0.8080586791038513, - 1.1259644031524658, - 0.960464596748352, - 0.3167303800582886, - 0.7729666829109192, - 0.9025675058364868 - ], - "type": "float32" - } - }, { "name": "depthwise conv2d float32 4D input and filter tensors options.groups= input_channels", "inputs": { @@ -1990,7 +1640,6 @@ "options": { "padding": [1, 0, 0, 1], "strides": [1, 1], - "autoPad": "explicit", "dilations": [1, 1], "groups": 2, "inputLayout": "nchw", diff --git a/testing/web-platform/tests/webnn/resources/test_data/conv_transpose2d.json b/testing/web-platform/tests/webnn/resources/test_data/conv_transpose2d.json index 42274e6fa3..742752fd41 100644 --- a/testing/web-platform/tests/webnn/resources/test_data/conv_transpose2d.json +++ b/testing/web-platform/tests/webnn/resources/test_data/conv_transpose2d.json @@ -971,553 +971,6 @@ "type": "float32" } }, - { - "name": "convTranspose2d float32 4D input and filter tensors options.autoPad=explicit options.padding", - "inputs": { - "input": { - "shape": [1, 1, 2, 2], - "data": [ - 0.5872158177067033, - 0.6077792328258038, - 0.01728916618181975, - 0.26146076483771563 - ], - "type": "float32" - }, - "filter": { - "shape": [1, 1, 2, 2], - "data": [ - 0.32927132527587477, - 0.5866857173772775, - 0.29701370673751004, - 0.0033378428248385106 - ], - "type": "float32", - "constant": true - } - }, - "options": { - "padding": [1, 1, 1, 1], - "autoPad": "explicit" - }, - "expected": { - "shape": [1, 1, 1, 1], - "data": [ - 0.2787136137485504 - ], - "type": "float32" - } - }, - { - "name": "convTranspose2d float32 4D input and filter tensors options.autoPad=same-upper", - "inputs": { - "input": { - "shape": [1, 1, 3, 3], - "data": [ - 0.05605664967552748, - 0.7114230061939892, - 0.6529743817798401, - 0.3862290922141163, - 0.38708372734474095, - 0.9461629334832131, - 0.0957319185290193, - 0.9234652551205444, - 0.6362779541136516 - ], - "type": "float32" - }, - "filter": { - "shape": [1, 2, 3, 3], - "data": [ - 0.861442276299335, - 0.6267672619279181, - 0.6366489967621862, - 0.8382642064548715, - 0.11884837321114183, - 0.9921330460504791, - 0.3285411258903119, - 0.8742373539889388, - 0.7205492498486465, - 0.9801966684571415, - 0.06169835353027997, - 0.3220160786486479, - 0.7498031716529909, - 0.39307147694602995, - 0.1381193362338462, - 0.283850915413119, - 0.4235861336377129, - 0.14485120857485168 - ], - "type": "float32", - "constant": true - } - }, - "options": { - "strides": [2, 2], - "autoPad": "same-upper" - }, - "expected": { - "shape": [1, 2, 6, 6], - "data": [ - 0.04828956723213196, - 0.03513447195291519, - 0.6485382318496704, - 0.4458966553211212, - 1.015426516532898, - 0.4092629551887512, - 0.0469902828335762, - 0.0066622416488826275, - 0.6519761085510254, - 0.08455146849155426, - 1.2531912326812744, - 0.07760494202375412, - 0.35113099217414856, - 0.29108259081840515, - 0.8534659743309021, - 0.8645639419555664, - 1.7886453866958618, - 1.1638785600662231, - 0.32376202940940857, - 0.04590269923210144, - 0.7076690793037415, - 0.0460042729973793, - 1.177173137664795, - 0.11244992911815643, - 0.20935966074466705, - 0.3976575434207916, - 1.2619296312332153, - 0.9172008633613586, - 1.7258063554763794, - 1.2259691953659058, - 0.0802486464381218, - 0.011377583257853985, - 0.8690866827964783, - 0.1097523421049118, - 1.4495694637298584, - 0.0756206065416336, - 0.05494653806090355, - 0.0034586030524224043, - 0.7153855562210083, - 0.04389362782239914, - 0.869132936000824, - 0.04028744250535965, - 0.04203145205974579, - 0.02203426882624626, - 0.5411697030067444, - 0.2796400785446167, - 0.5878635048866272, - 0.25666558742523193, - 0.3944922089576721, - 0.047574520111083984, - 0.7138481140136719, - 0.3252313435077667, - 1.340470790863037, - 0.33496758341789246, - 0.2895958125591278, - 0.15181563794612885, - 0.3435823321342468, - 0.15215156972408295, - 0.7628997564315796, - 0.37190964818000793, - 0.20346759259700775, - 0.16950778663158417, - 1.1018246412277222, - 0.22093959152698517, - 1.2456870079040527, - 0.440038800239563, - 0.07178010046482086, - 0.03762948885560036, - 0.7056396007537842, - 0.36298784613609314, - 0.6046316623687744, - 0.2501027286052704 - ], - "type": "float32" - } - }, - { - "name": "convTranspose2d float32 4D input and filter tensors options.autoPad=same-upper ignored options.padding", - "inputs": { - "input": { - "shape": [1, 1, 3, 3], - "data": [ - 0.05605664967552748, - 0.7114230061939892, - 0.6529743817798401, - 0.3862290922141163, - 0.38708372734474095, - 0.9461629334832131, - 0.0957319185290193, - 0.9234652551205444, - 0.6362779541136516 - ], - "type": "float32" - }, - "filter": { - "shape": [1, 2, 3, 3], - "data": [ - 0.861442276299335, - 0.6267672619279181, - 0.6366489967621862, - 0.8382642064548715, - 0.11884837321114183, - 0.9921330460504791, - 0.3285411258903119, - 0.8742373539889388, - 0.7205492498486465, - 0.9801966684571415, - 0.06169835353027997, - 0.3220160786486479, - 0.7498031716529909, - 0.39307147694602995, - 0.1381193362338462, - 0.283850915413119, - 0.4235861336377129, - 0.14485120857485168 - ], - "type": "float32", - "constant": true - } - }, - "options": { - "padding": [1, 1, 1, 1], - "strides": [2, 2], - "autoPad": "same-upper" - }, - "expected": { - "shape": [1, 2, 6, 6], - "data": [ - 0.04828956723213196, - 0.03513447195291519, - 0.6485382318496704, - 0.4458966553211212, - 1.015426516532898, - 0.4092629551887512, - 0.0469902828335762, - 0.0066622416488826275, - 0.6519761085510254, - 0.08455146849155426, - 1.2531912326812744, - 0.07760494202375412, - 0.35113099217414856, - 0.29108259081840515, - 0.8534659743309021, - 0.8645639419555664, - 1.7886453866958618, - 1.1638785600662231, - 0.32376202940940857, - 0.04590269923210144, - 0.7076690793037415, - 0.0460042729973793, - 1.177173137664795, - 0.11244992911815643, - 0.20935966074466705, - 0.3976575434207916, - 1.2619296312332153, - 0.9172008633613586, - 1.7258063554763794, - 1.2259691953659058, - 0.0802486464381218, - 0.011377583257853985, - 0.8690866827964783, - 0.1097523421049118, - 1.4495694637298584, - 0.0756206065416336, - 0.05494653806090355, - 0.0034586030524224043, - 0.7153855562210083, - 0.04389362782239914, - 0.869132936000824, - 0.04028744250535965, - 0.04203145205974579, - 0.02203426882624626, - 0.5411697030067444, - 0.2796400785446167, - 0.5878635048866272, - 0.25666558742523193, - 0.3944922089576721, - 0.047574520111083984, - 0.7138481140136719, - 0.3252313435077667, - 1.340470790863037, - 0.33496758341789246, - 0.2895958125591278, - 0.15181563794612885, - 0.3435823321342468, - 0.15215156972408295, - 0.7628997564315796, - 0.37190964818000793, - 0.20346759259700775, - 0.16950778663158417, - 1.1018246412277222, - 0.22093959152698517, - 1.2456870079040527, - 0.440038800239563, - 0.07178010046482086, - 0.03762948885560036, - 0.7056396007537842, - 0.36298784613609314, - 0.6046316623687744, - 0.2501027286052704 - ], - "type": "float32" - } - }, - { - "name": "convTranspose2d float32 4D input and filter tensors options.autoPad=same-lower", - "inputs": { - "input": { - "shape": [1, 1, 3, 3], - "data": [ - 0.05605664967552748, - 0.7114230061939892, - 0.6529743817798401, - 0.3862290922141163, - 0.38708372734474095, - 0.9461629334832131, - 0.0957319185290193, - 0.9234652551205444, - 0.6362779541136516 - ], - "type": "float32" - }, - "filter": { - "shape": [1, 2, 3, 3], - "data": [ - 0.861442276299335, - 0.6267672619279181, - 0.6366489967621862, - 0.8382642064548715, - 0.11884837321114183, - 0.9921330460504791, - 0.3285411258903119, - 0.8742373539889388, - 0.7205492498486465, - 0.9801966684571415, - 0.06169835353027997, - 0.3220160786486479, - 0.7498031716529909, - 0.39307147694602995, - 0.1381193362338462, - 0.283850915413119, - 0.4235861336377129, - 0.14485120857485168 - ], - "type": "float32", - "constant": true - } - }, - "options": { - "strides": [2, 2], - "autoPad": "same-lower" - }, - "expected": { - "shape": [1, 2, 6, 6], - "data": [ - 0.0066622416488826275, - 0.6519761085510254, - 0.08455146849155426, - 1.2531912326812744, - 0.07760494202375412, - 0.6478374600410461, - 0.29108259081840515, - 0.8534659743309021, - 0.8645639419555664, - 1.7886453866958618, - 1.1638785600662231, - 1.072873830795288, - 0.04590269923210144, - 0.7076690793037415, - 0.0460042729973793, - 1.177173137664795, - 0.11244992911815643, - 0.9387195110321045, - 0.3976575434207916, - 1.2619296312332153, - 0.9172008633613586, - 1.7258063554763794, - 1.2259691953659058, - 1.0868427753448486, - 0.011377583257853985, - 0.8690866827964783, - 0.1097523421049118, - 1.4495694637298584, - 0.0756206065416336, - 0.6312723755836487, - 0.08369242399930954, - 0.37237587571144104, - 0.8073278069496155, - 0.8744456768035889, - 0.556257963180542, - 0.45846959948539734, - 0.02203426882624626, - 0.5411697030067444, - 0.2796400785446167, - 0.5878635048866272, - 0.25666558742523193, - 0.0901883915066719, - 0.047574520111083984, - 0.7138481140136719, - 0.3252313435077667, - 1.340470790863037, - 0.33496758341789246, - 0.39926382899284363, - 0.15181563794612885, - 0.3435823321342468, - 0.15215156972408295, - 0.7628997564315796, - 0.37190964818000793, - 0.13068340718746185, - 0.16950778663158417, - 1.1018246412277222, - 0.22093959152698517, - 1.2456870079040527, - 0.440038800239563, - 0.3419445753097534, - 0.03762948885560036, - 0.7056396007537842, - 0.36298784613609314, - 0.6046316623687744, - 0.2501027286052704, - 0.08788229525089264, - 0.04055071249604225, - 0.27599334716796875, - 0.3911670744419098, - 0.3143731355667114, - 0.26951852440834045, - 0.09216563403606415 - ], - "type": "float32" - } - }, - { - "name": "convTranspose2d float32 4D input and filter tensors options.autoPad=same-lower ignored options.padding", - "inputs": { - "input": { - "shape": [1, 1, 3, 3], - "data": [ - 0.05605664967552748, - 0.7114230061939892, - 0.6529743817798401, - 0.3862290922141163, - 0.38708372734474095, - 0.9461629334832131, - 0.0957319185290193, - 0.9234652551205444, - 0.6362779541136516 - ], - "type": "float32" - }, - "filter": { - "shape": [1, 2, 3, 3], - "data": [ - 0.861442276299335, - 0.6267672619279181, - 0.6366489967621862, - 0.8382642064548715, - 0.11884837321114183, - 0.9921330460504791, - 0.3285411258903119, - 0.8742373539889388, - 0.7205492498486465, - 0.9801966684571415, - 0.06169835353027997, - 0.3220160786486479, - 0.7498031716529909, - 0.39307147694602995, - 0.1381193362338462, - 0.283850915413119, - 0.4235861336377129, - 0.14485120857485168 - ], - "type": "float32", - "constant": true - } - }, - "options": { - "padding": [1, 1, 1, 1], - "strides": [2, 2], - "autoPad": "same-lower" - }, - "expected": { - "shape": [1, 2, 6, 6], - "data": [ - 0.0066622416488826275, - 0.6519761085510254, - 0.08455146849155426, - 1.2531912326812744, - 0.07760494202375412, - 0.6478374600410461, - 0.29108259081840515, - 0.8534659743309021, - 0.8645639419555664, - 1.7886453866958618, - 1.1638785600662231, - 1.072873830795288, - 0.04590269923210144, - 0.7076690793037415, - 0.0460042729973793, - 1.177173137664795, - 0.11244992911815643, - 0.9387195110321045, - 0.3976575434207916, - 1.2619296312332153, - 0.9172008633613586, - 1.7258063554763794, - 1.2259691953659058, - 1.0868427753448486, - 0.011377583257853985, - 0.8690866827964783, - 0.1097523421049118, - 1.4495694637298584, - 0.0756206065416336, - 0.6312723755836487, - 0.08369242399930954, - 0.37237587571144104, - 0.8073278069496155, - 0.8744456768035889, - 0.556257963180542, - 0.45846959948539734, - 0.02203426882624626, - 0.5411697030067444, - 0.2796400785446167, - 0.5878635048866272, - 0.25666558742523193, - 0.0901883915066719, - 0.047574520111083984, - 0.7138481140136719, - 0.3252313435077667, - 1.340470790863037, - 0.33496758341789246, - 0.39926382899284363, - 0.15181563794612885, - 0.3435823321342468, - 0.15215156972408295, - 0.7628997564315796, - 0.37190964818000793, - 0.13068340718746185, - 0.16950778663158417, - 1.1018246412277222, - 0.22093959152698517, - 1.2456870079040527, - 0.440038800239563, - 0.3419445753097534, - 0.03762948885560036, - 0.7056396007537842, - 0.36298784613609314, - 0.6046316623687744, - 0.2501027286052704, - 0.08788229525089264, - 0.04055071249604225, - 0.27599334716796875, - 0.3911670744419098, - 0.3143731355667114, - 0.26951852440834045, - 0.09216563403606415 - ], - "type": "float32" - } - }, { "name": "convTranspose2d float32 4D input and filter tensors options.inputLayout=nchw", "inputs": { diff --git a/testing/web-platform/tests/webnn/resources/test_data/l2_pool2d.json b/testing/web-platform/tests/webnn/resources/test_data/l2_pool2d.json new file mode 100644 index 0000000000..a65687721a --- /dev/null +++ b/testing/web-platform/tests/webnn/resources/test_data/l2_pool2d.json @@ -0,0 +1,1174 @@ +{ + "tests": [ + { + "name": "l2Pool2d float32 4D constant tensor all positive default options", + "inputs": { + "input": { + "shape": [1, 2, 5, 5], + "data": [ + 94.07447814941406, + 76.55464172363281, + 62.71847152709961, + 83.8726577758789, + 73.10235595703125, + 41.52470779418945, + 39.3339729309082, + 86.59486389160156, + 23.09039306640625, + 53.650146484375, + 0.00902052316814661, + 42.78899383544922, + 81.03960418701172, + 33.48585510253906, + 33.67196273803711, + 0.42822372913360596, + 80.07991790771484, + 5.929991722106934, + 48.89164733886719, + 15.282920837402344, + 13.335721969604492, + 39.06557846069336, + 97.06050109863281, + 83.68133544921875, + 21.79571533203125, + 52.027313232421875, + 6.397815227508545, + 84.54785919189453, + 18.622516632080078, + 34.10626220703125, + 73.96932220458984, + 36.1437873840332, + 60.73781967163086, + 55.09187316894531, + 63.8924446105957, + 59.36124038696289, + 50.91202926635742, + 50.339813232421875, + 59.31963348388672, + 70.78031921386719, + 35.56179428100586, + 82.53382873535156, + 7.572360038757324, + 61.90089416503906, + 14.084012985229492, + 90.86540985107422, + 39.56248474121094, + 67.77167510986328, + 69.69512176513672, + 89.54518127441406 + ], + "type": "float32", + "constant": true + } + }, + "expected": { + "name": "output", + "shape": [1, 2, 1, 1], + "data": [ + 289.01953125, + 292.6146545410156 + ], + "type": "float32" + } + }, + { + "name": "l2Pool2d float32 4D tensor default all positive options", + "inputs": { + "input": { + "shape": [1, 2, 5, 5], + "data": [ + 94.07447814941406, + 76.55464172363281, + 62.71847152709961, + 83.8726577758789, + 73.10235595703125, + 41.52470779418945, + 39.3339729309082, + 86.59486389160156, + 23.09039306640625, + 53.650146484375, + 0.00902052316814661, + 42.78899383544922, + 81.03960418701172, + 33.48585510253906, + 33.67196273803711, + 0.42822372913360596, + 80.07991790771484, + 5.929991722106934, + 48.89164733886719, + 15.282920837402344, + 13.335721969604492, + 39.06557846069336, + 97.06050109863281, + 83.68133544921875, + 21.79571533203125, + 52.027313232421875, + 6.397815227508545, + 84.54785919189453, + 18.622516632080078, + 34.10626220703125, + 73.96932220458984, + 36.1437873840332, + 60.73781967163086, + 55.09187316894531, + 63.8924446105957, + 59.36124038696289, + 50.91202926635742, + 50.339813232421875, + 59.31963348388672, + 70.78031921386719, + 35.56179428100586, + 82.53382873535156, + 7.572360038757324, + 61.90089416503906, + 14.084012985229492, + 90.86540985107422, + 39.56248474121094, + 67.77167510986328, + 69.69512176513672, + 89.54518127441406 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [1, 2, 1, 1], + "data": [ + 289.01953125, + 292.6146545410156 + ], + "type": "float32" + } + }, + { + "name": "l2Pool2d float32 4D tensor default all negative options", + "inputs": { + "input": { + "shape": [1, 2, 5, 5], + "data": [ + -1.1957088708877563, + -9.706199645996094, + -39.54935836791992, + -82.34971618652344, + -32.87415313720703, + -50.22603225708008, + -31.17849349975586, + -55.817893981933594, + -46.70829391479492, + -38.68181228637695, + -63.299320220947266, + -35.09224319458008, + -80.93848419189453, + -82.8619613647461, + -40.41627502441406, + -34.86458206176758, + -84.33639526367188, + -84.11852264404297, + -5.525088787078857, + -99.03114318847656, + -75.505126953125, + -91.43389129638672, + -96.71258544921875, + -16.722585678100586, + -17.98292350769043, + -58.06570816040039, + -11.846800804138184, + -97.90313720703125, + -38.69822692871094, + -80.19510650634766, + -48.72047805786133, + -90.86722564697266, + -99.10758209228516, + -79.70288848876953, + -59.3824462890625, + -9.967330932617188, + -39.27534866333008, + -10.469644546508789, + -27.565326690673828, + -2.0468990802764893, + -81.88761901855469, + -66.88040161132812, + -85.98504638671875, + -29.674592971801758, + -19.649417877197266, + -89.39192199707031, + -61.13504409790039, + -84.16869354248047, + -77.36112213134766, + -91.17266082763672 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [1, 2, 1, 1], + "data": [ + 298.928955078125, + 326.83587646484375 + ], + "type": "float32" + } + }, + { + "name": "l2Pool2d float32 4D tensor options.windowDimensions", + "inputs": { + "input": { + "shape": [1, 2, 5, 5], + "data": [ + 94.07447814941406, + 76.55464172363281, + 62.71847152709961, + 83.8726577758789, + 73.10235595703125, + 41.52470779418945, + 39.3339729309082, + 86.59486389160156, + 23.09039306640625, + 53.650146484375, + 0.00902052316814661, + 42.78899383544922, + 81.03960418701172, + 33.48585510253906, + 33.67196273803711, + 0.42822372913360596, + 80.07991790771484, + 5.929991722106934, + 48.89164733886719, + 15.282920837402344, + 13.335721969604492, + 39.06557846069336, + 97.06050109863281, + 83.68133544921875, + 21.79571533203125, + 52.027313232421875, + 6.397815227508545, + 84.54785919189453, + 18.622516632080078, + 34.10626220703125, + 73.96932220458984, + 36.1437873840332, + 60.73781967163086, + 55.09187316894531, + 63.8924446105957, + 59.36124038696289, + 50.91202926635742, + 50.339813232421875, + 59.31963348388672, + 70.78031921386719, + 35.56179428100586, + 82.53382873535156, + 7.572360038757324, + 61.90089416503906, + 14.084012985229492, + 90.86540985107422, + 39.56248474121094, + 67.77167510986328, + 69.69512176513672, + 89.54518127441406 + ], + "type": "float32" + } + }, + "options": { + "windowDimensions": [3, 3] + }, + "expected": { + "name": "output", + "shape": [1, 2, 3, 3], + "data": [ + 194.45481872558594, + 189.54539489746094, + 189.85488891601562, + 160.0518341064453, + 167.1435546875, + 149.63897705078125, + 161.15570068359375, + 190.5449981689453, + 168.4636688232422, + 170.331787109375, + 155.60073852539062, + 174.72145080566406, + 165.07762145996094, + 165.45819091796875, + 161.11062622070312, + 176.6307373046875, + 174.245361328125, + 180.60714721679688 + ], + "type": "float32" + } + }, + { + "name": "l2Pool2d float32 4D tensor options.padding", + "inputs": { + "input": { + "shape": [1, 2, 5, 5], + "data": [ + 94.07447814941406, + 76.55464172363281, + 62.71847152709961, + 83.8726577758789, + 73.10235595703125, + 41.52470779418945, + 39.3339729309082, + 86.59486389160156, + 23.09039306640625, + 53.650146484375, + 0.00902052316814661, + 42.78899383544922, + 81.03960418701172, + 33.48585510253906, + 33.67196273803711, + 0.42822372913360596, + 80.07991790771484, + 5.929991722106934, + 48.89164733886719, + 15.282920837402344, + 13.335721969604492, + 39.06557846069336, + 97.06050109863281, + 83.68133544921875, + 21.79571533203125, + 52.027313232421875, + 6.397815227508545, + 84.54785919189453, + 18.622516632080078, + 34.10626220703125, + 73.96932220458984, + 36.1437873840332, + 60.73781967163086, + 55.09187316894531, + 63.8924446105957, + 59.36124038696289, + 50.91202926635742, + 50.339813232421875, + 59.31963348388672, + 70.78031921386719, + 35.56179428100586, + 82.53382873535156, + 7.572360038757324, + 61.90089416503906, + 14.084012985229492, + 90.86540985107422, + 39.56248474121094, + 67.77167510986328, + 69.69512176513672, + 89.54518127441406 + ], + "type": "float32" + } + }, + "options": { + "padding": [1, 0, 0, 1] + }, + "expected": { + "name": "output", + "shape": [1, 2, 2, 2], + "data": [ + 254.81358337402344, + 233.14259338378906, + 289.01953125, + 269.777587890625, + 241.52200317382812, + 212.99337768554688, + 292.6146545410156, + 253.77178955078125 + ], + "type": "float32" + } + }, + { + "name": "l2Pool2d float32 4D tensor options.strides", + "inputs": { + "input": { + "shape": [1, 2, 5, 5], + "data": [ + 94.07447814941406, + 76.55464172363281, + 62.71847152709961, + 83.8726577758789, + 73.10235595703125, + 41.52470779418945, + 39.3339729309082, + 86.59486389160156, + 23.09039306640625, + 53.650146484375, + 0.00902052316814661, + 42.78899383544922, + 81.03960418701172, + 33.48585510253906, + 33.67196273803711, + 0.42822372913360596, + 80.07991790771484, + 5.929991722106934, + 48.89164733886719, + 15.282920837402344, + 13.335721969604492, + 39.06557846069336, + 97.06050109863281, + 83.68133544921875, + 21.79571533203125, + 52.027313232421875, + 6.397815227508545, + 84.54785919189453, + 18.622516632080078, + 34.10626220703125, + 73.96932220458984, + 36.1437873840332, + 60.73781967163086, + 55.09187316894531, + 63.8924446105957, + 59.36124038696289, + 50.91202926635742, + 50.339813232421875, + 59.31963348388672, + 70.78031921386719, + 35.56179428100586, + 82.53382873535156, + 7.572360038757324, + 61.90089416503906, + 14.084012985229492, + 90.86540985107422, + 39.56248474121094, + 67.77167510986328, + 69.69512176513672, + 89.54518127441406 + ], + "type": "float32" + } + }, + "options": { + "windowDimensions": [3, 3], + "strides": [2, 2] + }, + "expected": { + "name": "output", + "shape": [1, 2, 2, 2], + "data": [ + 194.45481872558594, + 189.85488891601562, + 161.15570068359375, + 168.4636688232422, + 170.331787109375, + 174.72145080566406, + 176.6307373046875, + 180.60714721679688 + ], + "type": "float32" + } + }, + { + "name": "l2Pool2d float32 4D tensor options.dilations", + "inputs": { + "input": { + "shape": [1, 2, 5, 5], + "data": [ + 94.07447814941406, + 76.55464172363281, + 62.71847152709961, + 83.8726577758789, + 73.10235595703125, + 41.52470779418945, + 39.3339729309082, + 86.59486389160156, + 23.09039306640625, + 53.650146484375, + 0.00902052316814661, + 42.78899383544922, + 81.03960418701172, + 33.48585510253906, + 33.67196273803711, + 0.42822372913360596, + 80.07991790771484, + 5.929991722106934, + 48.89164733886719, + 15.282920837402344, + 13.335721969604492, + 39.06557846069336, + 97.06050109863281, + 83.68133544921875, + 21.79571533203125, + 52.027313232421875, + 6.397815227508545, + 84.54785919189453, + 18.622516632080078, + 34.10626220703125, + 73.96932220458984, + 36.1437873840332, + 60.73781967163086, + 55.09187316894531, + 63.8924446105957, + 59.36124038696289, + 50.91202926635742, + 50.339813232421875, + 59.31963348388672, + 70.78031921386719, + 35.56179428100586, + 82.53382873535156, + 7.572360038757324, + 61.90089416503906, + 14.084012985229492, + 90.86540985107422, + 39.56248474121094, + 67.77167510986328, + 69.69512176513672, + 89.54518127441406 + ], + "type": "float32" + } + }, + "options": { + "windowDimensions": [3, 3], + "dilations": [2, 2] + }, + "expected": { + "name": "output", + "shape": [1, 2, 1, 1], + "data": [ + 189.47933959960938, + 207.25343322753906 + ], + "type": "float32" + } + }, + { + "name": "l2Pool2d float32 4D tensor options.layout=nchw", + "inputs": { + "input": { + "shape": [1, 2, 5, 5], + "data": [ + 94.07447814941406, + 76.55464172363281, + 62.71847152709961, + 83.8726577758789, + 73.10235595703125, + 41.52470779418945, + 39.3339729309082, + 86.59486389160156, + 23.09039306640625, + 53.650146484375, + 0.00902052316814661, + 42.78899383544922, + 81.03960418701172, + 33.48585510253906, + 33.67196273803711, + 0.42822372913360596, + 80.07991790771484, + 5.929991722106934, + 48.89164733886719, + 15.282920837402344, + 13.335721969604492, + 39.06557846069336, + 97.06050109863281, + 83.68133544921875, + 21.79571533203125, + 52.027313232421875, + 6.397815227508545, + 84.54785919189453, + 18.622516632080078, + 34.10626220703125, + 73.96932220458984, + 36.1437873840332, + 60.73781967163086, + 55.09187316894531, + 63.8924446105957, + 59.36124038696289, + 50.91202926635742, + 50.339813232421875, + 59.31963348388672, + 70.78031921386719, + 35.56179428100586, + 82.53382873535156, + 7.572360038757324, + 61.90089416503906, + 14.084012985229492, + 90.86540985107422, + 39.56248474121094, + 67.77167510986328, + 69.69512176513672, + 89.54518127441406 + ], + "type": "float32" + } + }, + "options": { + "layout": "nchw" + }, + "expected": { + "name": "output", + "shape": [1, 2, 1, 1], + "data": [ + 289.01953125, + 292.6146545410156 + ], + "type": "float32" + } + }, + { + "name": "l2Pool2d float32 4D tensor options.layout=nhwc", + "inputs": { + "input": { + "shape": [1, 5, 5, 2], + "data": [ + 94.07447814941406, + 52.027313232421875, + 76.55464172363281, + 6.397815227508545, + 62.71847152709961, + 84.54785919189453, + 83.8726577758789, + 18.622516632080078, + 73.10235595703125, + 34.10626220703125, + 41.52470779418945, + 73.96932220458984, + 39.3339729309082, + 36.1437873840332, + 86.59486389160156, + 60.73781967163086, + 23.09039306640625, + 55.09187316894531, + 53.650146484375, + 63.8924446105957, + 0.00902052316814661, + 59.36124038696289, + 42.78899383544922, + 50.91202926635742, + 81.03960418701172, + 50.339813232421875, + 33.48585510253906, + 59.31963348388672, + 33.67196273803711, + 70.78031921386719, + 0.42822372913360596, + 35.56179428100586, + 80.07991790771484, + 82.53382873535156, + 5.929991722106934, + 7.572360038757324, + 48.89164733886719, + 61.90089416503906, + 15.282920837402344, + 14.084012985229492, + 13.335721969604492, + 90.86540985107422, + 39.06557846069336, + 39.56248474121094, + 97.06050109863281, + 67.77167510986328, + 83.68133544921875, + 69.69512176513672, + 21.79571533203125, + 89.54518127441406 + ], + "type": "float32" + } + }, + "options": { + "layout": "nhwc" + }, + "expected": { + "name": "output", + "shape": [1, 1, 1, 2], + "data": [ + 289.01953125, + 292.6146545410156 + ], + "type": "float32" + } + }, + { + "name": "l2Pool2d float32 4D tensor options.roundingType=floor", + "inputs": { + "input": { + "shape": [1, 2, 5, 5], + "data": [ + 94.07447814941406, + 76.55464172363281, + 62.71847152709961, + 83.8726577758789, + 73.10235595703125, + 41.52470779418945, + 39.3339729309082, + 86.59486389160156, + 23.09039306640625, + 53.650146484375, + 0.00902052316814661, + 42.78899383544922, + 81.03960418701172, + 33.48585510253906, + 33.67196273803711, + 0.42822372913360596, + 80.07991790771484, + 5.929991722106934, + 48.89164733886719, + 15.282920837402344, + 13.335721969604492, + 39.06557846069336, + 97.06050109863281, + 83.68133544921875, + 21.79571533203125, + 52.027313232421875, + 6.397815227508545, + 84.54785919189453, + 18.622516632080078, + 34.10626220703125, + 73.96932220458984, + 36.1437873840332, + 60.73781967163086, + 55.09187316894531, + 63.8924446105957, + 59.36124038696289, + 50.91202926635742, + 50.339813232421875, + 59.31963348388672, + 70.78031921386719, + 35.56179428100586, + 82.53382873535156, + 7.572360038757324, + 61.90089416503906, + 14.084012985229492, + 90.86540985107422, + 39.56248474121094, + 67.77167510986328, + 69.69512176513672, + 89.54518127441406 + ], + "type": "float32" + } + }, + "options": { + "windowDimensions": [3, 3], + "padding": [1, 0, 0, 1], + "strides": [2, 2], + "roundingType": "floor" + }, + "expected": { + "name": "output", + "shape": [1, 2, 2, 2], + "data": [ + 171.5061492919922, + 164.9919891357422, + 160.0518341064453, + 149.63897705078125, + 142.6990966796875, + 139.51637268066406, + 165.07762145996094, + 161.11062622070312 + ], + "type": "float32" + } + }, + { + "name": "l2Pool2d float32 4D tensor options.roundingType=ceil", + "inputs": { + "input": { + "shape": [1, 2, 5, 5], + "data": [ + 94.07447814941406, + 76.55464172363281, + 62.71847152709961, + 83.8726577758789, + 73.10235595703125, + 41.52470779418945, + 39.3339729309082, + 86.59486389160156, + 23.09039306640625, + 53.650146484375, + 0.00902052316814661, + 42.78899383544922, + 81.03960418701172, + 33.48585510253906, + 33.67196273803711, + 0.42822372913360596, + 80.07991790771484, + 5.929991722106934, + 48.89164733886719, + 15.282920837402344, + 13.335721969604492, + 39.06557846069336, + 97.06050109863281, + 83.68133544921875, + 21.79571533203125, + 52.027313232421875, + 6.397815227508545, + 84.54785919189453, + 18.622516632080078, + 34.10626220703125, + 73.96932220458984, + 36.1437873840332, + 60.73781967163086, + 55.09187316894531, + 63.8924446105957, + 59.36124038696289, + 50.91202926635742, + 50.339813232421875, + 59.31963348388672, + 70.78031921386719, + 35.56179428100586, + 82.53382873535156, + 7.572360038757324, + 61.90089416503906, + 14.084012985229492, + 90.86540985107422, + 39.56248474121094, + 67.77167510986328, + 69.69512176513672, + 89.54518127441406 + ], + "type": "float32" + } + }, + "options": { + "windowDimensions": [3, 3], + "padding": [1, 0, 0, 1], + "strides": [2, 2], + "roundingType": "ceil" + }, + "expected": { + "name": "output", + "shape": [1, 2, 3, 3], + "data": [ + 171.5061492919922, + 164.9919891357422, + 8222.29296875, + 160.0518341064453, + 149.63897705078125, + 65.15908813476562, + 132.56260681152344, + 139.84808349609375, + 708.620849609375, + 142.6990966796875, + 139.51637268066406, + 5245.4814453125, + 165.07762145996094, + 161.11062622070312, + 96.38701629638672, + 150.1616668701172, + 146.8201904296875, + 8216.69921875 + ], + "type": "float32" + } + }, + { + "name": "l2Pool2d float32 4D tensor options.outputSizes ignores options.roundingType=floor", + "inputs": { + "input": { + "shape": [1, 2, 5, 5], + "data": [ + 94.07447814941406, + 76.55464172363281, + 62.71847152709961, + 83.8726577758789, + 73.10235595703125, + 41.52470779418945, + 39.3339729309082, + 86.59486389160156, + 23.09039306640625, + 53.650146484375, + 0.00902052316814661, + 42.78899383544922, + 81.03960418701172, + 33.48585510253906, + 33.67196273803711, + 0.42822372913360596, + 80.07991790771484, + 5.929991722106934, + 48.89164733886719, + 15.282920837402344, + 13.335721969604492, + 39.06557846069336, + 97.06050109863281, + 83.68133544921875, + 21.79571533203125, + 52.027313232421875, + 6.397815227508545, + 84.54785919189453, + 18.622516632080078, + 34.10626220703125, + 73.96932220458984, + 36.1437873840332, + 60.73781967163086, + 55.09187316894531, + 63.8924446105957, + 59.36124038696289, + 50.91202926635742, + 50.339813232421875, + 59.31963348388672, + 70.78031921386719, + 35.56179428100586, + 82.53382873535156, + 7.572360038757324, + 61.90089416503906, + 14.084012985229492, + 90.86540985107422, + 39.56248474121094, + 67.77167510986328, + 69.69512176513672, + 89.54518127441406 + ], + "type": "float32" + } + }, + "options": { + "windowDimensions": [3, 3], + "padding": [1, 0, 0, 1], + "strides": [2, 2], + "roundingType": "floor", + "outputSizes": [3, 3] + }, + "expected": { + "name": "output", + "shape": [1, 2, 3, 3], + "data": [ + 171.5061492919922, + 164.9919891357422, + 8222.29296875, + 160.0518341064453, + 149.63897705078125, + 65.15908813476562, + 132.56260681152344, + 139.84808349609375, + 708.620849609375, + 142.6990966796875, + 139.51637268066406, + 5245.4814453125, + 165.07762145996094, + 161.11062622070312, + 96.38701629638672, + 150.1616668701172, + 146.8201904296875, + 8216.69921875 + ], + "type": "float32" + } + }, + { + "name": "l2Pool2d float32 4D tensor options.outputSizes ignores options.roundingType=ceil", + "inputs": { + "input": { + "shape": [1, 2, 5, 5], + "data": [ + 94.07447814941406, + 76.55464172363281, + 62.71847152709961, + 83.8726577758789, + 73.10235595703125, + 41.52470779418945, + 39.3339729309082, + 86.59486389160156, + 23.09039306640625, + 53.650146484375, + 0.00902052316814661, + 42.78899383544922, + 81.03960418701172, + 33.48585510253906, + 33.67196273803711, + 0.42822372913360596, + 80.07991790771484, + 5.929991722106934, + 48.89164733886719, + 15.282920837402344, + 13.335721969604492, + 39.06557846069336, + 97.06050109863281, + 83.68133544921875, + 21.79571533203125, + 52.027313232421875, + 6.397815227508545, + 84.54785919189453, + 18.622516632080078, + 34.10626220703125, + 73.96932220458984, + 36.1437873840332, + 60.73781967163086, + 55.09187316894531, + 63.8924446105957, + 59.36124038696289, + 50.91202926635742, + 50.339813232421875, + 59.31963348388672, + 70.78031921386719, + 35.56179428100586, + 82.53382873535156, + 7.572360038757324, + 61.90089416503906, + 14.084012985229492, + 90.86540985107422, + 39.56248474121094, + 67.77167510986328, + 69.69512176513672, + 89.54518127441406 + ], + "type": "float32" + } + }, + "options": { + "windowDimensions": [3, 3], + "padding": [1, 0, 0, 1], + "strides": [2, 2], + "roundingType": "ceil", + "outputSizes": [2, 2] + }, + "expected": { + "name": "output", + "shape": [1, 2, 2, 2], + "data": [ + 171.5061492919922, + 164.9919891357422, + 160.0518341064453, + 149.63897705078125, + 142.6990966796875, + 139.51637268066406, + 165.07762145996094, + 161.11062622070312 + ], + "type": "float32" + } + }, + { + "name": "l2Pool2d float32 4D tensor options.dilations with options.strides", + "inputs": { + "input": { + "shape": [1, 7, 7, 2], + "data": [ + 6.5550384521484375, + 26.254413604736328, + 28.47271156311035, + 64.81202697753906, + 39.65838623046875, + 10.465584754943848, + 47.94060134887695, + 42.208946228027344, + 36.834041595458984, + 68.50249481201172, + 2.0496721267700195, + 49.73927688598633, + 59.97947311401367, + 71.08380889892578, + 0.20033331215381622, + 19.39293670654297, + 70.1269302368164, + 86.8837661743164, + 84.28858184814453, + 9.695697784423828, + 62.69126510620117, + 51.924110412597656, + 5.412675857543945, + 70.82118225097656, + 81.61302947998047, + 29.148712158203125, + 85.83409881591797, + 71.36548614501953, + 44.09445571899414, + 58.343570709228516, + 43.37118148803711, + 54.025882720947266, + 85.50556945800781, + 93.19215393066406, + 10.992993354797363, + 34.864158630371094, + 96.2605209350586, + 44.29584503173828, + 61.12482833862305, + 79.62699127197266, + 4.066447734832764, + 64.89644622802734, + 97.5897445678711, + 11.257055282592773, + 61.151283264160156, + 20.312341690063477, + 39.862640380859375, + 68.747314453125, + 89.61034393310547, + 22.28224754333496, + 41.36311721801758, + 62.9378662109375, + 79.54936218261719, + 55.64254379272461, + 54.47548294067383, + 77.04864501953125, + 56.83576965332031, + 80.57747650146484, + 70.43293762207031, + 85.67094421386719, + 19.527807235717773, + 33.87490463256836, + 14.498117446899414, + 92.85955810546875, + 96.8167724609375, + 28.399721145629883, + 99.917236328125, + 48.76692199707031, + 86.08634948730469, + 47.32324981689453, + 7.223662376403809, + 82.97200775146484, + 38.374778747558594, + 22.10988426208496, + 14.797550201416016, + 2.3872148990631104, + 83.26342010498047, + 46.41500473022461, + 28.659175872802734, + 13.919462203979492, + 55.413089752197266, + 62.68498992919922, + 78.54127502441406, + 31.142845153808594, + 4.806727886199951, + 33.233642578125, + 24.749773025512695, + 1.529007077217102, + 42.976322174072266, + 93.08572387695312, + 77.908935546875, + 45.74395751953125, + 62.868892669677734, + 60.689762115478516, + 20.046878814697266, + 13.203198432922363, + 33.33952713012695, + 0.5279953479766846 + ], + "type": "float32" + } + }, + "options": { + "windowDimensions": [3, 3], + "padding": [1, 0, 0, 1], + "strides": [2, 2], + "dilations": [1, 1], + "layout": "nhwc" + }, + "expected": { + "name": "output", + "shape": [1, 3, 3, 2], + "data": [ + 120.20333862304688, + 114.0977783203125, + 127.63969421386719, + 119.95613861083984, + 137.89837646484375, + 152.24261474609375, + 194.9647216796875, + 168.20205688476562, + 197.7173309326172, + 169.85887145996094, + 195.1484832763672, + 190.96127319335938, + 158.64576721191406, + 166.2051544189453, + 171.07916259765625, + 148.70985412597656, + 218.7123260498047, + 153.33311462402344 + ], + "type": "float32" + } + } + ] +} \ No newline at end of file diff --git a/testing/web-platform/tests/webnn/resources/test_data/max_pool2d.json b/testing/web-platform/tests/webnn/resources/test_data/max_pool2d.json index 4532843d2b..216b4c55dd 100644 --- a/testing/web-platform/tests/webnn/resources/test_data/max_pool2d.json +++ b/testing/web-platform/tests/webnn/resources/test_data/max_pool2d.json @@ -463,340 +463,6 @@ "type": "float32" } }, - { - "name": "maxPool2d float32 4D tensor options.autoPad=explicit", - "inputs": { - "input": { - "shape": [1, 2, 5, 5], - "data": [ - 89.00830216793153, - -45.720390400208274, - -61.3061304134967, - -4.014514560596496, - -94.54893342858352, - 46.28090328619564, - 99.28312923953135, - -10.057873368956962, - 9.742474583994337, - -39.03501766575275, - 75.08192382950091, - 12.819415189421207, - -33.01505690327188, - 38.691340789603316, - 66.09259104681504, - 97.903480409299, - -8.737769993284147, - -53.4216238072017, - 72.10852084777076, - -40.42309116918719, - -35.68864442661396, - -87.64779401381033, - 38.87424286093716, - 39.38360329656629, - 7.429088108317444, - -76.72171237621149, - 50.21706410294061, - -52.89547724835329, - -44.64233565670091, - -97.86752535352848, - 81.73119248706783, - 5.428491238061412, - -29.227728678237995, - 72.44899280781078, - -59.34124718116585, - 39.19959912145927, - -65.99438957588619, - -4.204323589500888, - -60.5458643662661, - 55.89052583821697, - 80.30483906634527, - 72.88830243502153, - -46.59610987974246, - 20.503878887964206, - -31.126462826158445, - -57.29456052682171, - -26.62357805164706, - 15.93575469730375, - -78.77953474824318, - 72.33577555559427 - ], - "type": "float32" - } - }, - "options": { - "padding": [1, 0, 0, 1], - "autoPad": "explicit" - }, - "expected": { - "name": "output", - "shape": [1, 2, 2, 2], - "data": [ - 99.28312683105469, - 99.28312683105469, - 99.28312683105469, - 99.28312683105469, - 81.73119354248047, - 72.8883056640625, - 81.73119354248047, - 72.8883056640625 - ], - "type": "float32" - } - }, - { - "name": "maxPool2d float32 4D tensor options.autoPad=same-upper", - "inputs": { - "input": { - "shape": [1, 2, 4, 4], - "data": [ - 90.19580379109371, - 3.100482753598527, - 25.328822520960074, - 95.79016799138552, - -28.66704447898583, - -95.44752500898142, - -4.985161962403197, - -8.48460109616957, - -80.97691341362152, - -17.005109111308727, - -6.038760193142295, - 38.40922446364979, - -7.992178512477196, - 81.2006267730795, - 20.61885063772428, - -33.95224998477518, - -96.69404524982971, - -80.66036026545542, - 14.05812623156973, - 71.19384576769727, - 90.27735528668126, - -98.09758264975711, - 79.82735855507025, - 51.29492635990994, - 97.67522462775861, - -28.093948900517333, - 6.811551163368804, - 62.81929061329504, - -74.77656671772914, - 81.95471994368236, - 79.12276218750796, - -79.67557686936195 - ], - "type": "float32" - } - }, - "options": { - "windowDimensions": [3, 3], - "strides": [2, 2], - "autoPad": "same-upper" - }, - "expected": { - "name": "output", - "shape": [1, 2, 2, 2], - "data": [ - 90.19580078125, - 95.79016876220703, - 81.20063018798828, - 38.40922546386719, - 97.67522430419922, - 79.82736206054688, - 97.67522430419922, - 79.12276458740234 - ], - "type": "float32" - } - }, - { - "name": "maxPool2d float32 4D tensor options.autoPad=same-lower", - "inputs": { - "input": { - "shape": [1, 2, 4, 4], - "data": [ - 90.19580379109371, - 3.100482753598527, - 25.328822520960074, - 95.79016799138552, - -28.66704447898583, - -95.44752500898142, - -4.985161962403197, - -8.48460109616957, - -80.97691341362152, - -17.005109111308727, - -6.038760193142295, - 38.40922446364979, - -7.992178512477196, - 81.2006267730795, - 20.61885063772428, - -33.95224998477518, - -96.69404524982971, - -80.66036026545542, - 14.05812623156973, - 71.19384576769727, - 90.27735528668126, - -98.09758264975711, - 79.82735855507025, - 51.29492635990994, - 97.67522462775861, - -28.093948900517333, - 6.811551163368804, - 62.81929061329504, - -74.77656671772914, - 81.95471994368236, - 79.12276218750796, - -79.67557686936195 - ], - "type": "float32" - } - }, - "options": { - "windowDimensions": [3, 3], - "strides": [2, 2], - "autoPad": "same-lower" - }, - "expected": { - "name": "output", - "shape": [1, 2, 2, 2], - "data": [ - 90.19580078125, - 95.79016876220703, - 81.20063018798828, - 81.20063018798828, - 90.27735900878906, - 79.82736206054688, - 97.67522430419922, - 81.95471954345703 - ], - "type": "float32" - } - }, - { - "name": "maxPool2d float32 4D tensor options.autoPad=same-upper ignores options.padding", - "inputs": { - "input": { - "shape": [1, 2, 4, 4], - "data": [ - 90.19580379109371, - 3.100482753598527, - 25.328822520960074, - 95.79016799138552, - -28.66704447898583, - -95.44752500898142, - -4.985161962403197, - -8.48460109616957, - -80.97691341362152, - -17.005109111308727, - -6.038760193142295, - 38.40922446364979, - -7.992178512477196, - 81.2006267730795, - 20.61885063772428, - -33.95224998477518, - -96.69404524982971, - -80.66036026545542, - 14.05812623156973, - 71.19384576769727, - 90.27735528668126, - -98.09758264975711, - 79.82735855507025, - 51.29492635990994, - 97.67522462775861, - -28.093948900517333, - 6.811551163368804, - 62.81929061329504, - -74.77656671772914, - 81.95471994368236, - 79.12276218750796, - -79.67557686936195 - ], - "type": "float32" - } - }, - "options": { - "windowDimensions": [3, 3], - "padding": [2, 2, 2, 2], - "strides": [2, 2], - "autoPad": "same-upper" - }, - "expected": { - "name": "output", - "shape": [1, 2, 2, 2], - "data": [ - 90.19580078125, - 95.79016876220703, - 81.20063018798828, - 38.40922546386719, - 97.67522430419922, - 79.82736206054688, - 97.67522430419922, - 79.12276458740234 - ], - "type": "float32" - } - }, - { - "name": "maxPool2d float32 4D tensor options.autoPad=same-lower ignores options.padding", - "inputs": { - "input": { - "shape": [1, 2, 4, 4], - "data": [ - 90.19580379109371, - 3.100482753598527, - 25.328822520960074, - 95.79016799138552, - -28.66704447898583, - -95.44752500898142, - -4.985161962403197, - -8.48460109616957, - -80.97691341362152, - -17.005109111308727, - -6.038760193142295, - 38.40922446364979, - -7.992178512477196, - 81.2006267730795, - 20.61885063772428, - -33.95224998477518, - -96.69404524982971, - -80.66036026545542, - 14.05812623156973, - 71.19384576769727, - 90.27735528668126, - -98.09758264975711, - 79.82735855507025, - 51.29492635990994, - 97.67522462775861, - -28.093948900517333, - 6.811551163368804, - 62.81929061329504, - -74.77656671772914, - 81.95471994368236, - 79.12276218750796, - -79.67557686936195 - ], - "type": "float32" - } - }, - "options": { - "windowDimensions": [3, 3], - "padding": [2, 2, 2, 2], - "strides": [2, 2], - "autoPad": "same-lower" - }, - "expected": { - "name": "output", - "shape": [1, 2, 2, 2], - "data": [ - 90.19580078125, - 95.79016876220703, - 81.20063018798828, - 81.20063018798828, - 90.27735900878906, - 79.82736206054688, - 97.67522430419922, - 81.95471954345703 - ], - "type": "float32" - } - }, { "name": "maxPool2d float32 4D tensor options.layout=nchw", "inputs": { @@ -1404,7 +1070,6 @@ "options": { "windowDimensions": [3, 3], "padding": [1, 0, 0, 1], - "autoPad": "explicit", "strides": [2, 2], "dilations": [1, 1], "layout": "nhwc" diff --git a/testing/web-platform/tests/webnn/resources/test_data/resample2d.json b/testing/web-platform/tests/webnn/resources/test_data/resample2d.json new file mode 100644 index 0000000000..605d1b55c0 --- /dev/null +++ b/testing/web-platform/tests/webnn/resources/test_data/resample2d.json @@ -0,0 +1,527 @@ +{ + "tests": [ + { + "name": "resample2d float32 4D tensor default options", + "inputs": { + "input": { + "shape": [1, 1, 4, 6], // nchw + "data": [ + 3.8600528355143604, + 45.18463077286585, + 87.67153742917091, + 98.78210347338205, + 66.3741434682883, + 3.4115834948988955, + 86.14930500548006, + 95.98133720121507, + 76.87126314100948, + 16.52591355131756, + 65.98782867250333, + 25.470921564461158, + 22.56010547750855, + 92.08479613461083, + 85.80876634651386, + 92.6316602716033, + 29.91620870840146, + 75.40461275485572, + 62.063754512670435, + 1.7712158798243394, + 99.47231285272224, + 11.440550135595085, + 25.39634271166711, + 67.02175102425608 + ], + "type": "float32" + } + }, + "expected": { + "shape": [1, 1, 4, 6], + "data": [ + 3.8600528240203857, + 45.18463134765625, + 87.67153930664062, + 98.7821044921875, + 66.3741455078125, + 3.411583423614502, + 86.14930725097656, + 95.98133850097656, + 76.87126159667969, + 16.52591323852539, + 65.98783111572266, + 25.470922470092773, + 22.56010627746582, + 92.08479309082031, + 85.80876922607422, + 92.63166046142578, + 29.916208267211914, + 75.40460968017578, + 62.06375503540039, + 1.7712159156799316, + 99.4723129272461, + 11.440549850463867, + 25.396343231201172, + 67.0217514038086 + ], + "type": "float32" + } + }, + { + "name": "resample2d(upsample) float32 4D tensor options.scales", + "inputs": { + "input": { + "shape": [1, 1, 2, 3], + "data": [ + 59.92947164849423, + 41.989187594696546, + 66.39534663077877, + 90.70066412516924, + 86.95106056135486, + 79.10004839481242 + ], + "type": "float32" + } + }, + "options": { + "scales": [2.0, 2.0] + }, + "expected": { + "shape": [1, 1, 4, 6], + "data": [ + 59.92947006225586, + 59.92947006225586, + 41.98918914794922, + 41.98918914794922, + 66.39534759521484, + 66.39534759521484, + 59.92947006225586, + 59.92947006225586, + 41.98918914794922, + 41.98918914794922, + 66.39534759521484, + 66.39534759521484, + 90.7006607055664, + 90.7006607055664, + 86.95105743408203, + 86.95105743408203, + 79.10005187988281, + 79.10005187988281, + 90.7006607055664, + 90.7006607055664, + 86.95105743408203, + 86.95105743408203, + 79.10005187988281, + 79.10005187988281 + ], + "type": "float32" + } + }, + { + "name": "resample2d(upsample) float32 4D tensor options.sizes", + "inputs": { + "input": { + "shape": [1, 1, 2, 3], + "data": [ + 59.92947164849423, + 41.989187594696546, + 66.39534663077877, + 90.70066412516924, + 86.95106056135486, + 79.10004839481242 + ], + "type": "float32" + } + }, + "options": { + "sizes": [4, 6] + }, + "expected": { + "shape": [1, 1, 4, 6], + "data": [ + 59.92947006225586, + 59.92947006225586, + 41.98918914794922, + 41.98918914794922, + 66.39534759521484, + 66.39534759521484, + 59.92947006225586, + 59.92947006225586, + 41.98918914794922, + 41.98918914794922, + 66.39534759521484, + 66.39534759521484, + 90.7006607055664, + 90.7006607055664, + 86.95105743408203, + 86.95105743408203, + 79.10005187988281, + 79.10005187988281, + 90.7006607055664, + 90.7006607055664, + 86.95105743408203, + 86.95105743408203, + 79.10005187988281, + 79.10005187988281 + ], + "type": "float32" + } + }, + { + "name": "resample2d(upsample) float32 4D tensor options.sizes ignored options.scales", + "inputs": { + "input": { + "shape": [1, 1, 2, 3], + "data": [ + 59.92947164849423, + 41.989187594696546, + 66.39534663077877, + 90.70066412516924, + 86.95106056135486, + 79.10004839481242 + ], + "type": "float32" + } + }, + "options": { + "scales": [0.5, 0.5], + "sizes": [4, 6] + }, + "expected": { + "shape": [1, 1, 4, 6], + "data": [ + 59.92947006225586, + 59.92947006225586, + 41.98918914794922, + 41.98918914794922, + 66.39534759521484, + 66.39534759521484, + 59.92947006225586, + 59.92947006225586, + 41.98918914794922, + 41.98918914794922, + 66.39534759521484, + 66.39534759521484, + 90.7006607055664, + 90.7006607055664, + 86.95105743408203, + 86.95105743408203, + 79.10005187988281, + 79.10005187988281, + 90.7006607055664, + 90.7006607055664, + 86.95105743408203, + 86.95105743408203, + 79.10005187988281, + 79.10005187988281 + ], + "type": "float32" + } + }, + { + "name": "resample2d(upsample) float32 4D tensor options.axes=[1, 2]", + "inputs": { + "input": { + "shape": [1, 2, 3, 1], // nhwc + "data": [ + 59.92947164849423, + 41.989187594696546, + 66.39534663077877, + 90.70066412516924, + 86.95106056135486, + 79.10004839481242 + ], + "type": "float32" + } + }, + "options": { + "sizes": [4, 6], + "axes": [1, 2] + }, + "expected": { + "shape": [1, 4, 6, 1], + "data": [ + 59.92947006225586, + 59.92947006225586, + 41.98918914794922, + 41.98918914794922, + 66.39534759521484, + 66.39534759521484, + 59.92947006225586, + 59.92947006225586, + 41.98918914794922, + 41.98918914794922, + 66.39534759521484, + 66.39534759521484, + 90.7006607055664, + 90.7006607055664, + 86.95105743408203, + 86.95105743408203, + 79.10005187988281, + 79.10005187988281, + 90.7006607055664, + 90.7006607055664, + 86.95105743408203, + 86.95105743408203, + 79.10005187988281, + 79.10005187988281 + ], + "type": "float32" + } + }, + { + "name": "resample2d(upsample) float32 4D tensor explicit options.axes=[2, 3]", + "inputs": { + "input": { + "shape": [1, 1, 2, 3], // nchw + "data": [ + 59.92947164849423, + 41.989187594696546, + 66.39534663077877, + 90.70066412516924, + 86.95106056135486, + 79.10004839481242 + ], + "type": "float32" + } + }, + "options": { + "sizes": [4, 6], + "axes": [2, 3] + }, + "expected": { + "shape": [1, 1, 4, 6], + "data": [ + 59.92947006225586, + 59.92947006225586, + 41.98918914794922, + 41.98918914794922, + 66.39534759521484, + 66.39534759521484, + 59.92947006225586, + 59.92947006225586, + 41.98918914794922, + 41.98918914794922, + 66.39534759521484, + 66.39534759521484, + 90.7006607055664, + 90.7006607055664, + 86.95105743408203, + 86.95105743408203, + 79.10005187988281, + 79.10005187988281, + 90.7006607055664, + 90.7006607055664, + 86.95105743408203, + 86.95105743408203, + 79.10005187988281, + 79.10005187988281 + ], + "type": "float32" + } + }, + { + "name": "resample2d(upsample) float32 4D tensor explicit options.mode='nearest-neighbor'", + "inputs": { + "input": { + "shape": [1, 1, 2, 3], + "data": [ + 59.92947164849423, + 41.989187594696546, + 66.39534663077877, + 90.70066412516924, + 86.95106056135486, + 79.10004839481242 + ], + "type": "float32" + } + }, + "options": { + "mode": "nearest-neighbor", + "sizes": [4, 6] + }, + "expected": { + "shape": [1, 1, 4, 6], + "data": [ + 59.92947006225586, + 59.92947006225586, + 41.98918914794922, + 41.98918914794922, + 66.39534759521484, + 66.39534759521484, + 59.92947006225586, + 59.92947006225586, + 41.98918914794922, + 41.98918914794922, + 66.39534759521484, + 66.39534759521484, + 90.7006607055664, + 90.7006607055664, + 86.95105743408203, + 86.95105743408203, + 79.10005187988281, + 79.10005187988281, + 90.7006607055664, + 90.7006607055664, + 86.95105743408203, + 86.95105743408203, + 79.10005187988281, + 79.10005187988281 + ], + "type": "float32" + } + }, + { + "name": "resample2d(upsample) float32 4D tensor options.scales options.mode='linear'", + "inputs": { + "input": { + "shape": [1, 1, 2, 3], + "data": [ + 59.92947164849423, + 41.989187594696546, + 66.39534663077877, + 90.70066412516924, + 86.95106056135486, + 79.10004839481242 + ], + "type": "float32" + } + }, + "options": { + "mode": "linear", + "scales": [2.0, 2.0] + }, + "expected": { + "shape": [1, 1, 4, 6], + "data": [ + 59.92947006225586, + 55.444400787353516, + 46.47425842285156, + 48.090728759765625, + 60.29380798339844, + 66.39534759521484, + 67.62226867675781, + 64.02411651611328, + 56.82780838012695, + 57.31512451171875, + 65.48605346679688, + 69.57152557373047, + 83.00786590576172, + 81.18354797363281, + 77.534912109375, + 75.76390838623047, + 75.87055206298828, + 75.92387390136719, + 90.7006607055664, + 89.76325988769531, + 87.88845825195312, + 84.9883041381836, + 81.06280517578125, + 79.10005187988281 + ], + "type": "float32" + } + }, + { + "name": "resample2d(upsample) float32 4D tensor options.sizes options.mode='linear'", + "inputs": { + "input": { + "shape": [1, 1, 2, 3], + "data": [ + 59.92947164849423, + 41.989187594696546, + 66.39534663077877, + 90.70066412516924, + 86.95106056135486, + 79.10004839481242 + ], + "type": "float32" + } + }, + "options": { + "mode": "linear", + "sizes": [4, 6] + }, + "expected": { + "shape": [1, 1, 4, 6], + "data": [ + 59.92947006225586, + 55.444400787353516, + 46.47425842285156, + 48.090728759765625, + 60.29380798339844, + 66.39534759521484, + 67.62226867675781, + 64.02411651611328, + 56.82780838012695, + 57.31512451171875, + 65.48605346679688, + 69.57152557373047, + 83.00786590576172, + 81.18354797363281, + 77.534912109375, + 75.76390838623047, + 75.87055206298828, + 75.92387390136719, + 90.7006607055664, + 89.76325988769531, + 87.88845825195312, + 84.9883041381836, + 81.06280517578125, + 79.10005187988281 + ], + "type": "float32" + } + }, + { + "name": "resample2d(upsample) float32 4D tensor options.axes=[1, 2] options.mode='linear'", + "inputs": { + "input": { + "shape": [1, 2, 3, 1], + "data": [ + 59.92947164849423, + 41.989187594696546, + 66.39534663077877, + 90.70066412516924, + 86.95106056135486, + 79.10004839481242 + ], + "type": "float32" + } + }, + "options": { + "mode": "linear", + "sizes": [4, 6], + "axes": [1, 2] + }, + "expected": { + "shape": [1, 4, 6, 1], + "data": [ + 59.92947006225586, + 55.444400787353516, + 46.47425842285156, + 48.090728759765625, + 60.29380798339844, + 66.39534759521484, + 67.62226867675781, + 64.02411651611328, + 56.82780838012695, + 57.31512451171875, + 65.48605346679688, + 69.57152557373047, + 83.00786590576172, + 81.18354797363281, + 77.534912109375, + 75.76390838623047, + 75.87055206298828, + 75.92387390136719, + 90.7006607055664, + 89.76325988769531, + 87.88845825195312, + 84.9883041381836, + 81.06280517578125, + 79.10005187988281 + ], + "type": "float32" + } + } + ] +} \ No newline at end of file diff --git a/testing/web-platform/tests/webnn/resources/test_data/triangular.json b/testing/web-platform/tests/webnn/resources/test_data/triangular.json new file mode 100644 index 0000000000..652f780d58 --- /dev/null +++ b/testing/web-platform/tests/webnn/resources/test_data/triangular.json @@ -0,0 +1,1101 @@ +{ + "tests": [ + { + "name": "triangular float32 2D tensor default options", + "inputs": { + "input": { + "shape": [4, 6], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + -98.47772216796875, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 97.25071716308594, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 67.48285675048828, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + -88.97057342529297, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [4, 6], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + -98.47772216796875, + -94.51172637939453, + -21.42218589782715, + 0, + -50.355342864990234, + -37.015724182128906, + 97.25071716308594, + 73.36241149902344, + -75.12358856201172, + 0, + 0, + -29.916187286376953, + 67.48285675048828, + 42.132598876953125, + -70.27587127685547, + 0, + 0, + 0, + -88.97057342529297, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + { + "name": "triangular float32 3D tensor default options", + "inputs": { + "input": { + "shape": [2, 3, 4], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + -98.47772216796875, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 97.25071716308594, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 67.48285675048828, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + -88.97057342529297, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [2, 3, 4], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + -98.47772216796875, + 0, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + 0, + 0, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 67.48285675048828, + 0, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + 0, + 0, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + { + "name": "triangular float32 4D tensor default options", + "inputs": { + "input": { + "shape": [2, 2, 2, 3], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + -98.47772216796875, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 97.25071716308594, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 67.48285675048828, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + -88.97057342529297, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + 0, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 0, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 0, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + 0, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + { + "name": "triangular float32 5D tensor default options", + "inputs": { + "input": { + "shape": [2, 1, 4, 1, 3], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + -98.47772216796875, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 97.25071716308594, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 67.48285675048828, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + -88.97057342529297, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + "expected": { + "name": "output", + "shape": [2, 1, 4, 1, 3], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + -98.47772216796875, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 97.25071716308594, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 67.48285675048828, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + -88.97057342529297, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + { + "name": "triangular float32 4D tensor explict options.upper=true", + "inputs": { + "input": { + "shape": [2, 2, 2, 3], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + -98.47772216796875, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 97.25071716308594, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 67.48285675048828, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + -88.97057342529297, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + "options": { + "upper": true + }, + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + 0, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 0, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 0, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + 0, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + { + "name": "triangular float32 4D tensor options.upper=false", + "inputs": { + "input": { + "shape": [2, 2, 2, 3], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + -98.47772216796875, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 97.25071716308594, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 67.48285675048828, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + -88.97057342529297, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + "options": { + "upper": false + }, + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 84.9194564819336, + 0, + 0, + -98.47772216796875, + -94.51172637939453, + 0, + 24.678754806518555, + 0, + 0, + 97.25071716308594, + 73.36241149902344, + 0, + 41.64348602294922, + 0, + 0, + 67.48285675048828, + 42.132598876953125, + 0, + 20.88446617126465, + 0, + 0, + -88.97057342529297, + 77.58269500732422, + 0 + ], + "type": "float32" + } + }, + { + "name": "triangular float32 4D tensor explict options.diagonal=0", + "inputs": { + "input": { + "shape": [2, 2, 2, 3], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + -98.47772216796875, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 97.25071716308594, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 67.48285675048828, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + -88.97057342529297, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + "options": { + "diagonal": 0 + }, + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + 0, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 0, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 0, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + 0, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + { + "name": "triangular float32 4D tensor options.diagonal=1", + "inputs": { + "input": { + "shape": [2, 2, 2, 3], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + -98.47772216796875, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 97.25071716308594, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 67.48285675048828, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + -88.97057342529297, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + "options": { + "diagonal": 1 + }, + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 0, + -86.21631622314453, + 50.38116455078125, + 0, + 0, + -21.42218589782715, + 0, + -50.355342864990234, + -37.015724182128906, + 0, + 0, + -75.12358856201172, + 0, + 58.862911224365234, + -29.916187286376953, + 0, + 0, + -70.27587127685547, + 0, + 71.37139892578125, + -84.96932220458984, + 0, + 0, + 91.03327178955078 + ], + "type": "float32" + } + }, + { + "name": "triangular float32 4D tensor options.diagonal=-1", + "inputs": { + "input": { + "shape": [2, 2, 2, 3], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + -98.47772216796875, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 97.25071716308594, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 67.48285675048828, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + -88.97057342529297, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + "options": { + "diagonal": -1 + }, + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + -98.47772216796875, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 97.25071716308594, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 67.48285675048828, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + -88.97057342529297, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + { + "name": "triangular float32 4D tensor fully zero options.diagonal=3", + "inputs": { + "input": { + "shape": [2, 2, 2, 3], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + -98.47772216796875, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 97.25071716308594, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 67.48285675048828, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + -88.97057342529297, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + "options": { + "diagonal": 3 + }, + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "type": "float32" + } + }, + { + "name": "triangular float32 4D tensor fully copied options.diagonal=-2", + "inputs": { + "input": { + "shape": [2, 2, 2, 3], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + -98.47772216796875, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 97.25071716308594, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 67.48285675048828, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + -88.97057342529297, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + "options": { + "diagonal": -2 + }, + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + -98.47772216796875, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 97.25071716308594, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 67.48285675048828, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + -88.97057342529297, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + { + "name": "triangular float32 4D tensor options.upper=true options.diagonal=1", + "inputs": { + "input": { + "shape": [2, 2, 2, 3], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + -98.47772216796875, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 97.25071716308594, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 67.48285675048828, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + -88.97057342529297, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + "options": { + "upper": true, + "diagonal": 1 + }, + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 0, + -86.21631622314453, + 50.38116455078125, + 0, + 0, + -21.42218589782715, + 0, + -50.355342864990234, + -37.015724182128906, + 0, + 0, + -75.12358856201172, + 0, + 58.862911224365234, + -29.916187286376953, + 0, + 0, + -70.27587127685547, + 0, + 71.37139892578125, + -84.96932220458984, + 0, + 0, + 91.03327178955078 + ], + "type": "float32" + } + }, + { + "name": "triangular float32 4D tensor options.upper=false options.diagonal=1", + "inputs": { + "input": { + "shape": [2, 2, 2, 3], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + -98.47772216796875, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 97.25071716308594, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 67.48285675048828, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + -88.97057342529297, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + "options": { + "upper": false, + "diagonal": 1 + }, + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 84.9194564819336, + -86.21631622314453, + 0, + -98.47772216796875, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + 0, + 97.25071716308594, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + 0, + 67.48285675048828, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + 0, + -88.97057342529297, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + { + "name": "triangular float32 4D tensor options.upper=false options.diagonal=-1", + "inputs": { + "input": { + "shape": [2, 2, 2, 3], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + -98.47772216796875, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 97.25071716308594, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 67.48285675048828, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + -88.97057342529297, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + "options": { + "upper": false, + "diagonal": -1 + }, + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 0, + 0, + 0, + -98.47772216796875, + 0, + 0, + 0, + 0, + 0, + 97.25071716308594, + 0, + 0, + 0, + 0, + 0, + 67.48285675048828, + 0, + 0, + 0, + 0, + 0, + -88.97057342529297, + 0, + 0 + ], + "type": "float32" + } + }, + { + "name": "triangular float32 4D tensor fully copied options.upper=false options.diagonal=3", + "inputs": { + "input": { + "shape": [2, 2, 2, 3], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + -98.47772216796875, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 97.25071716308594, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 67.48285675048828, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + -88.97057342529297, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + "options": { + "upper": false, + "diagonal": 3 + }, + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + -98.47772216796875, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 97.25071716308594, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 67.48285675048828, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + -88.97057342529297, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + { + "name": "triangular float32 4D tensor fully zero options.upper=false options.diagonal=-2", + "inputs": { + "input": { + "shape": [2, 2, 2, 3], + "data": [ + 84.9194564819336, + -86.21631622314453, + 50.38116455078125, + -98.47772216796875, + -94.51172637939453, + -21.42218589782715, + 24.678754806518555, + -50.355342864990234, + -37.015724182128906, + 97.25071716308594, + 73.36241149902344, + -75.12358856201172, + 41.64348602294922, + 58.862911224365234, + -29.916187286376953, + 67.48285675048828, + 42.132598876953125, + -70.27587127685547, + 20.88446617126465, + 71.37139892578125, + -84.96932220458984, + -88.97057342529297, + 77.58269500732422, + 91.03327178955078 + ], + "type": "float32" + } + }, + "options": { + "upper": false, + "diagonal": -2 + }, + "expected": { + "name": "output", + "shape": [2, 2, 2, 3], + "data": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "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 index f91d6622d3..375c71174a 100644 --- a/testing/web-platform/tests/webnn/resources/utils.js +++ b/testing/web-platform/tests/webnn/resources/utils.js @@ -1,7 +1,5 @@ 'use strict'; -const ExecutionArray = ['sync', 'async']; - // https://webmachinelearning.github.io/webnn/#enumdef-mloperanddatatype const TypedArrayDict = { // workaround use Uint16 for Float16 @@ -193,7 +191,7 @@ const getMatmulPrecisionTolerance = (resources, operationName) => { }; /** - * Get ULP tolerance of averagePool2d operation. + * Get ULP tolerance of averagePool2d or l2Pool2d operation. * @param {Object} resources - Resources used for building a graph * @param {String} operationName - An operation name * @returns {Number} A tolerance number @@ -284,6 +282,32 @@ const getReductionPrecisionTolerance = (resources, operationName) => { return tolerance; }; +/** + * Get ULP tolerance of resample2d operations. + * @param {Object} resources - Resources used for building a graph + * @param {String} operationName - An operation name + * @returns {Number} A tolerance number + */ +const getResample2dPrecisionTolerance = (resources, operationName) => { + const options = {...resources.options}; + let tolerance; + if (options.mode && options.mode === 'linear') { + // interpolation mode is linear + const precisionType = resources.expected.type; + if (precisionType === 'float32') { + tolerance = 84; + } else if (precisionType === 'float16') { + tolerance = 10; + } else { + tolerance = 1; + } + } else { + // interpolation mode is nearest-neighbor + tolerance = 0; + } + return tolerance; +}; + // Refer to precision metrics on https://github.com/webmachinelearning/webnn/issues/265#issuecomment-1256242643 const PrecisionMetrics = { argMax: {ULP: {int64: 0}}, @@ -292,6 +316,7 @@ const PrecisionMetrics = { cast: {ULP: {float32: 1, float16: 1, int32: 0, uint32: 0, int64: 0, int8: 0, uint8: 0}}, clamp: {ULP: {float32: 0, float16: 0}}, concat: {ULP: {float32: 0, float16: 0}}, + constant: {ULP: {float32: 2, float16: 2, int32: 0, uint32: 0, int64: 0, int8: 0, uint8: 0}}, conv2d: {ULP: {float32: getConv2dPrecisionTolerance, float16: getConv2dPrecisionTolerance}}, convTranspose2d: {ULP: {float32: getConv2dPrecisionTolerance, float16: getConv2dPrecisionTolerance}}, // Begin Element-wise binary operations @@ -340,6 +365,7 @@ const PrecisionMetrics = { pad: {ULP: {float32: 0, float16: 0}}, // Begin Pooling operations averagePool2d: {ULP: {float32: getAveragePool2dPrecisionTolerance, float16: getAveragePool2dPrecisionTolerance}}, + l2Pool2d: {ULP: {float32: getAveragePool2dPrecisionTolerance, float16: getAveragePool2dPrecisionTolerance}}, maxPool2d: {ULP: {float32: 0, float16: 0}}, // End Pooling operations prelu: {ULP: {float32: 1, float16: 1}}, @@ -356,6 +382,7 @@ const PrecisionMetrics = { reduceSumSquare: {ULP: {float32: getReductionPrecisionTolerance, float16: getReductionPrecisionTolerance}}, // End Reduction operations relu: {ULP: {float32: 0, float16: 0}}, + resample2d: {ULP: {float32: getResample2dPrecisionTolerance, float16: getResample2dPrecisionTolerance}}, 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}}, @@ -365,6 +392,7 @@ const PrecisionMetrics = { split: {ULP: {float32: 0, float16: 0}}, tanh: {ATOL: {float32: 1/1024, float16: 1/512}}, transpose: {ULP: {float32: 0, float16: 0}}, + triangular: {ULP: {float32: 0, float16: 0}}, where: {ULP: {float32: 0, float16: 0}}, }; @@ -635,6 +663,13 @@ const buildConcat = (operationName, builder, resources) => { return namedOutputOperand; }; +const buildConstantRange = (operationName, builder, resources) => { + const namedOutputOperand = {}; + // invoke builder.constant(start, step, outputShape, type) + namedOutputOperand[resources.expected.name] = builder[operationName](resources.inputs.start, resources.inputs.step, resources.outputShape, resources.type); + return namedOutputOperand; +}; + const buildConvTranspose2d = (operationName, builder, resources) => { // MLOperand convTranspose2d(MLOperand input, MLOperand filter, optional MLConvTranspose2dOptions options = {}); const namedOutputOperand = {}; @@ -793,25 +828,7 @@ const buildGraph = (operationName, builder, resources, buildFunc) => { }; /** - * 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. + * Build a graph, 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 @@ -821,9 +838,9 @@ const runSync = (operationName, context, builder, resources, buildFunc) => { 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 + // compile the graph up to the output operand const graph = await builder.build(namedOutputOperands); - // asynchronously execute the compiled graph + // execute the compiled graph const result = await context.compute(graph, inputs, outputs); checkResults(operationName, namedOutputOperands, result.outputs, resources); }; @@ -835,6 +852,10 @@ const run = async (operationName, context, builder, resources, buildFunc) => { * @param {String} deviceType - The execution device type for this test */ const testWebNNOperation = (operationName, buildFunc, deviceType = 'cpu') => { + test(() => assert_not_equals(navigator.ml, undefined, "ml property is defined on navigator")); + if (navigator.ml === undefined) { + return; + } let operationNameArray; if (typeof operationName === 'string') { operationNameArray = [operationName]; @@ -842,41 +863,18 @@ const testWebNNOperation = (operationName, buildFunc, deviceType = 'cpu') => { operationNameArray = operationName; } - ExecutionArray.forEach(executionType => { - const isSync = executionType === 'sync'; - if (self.GLOBAL.isWindow() && isSync) { - return; - } - let context; - let builder; - if (isSync) { - // test sync - operationNameArray.forEach((subOperationName) => { - const tests = loadTests(subOperationName); - setup(() => { - context = navigator.ml.createContextSync({deviceType}); - builder = new MLGraphBuilder(context); - }); - for (const subTest of tests) { - test(() => { - runSync(subOperationName, context, builder, subTest, buildFunc); - }, `${subTest.name} / ${executionType}`); - } - }); - } else { - // test async - operationNameArray.forEach((subOperationName) => { - const tests = loadTests(subOperationName); - promise_setup(async () => { - context = await navigator.ml.createContext({deviceType}); - builder = new MLGraphBuilder(context); - }); - for (const subTest of tests) { - promise_test(async () => { - await run(subOperationName, context, builder, subTest, buildFunc); - }, `${subTest.name} / ${executionType}`); - } - }); + let context; + let builder; + operationNameArray.forEach((subOperationName) => { + const tests = loadTests(subOperationName); + promise_setup(async () => { + context = await navigator.ml.createContext({deviceType}); + builder = new MLGraphBuilder(context); + }); + for (const subTest of tests) { + promise_test(async () => { + await run(subOperationName, context, builder, subTest, buildFunc); + }, `${subTest.name}`); } }); }; @@ -926,4 +924,60 @@ const toHalf = (value) => { * the exponent, which is OK. */ bits += m & 1; return bits; +}; + + +/** + * WebNN buffer creation. + * @param {MLContext} context - the context used to create the buffer. + * @param {Number} bufferSize - Size of the buffer to create, in bytes. + */ +const createBuffer = (context, bufferSize) => { + let buffer; + try { + buffer = context.createBuffer({size: bufferSize}); + assert_equals(buffer.size, bufferSize); + } catch (e) { + assert_true(e instanceof DOMException); + assert_equals(e.name, "NotSupportedError"); + } + return buffer; +}; + +/** + * WebNN destroy buffer twice test. + * @param {String} testName - The name of the test operation. + * @param {String} deviceType - The execution device type for this test. + */ +const testDestroyWebNNBuffer = (testName, deviceType = 'cpu') => { + let context; + let buffer; + promise_setup(async () => { + context = await navigator.ml.createContext({deviceType}); + buffer = createBuffer(context, 4); + }); + promise_test(async () => { + // MLBuffer is not supported for this deviceType. + if (buffer === undefined) { + return; + } + buffer.destroy(); + buffer.destroy(); + }, `${testName}`); +}; + +/** + * WebNN create buffer test. + * @param {String} testName - The name of the test operation. + * @param {Number} bufferSize - Size of the buffer to create, in bytes. + * @param {String} deviceType - The execution device type for this test. + */ +const testCreateWebNNBuffer = (testName, bufferSize, deviceType = 'cpu') => { + let context; + promise_setup(async () => { + context = await navigator.ml.createContext({deviceType}); + }); + promise_test(async () => { + createBuffer(context, bufferSize); + }, `${testName} / ${bufferSize}`); }; \ No newline at end of file diff --git a/testing/web-platform/tests/webnn/resources/utils_validation.js b/testing/web-platform/tests/webnn/resources/utils_validation.js new file mode 100644 index 0000000000..7f1d4a4a94 --- /dev/null +++ b/testing/web-platform/tests/webnn/resources/utils_validation.js @@ -0,0 +1,359 @@ +'use strict'; + +// https://webmachinelearning.github.io/webnn/#enumdef-mloperanddatatype +const allWebNNOperandDataTypes = [ + 'float32', + 'float16', + 'int32', + 'uint32', + 'int64', + 'uint64', + 'int8', + 'uint8' +]; + +const unsignedLongType = 'unsigned long'; + +const dimensions0D = []; +const dimensions1D = [2]; +const dimensions2D = [2, 3]; +const dimensions3D = [2, 3, 4]; +const dimensions4D = [2, 3, 4, 5]; +const dimensions5D = [2, 3, 4, 5, 6]; + +const adjustOffsetsArray = [ + // Decrease 1 + -1, + // Increase 1 + 1 +]; + +// TODO +// Add more 5+ dimensions +const allWebNNDimensionsArray = [ + dimensions0D, + dimensions1D, + dimensions2D, + dimensions3D, + dimensions4D, + dimensions5D +]; + +const notUnsignedLongAxisArray = [ + // String + 'abc', + // BigInt + BigInt(100), + // Object + { + value: 1 + }, + // Array Object + [0, 1], + // Date Object + new Date("2024-01-01"), +]; + +function getRank(inputDimensions) { + return inputDimensions.length; +} + +function getAxisArray(inputDimensions) { + return Array.from({length: inputDimensions.length}, (_, i) => i); +} + +function getAxesArrayContainSameValues(inputDimensions) { + // TODO + // Currently this function returns an array containing each element which all have the same value. + // For example axes: [0, 1, 2] for 3D input tensor + // this function returns + // [ + // // two values are same + // [0, 0], + // [1, 1], + // [2, 2], + // // three values are same + // [0, 0, 0], + // [1, 1, 1] + // [2, 2, 2] + // ] + // while it should return + // [ + // // two values are same + // [0, 0], + // [1, 1], + // [2, 2], + // [0, 0, 1], + // [0, 0, 2], + // [0, 1, 0], + // [0, 2, 0], + // [1, 0, 0], + // [2, 0, 0], + // [1, 1, 0], + // [1, 1, 2], + // [1, 0, 1], + // [1, 2, 1], + // [0, 1, 1], + // [2, 1, 1], + // [2, 2, 0], + // [2, 2, 1], + // [2, 0, 2], + // [2, 1, 2], + // [0, 2, 2], + // [1, 2, 2], + // // three (all) values are same + // [0, 0, 0], + // [1, 1, 1] + // [2, 2, 2] + // ] + const axesArrayContainSameValues = []; + const length = inputDimensions.length; + if (length >= 2) { + const validAxesArrayFull = getAxisArray(inputDimensions); + for (let index = 0; index < length; index++) { + axesArrayContainSameValues.push(new Array(2).fill(validAxesArrayFull[index])); + if (length > 2) { + axesArrayContainSameValues.push(new Array(3).fill(validAxesArrayFull[index])); + } + } + } + return axesArrayContainSameValues; +} + +function generateUnbroadcastableDimensionsArray(dimensions) { + // Currently this function returns an array of some unbroadcastable dimensions. + // for example given dimensions [2, 3, 4] + // this function returns + // [ + // [3, 3, 4], + // [2, 2, 4], + // [2, 4, 4], + // [2, 3, 3], + // [2, 3, 5], + // [3], + // [5], + // [1, 3], + // [1, 5], + // [1, 1, 3], + // [1, 1, 5], + // [1, 1, 1, 3], + // [1, 1, 1, 5], + // ] + if (dimensions.every(v => v === 1)) { + throw new Error(`[${dimensions}] always can be broadcasted`); + } + const resultDimensions = []; + const length = dimensions.length; + if (!dimensions.slice(0, length - 1).every(v => v === 1)) { + for (let i = 0; i < length; i++) { + if (dimensions[i] !== 1) { + for (let offset of [-1, 1]) { + const dimensionsB = dimensions.slice(); + dimensionsB[i] += offset; + if (dimensionsB[i] !== 1) { + resultDimensions.push(dimensionsB); + } + } + } + } + } + const lastDimensionSize = dimensions[length - 1]; + if (lastDimensionSize !== 1) { + for (let j = 0; j <= length; j++) { + if (lastDimensionSize > 2) { + resultDimensions.push(Array(j).fill(1).concat([lastDimensionSize - 1])); + } + resultDimensions.push(Array(j).fill(1).concat([lastDimensionSize + 1])); + } + } + return resultDimensions; +} + +function generateOutOfRangeValuesArray(type) { + let range, outsideValueArray; + switch (type) { + case 'unsigned long': + // https://webidl.spec.whatwg.org/#idl-unsigned-long + // The unsigned long type is an unsigned integer type that has values in the range [0, 4294967295]. + range = [0, 4294967295]; + break; + default: + throw new Error(`Unsupport ${type}`); + } + outsideValueArray = [range[0] - 1, range[1] + 1]; + return outsideValueArray; +} + +let inputIndex = 0; +let inputAIndex = 0; +let inputBIndex = 0; +let context, builder; + +test(() => assert_not_equals(navigator.ml, undefined, "ml property is defined on navigator")); + +promise_setup(async () => { + if (navigator.ml === undefined) { + return; + } + context = await navigator.ml.createContext(); + builder = new MLGraphBuilder(context); +}, {explicit_timeout: true}); + +function validateTwoInputsBroadcastable(operationName) { + if (navigator.ml === undefined) { + return; + } + promise_test(async t => { + for (let dataType of allWebNNOperandDataTypes) { + for (let dimensions of allWebNNDimensionsArray) { + if (dimensions.length > 0) { + const inputA = builder.input(`inputA${++inputAIndex}`, {dataType, dimensions}); + const unbroadcastableDimensionsArray = generateUnbroadcastableDimensionsArray(dimensions); + for (let unbroadcastableDimensions of unbroadcastableDimensionsArray) { + const inputB = builder.input(`inputB${++inputBIndex}`, {dataType, dimensions: unbroadcastableDimensions}); + assert_throws_dom('DataError', () => builder[operationName](inputA, inputB)); + assert_throws_dom('DataError', () => builder[operationName](inputB, inputA)); + } + } + } + } + }, `[${operationName}] DataError is expected if two inputs aren't broadcastable`); +} + +function validateTwoInputsOfSameDataType(operationName) { + if (navigator.ml === undefined) { + return; + } + let operationNameArray; + if (typeof operationName === 'string') { + operationNameArray = [operationName]; + } else if (Array.isArray(operationName)) { + operationNameArray = operationName; + } else { + throw new Error(`${operationName} should be an operation name string or an operation name string array`); + } + for (let subOperationName of operationNameArray) { + promise_test(async t => { + for (let dataType of allWebNNOperandDataTypes) { + for (let dimensions of allWebNNDimensionsArray) { + const inputA = builder.input(`inputA${++inputAIndex}`, {dataType, dimensions}); + for (let dataTypeB of allWebNNOperandDataTypes) { + if (dataType !== dataTypeB) { + const inputB = builder.input(`inputB${++inputBIndex}`, {dataType: dataTypeB, dimensions}); + assert_throws_dom('DataError', () => builder[subOperationName](inputA, inputB)); + } + } + } + } + }, `[${subOperationName}] DataError is expected if two inputs aren't of same data type`); + } +} + +/** + * Validate options.axes by given operation and input rank for + * argMin/Max / layerNormalization / Reduction operations / resample2d operations + * @param {(String[]|String)} operationName - An operation name array or an operation name + * @param {Number} [inputRank] + */ +function validateOptionsAxes(operationName, inputRank) { + if (navigator.ml === undefined) { + return; + } + let operationNameArray; + if (typeof operationName === 'string') { + operationNameArray = [operationName]; + } else if (Array.isArray(operationName)) { + operationNameArray = operationName; + } else { + throw new Error(`${operationName} should be an operation name string or an operation name string array`); + } + const invalidAxisArray = generateOutOfRangeValuesArray(unsignedLongType); + for (let subOperationName of operationNameArray) { + // TypeError is expected if any of options.axes elements is not an unsigned long interger + promise_test(async t => { + if (inputRank === undefined) { + // argMin/Max / layerNormalization / Reduction operations + for (let dataType of allWebNNOperandDataTypes) { + for (let dimensions of allWebNNDimensionsArray) { + const rank = getRank(dimensions); + if (rank >= 1) { + const input = builder.input(`input${++inputIndex}`, {dataType, dimensions}); + for (let invalidAxis of invalidAxisArray) { + assert_throws_js(TypeError, () => builder[subOperationName](input, {axes: invalidAxis})); + } + for (let axis of notUnsignedLongAxisArray) { + assert_false(typeof axis === 'number' && Number.isInteger(axis), `[${subOperationName}] any of options.axes elements should be of 'unsigned long'`); + assert_throws_js(TypeError, () => builder[subOperationName](input, {axes: [axis]})); + } + } + } + } + } else { + // resample2d + for (let dataType of allWebNNOperandDataTypes) { + const input = builder.input(`input${++inputIndex}`, {dataType, dimensions: allWebNNDimensionsArray[inputRank]}); + for (let invalidAxis of invalidAxisArray) { + assert_throws_js(TypeError, () => builder[subOperationName](input, {axes: invalidAxis})); + } + for (let axis of notUnsignedLongAxisArray) { + assert_false(typeof axis === 'number' && Number.isInteger(axis), `[${subOperationName}] any of options.axes elements should be of 'unsigned long'`); + assert_throws_js(TypeError, () => builder[subOperationName](input, {axes: [axis]})); + } + } + } + }, `[${subOperationName}] TypeError is expected if any of options.axes elements is not an unsigned long interger`); + + // DataError is expected if any of options.axes elements is greater or equal to the size of input + promise_test(async t => { + if (inputRank === undefined) { + // argMin/Max / layerNormalization / Reduction operations + for (let dataType of allWebNNOperandDataTypes) { + for (let dimensions of allWebNNDimensionsArray) { + const rank = getRank(dimensions); + if (rank >= 1) { + const input = builder.input(`input${++inputIndex}`, {dataType, dimensions}); + assert_throws_dom('DataError', () => builder[subOperationName](input, {axes: [rank]})); + assert_throws_dom('DataError', () => builder[subOperationName](input, {axes: [rank + 1]})); + } + } + } + } else { + // resample2d + for (let dataType of allWebNNOperandDataTypes) { + const input = builder.input(`input${++inputIndex}`, {dataType, dimensions: allWebNNDimensionsArray[inputRank]}); + assert_throws_dom('DataError', () => builder[subOperationName](input, {axes: [inputRank]})); + assert_throws_dom('DataError', () => builder[subOperationName](input, {axes: [inputRank + 1]})); + } + } + }, `[${subOperationName}] DataError is expected if any of options.axes elements is greater or equal to the size of input`); + + // DataError is expected if two or more values are same in the axes sequence + promise_test(async t => { + if (inputRank === undefined) { + // argMin/Max / layerNormalization / Reduction operations + for (let dataType of allWebNNOperandDataTypes) { + for (let dimensions of allWebNNDimensionsArray) { + const rank = getRank(dimensions); + if (rank >= 2) { + const input = builder.input(`input${++inputIndex}`, {dataType, dimensions}); + const axesArrayContainSameValues = getAxesArrayContainSameValues(dimensions); + for (let axes of axesArrayContainSameValues) { + assert_throws_dom('DataError', () => builder[subOperationName](input, {axes})); + } + } + } + } + } else { + // resample2d + for (let dataType of allWebNNOperandDataTypes) { + const dimensions = allWebNNDimensionsArray[inputRank]; + const input = builder.input(`input${++inputIndex}`, {dataType, dimensions}); + const axesArrayContainSameValues = getAxesArrayContainSameValues(dimensions); + for (let axes of axesArrayContainSameValues) { + assert_throws_dom('DataError', () => builder[subOperationName](input, {axes})); + } + } + } + }, `[${subOperationName}] DataError is expected if two or more values are same in the axes sequence`); + } +} -- cgit v1.2.3