From bbb6dbf6d2c77962ba2cf137c5925186fefaa10c Mon Sep 17 00:00:00 2001 From: Wanming Lin Date: Mon, 17 Jun 2024 23:46:18 +0800 Subject: [PATCH] [WebNN EP] Update data type constraints for Reduction ops (#20912) WebNN Spec adds missing 64-bit integers support for `reduceL1`, `reduceSum`, `reduceSumSquare` and `reduceProduct` ops at this [PR](https://github.com/webmachinelearning/webnn/pull/695), which has already been implemented in Chromium. Update corresponding data type constraints in WebNN EP. Besides, WebNN CPU backend currently doesn't support `uint64` and `uint32` for these ops. --- .../webnn/builders/impl/reduction_op_builder.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/onnxruntime/core/providers/webnn/builders/impl/reduction_op_builder.cc b/onnxruntime/core/providers/webnn/builders/impl/reduction_op_builder.cc index de65f015ded3a..461050849385a 100644 --- a/onnxruntime/core/providers/webnn/builders/impl/reduction_op_builder.cc +++ b/onnxruntime/core/providers/webnn/builders/impl/reduction_op_builder.cc @@ -162,10 +162,15 @@ bool ReductionOpBuilder::HasSupportedInputsImpl(const Node& node, const WebnnDev ONNX_NAMESPACE::TensorProto_DataType_FLOAT16, ONNX_NAMESPACE::TensorProto_DataType_INT32, ONNX_NAMESPACE::TensorProto_DataType_UINT32, + ONNX_NAMESPACE::TensorProto_DataType_INT64, + ONNX_NAMESPACE::TensorProto_DataType_UINT64, }; - // WebNN CPU backend doesn't support uint32 for reduceProd and reduceSum. - if (device_type == WebnnDeviceType::CPU && (op_type == "ReduceProd" || op_type == "ReduceSum")) { + + if (device_type == WebnnDeviceType::CPU) { + // WebNN CPU backend doesn't support uint32 and uint64 for reduceL1, + // reduceProd, reduceSum and reduceSumSquare. supported_data_types.erase(ONNX_NAMESPACE::TensorProto_DataType_UINT32); + supported_data_types.erase(ONNX_NAMESPACE::TensorProto_DataType_UINT64); } } else if (op_type == "ReduceL2" || op_type == "ReduceLogSum" || op_type == "ReduceLogSumExp" || op_type == "ReduceMean") {