From 8fd40366064ab60a9693b2a6d8be95094718e9a6 Mon Sep 17 00:00:00 2001 From: lisa0314 Date: Fri, 10 May 2024 20:30:34 -0700 Subject: [PATCH] Reland "webnn: Enforce input data type constraints for gather indices" This is a reland of commit ef29e11bfb1f1f4eae0935fb58f0e4129620837b 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 --- webnn/validation_tests/gather.https.any.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/webnn/validation_tests/gather.https.any.js b/webnn/validation_tests/gather.https.any.js index 184e8033e6624c..95bd074adc01aa 100644 --- a/webnn/validation_tests/gather.https.any.js +++ b/webnn/validation_tests/gather.https.any.js @@ -8,7 +8,7 @@ const tests = [ { name: '[gather] Test gather with default options and 0-D indices', input: {dataType: 'int32', dimensions: [3]}, - indices: {dataType: 'uint64', dimensions: []}, + indices: {dataType: 'int64', dimensions: []}, output: {dataType: 'int32', dimensions: []} }, { @@ -24,15 +24,23 @@ const tests = [ indices: {dataType: 'int64', dimensions: [1]} }, { - name: '[gather] TypeError is expected if the axis is greater than the rank of input', + 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]}, + indices: {dataType: 'uint32', dimensions: [5, 6]}, axis: 4 }, { - name: '[gather] TypeError is expected if the data type of indices is invalid', + name: + '[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 int32 which is invalid', + input: {dataType: 'float16', dimensions: [1, 2, 3, 4]}, + indices: {dataType: 'int32', dimensions: [5, 6]} } ];