diff options
Diffstat (limited to 'testing/web-platform/tests/webnn')
101 files changed, 5317 insertions, 1735 deletions
diff --git a/testing/web-platform/tests/webnn/gpu/arg_min_max.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/arg_min_max.https.any.js index 76092ea92e..123c8b1048 100644 --- a/testing/web-platform/tests/webnn/gpu/arg_min_max.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/arg_min_max.https.any.js @@ -7,4 +7,4 @@ // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-argminmax -testWebNNOperation(['argMin', 'argMax'], buildOperationWithSingleInput, 'gpu');
\ No newline at end of file +testWebNNOperation(['argMin', 'argMax'], buildOperationWithSingleInput);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/batch_normalization.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/batch_normalization.https.any.js index 15e66a8bc0..9a1c85db19 100644 --- a/testing/web-platform/tests/webnn/batch_normalization.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/batch_normalization.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API batchNormalization operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/conformance_tests/buffer.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/buffer.https.any.js new file mode 100644 index 0000000000..5b0f46dae0 --- /dev/null +++ b/testing/web-platform/tests/webnn/conformance_tests/buffer.https.any.js @@ -0,0 +1,12 @@ +// META: title=test WebNN API buffer operations +// META: global=window,dedicatedworker +// META: script=../resources/utils.js +// META: timeout=long + +'use strict'; + +// https://webmachinelearning.github.io/webnn/#api-mlbuffer + +testCreateWebNNBuffer("create", 4); + +testDestroyWebNNBuffer("destroyTwice");
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/gpu/cast.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/cast.https.any.js index 1830364eb5..bde2b9a4ce 100644 --- a/testing/web-platform/tests/webnn/gpu/cast.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/cast.https.any.js @@ -7,4 +7,4 @@ // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-cast -testWebNNOperation('cast', buildCast, 'gpu');
\ No newline at end of file +testWebNNOperation('cast', buildCast);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/clamp.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/clamp.https.any.js index 9818aed7c1..7b60c41f2c 100644 --- a/testing/web-platform/tests/webnn/clamp.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/clamp.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API clamp operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/gpu/concat.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/concat.https.any.js index 07073724fe..254e0b657b 100644 --- a/testing/web-platform/tests/webnn/gpu/concat.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/concat.https.any.js @@ -7,4 +7,4 @@ // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-concat -testWebNNOperation('concat', buildConcat, 'gpu');
\ No newline at end of file +testWebNNOperation('concat', buildConcat);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/conformance_tests/constant.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/constant.https.any.js new file mode 100644 index 0000000000..4814734886 --- /dev/null +++ b/testing/web-platform/tests/webnn/conformance_tests/constant.https.any.js @@ -0,0 +1,10 @@ +// META: title=test WebNN API constant +// META: global=window,dedicatedworker +// META: script=../resources/utils.js +// META: timeout=long + +'use strict'; + +// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-constant-range + +testWebNNOperation('constant', buildConstantRange);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/gpu/conv2d.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/conv2d.https.any.js index b3986b6555..0d9a621356 100644 --- a/testing/web-platform/tests/webnn/gpu/conv2d.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/conv2d.https.any.js @@ -7,4 +7,4 @@ // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-conv2d -testWebNNOperation('conv2d', buildConv2d, 'gpu');
\ No newline at end of file +testWebNNOperation('conv2d', buildConv2d);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/conv_transpose2d.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/conv_transpose2d.https.any.js index 99e76b825e..ee5d28c72a 100644 --- a/testing/web-platform/tests/webnn/conv_transpose2d.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/conv_transpose2d.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API convTranspose2d operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/gpu/elementwise_binary.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/elementwise_binary.https.any.js index 035d0c77c0..5db14a43a1 100644 --- a/testing/web-platform/tests/webnn/gpu/elementwise_binary.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/elementwise_binary.https.any.js @@ -7,4 +7,4 @@ // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-binary -testWebNNOperation(['add', 'sub', 'mul', 'div', 'max', 'min', 'pow'], buildOperationWithTwoInputs, 'gpu');
\ No newline at end of file +testWebNNOperation(['add', 'sub', 'mul', 'div', 'max', 'min', 'pow'], buildOperationWithTwoInputs);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/elementwise_logical.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/elementwise_logical.https.any.js index e614b94df5..a60c199447 100644 --- a/testing/web-platform/tests/webnn/elementwise_logical.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/elementwise_logical.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API element-wise logical operations // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/elementwise_unary.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/elementwise_unary.https.any.js index 4cdfee5bcb..8029539eda 100644 --- a/testing/web-platform/tests/webnn/elementwise_unary.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/elementwise_unary.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API element-wise unary operations // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/elu.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/elu.https.any.js index 57b624b5da..382faa97fd 100644 --- a/testing/web-platform/tests/webnn/elu.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/elu.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API elu operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/gpu/expand.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/expand.https.any.js index 82fa891a39..b1be129eac 100644 --- a/testing/web-platform/tests/webnn/gpu/expand.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/expand.https.any.js @@ -8,4 +8,4 @@ // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-expand // reuse buildReshape method -testWebNNOperation('expand', buildReshape, 'gpu');
\ No newline at end of file +testWebNNOperation('expand', buildReshape);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/gather.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gather.https.any.js index 52bcece804..39b1970563 100644 --- a/testing/web-platform/tests/webnn/gather.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gather.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API gather operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/gpu/gemm.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gemm.https.any.js index a19dc39bbc..61fd7c9b39 100644 --- a/testing/web-platform/tests/webnn/gpu/gemm.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gemm.https.any.js @@ -7,4 +7,4 @@ // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-gemm -testWebNNOperation('gemm', buildGemm, 'gpu');
\ No newline at end of file +testWebNNOperation('gemm', buildGemm);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/arg_min_max.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/arg_min_max.https.any.js index cff1d6a955..c700ee5cad 100644 --- a/testing/web-platform/tests/webnn/arg_min_max.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/arg_min_max.https.any.js @@ -1,10 +1,10 @@ // META: title=test WebNN API argMin/Max operations // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-argminmax -testWebNNOperation(['argMin', 'argMax'], buildOperationWithSingleInput);
\ No newline at end of file +testWebNNOperation(['argMin', 'argMax'], buildOperationWithSingleInput, 'gpu');
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/gpu/batch_normalization.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/batch_normalization.https.any.js index 90b6def636..534cdf6365 100644 --- a/testing/web-platform/tests/webnn/gpu/batch_normalization.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/batch_normalization.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API batchNormalization operation // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/conformance_tests/gpu/buffer.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/buffer.https.any.js new file mode 100644 index 0000000000..66bba9ef4a --- /dev/null +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/buffer.https.any.js @@ -0,0 +1,12 @@ +// META: title=test WebNN API buffer operations +// META: global=window,dedicatedworker +// META: script=../../resources/utils.js +// META: timeout=long + +'use strict'; + +// https://webmachinelearning.github.io/webnn/#api-mlbuffer + +testCreateWebNNBuffer("create", 4, 'gpu'); + +testDestroyWebNNBuffer("destroyTwice", 'gpu');
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/cast.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/cast.https.any.js index c9be45a770..e4309ffd8e 100644 --- a/testing/web-platform/tests/webnn/cast.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/cast.https.any.js @@ -1,10 +1,10 @@ // META: title=test WebNN API cast operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-cast -testWebNNOperation('cast', buildCast);
\ No newline at end of file +testWebNNOperation('cast', buildCast, 'gpu');
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/gpu/clamp.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/clamp.https.any.js index 98313868b6..9b3f93ecc7 100644 --- a/testing/web-platform/tests/webnn/gpu/clamp.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/clamp.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API clamp operation // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/concat.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/concat.https.any.js index cce43e492f..c0cfb8626b 100644 --- a/testing/web-platform/tests/webnn/concat.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/concat.https.any.js @@ -1,10 +1,10 @@ // META: title=test WebNN API concat operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-concat -testWebNNOperation('concat', buildConcat);
\ No newline at end of file +testWebNNOperation('concat', buildConcat, 'gpu');
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/conformance_tests/gpu/constant.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/constant.https.any.js new file mode 100644 index 0000000000..77b4d889a2 --- /dev/null +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/constant.https.any.js @@ -0,0 +1,10 @@ +// META: title=test WebNN API constant +// META: global=window,dedicatedworker +// META: script=../../resources/utils.js +// META: timeout=long + +'use strict'; + +// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-constant-range + +testWebNNOperation('constant', buildConstantRange, 'gpu');
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/conv2d.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/conv2d.https.any.js index b26b35ec67..770540abd8 100644 --- a/testing/web-platform/tests/webnn/conv2d.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/conv2d.https.any.js @@ -1,10 +1,10 @@ // META: title=test WebNN API conv2d operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-conv2d -testWebNNOperation('conv2d', buildConv2d);
\ No newline at end of file +testWebNNOperation('conv2d', buildConv2d, 'gpu');
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/gpu/conv_transpose2d.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/conv_transpose2d.https.any.js index 020bfa9c97..08c441b5b4 100644 --- a/testing/web-platform/tests/webnn/gpu/conv_transpose2d.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/conv_transpose2d.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API convTranspose2d operation // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/elementwise_binary.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/elementwise_binary.https.any.js index 06c2404f95..8b9fa486f8 100644 --- a/testing/web-platform/tests/webnn/elementwise_binary.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/elementwise_binary.https.any.js @@ -1,10 +1,10 @@ // META: title=test WebNN API element-wise binary operations // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-binary -testWebNNOperation(['add', 'sub', 'mul', 'div', 'max', 'min', 'pow'], buildOperationWithTwoInputs);
\ No newline at end of file +testWebNNOperation(['add', 'sub', 'mul', 'div', 'max', 'min', 'pow'], buildOperationWithTwoInputs, 'gpu');
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/gpu/elementwise_logical.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/elementwise_logical.https.any.js index f597ce8e0b..70a887a147 100644 --- a/testing/web-platform/tests/webnn/gpu/elementwise_logical.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/elementwise_logical.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API element-wise logical operations // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/gpu/elementwise_unary.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/elementwise_unary.https.any.js index 45978f91ec..8871129311 100644 --- a/testing/web-platform/tests/webnn/gpu/elementwise_unary.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/elementwise_unary.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API element-wise unary operations // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/gpu/elu.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/elu.https.any.js index 965bb4d35f..db14442641 100644 --- a/testing/web-platform/tests/webnn/gpu/elu.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/elu.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API elu operation // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/expand.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/expand.https.any.js index 11abb9baa8..f46f463781 100644 --- a/testing/web-platform/tests/webnn/expand.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/expand.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API expand operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; @@ -8,4 +8,4 @@ // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-expand // reuse buildReshape method -testWebNNOperation('expand', buildReshape);
\ No newline at end of file +testWebNNOperation('expand', buildReshape, 'gpu');
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/gpu/gather.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/gather.https.any.js index 7c8a685c5c..8e457192d8 100644 --- a/testing/web-platform/tests/webnn/gpu/gather.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/gather.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API gather operation // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/gemm.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/gemm.https.any.js index e5de9521fb..f288c31bed 100644 --- a/testing/web-platform/tests/webnn/gemm.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/gemm.https.any.js @@ -1,10 +1,10 @@ // META: title=test WebNN API gemm operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-gemm -testWebNNOperation('gemm', buildGemm);
\ No newline at end of file +testWebNNOperation('gemm', buildGemm, 'gpu');
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/gpu/hard_sigmoid.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/hard_sigmoid.https.any.js index b6f2f53b32..d40e42a211 100644 --- a/testing/web-platform/tests/webnn/gpu/hard_sigmoid.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/hard_sigmoid.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API hardSigmoid operation // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/gpu/hard_swish.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/hard_swish.https.any.js index a1731490bd..031e65ee16 100644 --- a/testing/web-platform/tests/webnn/gpu/hard_swish.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/hard_swish.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API tanh operation // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/gpu/instance_normalization.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/instance_normalization.https.any.js index e1d73de387..ecfaac71ee 100644 --- a/testing/web-platform/tests/webnn/gpu/instance_normalization.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/instance_normalization.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API instanceNormalization operation // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/gpu/layer_normalization.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/layer_normalization.https.any.js index 1deb43bee5..0e4f6caebf 100644 --- a/testing/web-platform/tests/webnn/gpu/layer_normalization.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/layer_normalization.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API layerNormalization operation // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/gpu/leaky_relu.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/leaky_relu.https.any.js index f3a7bd8ba5..9fab2353b9 100644 --- a/testing/web-platform/tests/webnn/gpu/leaky_relu.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/leaky_relu.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API leakyRelu operation // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/gpu/linear.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/linear.https.any.js index 48b8d82c1e..ccec2c3eac 100644 --- a/testing/web-platform/tests/webnn/gpu/linear.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/linear.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API linear operation // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/gpu/matmul.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/matmul.https.any.js index 01fed04e3d..635ce84ac6 100644 --- a/testing/web-platform/tests/webnn/gpu/matmul.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/matmul.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API matmul operation // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/pad.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/pad.https.any.js index 05eec653c6..f313e2c9f9 100644 --- a/testing/web-platform/tests/webnn/pad.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/pad.https.any.js @@ -1,10 +1,10 @@ // META: title=test WebNN API pad operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-pad -testWebNNOperation('pad', buildPad);
\ No newline at end of file +testWebNNOperation('pad', buildPad, 'gpu');
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/pooling.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/pooling.https.any.js index df19e57709..837bca2c71 100644 --- a/testing/web-platform/tests/webnn/pooling.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/pooling.https.any.js @@ -1,10 +1,10 @@ // META: title=test WebNN API pooling operations // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-pool2d -testWebNNOperation(['averagePool2d', 'maxPool2d'], buildOperationWithSingleInput);
\ No newline at end of file +testWebNNOperation(['averagePool2d', 'l2Pool2d', 'maxPool2d'], buildOperationWithSingleInput, 'gpu');
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/gpu/prelu.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/prelu.https.any.js index 5a1580e662..475cd9e5ce 100644 --- a/testing/web-platform/tests/webnn/gpu/prelu.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/prelu.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API prelu operation // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/gpu/reduction.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/reduction.https.any.js index 69f9b64df4..0f3cefa02e 100644 --- a/testing/web-platform/tests/webnn/gpu/reduction.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/reduction.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API reduction operation // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/gpu/relu.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/relu.https.any.js index dc09846e3b..d1a35367df 100644 --- a/testing/web-platform/tests/webnn/gpu/relu.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/relu.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API relu operation // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/conformance_tests/gpu/resample2d.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/resample2d.https.any.js new file mode 100644 index 0000000000..dd8e441946 --- /dev/null +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/resample2d.https.any.js @@ -0,0 +1,10 @@ +// META: title=test WebNN API resample2d operation +// META: global=window,dedicatedworker +// META: script=../../resources/utils.js +// META: timeout=long + +'use strict'; + +// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-resample2d-method + +testWebNNOperation('resample2d', buildOperationWithSingleInput, 'gpu');
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/gpu/reshape.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/reshape.https.any.js index e5145e2403..b0217d2e67 100644 --- a/testing/web-platform/tests/webnn/gpu/reshape.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/reshape.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API reshape operation // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/gpu/sigmoid.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/sigmoid.https.any.js index 6c85f5b303..26116c0ff9 100644 --- a/testing/web-platform/tests/webnn/gpu/sigmoid.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/sigmoid.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API sigmoid operation // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/slice.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/slice.https.any.js index cb7acefc05..1710c79a9c 100644 --- a/testing/web-platform/tests/webnn/slice.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/slice.https.any.js @@ -1,10 +1,10 @@ // META: title=test WebNN API slice operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-slice -testWebNNOperation('slice', buildSlice);
\ No newline at end of file +testWebNNOperation('slice', buildSlice, 'gpu');
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/gpu/softmax.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/softmax.https.any.js index 9170dd0e14..9eaffe2beb 100644 --- a/testing/web-platform/tests/webnn/gpu/softmax.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/softmax.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API softmax operation // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/gpu/softplus.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/softplus.https.any.js index a61e5beaef..5f06846113 100644 --- a/testing/web-platform/tests/webnn/gpu/softplus.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/softplus.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API softplus operation // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/gpu/softsign.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/softsign.https.any.js index f598cbfcef..eac0b7ec40 100644 --- a/testing/web-platform/tests/webnn/gpu/softsign.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/softsign.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API softsign operation // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/split.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/split.https.any.js index b6fc5b4d98..3b0aafd787 100644 --- a/testing/web-platform/tests/webnn/split.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/split.https.any.js @@ -1,10 +1,10 @@ // META: title=test WebNN API split operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-split -testWebNNOperation('split', buildSplit);
\ No newline at end of file +testWebNNOperation('split', buildSplit, 'gpu');
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/gpu/tanh.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/tanh.https.any.js index 15a9eeb013..3029f4865a 100644 --- a/testing/web-platform/tests/webnn/gpu/tanh.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/tanh.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API tanh operation // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/gpu/transpose.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/transpose.https.any.js index 074e18a488..295ef43ec1 100644 --- a/testing/web-platform/tests/webnn/gpu/transpose.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/transpose.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API transpose operation // META: global=window,dedicatedworker -// META: script=../resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/conformance_tests/gpu/triangular.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/triangular.https.any.js new file mode 100644 index 0000000000..3e1b0d5ab1 --- /dev/null +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/triangular.https.any.js @@ -0,0 +1,10 @@ +// META: title=test WebNN API triangular operation +// META: global=window,dedicatedworker +// META: script=../../resources/utils.js +// META: timeout=long + +'use strict'; + +// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-triangular + +testWebNNOperation('triangular', buildOperationWithSingleInput, 'gpu');
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/where.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/gpu/where.https.any.js index 306128a814..49c6cbd4e3 100644 --- a/testing/web-platform/tests/webnn/where.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/gpu/where.https.any.js @@ -1,10 +1,10 @@ // META: title=test WebNN API where operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../../resources/utils.js // META: timeout=long 'use strict'; // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-where -testWebNNOperation('where', buildWhere);
\ No newline at end of file +testWebNNOperation('where', buildWhere, 'gpu');
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/hard_sigmoid.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/hard_sigmoid.https.any.js index 81bd5124ce..8161a24538 100644 --- a/testing/web-platform/tests/webnn/hard_sigmoid.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/hard_sigmoid.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API hardSigmoid operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/hard_swish.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/hard_swish.https.any.js index 052c7f2a20..b4a7c53d8d 100644 --- a/testing/web-platform/tests/webnn/hard_swish.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/hard_swish.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API tanh operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/instance_normalization.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/instance_normalization.https.any.js index 0b7a708917..fce879172e 100644 --- a/testing/web-platform/tests/webnn/instance_normalization.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/instance_normalization.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API instanceNormalization operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/layer_normalization.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/layer_normalization.https.any.js index 380db4ea52..ab8a50cc03 100644 --- a/testing/web-platform/tests/webnn/layer_normalization.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/layer_normalization.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API layerNormalization operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/leaky_relu.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/leaky_relu.https.any.js index 61539ce92e..2b6f17e95d 100644 --- a/testing/web-platform/tests/webnn/leaky_relu.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/leaky_relu.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API leakyRelu operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/linear.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/linear.https.any.js index 4b2c05540b..465b697f29 100644 --- a/testing/web-platform/tests/webnn/linear.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/linear.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API linear operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/matmul.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/matmul.https.any.js index 8a9882afe6..64eeb37f08 100644 --- a/testing/web-platform/tests/webnn/matmul.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/matmul.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API matmul operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/gpu/pad.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/pad.https.any.js index 26d1bf0f38..f1a2400d1c 100644 --- a/testing/web-platform/tests/webnn/gpu/pad.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/pad.https.any.js @@ -7,4 +7,4 @@ // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-pad -testWebNNOperation('pad', buildPad, 'gpu');
\ No newline at end of file +testWebNNOperation('pad', buildPad);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/gpu/pooling.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/pooling.https.any.js index ab12881881..400d5ed37d 100644 --- a/testing/web-platform/tests/webnn/gpu/pooling.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/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);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/prelu.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/prelu.https.any.js index c1b2e9fa2a..83cc9db4b4 100644 --- a/testing/web-platform/tests/webnn/prelu.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/prelu.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API prelu operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/reduction.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/reduction.https.any.js index 20bd74d8de..30bfb4ba7a 100644 --- a/testing/web-platform/tests/webnn/reduction.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/reduction.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API reduction operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/relu.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/relu.https.any.js index 42b64e11de..51e427898f 100644 --- a/testing/web-platform/tests/webnn/relu.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/relu.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API relu operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/conformance_tests/resample2d.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/resample2d.https.any.js new file mode 100644 index 0000000000..0b5b3e0032 --- /dev/null +++ b/testing/web-platform/tests/webnn/conformance_tests/resample2d.https.any.js @@ -0,0 +1,10 @@ +// META: title=test WebNN API resample2d operation +// META: global=window,dedicatedworker +// META: script=../resources/utils.js +// META: timeout=long + +'use strict'; + +// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-resample2d-method + +testWebNNOperation('resample2d', buildOperationWithSingleInput);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/reshape.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/reshape.https.any.js index e0733635f8..c0dafb176c 100644 --- a/testing/web-platform/tests/webnn/reshape.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/reshape.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API reshape operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/sigmoid.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/sigmoid.https.any.js index e904d8dfa7..186f468918 100644 --- a/testing/web-platform/tests/webnn/sigmoid.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/sigmoid.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API sigmoid operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/gpu/slice.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/slice.https.any.js index 98e5f422da..6441204517 100644 --- a/testing/web-platform/tests/webnn/gpu/slice.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/slice.https.any.js @@ -7,4 +7,4 @@ // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-slice -testWebNNOperation('slice', buildSlice, 'gpu');
\ No newline at end of file +testWebNNOperation('slice', buildSlice);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/softmax.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/softmax.https.any.js index 8e5342bd75..143b7d969f 100644 --- a/testing/web-platform/tests/webnn/softmax.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/softmax.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API softmax operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/softplus.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/softplus.https.any.js index 7096f64a04..fcd6410bdb 100644 --- a/testing/web-platform/tests/webnn/softplus.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/softplus.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API softplus operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/softsign.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/softsign.https.any.js index 61a7d5365f..6e26afdade 100644 --- a/testing/web-platform/tests/webnn/softsign.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/softsign.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API softsign operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/gpu/split.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/split.https.any.js index 8eecd76fa1..0de6cb4d8d 100644 --- a/testing/web-platform/tests/webnn/gpu/split.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/split.https.any.js @@ -7,4 +7,4 @@ // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-split -testWebNNOperation('split', buildSplit, 'gpu');
\ No newline at end of file +testWebNNOperation('split', buildSplit);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/tanh.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/tanh.https.any.js index d0d45e754b..c5d1f86ab1 100644 --- a/testing/web-platform/tests/webnn/tanh.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/tanh.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API tanh operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/transpose.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/transpose.https.any.js index 63a123342a..746e53d512 100644 --- a/testing/web-platform/tests/webnn/transpose.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/transpose.https.any.js @@ -1,6 +1,6 @@ // META: title=test WebNN API transpose operation // META: global=window,dedicatedworker -// META: script=./resources/utils.js +// META: script=../resources/utils.js // META: timeout=long 'use strict'; diff --git a/testing/web-platform/tests/webnn/conformance_tests/triangular.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/triangular.https.any.js new file mode 100644 index 0000000000..503f310620 --- /dev/null +++ b/testing/web-platform/tests/webnn/conformance_tests/triangular.https.any.js @@ -0,0 +1,10 @@ +// META: title=test WebNN API triangular operation +// META: global=window,dedicatedworker +// META: script=../resources/utils.js +// META: timeout=long + +'use strict'; + +// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-triangular + +testWebNNOperation('triangular', buildOperationWithSingleInput);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/gpu/where.https.any.js b/testing/web-platform/tests/webnn/conformance_tests/where.https.any.js index ec0c5530a0..7926221d3a 100644 --- a/testing/web-platform/tests/webnn/gpu/where.https.any.js +++ b/testing/web-platform/tests/webnn/conformance_tests/where.https.any.js @@ -7,4 +7,4 @@ // https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-where -testWebNNOperation('where', buildWhere, 'gpu');
\ No newline at end of file +testWebNNOperation('where', buildWhere);
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/idlharness.https.any.js b/testing/web-platform/tests/webnn/idlharness.https.any.js index 65e21d5a1d..93e88294ef 100644 --- a/testing/web-platform/tests/webnn/idlharness.https.any.js +++ b/testing/web-platform/tests/webnn/idlharness.https.any.js @@ -28,29 +28,18 @@ idl_test( MLGraph: ['graph'] }); - for (const executionType of ExecutionArray) { - const isSync = executionType === 'sync'; - if (self.GLOBAL.isWindow() && isSync) { - continue; - } - - if (isSync) { - self.context = navigator.ml.createContextSync(); - } else { - self.context = await navigator.ml.createContext(); - } - - self.builder = new MLGraphBuilder(self.context); - self.input = builder.input('input', {dataType: 'float32', dimensions: [1, 1, 5, 5]}); - self.filter = builder.constant({dataType: 'float32', dimensions: [1, 1, 3, 3]}, new Float32Array(9).fill(1)); - self.relu = builder.relu(); - self.output = builder.conv2d(input, filter, {activation: relu, inputLayout: "nchw"}); - - if (isSync) { - self.graph = builder.buildSync({output}); - } else { - self.graph = await builder.build({output}); - } - } + self.context = await navigator.ml.createContext(); + + self.builder = new MLGraphBuilder(self.context); + self.input = + builder.input('input', {dataType: 'float32', dimensions: [1, 1, 5, 5]}); + self.filter = builder.constant( + {dataType: 'float32', dimensions: [1, 1, 3, 3]}, + new Float32Array(9).fill(1)); + self.relu = builder.relu(); + self.output = + builder.conv2d(input, filter, {activation: relu, inputLayout: "nchw"}); + + self.graph = await builder.build({output}); } ); 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 @@ -534,340 +534,6 @@ } }, { - "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": { "input": { @@ -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 @@ -421,356 +421,6 @@ } }, { - "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": { "input": { @@ -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 @@ -972,553 +972,6 @@ } }, { - "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": { "input": { 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 @@ -464,340 +464,6 @@ } }, { - "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": { "input": { @@ -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`); + } +} diff --git a/testing/web-platform/tests/webnn/validation_tests/arg_min_max.https.any.js b/testing/web-platform/tests/webnn/validation_tests/arg_min_max.https.any.js new file mode 100644 index 0000000000..700be83b04 --- /dev/null +++ b/testing/web-platform/tests/webnn/validation_tests/arg_min_max.https.any.js @@ -0,0 +1,8 @@ +// META: title=validation tests for WebNN API argMin/Max operations +// META: global=window,dedicatedworker +// META: script=../resources/utils_validation.js +// META: timeout=long + +'use strict'; + +validateOptionsAxes(['argMin', 'argMax']); diff --git a/testing/web-platform/tests/webnn/validation_tests/batch_normalization.https.any.js b/testing/web-platform/tests/webnn/validation_tests/batch_normalization.https.any.js new file mode 100644 index 0000000000..25b542d34e --- /dev/null +++ b/testing/web-platform/tests/webnn/validation_tests/batch_normalization.https.any.js @@ -0,0 +1,190 @@ +// META: title=validation tests for WebNN API batchNormalization operation +// META: global=window,dedicatedworker +// META: script=../resources/utils_validation.js +// META: timeout=long + +'use strict'; + +let meanIndex = 0; +let varianceIndex = 0; + +promise_test(async t => { + for (let dataType of allWebNNOperandDataTypes) { + const input = builder.input(`input${++inputIndex}`, {dataType, dimensions: dimensions2D}); + const validAxisArray = getAxisArray(dimensions2D); + const invalidAxisArray = generateOutOfRangeValuesArray(unsignedLongType); + for (let axis of validAxisArray) { + let size = dimensions2D[axis]; + const mean = builder.input(`mean${++meanIndex}`, {dataType, dimensions: [size]}); + const variance = builder.input(`variance${++varianceIndex}`, {dataType, dimensions: [size]}); + for (let invalidAxis of invalidAxisArray) { + assert_throws_js(TypeError, () => builder.batchNormalization(input, mean, variance, {axis: invalidAxis})); + } + } + } +}, "[batchNormalization] TypeError is expected if options.axis is outside the 'unsigned long' value range"); + +promise_test(async t => { + for (let dataType of allWebNNOperandDataTypes) { + const input = builder.input(`input${++inputIndex}`, {dataType, dimensions: dimensions2D}); + const validAxisArray = getAxisArray(dimensions2D); + for (let axis of validAxisArray) { + let size = dimensions2D[axis]; + const mean = builder.input(`mean${++meanIndex}`, {dataType, dimensions: [size]}); + const variance = builder.input(`variance${++varianceIndex}`, {dataType, dimensions: [size]}); + assert_throws_dom('DataError', () => builder.batchNormalization(input, mean, variance, {axis: getRank(dimensions2D)})); + } + } +}, "[batchNormalization] DataError is expected if options.axis is 'unsigned long' and it's not in the range 0 to the rank of input, exclusive"); + +promise_test(async t => { + for (let dataType of allWebNNOperandDataTypes) { + const input = builder.input(`input${++inputIndex}`, {dataType, dimensions: dimensions2D}); + const validAxisArray = getAxisArray(dimensions2D); + for (let axis of validAxisArray) { + let size = dimensions2D[axis]; + const mean = builder.input(`mean${++meanIndex}`, {dataType, dimensions: [size]}); + const variance = builder.input(`variance${++varianceIndex}`, {dataType, dimensions: [size]}); + for (let axis of notUnsignedLongAxisArray) { + assert_false(typeof axis === 'number' && Number.isInteger(axis), "[batchNormalization] options.axis should be of 'unsigned long'"); + assert_throws_js(TypeError, () => builder.batchNormalization(input, mean, variance, {axis})); + } + } + } +}, '[batchNormalization] TypeError is expected if options.axis is not an unsigned long interger'); + +promise_test(async t => { + for (let dataType of allWebNNOperandDataTypes) { + const input = builder.input(`input${++inputIndex}`, {dataType, dimensions: dimensions2D}); + const validAxisArray = getAxisArray(dimensions2D); + for (let axis of validAxisArray) { + const variance = builder.input(`variance${++varianceIndex}`, {dataType, dimensions: [dimensions2D[axis]]}); + for (let dimensions of allWebNNDimensionsArray) { + if (dimensions.length !== 1) { + // set mean not be 1D tensor + const mean = builder.input(`mean${++meanIndex}`, {dataType, dimensions}); + assert_throws_dom('DataError', () => builder.batchNormalization(input, mean, variance)); + } + } + } + } +}, "[batchNormalization] DataError is expected if the size of mean.dimensions is not 1"); + +promise_test(async t => { + for (let dataType of allWebNNOperandDataTypes) { + const input = builder.input(`input${++inputIndex}`, {dataType, dimensions: dimensions2D}); + const validAxisArray = getAxisArray(dimensions2D); + for (let axis of validAxisArray) { + let size = dimensions2D[axis]; + const variance = builder.input(`variance${++varianceIndex}`, {dataType, dimensions: [size]}); + for (let offset of adjustOffsetsArray) { + const adjustedSize = size + offset; + const mean = builder.input(`mean${++meanIndex}`, {dataType, dimensions: [adjustedSize]}); + assert_throws_dom('DataError', () => builder.batchNormalization(input, mean, variance, {axis})); + } + } + } +}, "[batchNormalization] DataError is expected if mean.dimensions[0] is not equal to input.dimensions[options.axis]"); + +promise_test(async t => { + for (let dataType of allWebNNOperandDataTypes) { + const input = builder.input(`input${++inputIndex}`, {dataType, dimensions: dimensions2D}); + const validAxisArray = getAxisArray(dimensions2D); + for (let axis of validAxisArray) { + const mean = builder.input(`mean${++meanIndex}`, {dataType, dimensions: [dimensions2D[axis]]}); + for (let dimensions of allWebNNDimensionsArray) { + if (dimensions.length !== 1) { + // set variance not be 1D tensor + const variance = builder.input(`variance${++varianceIndex}`, {dataType, dimensions}); + assert_throws_dom('DataError', () => builder.batchNormalization(input, mean, variance)); + } + } + } + } +}, "[batchNormalization] DataError is expected if the size of variance.dimensions is not 1"); + +promise_test(async t => { + for (let dataType of allWebNNOperandDataTypes) { + const input = builder.input(`input${++inputIndex}`, {dataType, dimensions: dimensions2D}); + const validAxisArray = getAxisArray(dimensions2D); + for (let axis of validAxisArray) { + let size = dimensions2D[axis]; + const mean = builder.input(`mean${++meanIndex}`, {dataType, dimensions: [size]}); + for (let offset of adjustOffsetsArray) { + const adjustedSize = size + offset; + const variance = builder.input(`variance${++varianceIndex}`, {dataType, dimensions: [adjustedSize]}); + assert_throws_dom('DataError', () => builder.batchNormalization(input, mean, variance, {axis})); + } + } + } +}, "[batchNormalization] DataError is expected if variance.dimensions[0] is not equal to input.dimensions[options.axis]"); + +promise_test(async t => { + for (let dataType of allWebNNOperandDataTypes) { + const input = builder.input(`input${++inputIndex}`, {dataType, dimensions: dimensions2D}); + const validAxisArray = getAxisArray(dimensions2D); + for (let axis of validAxisArray) { + const mean = builder.input(`mean${++meanIndex}`, {dataType, dimensions: [dimensions2D[axis]]}); + const variance = builder.input(`variance${++varianceIndex}`, {dataType, dimensions: [dimensions2D[axis]]}); + for (let dimensions of allWebNNDimensionsArray) { + if (dimensions.length !== 1) { + // set scale not be 1D tensor + const scale = builder.input('scale', {dataType, dimensions}); + assert_throws_dom('DataError', () => builder.batchNormalization(input, mean, variance, {axis, scale})); + } + } + } + } +}, "[batchNormalization] DataError is expected if the size of scale.dimensions is not 1"); + +promise_test(async t => { + for (let dataType of allWebNNOperandDataTypes) { + const input = builder.input(`input${++inputIndex}`, {dataType, dimensions: dimensions2D}); + const validAxisArray = getAxisArray(dimensions2D); + for (let axis of validAxisArray) { + let size = dimensions2D[axis]; + const mean = builder.input(`mean${++meanIndex}`, {dataType, dimensions: [size]}); + const variance = builder.input(`variance${++varianceIndex}`, {dataType, dimensions: [size]}); + for (let offset of adjustOffsetsArray) { + const adjustedSize = size + offset; + const scale = builder.input('scale', {dataType, dimensions: [adjustedSize]}); + assert_throws_dom('DataError', () => builder.batchNormalization(input, mean, variance, {axis, scale})); + } + } + } +}, "[batchNormalization] DataError is expected if scale.dimensions[0] is not equal to input.dimensions[options.axis]"); + +promise_test(async t => { + for (let dataType of allWebNNOperandDataTypes) { + const input = builder.input(`input${++inputIndex}`, {dataType, dimensions: dimensions2D}); + const validAxisArray = getAxisArray(dimensions2D); + for (let axis of validAxisArray) { + const mean = builder.input(`mean${++meanIndex}`, {dataType, dimensions: [dimensions2D[axis]]}); + const variance = builder.input(`variance${++varianceIndex}`, {dataType, dimensions: [dimensions2D[axis]]}); + for (let dimensions of allWebNNDimensionsArray) { + if (dimensions.length !== 1) { + // set bias not be 1D tensor + const bias = builder.input('bias', {dataType, dimensions}); + assert_throws_dom('DataError', () => builder.batchNormalization(input, mean, variance, {axis, bias})); + } + } + } + } +}, "[batchNormalization] DataError is expected if the size of bias.dimensions is not 1"); + +promise_test(async t => { + for (let dataType of allWebNNOperandDataTypes) { + const input = builder.input(`input${++inputIndex}`, {dataType, dimensions: dimensions2D}); + const validAxisArray = getAxisArray(dimensions2D); + for (let axis of validAxisArray) { + let size = dimensions2D[axis]; + const mean = builder.input(`mean${++meanIndex}`, {dataType, dimensions: [size]}); + const variance = builder.input(`variance${++varianceIndex}`, {dataType, dimensions: [size]}); + for (let offset of adjustOffsetsArray) { + const adjustedSize = size + offset; + const bias = builder.input('bias', {dataType, dimensions: [adjustedSize]}); + assert_throws_dom('DataError', () => builder.batchNormalization(input, mean, variance, {axis, bias})); + } + } + } +}, "[batchNormalization] DataError is expected if bias.dimensions[0] is not equal to input.dimensions[options.axis]"); diff --git a/testing/web-platform/tests/webnn/validation_tests/elementwise_binary.https.any.js b/testing/web-platform/tests/webnn/validation_tests/elementwise_binary.https.any.js new file mode 100644 index 0000000000..97a1a2b93c --- /dev/null +++ b/testing/web-platform/tests/webnn/validation_tests/elementwise_binary.https.any.js @@ -0,0 +1,11 @@ +// META: title=validation tests for WebNN API element-wise binary operations +// META: global=window,dedicatedworker +// META: script=../resources/utils_validation.js +// META: timeout=long + +'use strict'; + +['add', 'sub', 'mul', 'div', 'max', 'min', 'pow'].forEach((operationName) => { + validateTwoInputsOfSameDataType(operationName); + validateTwoInputsBroadcastable(operationName); +}); diff --git a/testing/web-platform/tests/webnn/validation_tests/gather.https.any.js b/testing/web-platform/tests/webnn/validation_tests/gather.https.any.js new file mode 100644 index 0000000000..67ac7d7be3 --- /dev/null +++ b/testing/web-platform/tests/webnn/validation_tests/gather.https.any.js @@ -0,0 +1,62 @@ +// META: title=validation tests for WebNN API gather operation +// META: global=window,dedicatedworker +// META: script=../resources/utils_validation.js +// META: timeout=long + +'use strict'; + +const tests = [ + { + name: '[gather] Test gather with default options and 0-D indices', + input: {dataType: 'int32', dimensions: [3]}, + indices: {dataType: 'uint64', dimensions: []}, + output: {dataType: 'int32', dimensions: []} + }, + { + name: '[gather] Test gather with axis = 2', + input: {dataType: 'float32', dimensions: [1, 2, 3, 4]}, + indices: {dataType: 'int64', dimensions: [5, 6]}, + axis: 2, + output: {dataType: 'float32', dimensions: [1, 2, 5, 6, 4]} + }, + { + name: '[gather] TypeError is expected if the input is a scalar', + input: {dataType: 'float16', dimensions: []}, + indices: {dataType: 'int64', dimensions: [1]} + }, + { + name: '[gather] TypeError is expected if the axis is greater than the rank of input', + input: {dataType: 'float16', dimensions: [1, 2, 3]}, + indices: {dataType: 'int32', dimensions: [5, 6]}, + axis: 4 + }, + { + name: '[gather] TypeError is expected if the data type of indices is invalid', + input: {dataType: 'float16', dimensions: [1, 2, 3, 4]}, + indices: {dataType: 'float32', dimensions: [5, 6]} + } +]; + +tests.forEach( + test => promise_test(async t => { + const input = builder.input( + 'input', + {dataType: test.input.dataType, dimensions: test.input.dimensions}); + const indices = builder.input( + 'indices', + {dataType: test.indices.dataType, dimensions: test.indices.dimensions}); + + const options = {}; + if (test.axis) { + options.axis = test.axis; + } + + if (test.output) { + const output = builder.gather(input, indices, options); + assert_equals(output.dataType(), test.output.dataType); + assert_array_equals(output.shape(), test.output.dimensions); + } else { + assert_throws_js( + TypeError, () => builder.gather(input, indices, options)); + } + }, test.name)); diff --git a/testing/web-platform/tests/webnn/validation_tests/gru.https.any.js b/testing/web-platform/tests/webnn/validation_tests/gru.https.any.js new file mode 100644 index 0000000000..295baab9c2 --- /dev/null +++ b/testing/web-platform/tests/webnn/validation_tests/gru.https.any.js @@ -0,0 +1,398 @@ +// META: title=validation tests for WebNN API gru operation +// META: global=window,dedicatedworker +// META: script=../resources/utils_validation.js +// META: timeout=long + +'use strict'; + +const steps = 2, batchSize = 3, inputSize = 4, hiddenSize = 5, + numDirections = 1; + +const tests = [ + { + name: '[gru] Test with default options', + input: { dataType: 'float32', dimensions: [steps, batchSize, inputSize] }, + weight: { + dataType: 'float32', + dimensions: [numDirections, 3 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float32', + dimensions: [numDirections, 3 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize, + outputs: [ + { dataType: 'float32', dimensions: [numDirections, batchSize, hiddenSize] } + ] + }, + { + name: '[gru] Test with given options', + input: { dataType: 'float32', dimensions: [steps, batchSize, inputSize] }, + weight: { + dataType: 'float32', + dimensions: [/*numDirections=*/ 2, 3 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float32', + dimensions: [/*numDirections=*/ 2, 3 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize, + options: { + bias: { + dataType: 'float32', + dimensions: [/*numDirections=*/ 2, 3 * hiddenSize] + }, + recurrentBias: { + dataType: 'float32', + dimensions: [/*numDirections=*/ 2, 3 * hiddenSize] + }, + initialHiddenState: { + dataType: 'float32', + dimensions: [/*numDirections=*/ 2, batchSize, hiddenSize] + }, + restAfter: true, + returnSequence: true, + direction: 'both', + layout: 'rzn', + activations: ['sigmoid', 'relu'] + }, + outputs: [ + { + dataType: 'float32', + dimensions: [/*numDirections=*/ 2, batchSize, hiddenSize] + }, + { + dataType: 'float32', + dimensions: [steps, /*numDirections=*/ 2, batchSize, hiddenSize] + } + ] + }, + { + name: '[gru] TypeError is expected if steps equals to zero', + input: { dataType: 'float32', dimensions: [steps, batchSize, inputSize] }, + weight: { + dataType: 'float32', + dimensions: [numDirections, 4 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float32', + dimensions: [numDirections, 4 * hiddenSize, hiddenSize] + }, + steps: 0, + hiddenSize: hiddenSize, + }, + { + name: '[gru] TypeError is expected if hiddenSize equals to zero', + input: { dataType: 'float32', dimensions: [steps, batchSize, inputSize] }, + weight: { + dataType: 'float32', + dimensions: [numDirections, 3 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float32', + dimensions: [numDirections, 3 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: 0 + }, + { + name: '[gru] TypeError is expected if hiddenSize is too large', + input: { dataType: 'float32', dimensions: [steps, batchSize, inputSize] }, + weight: { + dataType: 'float32', + dimensions: [numDirections, 3 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float32', + dimensions: [numDirections, 3 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: 4294967295, + }, + { + name: + '[gru] TypeError is expected if the data type of the inputs is not one of the floating point types', + input: { dataType: 'uint32', dimensions: [steps, batchSize, inputSize] }, + weight: { + dataType: 'uint32', + dimensions: [numDirections, 3 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'uint32', + dimensions: [numDirections, 3 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize + }, + { + name: + '[gru] TypeError is expected if the rank of input is not 3', + input: { dataType: 'float32', dimensions: [steps, batchSize] }, + weight: { + dataType: 'float32', + dimensions: [numDirections, 3 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float32', + dimensions: [numDirections, 3 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize + }, + { + name: + '[gru] TypeError is expected if input.dimensions[0] is not equal to steps', + input: { dataType: 'float32', dimensions: [1000, batchSize, inputSize] }, + weight: { + dataType: 'float32', + dimensions: [numDirections, 3 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float32', + dimensions: [numDirections, 3 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize + }, + { + name: '[gru] TypeError is expected if weight.dimensions[1] is not 3 * hiddenSize', + input: { dataType: 'float32', dimensions: [steps, batchSize, inputSize] }, + weight: { + dataType: 'float32', + dimensions: [numDirections, 4 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float32', + dimensions: [numDirections, 3 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize + }, + { + name: + '[gru] TypeError is expected if the rank of recurrentWeight is not 3', + input: { dataType: 'float32', dimensions: [steps, batchSize, inputSize] }, + weight: { + dataType: 'float32', + dimensions: [numDirections, 3 * hiddenSize, inputSize] + }, + recurrentWeight: + { dataType: 'float32', dimensions: [numDirections, 3 * hiddenSize] }, + steps: steps, + hiddenSize: hiddenSize + }, + { + name: + '[gru] TypeError is expected if the recurrentWeight.dimensions is invalid', + input: { dataType: 'float32', dimensions: [steps, batchSize, inputSize] }, + weight: { + dataType: 'float32', + dimensions: [numDirections, 3 * hiddenSize, inputSize] + }, + recurrentWeight: + { dataType: 'float32', dimensions: [numDirections, 4 * hiddenSize, inputSize] }, + steps: steps, + hiddenSize: hiddenSize + }, + { + name: + '[gru] TypeError is expected if the size of options.activations is not 2', + input: { dataType: 'float32', dimensions: [steps, batchSize, inputSize] }, + weight: { + dataType: 'float32', + dimensions: [numDirections, 3 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float32', + dimensions: [numDirections, 3 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize, + options: { activations: ['sigmoid', 'tanh', 'relu'] } + }, + { + name: + '[gru] TypeError is expected if the rank of options.bias is not 2', + input: { dataType: 'float32', dimensions: [steps, batchSize, inputSize] }, + weight: { + dataType: 'float32', + dimensions: [numDirections, 3 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float32', + dimensions: [numDirections, 3 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize, + options: { bias: { dataType: 'float32', dimensions: [numDirections] } } + }, + { + name: + '[gru] TypeError is expected if options.bias.dimensions[1] is not 3 * hiddenSize', + input: { dataType: 'float32', dimensions: [steps, batchSize, inputSize] }, + weight: { + dataType: 'float32', + dimensions: [numDirections, 3 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float32', + dimensions: [numDirections, 3 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize, + options: { bias: { dataType: 'float32', dimensions: [numDirections, hiddenSize] } } + }, + { + name: + '[gru] TypeError is expected if options.recurrentBias.dimensions[1] is not 3 * hiddenSize', + input: { dataType: 'float16', dimensions: [steps, batchSize, inputSize] }, + weight: { + dataType: 'float16', + dimensions: [numDirections, 3 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float16', + dimensions: [numDirections, 3 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize, + options: { + recurrentBias: { dataType: 'float16', dimensions: [numDirections, 4 * hiddenSize] } + } + }, + { + name: + '[gru] TypeError is expected if the rank of options.initialHiddenState is not 3', + input: { dataType: 'float16', dimensions: [steps, batchSize, inputSize] }, + weight: { + dataType: 'float16', + dimensions: [numDirections, 3 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float16', + dimensions: [numDirections, 3 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize, + options: { + initialHiddenState: { + dataType: 'float16', + dimensions: [numDirections, batchSize] + } + } + }, + { + name: + '[gru] TypeError is expected if options.initialHiddenState.dimensions[2] is not inputSize', + input: { dataType: 'float16', dimensions: [steps, batchSize, inputSize] }, + weight: { + dataType: 'float16', + dimensions: [numDirections, 3 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float16', + dimensions: [numDirections, 3 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize, + options: { + initialHiddenState: { + dataType: 'float16', + dimensions: [numDirections, batchSize, 3 * hiddenSize] + } + } + }, + { + name: + '[gru] TypeError is expected if the dataType of options.initialHiddenState is incorrect', + input: { dataType: 'float16', dimensions: [steps, batchSize, inputSize] }, + weight: { + dataType: 'float16', + dimensions: [numDirections, 3 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float16', + dimensions: [numDirections, 3 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize, + options: { + initialHiddenState: { + dataType: 'uint64', + dimensions: [numDirections, batchSize, hiddenSize] + } + } + } +]; + +tests.forEach( + test => promise_test(async t => { + const input = builder.input( + 'input', + { dataType: test.input.dataType, dimensions: test.input.dimensions }); + const weight = builder.input( + 'weight', + { dataType: test.weight.dataType, dimensions: test.weight.dimensions }); + const recurrentWeight = builder.input('recurrentWeight', { + dataType: test.recurrentWeight.dataType, + dimensions: test.recurrentWeight.dimensions + }); + + const options = {}; + if (test.options) { + if (test.options.bias) { + options.bias = builder.input('bias', { + dataType: test.options.bias.dataType, + dimensions: test.options.bias.dimensions + }); + } + if (test.options.recurrentBias) { + options.bias = builder.input('recurrentBias', { + dataType: test.options.recurrentBias.dataType, + dimensions: test.options.recurrentBias.dimensions + }); + } + if (test.options.initialHiddenState) { + options.initialHiddenState = builder.input('initialHiddenState', { + dataType: test.options.initialHiddenState.dataType, + dimensions: test.options.initialHiddenState.dimensions + }); + } + if (test.options.resetAfter) { + options.resetAfter = test.options.resetAfter; + } + if (test.options.returnSequence) { + options.returnSequence = test.options.returnSequence; + } + if (test.options.direction) { + options.direction = test.options.direction; + } + if (test.options.layout) { + options.layout = test.options.layout; + } + if (test.options.activations) { + options.activations = []; + test.options.activations.forEach( + activation => options.activations.push(builder[activation]())); + } + } + + if (test.outputs) { + const outputs = builder.gru( + input, weight, recurrentWeight, test.steps, test.hiddenSize, + options); + assert_equals(outputs.length, test.outputs.length); + for (let i = 0; i < outputs.length; ++i) { + assert_equals(outputs[i].dataType(), test.outputs[i].dataType); + assert_array_equals(outputs[i].shape(), test.outputs[i].dimensions); + } + } else { + assert_throws_js( + TypeError, + () => builder.gru( + input, weight, recurrentWeight, test.steps, test.hiddenSize, + options)); + } + }, test.name));
\ No newline at end of file diff --git a/testing/web-platform/tests/webnn/validation_tests/layer_normalization.https.any.js b/testing/web-platform/tests/webnn/validation_tests/layer_normalization.https.any.js new file mode 100644 index 0000000000..7dbcf5c74a --- /dev/null +++ b/testing/web-platform/tests/webnn/validation_tests/layer_normalization.https.any.js @@ -0,0 +1,8 @@ +// META: title=validation tests for WebNN API +// META: global=window,dedicatedworker +// META: script=../resources/utils_validation.js +// META: timeout=long + +'use strict'; + +validateOptionsAxes('layerNormalization', 4); diff --git a/testing/web-platform/tests/webnn/validation_tests/lstm.https.any.js b/testing/web-platform/tests/webnn/validation_tests/lstm.https.any.js new file mode 100644 index 0000000000..efa05090ca --- /dev/null +++ b/testing/web-platform/tests/webnn/validation_tests/lstm.https.any.js @@ -0,0 +1,386 @@ +// META: title=validation tests for WebNN API lstm operation +// META: global=window,dedicatedworker +// META: script=../resources/utils_validation.js +// META: timeout=long + +'use strict'; + +const steps = 10, batchSize = 5, inputSize = 3, hiddenSize = 8, + numDirections = 1; + +const tests = [ + { + name: '[lstm] Test with default options', + input: {dataType: 'float16', dimensions: [steps, batchSize, inputSize]}, + weight: { + dataType: 'float16', + dimensions: [numDirections, 4 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float16', + dimensions: [numDirections, 4 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize, + outputs: [ + {dataType: 'float16', dimensions: [numDirections, batchSize, hiddenSize]}, + {dataType: 'float16', dimensions: [numDirections, batchSize, hiddenSize]} + ] + }, + { + name: '[lstm] Test with given options', + input: {dataType: 'float32', dimensions: [steps, batchSize, inputSize]}, + weight: { + dataType: 'float32', + dimensions: [/*numDirections=*/ 2, 4 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float32', + dimensions: [/*numDirections=*/ 2, 4 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize, + options: { + bias: { + dataType: 'float32', + dimensions: [/*numDirections=*/ 2, 4 * hiddenSize] + }, + recurrentBias: { + dataType: 'float32', + dimensions: [/*numDirections=*/ 2, 4 * hiddenSize] + }, + peepholeWeight: { + dataType: 'float32', + dimensions: [/*numDirections=*/ 2, 3 * hiddenSize] + }, + initialHiddenState: { + dataType: 'float32', + dimensions: [/*numDirections=*/ 2, batchSize, hiddenSize] + }, + initialCellState: { + dataType: 'float32', + dimensions: [/*numDirections=*/ 2, batchSize, hiddenSize] + }, + returnSequence: true, + direction: 'both', + layout: 'ifgo', + activations: ['sigmoid', 'relu', 'tanh'] + }, + outputs: [ + { + dataType: 'float32', + dimensions: [/*numDirections=*/ 2, batchSize, hiddenSize] + }, + { + dataType: 'float32', + dimensions: [/*numDirections=*/ 2, batchSize, hiddenSize] + }, + { + dataType: 'float32', + dimensions: [steps, /*numDirections=*/ 2, batchSize, hiddenSize] + } + ] + }, + { + name: '[lstm] DataError is expected if hiddenSize equals to zero', + input: {dataType: 'float32', dimensions: [steps, batchSize, inputSize]}, + weight: { + dataType: 'float32', + dimensions: [numDirections, 4 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float32', + dimensions: [numDirections, 4 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: 0 + }, + { + name: '[lstm] DataError is expected if hiddenSize is too large', + input: {dataType: 'float32', dimensions: [steps, batchSize, inputSize]}, + weight: { + dataType: 'float32', + dimensions: [numDirections, 4 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float32', + dimensions: [numDirections, 4 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: 4294967295, + }, + { + name: '[lstm] DataError is expected if steps equals to zero', + input: {dataType: 'float32', dimensions: [steps, batchSize, inputSize]}, + weight: { + dataType: 'float32', + dimensions: [numDirections, 4 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float32', + dimensions: [numDirections, 4 * hiddenSize, hiddenSize] + }, + steps: 0, + hiddenSize: hiddenSize, + }, + { + name: + '[lstm] DataError is expected if the data type is not one of the floating point types', + input: {dataType: 'uint32', dimensions: [steps, batchSize, inputSize]}, + weight: { + dataType: 'uint32', + dimensions: [numDirections, 4 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'uint32', + dimensions: [numDirections, 4 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize + }, + { + name: + '[lstm] DataError is expected if the rank of input is not 3', + input: {dataType: 'float32', dimensions: [steps, batchSize]}, + weight: { + dataType: 'float32', + dimensions: [numDirections, 4 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float32', + dimensions: [numDirections, 4 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize + }, + { + name: + '[lstm] DataError is expected if input.dimensions[0] is not equal to steps', + input: {dataType: 'float32', dimensions: [1000, batchSize, inputSize]}, + weight: { + dataType: 'float32', + dimensions: [numDirections, 4 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float32', + dimensions: [numDirections, 4 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize + }, + { + name: '[lstm] DataError is expected if the shape of weight is incorrect', + input: {dataType: 'float32', dimensions: [steps, batchSize, inputSize]}, + weight: { + dataType: 'float32', + dimensions: [numDirections, 4 * hiddenSize, 1000] + }, + recurrentWeight: { + dataType: 'float32', + dimensions: [numDirections, 4 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize + }, + { + name: + '[lstm] DataError is expected if the rank of recurrentWeight is not 3', + input: {dataType: 'float32', dimensions: [steps, batchSize, inputSize]}, + weight: { + dataType: 'float32', + dimensions: [numDirections, 4 * hiddenSize, inputSize] + }, + recurrentWeight: + {dataType: 'float32', dimensions: [numDirections, 4 * hiddenSize]}, + steps: steps, + hiddenSize: hiddenSize + }, + { + name: + '[lstm] DataError is expected if the size of options.activations is not 3', + input: {dataType: 'float32', dimensions: [steps, batchSize, inputSize]}, + weight: { + dataType: 'float32', + dimensions: [numDirections, 4 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float32', + dimensions: [numDirections, 4 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize, + options: {activations: ['sigmoid', 'tanh']} + }, + { + name: + '[lstm] DataError is expected if the rank of options.bias is not 2', + input: {dataType: 'float16', dimensions: [steps, batchSize, inputSize]}, + weight: { + dataType: 'float16', + dimensions: [numDirections, 4 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float16', + dimensions: [numDirections, 4 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize, + options: {bias: {dataType: 'float16', dimensions: [numDirections]}} + }, + { + name: + '[lstm] DataError is expected if the shape of options.recurrentBias.dimensions is incorrect', + input: {dataType: 'float16', dimensions: [steps, batchSize, inputSize]}, + weight: { + dataType: 'float16', + dimensions: [numDirections, 4 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float16', + dimensions: [numDirections, 4 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize, + options: { + recurrentBias: {dataType: 'float16', dimensions: [numDirections, 1000]} + } + }, + { + name: + '[lstm] DataError is expected if the dataType of options.peepholeWeight is incorrect', + input: {dataType: 'float16', dimensions: [steps, batchSize, inputSize]}, + weight: { + dataType: 'float16', + dimensions: [numDirections, 4 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float16', + dimensions: [numDirections, 4 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize, + options: { + peepholeWeight: + {dataType: 'float32', dimensions: [numDirections, 3 * hiddenSize]} + } + }, + { + name: + '[lstm] DataError is expected if the dataType of options.initialHiddenState is incorrect', + input: {dataType: 'float16', dimensions: [steps, batchSize, inputSize]}, + weight: { + dataType: 'float16', + dimensions: [numDirections, 4 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float16', + dimensions: [numDirections, 4 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize, + options: { + initialHiddenState: { + dataType: 'uint64', + dimensions: [numDirections, batchSize, hiddenSize] + } + } + }, + { + name: + '[lstm] DataError is expected if the shape of options.initialCellState is incorrect', + input: {dataType: 'float32', dimensions: [steps, batchSize, inputSize]}, + weight: { + dataType: 'float32', + dimensions: [numDirections, 4 * hiddenSize, inputSize] + }, + recurrentWeight: { + dataType: 'float32', + dimensions: [numDirections, 4 * hiddenSize, hiddenSize] + }, + steps: steps, + hiddenSize: hiddenSize, + options: { + initialCellState: + {dataType: 'float32', dimensions: [numDirections, batchSize, 1000]} + } + } +]; + +tests.forEach( + test => promise_test(async t => { + const input = builder.input( + 'input', + {dataType: test.input.dataType, dimensions: test.input.dimensions}); + const weight = builder.input( + 'weight', + {dataType: test.weight.dataType, dimensions: test.weight.dimensions}); + const recurrentWeight = builder.input('recurrentWeight', { + dataType: test.recurrentWeight.dataType, + dimensions: test.recurrentWeight.dimensions + }); + + const options = {}; + if (test.options) { + if (test.options.bias) { + options.bias = builder.input('bias', { + dataType: test.options.bias.dataType, + dimensions: test.options.bias.dimensions + }); + } + if (test.options.recurrentBias) { + options.bias = builder.input('recurrentBias', { + dataType: test.options.recurrentBias.dataType, + dimensions: test.options.recurrentBias.dimensions + }); + } + if (test.options.peepholeWeight) { + options.peepholeWeight = builder.input('peepholeWeight', { + dataType: test.options.peepholeWeight.dataType, + dimensions: test.options.peepholeWeight.dimensions + }); + } + if (test.options.initialHiddenState) { + options.initialHiddenState = builder.input('initialHiddenState', { + dataType: test.options.initialHiddenState.dataType, + dimensions: test.options.initialHiddenState.dimensions + }); + } + if (test.options.initialCellState) { + options.initialCellState = builder.input('initialCellState', { + dataType: test.options.initialCellState.dataType, + dimensions: test.options.initialCellState.dimensions + }); + } + if (test.options.returnSequence) { + options.returnSequence = test.options.returnSequence; + } + if (test.options.direction) { + options.direction = test.options.direction; + } + if (test.options.layout) { + options.layout = test.options.layout; + } + if (test.options.activations) { + options.activations = []; + test.options.activations.forEach( + activation => options.activations.push(builder[activation]())); + } + } + + if (test.outputs) { + const outputs = builder.lstm( + input, weight, recurrentWeight, test.steps, test.hiddenSize, + options); + assert_equals(outputs.length, test.outputs.length); + for (let i = 0; i < outputs.length; ++i) { + assert_equals(outputs[i].dataType(), test.outputs[i].dataType); + assert_array_equals(outputs[i].shape(), test.outputs[i].dimensions); + } + } else { + assert_throws_dom( + 'DataError', + () => builder.lstm( + input, weight, recurrentWeight, test.steps, test.hiddenSize, + options)); + } + }, test.name)); diff --git a/testing/web-platform/tests/webnn/validation_tests/reduction.https.any.js b/testing/web-platform/tests/webnn/validation_tests/reduction.https.any.js new file mode 100644 index 0000000000..65b71239b9 --- /dev/null +++ b/testing/web-platform/tests/webnn/validation_tests/reduction.https.any.js @@ -0,0 +1,21 @@ +// META: title=validation tests for WebNN API reduction operation +// META: global=window,dedicatedworker +// META: script=../resources/utils_validation.js +// META: timeout=long + +'use strict'; + +[ + 'reduceL1', + 'reduceL2', + 'reduceLogSum', + 'reduceLogSumExp', + 'reduceMax', + 'reduceMean', + 'reduceMin', + 'reduceProduct', + 'reduceSum', + 'reduceSumSquare', +].forEach((operationName) => { + validateOptionsAxes(operationName); +}); diff --git a/testing/web-platform/tests/webnn/validation_tests/resample2d.https.any.js b/testing/web-platform/tests/webnn/validation_tests/resample2d.https.any.js new file mode 100644 index 0000000000..2e00cf297c --- /dev/null +++ b/testing/web-platform/tests/webnn/validation_tests/resample2d.https.any.js @@ -0,0 +1,8 @@ +// META: title=validation tests for WebNN API resample2d operation +// META: global=window,dedicatedworker +// META: script=../resources/utils_validation.js +// META: timeout=long + +'use strict'; + +validateOptionsAxes('resample2d', 4); diff --git a/testing/web-platform/tests/webnn/validation_tests/triangular.https.any.js b/testing/web-platform/tests/webnn/validation_tests/triangular.https.any.js new file mode 100644 index 0000000000..4e4c368f82 --- /dev/null +++ b/testing/web-platform/tests/webnn/validation_tests/triangular.https.any.js @@ -0,0 +1,16 @@ +// META: title=validation tests for WebNN API triangular operation +// META: global=window,dedicatedworker +// META: script=../resources/utils_validation.js +// META: timeout=long + +'use strict'; + +promise_test(async t => { + // The input tensor which is at least 2-D. + for (let dimensions of allWebNNDimensionsArray.slice(0, 2)) { + for (let dataType of allWebNNOperandDataTypes) { + const input = builder.input(`input${++inputIndex}`, {dataType, dimensions}); + assert_throws_js(TypeError, () => builder.triangular(input)); + } + } +}, "[triangular] DataError is expected if input's rank is less than 2"); |