From a90a5cba08fdf6c0ceb95101c275108a152a3aed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:37 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- .../webnn/validation_tests/split.https.any.js | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) (limited to 'testing/web-platform/tests/webnn/validation_tests/split.https.any.js') diff --git a/testing/web-platform/tests/webnn/validation_tests/split.https.any.js b/testing/web-platform/tests/webnn/validation_tests/split.https.any.js index 38f3126603..6f7809744a 100644 --- a/testing/web-platform/tests/webnn/validation_tests/split.https.any.js +++ b/testing/web-platform/tests/webnn/validation_tests/split.https.any.js @@ -12,3 +12,83 @@ multi_builder_test(async (t, builder, otherBuilder) => { assert_throws_js( TypeError, () => builder.split(inputFromOtherBuilder, splits)); }, '[split] throw if input is from another builder'); + +const tests = [ + { + name: '[split] Test with default options.', + input: {dataType: 'float32', dimensions: [2, 6]}, + splits: [2], + outputs: [ + {dataType: 'float32', dimensions: [2, 6]}, + ] + }, + { + name: + '[split] Test with a sequence of unsigned long splits and with options.axis = 1.', + input: {dataType: 'float32', dimensions: [2, 6]}, + splits: [1, 2, 3], + options: {axis: 1}, + outputs: [ + {dataType: 'float32', dimensions: [2, 1]}, + {dataType: 'float32', dimensions: [2, 2]}, + {dataType: 'float32', dimensions: [2, 3]}, + ] + }, + { + name: '[split] Throw if splitting a scalar.', + input: {dataType: 'float32', dimensions: []}, + splits: [2], + }, + { + name: '[split] Throw if axis is larger than input rank.', + input: {dataType: 'float32', dimensions: [2, 6]}, + splits: [2], + options: { + axis: 2, + } + }, + { + name: '[split] Throw if splits is equal to 0.', + input: {dataType: 'float32', dimensions: [2, 6]}, + splits: [0], + options: { + axis: 2, + } + }, + { + name: + '[split] Throw if the splits can not evenly divide the dimension size of input along options.axis.', + input: {dataType: 'float32', dimensions: [2, 5]}, + splits: [2], + options: { + axis: 1, + } + }, + { + name: + '[split] Throw if the sum of splits sizes not equal to the dimension size of input along options.axis.', + input: {dataType: 'float32', dimensions: [2, 6]}, + splits: [2, 2, 3], + options: { + axis: 1, + } + }, +]; + +tests.forEach( + test => promise_test(async t => { + const input = builder.input( + 'input', + {dataType: test.input.dataType, dimensions: test.input.dimensions}); + if (test.outputs) { + 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].dimensions); + } + } else { + assert_throws_js( + TypeError, () => builder.split(input, test.splits, test.options)); + } + }, test.name)); -- cgit v1.2.3