diff --git a/webnn/expand.https.any.js b/webnn/expand.https.any.js new file mode 100644 index 00000000000000..11abb9baa89da3 --- /dev/null +++ b/webnn/expand.https.any.js @@ -0,0 +1,11 @@ +// META: title=test WebNN API expand operation +// META: global=window,dedicatedworker +// META: script=./resources/utils.js +// META: timeout=long + +'use strict'; + +// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-expand + +// reuse buildReshape method +testWebNNOperation('expand', buildReshape); \ No newline at end of file diff --git a/webnn/gpu/expand.https.any.js b/webnn/gpu/expand.https.any.js new file mode 100644 index 00000000000000..82fa891a39933a --- /dev/null +++ b/webnn/gpu/expand.https.any.js @@ -0,0 +1,11 @@ +// META: title=test WebNN API expand operation +// META: global=window,dedicatedworker +// META: script=../resources/utils.js +// META: timeout=long + +'use strict'; + +// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-expand + +// reuse buildReshape method +testWebNNOperation('expand', buildReshape, 'gpu'); \ No newline at end of file diff --git a/webnn/resources/utils.js b/webnn/resources/utils.js index 68fc3550585ba5..328b0bb8a5e1a9 100644 --- a/webnn/resources/utils.js +++ b/webnn/resources/utils.js @@ -318,6 +318,7 @@ const PrecisionMetrics = { tan: {ATOL: {float32: 1/1024, float16: 1/512}}, // End Element-wise unary operations elu: {ULP: {float32: 18, float16: 18}}, + expand: {ULP: {float32: 0, float16: 0}}, gemm: {ULP: {float32: getGemmPrecisionTolerance, float16: getGemmPrecisionTolerance}}, hardSigmoid: {ULP: {float32: 2, float16: 2}}, hardSwish: {ULP: {float32: 4, float16: 4}}, @@ -661,10 +662,11 @@ const buildPad = (operationName, builder, resources) => { }; const buildReshape = (operationName, builder, resources) => { - // MLOperand reshape(MLOperand input, sequence newShape); + // MLOperand reshape(MLOperand input, sequence newShape); + // MLOperand expand(MLOperand input, sequence newShape); const namedOutputOperand = {}; const inputOperand = createSingleInputOperand(builder, resources); - // invoke builder.reshape() + // invoke builder.reshape() or builder.expand() namedOutputOperand[resources.expected.name] = builder[operationName](inputOperand, resources.newShape); return namedOutputOperand; };