From aa4eddf17cdc5dd2c9cf3853b9a1c6e054281554 Mon Sep 17 00:00:00 2001 From: Austin Sullivan Date: Wed, 30 Oct 2024 01:12:45 -0700 Subject: [PATCH] webnn: Deprecate MLOperand members in favor of readonly attributes As proposed in https://github.com/webmachinelearning/webnn/issues/666 Bug: 365813262 Cq-Include-Trybots: luci.chromium.try:mac14-blink-rel,win11-blink-rel Change-Id: I1fb29ee349ee527a574dc7e135200f8e774d709b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5975719 Auto-Submit: Austin Sullivan Reviewed-by: ningxin hu Commit-Queue: ningxin hu Cr-Commit-Position: refs/heads/main@{#1375719} --- webnn/resources/utils.js | 12 ++++++------ webnn/resources/utils_validation.js | 8 ++++---- webnn/validation_tests/argMinMax.https.any.js | 8 ++++---- .../validation_tests/batchNormalization.https.any.js | 4 ++-- webnn/validation_tests/clamp.https.any.js | 8 ++++---- webnn/validation_tests/concat.https.any.js | 4 ++-- webnn/validation_tests/constant.https.any.js | 4 ++-- webnn/validation_tests/conv2d.https.any.js | 4 ++-- webnn/validation_tests/convTranspose2d.https.any.js | 4 ++-- webnn/validation_tests/cumulativeSum.https.any.js | 4 ++-- webnn/validation_tests/dequantizeLinear.https.any.js | 4 ++-- .../validation_tests/elementwise-binary.https.any.js | 4 ++-- webnn/validation_tests/elu.https.any.js | 4 ++-- webnn/validation_tests/expand.https.any.js | 8 ++++---- webnn/validation_tests/gather.https.any.js | 4 ++-- webnn/validation_tests/gatherElements.https.any.js | 4 ++-- webnn/validation_tests/gatherND.https.any.js | 4 ++-- webnn/validation_tests/gemm.https.any.js | 4 ++-- webnn/validation_tests/gru.https.any.js | 4 ++-- webnn/validation_tests/gruCell.https.any.js | 4 ++-- webnn/validation_tests/hardSigmoid.https.any.js | 4 ++-- webnn/validation_tests/input.https.any.js | 4 ++-- .../instanceNormalization.https.any.js | 4 ++-- .../validation_tests/layerNormalization.https.any.js | 4 ++-- webnn/validation_tests/leakyRelu.https.any.js | 4 ++-- webnn/validation_tests/linear.https.any.js | 4 ++-- webnn/validation_tests/lstm.https.any.js | 4 ++-- webnn/validation_tests/lstmCell.https.any.js | 4 ++-- webnn/validation_tests/matmul.https.any.js | 4 ++-- webnn/validation_tests/pad.https.any.js | 4 ++-- .../pooling-and-reduction-keep-dims.https.any.js | 8 ++++---- webnn/validation_tests/pooling.https.any.js | 8 ++++---- webnn/validation_tests/prelu.https.any.js | 8 ++++---- webnn/validation_tests/quantizeLinear.https.any.js | 4 ++-- webnn/validation_tests/reduction.https.any.js | 8 ++++---- webnn/validation_tests/resample2d.https.any.js | 8 ++++---- webnn/validation_tests/reshape.https.any.js | 4 ++-- webnn/validation_tests/scatterElements.https.any.js | 4 ++-- webnn/validation_tests/scatterND.https.any.js | 4 ++-- webnn/validation_tests/slice.https.any.js | 4 ++-- webnn/validation_tests/softmax.https.any.js | 8 ++++---- webnn/validation_tests/split.https.any.js | 4 ++-- webnn/validation_tests/tile.https.any.js | 4 ++-- webnn/validation_tests/transpose.https.any.js | 8 ++++---- webnn/validation_tests/where.https.any.js | 4 ++-- 45 files changed, 116 insertions(+), 116 deletions(-) diff --git a/webnn/resources/utils.js b/webnn/resources/utils.js index 973c16baca7602..112d48774863cd 100644 --- a/webnn/resources/utils.js +++ b/webnn/resources/utils.js @@ -26,7 +26,7 @@ const getSoftmaxPrecisionTolerance = if (inputs[inputIndex]) { inputShape = inputs[inputIndex].descriptor.shape; } else { - inputShape = intermediateOperands[inputIndex].shape(); + inputShape = intermediateOperands[inputIndex].shape; } const axis = args.length === 2 ? args[1][Object.keys(args[1])[0]] : 1; const tolerance = inputShape[axis] * 3 + 3; @@ -132,10 +132,10 @@ const assertDescriptorsEquals = (outputOperand, expected) => { const dataType = expected.castedType ? expected.castedType : expected.dataType; assert_true( - outputOperand.dataType() === dataType, + outputOperand.dataType === dataType, 'actual output dataType should be equal to expected output dataType'); assert_array_equals( - outputOperand.shape(), expected.shape, + outputOperand.shape, expected.shape, 'actual output shape should be equal to expected output shape'); }; @@ -634,7 +634,7 @@ const getGemmPrecisionTolerance = if (inputs[indexA]) { ShapeA = inputs[indexA].descriptor.shape; } else { - ShapeA = intermediateOperands[indexA].shape(); + ShapeA = intermediateOperands[indexA].shape; } const options = args.length === 3 ? {...args[2][Object.keys(args[2])[0]]} : {}; @@ -671,13 +671,13 @@ const getConv2dPrecisionTolerance = if (inputs[inputIndex]) { inputShape = inputs[inputIndex].descriptor.shape; } else { - inputShape = intermediateOperands[inputIndex].shape(); + inputShape = intermediateOperands[inputIndex].shape; } let filterShape; if (inputs[filterIndex]) { filterShape = inputs[filterIndex].descriptor.shape; } else { - filterShape = intermediateOperands[filterIndex].shape(); + filterShape = intermediateOperands[filterIndex].shape; } const options = args.length === 3 ? {...args[2][Object.keys(args[2])[0]]} : {}; diff --git a/webnn/resources/utils_validation.js b/webnn/resources/utils_validation.js index f491801bf3a6c0..0f07b777def10f 100644 --- a/webnn/resources/utils_validation.js +++ b/webnn/resources/utils_validation.js @@ -438,8 +438,8 @@ function validateUnaryOperation(operationName, supportedDataTypes, label) { const input = builder.input(`input`, {dataType, shape}); assert_equals(typeof builder[operationName], 'function'); const output = builder[operationName](input); - assert_equals(output.dataType(), dataType); - assert_array_equals(output.shape(), shape); + assert_equals(output.dataType, dataType); + assert_array_equals(output.shape, shape); } } }, `[${operationName}] Test building an unary operator with supported type.`); @@ -484,8 +484,8 @@ function validateSingleInputOperation(operationName, label) { for (let shape of allWebNNShapesArray) { const input = builder.input(`input`, {dataType, shape}); const output = builder[operationName](input); - assert_equals(output.dataType(), dataType); - assert_array_equals(output.shape(), shape); + assert_equals(output.dataType, dataType); + assert_array_equals(output.shape, shape); } } }, `[${operationName}] Test building the operator with supported data type.`); diff --git a/webnn/validation_tests/argMinMax.https.any.js b/webnn/validation_tests/argMinMax.https.any.js index abd4e878a2a589..a6c74f1fb41b94 100644 --- a/webnn/validation_tests/argMinMax.https.any.js +++ b/webnn/validation_tests/argMinMax.https.any.js @@ -74,8 +74,8 @@ function runTests(operatorName, tests) { if (context.opSupportLimits()[operatorName].output.dataTypes.includes( test.options.outputDataType)) { const output = builder[operatorName](input, axis, test.options); - assert_equals(output.dataType(), test.options.outputDataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.options.outputDataType); + assert_array_equals(output.shape, test.output.shape); } else { assert_throws_js( TypeError, () => builder[operatorName](input, axis, test.options)); @@ -84,8 +84,8 @@ function runTests(operatorName, tests) { } if (test.output) { const output = builder[operatorName](input, axis, test.options); - assert_equals(output.dataType(), 'int32'); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, 'int32'); + assert_array_equals(output.shape, test.output.shape); } else { const regrexp = /\[arg_min_max_1_\!\]/; assert_throws_with_label( diff --git a/webnn/validation_tests/batchNormalization.https.any.js b/webnn/validation_tests/batchNormalization.https.any.js index 636f803ecb7ee3..d503899a193741 100644 --- a/webnn/validation_tests/batchNormalization.https.any.js +++ b/webnn/validation_tests/batchNormalization.https.any.js @@ -267,8 +267,8 @@ tests.forEach( if (test.output) { const output = builder.batchNormalization(input, mean, variance, test.options); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const regrexp = /\[batchNormalization_\?_123\]/; assert_throws_with_label( diff --git a/webnn/validation_tests/clamp.https.any.js b/webnn/validation_tests/clamp.https.any.js index e76092daf43adb..787c40fea604b8 100644 --- a/webnn/validation_tests/clamp.https.any.js +++ b/webnn/validation_tests/clamp.https.any.js @@ -18,8 +18,8 @@ promise_test(async t => { const options = {minValue: 1.0, maxValue: 3.0}; const input = builder.input('input', {dataType: 'float32', shape: [1, 2, 3]}); const output = builder.clamp(input, options); - assert_equals(output.dataType(), 'float32'); - assert_array_equals(output.shape(), [1, 2, 3]); + assert_equals(output.dataType, 'float32'); + assert_array_equals(output.shape, [1, 2, 3]); }, '[clamp] Build with options'); promise_test(async t => { @@ -28,8 +28,8 @@ promise_test(async t => { const input = builder.input('input', {dataType: 'float32', shape: [1, 2, 3, 4]}); const output = builder.clamp(input, options); - assert_equals(output.dataType(), 'float32'); - assert_array_equals(output.shape(), [1, 2, 3, 4]); + assert_equals(output.dataType, 'float32'); + assert_array_equals(output.shape, [1, 2, 3, 4]); }, '[clamp] Build with options.minValue == options.maxValue'); promise_test(async t => { diff --git a/webnn/validation_tests/concat.https.any.js b/webnn/validation_tests/concat.https.any.js index 65c56a842461e6..6ccac4e7e8b5a3 100644 --- a/webnn/validation_tests/concat.https.any.js +++ b/webnn/validation_tests/concat.https.any.js @@ -97,8 +97,8 @@ tests.forEach( } if (test.output) { const output = builder.concat(inputs, test.axis); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const options = {label}; const regrexp = new RegExp('\\[' + label + '\\]'); diff --git a/webnn/validation_tests/constant.https.any.js b/webnn/validation_tests/constant.https.any.js index fc0243197dba43..dccb41d4b24037 100644 --- a/webnn/validation_tests/constant.https.any.js +++ b/webnn/validation_tests/constant.https.any.js @@ -129,8 +129,8 @@ tests.forEach( const bufferView = new test.bufferView.type(buffer); if (test.output) { const constantOperand = builder.constant(test.descriptor, bufferView); - assert_equals(constantOperand.dataType(), test.output.dataType); - assert_array_equals(constantOperand.shape(), test.output.shape); + assert_equals(constantOperand.dataType, test.output.dataType); + assert_array_equals(constantOperand.shape, test.output.shape); } else { assert_throws_js( TypeError, () => builder.constant(test.descriptor, bufferView)); diff --git a/webnn/validation_tests/conv2d.https.any.js b/webnn/validation_tests/conv2d.https.any.js index 405538ff4d8040..eda93e38b2b499 100644 --- a/webnn/validation_tests/conv2d.https.any.js +++ b/webnn/validation_tests/conv2d.https.any.js @@ -550,8 +550,8 @@ tests.forEach( context.opSupportLimits().conv2d.input.dataTypes.includes( test.input.dataType)) { const output = builder.conv2d(input, filter, test.options); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const regrexp = /\[conv_2d_\*\]/; assert_throws_with_label( diff --git a/webnn/validation_tests/convTranspose2d.https.any.js b/webnn/validation_tests/convTranspose2d.https.any.js index c128903e9cc51f..cafb0e86e44a7d 100644 --- a/webnn/validation_tests/convTranspose2d.https.any.js +++ b/webnn/validation_tests/convTranspose2d.https.any.js @@ -565,8 +565,8 @@ tests.forEach( context.opSupportLimits().convTranspose2d.input.dataTypes.includes( test.input.dataType)) { const output = builder.convTranspose2d(input, filter, test.options); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const regrexp = new RegExp('\\[' + label + '\\]'); assert_throws_with_label( diff --git a/webnn/validation_tests/cumulativeSum.https.any.js b/webnn/validation_tests/cumulativeSum.https.any.js index 6381d674ab4e95..9e6a22d825bc7a 100644 --- a/webnn/validation_tests/cumulativeSum.https.any.js +++ b/webnn/validation_tests/cumulativeSum.https.any.js @@ -62,8 +62,8 @@ tests.forEach( } if (test.output) { const output = builder.cumulativeSum(input, test.axis, options); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const label = 'cumulative_sum'; options.label = label; diff --git a/webnn/validation_tests/dequantizeLinear.https.any.js b/webnn/validation_tests/dequantizeLinear.https.any.js index a5e6c8ea50e199..d0dd2c15dfff2d 100644 --- a/webnn/validation_tests/dequantizeLinear.https.any.js +++ b/webnn/validation_tests/dequantizeLinear.https.any.js @@ -83,8 +83,8 @@ tests.forEach( const zeroPoint = builder.input('zeroPoint', test.zeroPoint); if (test.output) { const output = builder.dequantizeLinear(input, scale, zeroPoint); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const label = 'dequantize_linear_123'; const options = {label}; diff --git a/webnn/validation_tests/elementwise-binary.https.any.js b/webnn/validation_tests/elementwise-binary.https.any.js index e578a343468f01..32777f84681a9e 100644 --- a/webnn/validation_tests/elementwise-binary.https.any.js +++ b/webnn/validation_tests/elementwise-binary.https.any.js @@ -73,8 +73,8 @@ function runElementWiseBinaryTests(operatorName, tests) { if (test.output) { const output = builder[operatorName](a, b); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const options = {label}; assert_throws_with_label( diff --git a/webnn/validation_tests/elu.https.any.js b/webnn/validation_tests/elu.https.any.js index 4fe08b1b0cef18..5ddcdaf8484b60 100644 --- a/webnn/validation_tests/elu.https.any.js +++ b/webnn/validation_tests/elu.https.any.js @@ -19,8 +19,8 @@ promise_test(async t => { const options = {alpha: 1.0}; const input = builder.input('input', {dataType: 'float32', shape: [1, 2, 3]}); const output = builder.elu(input, options); - assert_equals(output.dataType(), 'float32'); - assert_array_equals(output.shape(), [1, 2, 3]); + assert_equals(output.dataType, 'float32'); + assert_array_equals(output.shape, [1, 2, 3]); }, '[elu] Build with options'); promise_test(async t => { diff --git a/webnn/validation_tests/expand.https.any.js b/webnn/validation_tests/expand.https.any.js index 23fe94aedc1eb1..c9c60358917f8b 100644 --- a/webnn/validation_tests/expand.https.any.js +++ b/webnn/validation_tests/expand.https.any.js @@ -71,8 +71,8 @@ tests.forEach( if (test.output) { const output = builder.expand(input, test.newShape); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const options = {...test.options}; if (options.label) { @@ -97,8 +97,8 @@ promise_test(async t => { const input = builder.input(`input`, {dataType, shape}); if (context.opSupportLimits().expand.input.dataTypes.includes(dataType)) { const output = builder.expand(input, newShape); - assert_equals(output.dataType(), dataType); - assert_array_equals(output.shape(), newShape); + assert_equals(output.dataType, dataType); + assert_array_equals(output.shape, newShape); } else { assert_throws_js(TypeError, () => builder.expand(input, newShape)); } diff --git a/webnn/validation_tests/gather.https.any.js b/webnn/validation_tests/gather.https.any.js index dbeacbfc2791f0..e4a46a90d4b363 100644 --- a/webnn/validation_tests/gather.https.any.js +++ b/webnn/validation_tests/gather.https.any.js @@ -74,8 +74,8 @@ tests.forEach( if (test.output) { const output = builder.gather(input, indices, options); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const label = 'gather_' options.label = label; diff --git a/webnn/validation_tests/gatherElements.https.any.js b/webnn/validation_tests/gatherElements.https.any.js index 4c4b04490e8b6c..e30e4a5a13b1b8 100644 --- a/webnn/validation_tests/gatherElements.https.any.js +++ b/webnn/validation_tests/gatherElements.https.any.js @@ -64,8 +64,8 @@ tests.forEach( if (test.output) { const output = builder.gatherElements(input, indices, options); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const label = 'gatherElements_' options.label = label; diff --git a/webnn/validation_tests/gatherND.https.any.js b/webnn/validation_tests/gatherND.https.any.js index a8bfa2b336bf56..697dda00776404 100644 --- a/webnn/validation_tests/gatherND.https.any.js +++ b/webnn/validation_tests/gatherND.https.any.js @@ -46,8 +46,8 @@ tests.forEach(test => promise_test(async t => { context.opSupportLimits().gatherND.input.dataTypes.includes( test.input.dataType)) { const output = builder.gatherND(input, indices); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const label = 'gatherND_'; const options = {label: label}; diff --git a/webnn/validation_tests/gemm.https.any.js b/webnn/validation_tests/gemm.https.any.js index cad1806b5ff918..6115003d0392bb 100644 --- a/webnn/validation_tests/gemm.https.any.js +++ b/webnn/validation_tests/gemm.https.any.js @@ -164,8 +164,8 @@ tests.forEach( } if (test.output) { const output = builder.gemm(a, b, test.options); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const regrexp = new RegExp('\\[' + label + '\\]'); assert_throws_with_label( diff --git a/webnn/validation_tests/gru.https.any.js b/webnn/validation_tests/gru.https.any.js index 158384a4b78777..e074a27648f091 100644 --- a/webnn/validation_tests/gru.https.any.js +++ b/webnn/validation_tests/gru.https.any.js @@ -300,8 +300,8 @@ tests.forEach( 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].shape); + assert_equals(outputs[i].dataType, test.outputs[i].dataType); + assert_array_equals(outputs[i].shape, test.outputs[i].shape); } } else { const label = 'gru_xxx'; diff --git a/webnn/validation_tests/gruCell.https.any.js b/webnn/validation_tests/gruCell.https.any.js index 7bbb9afcff0eac..b176b379330440 100644 --- a/webnn/validation_tests/gruCell.https.any.js +++ b/webnn/validation_tests/gruCell.https.any.js @@ -298,8 +298,8 @@ tests.forEach( const output = builder.gruCell( input, weight, recurrentWeight, hiddenState, test.hiddenSize, options); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const label = 'gru_cell_xxx'; options.label = label; diff --git a/webnn/validation_tests/hardSigmoid.https.any.js b/webnn/validation_tests/hardSigmoid.https.any.js index 8134863a3112c8..f3a9ea0ba0e81c 100644 --- a/webnn/validation_tests/hardSigmoid.https.any.js +++ b/webnn/validation_tests/hardSigmoid.https.any.js @@ -18,8 +18,8 @@ promise_test(async t => { const options = {alpha: 0.5, beta: 1.0}; const input = builder.input('input', {dataType: 'float16', shape: [1, 2, 3]}); const output = builder.hardSigmoid(input, options); - assert_equals(output.dataType(), 'float16'); - assert_array_equals(output.shape(), [1, 2, 3]); + assert_equals(output.dataType, 'float16'); + assert_array_equals(output.shape, [1, 2, 3]); }, '[hardSigmoid] Test building with options'); promise_test(async t => { diff --git a/webnn/validation_tests/input.https.any.js b/webnn/validation_tests/input.https.any.js index b5b257d8bb02a2..cc60c44567046b 100644 --- a/webnn/validation_tests/input.https.any.js +++ b/webnn/validation_tests/input.https.any.js @@ -58,8 +58,8 @@ tests.forEach( const builder = new MLGraphBuilder(context); if (test.output) { const inputOperand = builder.input(test.name, test.descriptor); - assert_equals(inputOperand.dataType(), test.output.dataType); - assert_array_equals(inputOperand.shape(), test.output.shape); + assert_equals(inputOperand.dataType, test.output.dataType); + assert_array_equals(inputOperand.shape, test.output.shape); } else { assert_throws_js( TypeError, () => builder.input(test.name, test.descriptor)); diff --git a/webnn/validation_tests/instanceNormalization.https.any.js b/webnn/validation_tests/instanceNormalization.https.any.js index 618be23fdec86a..f09e67da414b6a 100644 --- a/webnn/validation_tests/instanceNormalization.https.any.js +++ b/webnn/validation_tests/instanceNormalization.https.any.js @@ -193,8 +193,8 @@ tests.forEach( .instanceNormalization.input.dataTypes.includes( test.input.dataType)) { const output = builder.instanceNormalization(input, test.options); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const regrexp = new RegExp('\\[' + label + '\\]'); assert_throws_with_label( diff --git a/webnn/validation_tests/layerNormalization.https.any.js b/webnn/validation_tests/layerNormalization.https.any.js index 97bb479f04d4ae..445bace965193d 100644 --- a/webnn/validation_tests/layerNormalization.https.any.js +++ b/webnn/validation_tests/layerNormalization.https.any.js @@ -210,8 +210,8 @@ tests.forEach( context.opSupportLimits().layerNormalization.input.dataTypes.includes( test.input.dataType)) { const output = builder.layerNormalization(input, test.options); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const regrexp = new RegExp('\\[' + label + '\\]'); assert_throws_with_label( diff --git a/webnn/validation_tests/leakyRelu.https.any.js b/webnn/validation_tests/leakyRelu.https.any.js index c49ac659ef4d7d..b64d7681d93aea 100644 --- a/webnn/validation_tests/leakyRelu.https.any.js +++ b/webnn/validation_tests/leakyRelu.https.any.js @@ -17,8 +17,8 @@ promise_test(async t => { const options = {alpha: 0.02}; const input = builder.input('input', {dataType: 'float32', shape: [1, 2, 3]}); const output = builder.leakyRelu(input, options); - assert_equals(output.dataType(), 'float32'); - assert_array_equals(output.shape(), [1, 2, 3]); + assert_equals(output.dataType, 'float32'); + assert_array_equals(output.shape, [1, 2, 3]); }, '[leakyRelu] Build with options'); promise_test(async t => { diff --git a/webnn/validation_tests/linear.https.any.js b/webnn/validation_tests/linear.https.any.js index 816dad35039a30..d904b9290ff24a 100644 --- a/webnn/validation_tests/linear.https.any.js +++ b/webnn/validation_tests/linear.https.any.js @@ -17,8 +17,8 @@ promise_test(async t => { const options = {alpha: 1.5, beta: 0.3}; const input = builder.input('input', {dataType: 'float32', shape: [1, 2, 3]}); const output = builder.linear(input, options); - assert_equals(output.dataType(), 'float32'); - assert_array_equals(output.shape(), [1, 2, 3]); + assert_equals(output.dataType, 'float32'); + assert_array_equals(output.shape, [1, 2, 3]); }, '[linear] Build with options'); promise_test(async t => { diff --git a/webnn/validation_tests/lstm.https.any.js b/webnn/validation_tests/lstm.https.any.js index 8cc2a014a7c4aa..8d8175ecb0988e 100644 --- a/webnn/validation_tests/lstm.https.any.js +++ b/webnn/validation_tests/lstm.https.any.js @@ -296,8 +296,8 @@ tests.forEach( 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].shape); + assert_equals(outputs[i].dataType, test.outputs[i].dataType); + assert_array_equals(outputs[i].shape, test.outputs[i].shape); } } else { const label = 'lstm_xxx'; diff --git a/webnn/validation_tests/lstmCell.https.any.js b/webnn/validation_tests/lstmCell.https.any.js index a739761d56ea7e..a4e15af1b25f8f 100644 --- a/webnn/validation_tests/lstmCell.https.any.js +++ b/webnn/validation_tests/lstmCell.https.any.js @@ -523,8 +523,8 @@ tests.forEach( 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].shape); + assert_equals(outputs[i].dataType, test.outputs[i].dataType); + assert_array_equals(outputs[i].shape, test.outputs[i].shape); } } else { const label = 'lstm_cell_xxx'; diff --git a/webnn/validation_tests/matmul.https.any.js b/webnn/validation_tests/matmul.https.any.js index 4f8a1ee59a3816..86440e2b0f1c97 100644 --- a/webnn/validation_tests/matmul.https.any.js +++ b/webnn/validation_tests/matmul.https.any.js @@ -109,8 +109,8 @@ tests.forEach(test => promise_test(async t => { const inputB = builder.input('b', test.inputs.b); if (test.output) { const output = builder.matmul(inputA, inputB); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const label = 'matmul_123'; const options = {label}; diff --git a/webnn/validation_tests/pad.https.any.js b/webnn/validation_tests/pad.https.any.js index b45f68ab014114..ca11bd2c9695a4 100644 --- a/webnn/validation_tests/pad.https.any.js +++ b/webnn/validation_tests/pad.https.any.js @@ -82,8 +82,8 @@ tests.forEach( if (test.output) { const output = builder.pad( input, test.beginningPadding, test.endingPadding, test.options); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const regrexp = new RegExp('\\[' + label + '\\]'); assert_throws_with_label( diff --git a/webnn/validation_tests/pooling-and-reduction-keep-dims.https.any.js b/webnn/validation_tests/pooling-and-reduction-keep-dims.https.any.js index 3beee94cd44dcd..969c5c61a498e1 100644 --- a/webnn/validation_tests/pooling-and-reduction-keep-dims.https.any.js +++ b/webnn/validation_tests/pooling-and-reduction-keep-dims.https.any.js @@ -42,8 +42,8 @@ promise_test(async t => { }); const newShape = [1, 1001]; const reshapeOutput = builder.reshape(conv2dOutput, newShape); - assert_equals(reshapeOutput.dataType(), avgPool2dInput.dataType()); - assert_array_equals(reshapeOutput.shape(), newShape); + assert_equals(reshapeOutput.dataType, avgPool2dInput.dataType); + assert_array_equals(reshapeOutput.shape, newShape); const graph = await builder.build({reshapeOutput}); const result = await context.compute( graph, { @@ -86,8 +86,8 @@ promise_test(async t => { }); const newShape = [1, 1001]; const reshapeOutput = builder.reshape(conv2dOutput, newShape); - assert_equals(reshapeOutput.dataType(), reduceMeanInput.dataType()); - assert_array_equals(reshapeOutput.shape(), newShape); + assert_equals(reshapeOutput.dataType, reduceMeanInput.dataType); + assert_array_equals(reshapeOutput.shape, newShape); const graph = await builder.build({reshapeOutput}); const result = await context.compute( graph, { diff --git a/webnn/validation_tests/pooling.https.any.js b/webnn/validation_tests/pooling.https.any.js index d862d807ab443a..e02d41e996be42 100644 --- a/webnn/validation_tests/pooling.https.any.js +++ b/webnn/validation_tests/pooling.https.any.js @@ -305,8 +305,8 @@ tests.forEach( kPoolingOperators.forEach((operatorName) => { if (test.output) { const output = builder[operatorName](input, test.options); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const regrexp = new RegExp('\\[' + label + '\\]'); assert_throws_with_label( @@ -320,8 +320,8 @@ tests.forEach( const builder = new MLGraphBuilder(context); const input = builder.input('input', {dataType, shape: [1, 3, 4, 4]}); const output = builder.maxPool2d(input); - assert_equals(output.dataType(), dataType); - assert_array_equals(output.shape(), [1, 3, 1, 1]); + assert_equals(output.dataType, dataType); + assert_array_equals(output.shape, [1, 3, 1, 1]); }, `[maxPool2d] Test maxPool2d with data type ${dataType}`)); promise_test(async t => { diff --git a/webnn/validation_tests/prelu.https.any.js b/webnn/validation_tests/prelu.https.any.js index 94eb6995374e65..e3a43c61d8d97b 100644 --- a/webnn/validation_tests/prelu.https.any.js +++ b/webnn/validation_tests/prelu.https.any.js @@ -59,8 +59,8 @@ tests.forEach( const slope = builder.input('input', test.slope); if (test.output) { const output = builder.prelu(input, slope); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const label = 'prelu_123'; const options = {label}; @@ -80,8 +80,8 @@ promise_test(async t => { const input = builder.input(`input`, {dataType, shape}); if (context.opSupportLimits().prelu.input.dataTypes.includes(dataType)) { const output = builder.prelu(input, input); - assert_equals(output.dataType(), dataType); - assert_array_equals(output.shape(), shape); + assert_equals(output.dataType, dataType); + assert_array_equals(output.shape, shape); } else { assert_throws_js(TypeError, () => builder.prelu(input, input)); } diff --git a/webnn/validation_tests/quantizeLinear.https.any.js b/webnn/validation_tests/quantizeLinear.https.any.js index 2f0b21d225a8cb..42b8ac4b1f2c36 100644 --- a/webnn/validation_tests/quantizeLinear.https.any.js +++ b/webnn/validation_tests/quantizeLinear.https.any.js @@ -82,8 +82,8 @@ tests.forEach( const zeroPoint = builder.input('zeroPoint', test.zeroPoint); if (test.output) { const output = builder.quantizeLinear(input, scale, zeroPoint); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const label = 'quantize_linear_123'; const options = {label}; diff --git a/webnn/validation_tests/reduction.https.any.js b/webnn/validation_tests/reduction.https.any.js index b56306351f05e6..d872b7fb4f0393 100644 --- a/webnn/validation_tests/reduction.https.any.js +++ b/webnn/validation_tests/reduction.https.any.js @@ -63,8 +63,8 @@ function runReductionTests(operatorName, tests) { if (test.output) { const output = builder[operatorName](input, test.options); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const regrexp = new RegExp('\\[' + label + '\\]'); assert_throws_with_label( @@ -90,8 +90,8 @@ kReductionOperators.forEach((operatorName) => { if (context.opSupportLimits()[operatorName].input.dataTypes.includes( dataType)) { const output = builder[operatorName](input); - assert_equals(output.dataType(), dataType); - assert_array_equals(output.shape(), []); + assert_equals(output.dataType, dataType); + assert_array_equals(output.shape, []); } else { assert_throws_js(TypeError, () => builder[operatorName](input)); } diff --git a/webnn/validation_tests/resample2d.https.any.js b/webnn/validation_tests/resample2d.https.any.js index df2b85d02de25a..1278143d232f05 100644 --- a/webnn/validation_tests/resample2d.https.any.js +++ b/webnn/validation_tests/resample2d.https.any.js @@ -204,8 +204,8 @@ tests.forEach( const options = test.options ?? {}; if (test.output) { const output = builder.resample2d(input, options); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const options = {...test.options}; if (options.label) { @@ -232,8 +232,8 @@ promise_test(async t => { if (context.opSupportLimits().resample2d.input.dataTypes.includes( dataType)) { const output = builder.resample2d(input); - assert_equals(output.dataType(), dataType); - assert_array_equals(output.shape(), shape); + assert_equals(output.dataType, dataType); + assert_array_equals(output.shape, shape); } else { assert_throws_js(TypeError, () => builder.resample2d(input)); } diff --git a/webnn/validation_tests/reshape.https.any.js b/webnn/validation_tests/reshape.https.any.js index 7e49cada67a207..67c895be9b7881 100644 --- a/webnn/validation_tests/reshape.https.any.js +++ b/webnn/validation_tests/reshape.https.any.js @@ -72,8 +72,8 @@ tests.forEach( const input = builder.input('input', test.input); if (test.output) { const output = builder.reshape(input, test.newShape); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const label = 'reshape_xxx'; const options = {label}; diff --git a/webnn/validation_tests/scatterElements.https.any.js b/webnn/validation_tests/scatterElements.https.any.js index 15551b2bbe5b48..39e99ddfdfc7f6 100644 --- a/webnn/validation_tests/scatterElements.https.any.js +++ b/webnn/validation_tests/scatterElements.https.any.js @@ -105,8 +105,8 @@ tests.forEach( if (test.output) { const output = builder.scatterElements(input, indices, updates, options); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const label = 'a_scatter_elements' options.label = label; diff --git a/webnn/validation_tests/scatterND.https.any.js b/webnn/validation_tests/scatterND.https.any.js index 5e28471fffa47a..e529aea52ee213 100644 --- a/webnn/validation_tests/scatterND.https.any.js +++ b/webnn/validation_tests/scatterND.https.any.js @@ -58,8 +58,8 @@ tests.forEach(test => promise_test(async t => { if (test.output) { const output = builder.scatterND(input, indices, updates); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const label = 'a_scatter_nd' const options = {label}; diff --git a/webnn/validation_tests/slice.https.any.js b/webnn/validation_tests/slice.https.any.js index 3fb3cdcd6f67a8..cc442d3d2b1958 100644 --- a/webnn/validation_tests/slice.https.any.js +++ b/webnn/validation_tests/slice.https.any.js @@ -74,8 +74,8 @@ tests.forEach( if (test.output) { const output = builder.slice(input, test.starts, test.sizes); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const label = 'slice_xxx'; const options = {label}; diff --git a/webnn/validation_tests/softmax.https.any.js b/webnn/validation_tests/softmax.https.any.js index 4a5ee563070fb7..eb7ebbd3070c37 100644 --- a/webnn/validation_tests/softmax.https.any.js +++ b/webnn/validation_tests/softmax.https.any.js @@ -34,8 +34,8 @@ tests_without_axis.forEach( let input = builder.input(`input`, test.input); if (test.output) { const output = builder.softmax(input); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const options = { label: 'softmax_xxx', @@ -89,8 +89,8 @@ tests.forEach( let input = builder.input(`input`, test.input); if (test.output) { const output = builder.softmax(input, test.axis); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const label = 'softmax_xxx'; const options = {label}; diff --git a/webnn/validation_tests/split.https.any.js b/webnn/validation_tests/split.https.any.js index c25f839168d39a..863e6a79c5f576 100644 --- a/webnn/validation_tests/split.https.any.js +++ b/webnn/validation_tests/split.https.any.js @@ -111,8 +111,8 @@ tests.forEach( const outputs = builder.split(input, test.splits, test.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].shape); + assert_equals(outputs[i].dataType, test.outputs[i].dataType); + assert_array_equals(outputs[i].shape, test.outputs[i].shape); } } else { const regrexp = new RegExp('\\[' + label + '\\]'); diff --git a/webnn/validation_tests/tile.https.any.js b/webnn/validation_tests/tile.https.any.js index 6ad81cba4beb70..067335409178db 100644 --- a/webnn/validation_tests/tile.https.any.js +++ b/webnn/validation_tests/tile.https.any.js @@ -58,8 +58,8 @@ tests.forEach( const input = builder.input('input', test.input); if (test.output) { const output = builder.tile(input, test.repetitions, test.options); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const options = {...test.options}; if (options.label) { diff --git a/webnn/validation_tests/transpose.https.any.js b/webnn/validation_tests/transpose.https.any.js index a79e14008a6abe..67a05ce057c587 100644 --- a/webnn/validation_tests/transpose.https.any.js +++ b/webnn/validation_tests/transpose.https.any.js @@ -58,8 +58,8 @@ tests.forEach( const input = builder.input('input', test.input); if (test.output) { const output = builder.transpose(input, test.options); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const options = {...test.options}; if (options.label) { @@ -83,8 +83,8 @@ promise_test(async t => { if (context.opSupportLimits().transpose.input.dataTypes.includes( dataType)) { const output = builder.transpose(input); - assert_equals(output.dataType(), dataType); - assert_array_equals(output.shape(), [4, 3, 2, 1]); + assert_equals(output.dataType, dataType); + assert_array_equals(output.shape, [4, 3, 2, 1]); } else { assert_throws_js(TypeError, () => builder.transpose(input)); } diff --git a/webnn/validation_tests/where.https.any.js b/webnn/validation_tests/where.https.any.js index 2f1941556b1c3a..424d080c009d32 100644 --- a/webnn/validation_tests/where.https.any.js +++ b/webnn/validation_tests/where.https.any.js @@ -99,8 +99,8 @@ tests.forEach( context.opSupportLimits().where.falseValue.dataTypes.includes( test.falseValue.dataType)) { const output = builder.where(condition, trueValue, falseValue); - assert_equals(output.dataType(), test.output.dataType); - assert_array_equals(output.shape(), test.output.shape); + assert_equals(output.dataType, test.output.dataType); + assert_array_equals(output.shape, test.output.shape); } else { const label = 'where_123'; const options = {label};