From 79baf4c04cb581bf41c447133253365650d2e6cb Mon Sep 17 00:00:00 2001 From: Austin Sullivan Date: Fri, 26 Apr 2024 10:59:40 -0700 Subject: [PATCH] webnn: Enforce input data type constraints for conv2d As specified in https://github.com/webmachinelearning/webnn/pull/646 Bug: 328567884 Change-Id: I620653f574303e6f5b18d3b540b647f07e0cf64c --- webnn/validation_tests/conv2d.https.any.js | 5 +++++ webnn/validation_tests/convTranspose2d.https.any.js | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/webnn/validation_tests/conv2d.https.any.js b/webnn/validation_tests/conv2d.https.any.js index c38174e6169fcbf..7dac654951b7781 100644 --- a/webnn/validation_tests/conv2d.https.any.js +++ b/webnn/validation_tests/conv2d.https.any.js @@ -210,6 +210,11 @@ const tests = [ input: {dataType: 'float32', dimensions: [1, 5, 5]}, filter: {dataType: 'float32', dimensions: [1, 2, 2, 1]}, }, + { + name: '[conv2d] Throw if the input data type is not floating point.', + input: {dataType: 'int32', dimensions: [1, 1, 5, 5]}, + filter: {dataType: 'int32', dimensions: [1, 1, 2, 2]}, + }, { name: '[conv2d] Throw if the filter is not a 4-D tensor.', input: {dataType: 'float32', dimensions: [1, 1, 5, 5]}, diff --git a/webnn/validation_tests/convTranspose2d.https.any.js b/webnn/validation_tests/convTranspose2d.https.any.js index 3c3c49566439da0..02822c52749e8c6 100644 --- a/webnn/validation_tests/convTranspose2d.https.any.js +++ b/webnn/validation_tests/convTranspose2d.https.any.js @@ -195,6 +195,12 @@ const tests = [ input: {dataType: 'float32', dimensions: [1, 5, 5]}, filter: {dataType: 'float32', dimensions: [1, 1, 2, 2]}, }, + { + name: + '[convTranspose2d] Throw if the input data type is not floating point.', + input: {dataType: 'int32', dimensions: [1, 1, 5, 5]}, + filter: {dataType: 'int32', dimensions: [1, 1, 2, 2]}, + }, { name: '[convTranspose2d] Throw if the filter is not a 4-D tensor.', input: {dataType: 'float32', dimensions: [1, 1, 5, 5]},