Skip to content

Commit d32b68c

Browse files
lisa0314chromium-wpt-export-bot
authored andcommitted
webnn: Enforce input data type constraints for gather indices
As specified in webmachinelearning/webnn#646 Bug: 328567884 Change-Id: I33eba7e1def430b1cb94e3e7a4868e82c5bbd9a3 Cq-Include-Trybots: luci.chromium.try:mac14-blink-rel,mac14.arm64-blink-rel Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5520313 Reviewed-by: Austin Sullivan <asully@chromium.org> Commit-Queue: Lisha Guo <lisha.guo@intel.com> Reviewed-by: ningxin hu <ningxin.hu@intel.com> Cr-Commit-Position: refs/heads/main@{#1298443}
1 parent 6830aff commit d32b68c

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

webnn/validation_tests/gather.https.any.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const tests = [
88
{
99
name: '[gather] Test gather with default options and 0-D indices',
1010
input: {dataType: 'int32', dimensions: [3]},
11-
indices: {dataType: 'uint64', dimensions: []},
11+
indices: {dataType: 'int64', dimensions: []},
1212
output: {dataType: 'int32', dimensions: []}
1313
},
1414
{
@@ -24,15 +24,23 @@ const tests = [
2424
indices: {dataType: 'int64', dimensions: [1]}
2525
},
2626
{
27-
name: '[gather] TypeError is expected if the axis is greater than the rank of input',
27+
name:
28+
'[gather] TypeError is expected if the axis is greater than the rank of input',
2829
input: {dataType: 'float16', dimensions: [1, 2, 3]},
29-
indices: {dataType: 'int32', dimensions: [5, 6]},
30+
indices: {dataType: 'uint32', dimensions: [5, 6]},
3031
axis: 4
3132
},
3233
{
33-
name: '[gather] TypeError is expected if the data type of indices is invalid',
34+
name:
35+
'[gather] TypeError is expected if the data type of indices is float32 which is invalid',
3436
input: {dataType: 'float16', dimensions: [1, 2, 3, 4]},
3537
indices: {dataType: 'float32', dimensions: [5, 6]}
38+
},
39+
{
40+
name:
41+
'[gather] TypeError is expected if the data type of indices is int32 which is invalid',
42+
input: {dataType: 'float16', dimensions: [1, 2, 3, 4]},
43+
indices: {dataType: 'int32', dimensions: [5, 6]}
3644
}
3745
];
3846

0 commit comments

Comments
 (0)