diff --git a/webnn/gpu/pooling.https.any.js b/webnn/gpu/pooling.https.any.js index ab128818812495..e174bb5186a87f 100644 --- a/webnn/gpu/pooling.https.any.js +++ b/webnn/gpu/pooling.https.any.js @@ -7,4 +7,4 @@ // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-pool2d -testWebNNOperation(['averagePool2d', 'maxPool2d'], buildOperationWithSingleInput, 'gpu'); \ No newline at end of file +testWebNNOperation(['averagePool2d', 'l2Pool2d', 'maxPool2d'], buildOperationWithSingleInput, 'gpu'); \ No newline at end of file diff --git a/webnn/pooling.https.any.js b/webnn/pooling.https.any.js index df19e577094840..c34ae2bba24225 100644 --- a/webnn/pooling.https.any.js +++ b/webnn/pooling.https.any.js @@ -7,4 +7,4 @@ // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-pool2d -testWebNNOperation(['averagePool2d', 'maxPool2d'], buildOperationWithSingleInput); \ No newline at end of file +testWebNNOperation(['averagePool2d', 'l2Pool2d', 'maxPool2d'], buildOperationWithSingleInput); \ No newline at end of file diff --git a/webnn/resources/test_data/l2_pool2d.json b/webnn/resources/test_data/l2_pool2d.json new file mode 100644 index 00000000000000..bab89e0e3940b9 --- /dev/null +++ b/webnn/resources/test_data/l2_pool2d.json @@ -0,0 +1,1509 @@ +{ + "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.autoPad=explicit", + "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], + "autoPad": "explicit" + }, + "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.autoPad=same-upper", + "inputs": { + "input": { + "shape": [1, 2, 4, 4], + "data": [ + 89.69132995605469, + 49.80897521972656, + 84.17794036865234, + 98.6054458618164, + 25.800601959228516, + 71.89942932128906, + 95.26441192626953, + 26.428104400634766, + 44.16105270385742, + 24.04642105102539, + 30.115402221679688, + 54.41345977783203, + 47.779483795166016, + 22.942420959472656, + 24.280946731567383, + 81.68242645263672, + 84.46887969970703, + 84.59886932373047, + 12.081207275390625, + 37.8386344909668, + 57.85399627685547, + 28.702816009521484, + 74.17911529541016, + 67.8487319946289, + 0.811935305595398, + 79.18359375, + 83.0001449584961, + 82.172119140625, + 92.50651550292969, + 8.42988395690918, + 93.89906311035156, + 58.69465255737305 + ], + "type": "float32" + } + }, + "options": { + "windowDimensions": [3, 3], + "strides": [2, 2], + "autoPad": "same-upper" + }, + "expected": { + "name": "output", + "shape": [1, 2, 2, 2], + "data": [ + 189.6240234375, + 174.50064086914062, + 82.66900634765625, + 105.49571228027344, + 193.0572967529297, + 159.13827514648438, + 174.94363403320312, + 160.9452667236328 + ], + "type": "float32" + } + }, + { + "name": "l2Pool2d float32 4D tensor options.autoPad=same-lower", + "inputs": { + "input": { + "shape": [1, 2, 4, 4], + "data": [ + 89.69132995605469, + 49.80897521972656, + 84.17794036865234, + 98.6054458618164, + 25.800601959228516, + 71.89942932128906, + 95.26441192626953, + 26.428104400634766, + 44.16105270385742, + 24.04642105102539, + 30.115402221679688, + 54.41345977783203, + 47.779483795166016, + 22.942420959472656, + 24.280946731567383, + 81.68242645263672, + 84.46887969970703, + 84.59886932373047, + 12.081207275390625, + 37.8386344909668, + 57.85399627685547, + 28.702816009521484, + 74.17911529541016, + 67.8487319946289, + 0.811935305595398, + 79.18359375, + 83.0001449584961, + 82.172119140625, + 92.50651550292969, + 8.42988395690918, + 93.89906311035156, + 58.69465255737305 + ], + "type": "float32" + } + }, + "options": { + "windowDimensions": [3, 3], + "strides": [2, 2], + "autoPad": "same-lower" + }, + "expected": { + "name": "output", + "shape": [1, 2, 2, 2], + "data": [ + 127.90882873535156, + 185.0220947265625, + 105.7017593383789, + 164.85511779785156, + 135.8782501220703, + 140.2302703857422, + 138.09474182128906, + 207.78431701660156 + ], + "type": "float32" + } + }, + { + "name": "l2Pool2d float32 4D tensor options.autoPad=same-upper ignores options.padding", + "inputs": { + "input": { + "shape": [1, 2, 4, 4], + "data": [ + 89.69132995605469, + 49.80897521972656, + 84.17794036865234, + 98.6054458618164, + 25.800601959228516, + 71.89942932128906, + 95.26441192626953, + 26.428104400634766, + 44.16105270385742, + 24.04642105102539, + 30.115402221679688, + 54.41345977783203, + 47.779483795166016, + 22.942420959472656, + 24.280946731567383, + 81.68242645263672, + 84.46887969970703, + 84.59886932373047, + 12.081207275390625, + 37.8386344909668, + 57.85399627685547, + 28.702816009521484, + 74.17911529541016, + 67.8487319946289, + 0.811935305595398, + 79.18359375, + 83.0001449584961, + 82.172119140625, + 92.50651550292969, + 8.42988395690918, + 93.89906311035156, + 58.69465255737305 + ], + "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": [ + 189.6240234375, + 174.50064086914062, + 82.66900634765625, + 105.49571228027344, + 193.0572967529297, + 159.13827514648438, + 174.94363403320312, + 160.9452667236328 + ], + "type": "float32" + } + }, + { + "name": "l2Pool2d float32 4D tensor options.autoPad=same-lower ignores options.padding", + "inputs": { + "input": { + "shape": [1, 2, 4, 4], + "data": [ + 89.69132995605469, + 49.80897521972656, + 84.17794036865234, + 98.6054458618164, + 25.800601959228516, + 71.89942932128906, + 95.26441192626953, + 26.428104400634766, + 44.16105270385742, + 24.04642105102539, + 30.115402221679688, + 54.41345977783203, + 47.779483795166016, + 22.942420959472656, + 24.280946731567383, + 81.68242645263672, + 84.46887969970703, + 84.59886932373047, + 12.081207275390625, + 37.8386344909668, + 57.85399627685547, + 28.702816009521484, + 74.17911529541016, + 67.8487319946289, + 0.811935305595398, + 79.18359375, + 83.0001449584961, + 82.172119140625, + 92.50651550292969, + 8.42988395690918, + 93.89906311035156, + 58.69465255737305 + ], + "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": [ + 127.90882873535156, + 185.0220947265625, + 105.7017593383789, + 164.85511779785156, + 135.8782501220703, + 140.2302703857422, + 138.09474182128906, + 207.78431701660156 + ], + "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], + "autoPad": "explicit", + "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/webnn/resources/utils.js b/webnn/resources/utils.js index f91d6622d3c8e2..c57cec27f082d0 100644 --- a/webnn/resources/utils.js +++ b/webnn/resources/utils.js @@ -193,7 +193,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 @@ -340,6 +340,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}},