From 5145a9506de97ac2f0a3899dcb25fa3cac2b2dcc Mon Sep 17 00:00:00 2001 From: lisa0314 Date: Wed, 22 May 2024 22:56:32 -0700 Subject: [PATCH] Reland "webnn: Enforce input data type constraints for gather indices" This is a reland of commit ef29e11bfb1f1f4eae0935fb58f0e4129620837b The failure of services_unittests/WebNNGraphImplBackendTest. BuildAndComputeSingleOperatorGather has been fixed by another CL: https://chromium-review.googlesource.com/c/chromium/src/+/5544945. This CL adds int32 dataType support check besides uint32 and int64 for gather indices compared with original CL. Original change's description: > webnn: Enforce input data type constraints for gather indices > > As specified in https://github.com/webmachinelearning/webnn/pull/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 > Commit-Queue: Lisha Guo > Reviewed-by: ningxin hu > Cr-Commit-Position: refs/heads/main@{#1298443} Bug: 328567884 Change-Id: Ide6a0e1bc6d3ebea7dce6bf37da4318e7b6e1bd1 Cq-Include-Trybots: luci.chromium.try:mac14-blink-rel,mac14.arm64-blink-rel,gpu-fyi-try-win11-qualcomm-rel-64 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5532907 Reviewed-by: ningxin hu Commit-Queue: Lisha Guo Reviewed-by: Austin Sullivan Cr-Commit-Position: refs/heads/main@{#1304870} --- webnn/validation_tests/gather.https.any.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/webnn/validation_tests/gather.https.any.js b/webnn/validation_tests/gather.https.any.js index 668112cc10fff9..4a2ab218f8d2ab 100644 --- a/webnn/validation_tests/gather.https.any.js +++ b/webnn/validation_tests/gather.https.any.js @@ -18,6 +18,20 @@ const tests = [ axis: 2, output: {dataType: 'float32', dimensions: [1, 2, 5, 6, 4]} }, + { + name: '[gather] Test gather with indices\'s dataType = uint32', + input: {dataType: 'float32', dimensions: [1, 2, 3, 4]}, + indices: {dataType: 'uint32', dimensions: [5, 6]}, + axis: 2, + output: {dataType: 'float32', dimensions: [1, 2, 5, 6, 4]} + }, + { + name: '[gather] Test gather with indices\'s dataType = int32', + input: {dataType: 'float32', dimensions: [1, 2, 3, 4]}, + indices: {dataType: 'int32', 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: []}, @@ -32,9 +46,15 @@ const tests = [ }, { name: - '[gather] TypeError is expected if the data type of indices is invalid', + '[gather] TypeError is expected if the data type of indices is float32 which is invalid', input: {dataType: 'float16', dimensions: [1, 2, 3, 4]}, indices: {dataType: 'float32', dimensions: [5, 6]} + }, + { + name: + '[gather] TypeError is expected if the data type of indices is uint64 which is invalid', + input: {dataType: 'float16', dimensions: [1, 2, 3, 4]}, + indices: {dataType: 'uint64', dimensions: [5, 6]} } ];