diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:14:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:14:29 +0000 |
commit | fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch) | |
tree | 4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /testing/web-platform/tests/webnn/validation_tests/gather.https.any.js | |
parent | Releasing progress-linux version 124.0.1-1~progress7.99u1. (diff) | |
download | firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webnn/validation_tests/gather.https.any.js')
-rw-r--r-- | testing/web-platform/tests/webnn/validation_tests/gather.https.any.js | 62 |
1 files changed, 62 insertions, 0 deletions
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)); |