diff --git a/onnxruntime/core/providers/webnn/builders/impl/pad_op_builder.cc b/onnxruntime/core/providers/webnn/builders/impl/pad_op_builder.cc index 80e72875072ea..9852db0abc9d2 100644 --- a/onnxruntime/core/providers/webnn/builders/impl/pad_op_builder.cc +++ b/onnxruntime/core/providers/webnn/builders/impl/pad_op_builder.cc @@ -89,14 +89,14 @@ Status PadOpBuilder::AddToModelBuilderImpl(ModelBuilder& model_builder, ORT_RETURN_IF_NOT(ReadIntArrayFrom1DTensor(pads_tensor, pads, logger), "Error while read pads tensor"); // Constant value and axes are optional. Make sure they are not empty. - if (input_defs.size() >= 3 && !GetTensorName(input_defs, 2).empty()) { + if (!GetTensorName(input_defs, 2).empty()) { const auto value_tensor = *initializers.at(input_defs[2]->Name()); emscripten::val value = emscripten::val::object(); ORT_RETURN_IF_NOT(ReadScalarTensorData(value_tensor, value, logger), "Cannot read constant value"); options.set("value", value); } - if (input_defs.size() == 4 && !GetTensorName(input_defs, 3).empty()) { + if (!GetTensorName(input_defs, 3).empty()) { const auto input_rank = input_shape.size(); std::vector axes; const auto& axes_tensor = *initializers.at(input_defs[3]->Name()); 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 5e2888317f4f5..c0954f7cf6fb1 100644 --- a/onnxruntime/core/providers/webnn/builders/impl/reduction_op_builder.cc +++ b/onnxruntime/core/providers/webnn/builders/impl/reduction_op_builder.cc @@ -65,7 +65,7 @@ Status ReductionOpBuilder::AddToModelBuilderImpl(ModelBuilder& model_builder, if (opset >= 18 || (op_type == "ReduceSum" && opset >= 13)) { // 'axes' is an optional input. const auto noop_with_empty_axes = helper.Get("noop_with_empty_axes", 0); - if (input_defs.size() > 1 && !GetTensorName(input_defs, 1).empty()) { + if (!GetTensorName(input_defs, 1).empty()) { // Optional input axes is provided, use axes initializer data. const auto& initializers(model_builder.GetInitializerTensors()); const auto& axes_tensor = *initializers.at(input_defs[1]->Name()); diff --git a/onnxruntime/core/providers/webnn/builders/impl/split_op_builder.cc b/onnxruntime/core/providers/webnn/builders/impl/split_op_builder.cc index bcc2c9a86ebab..9819e4ce7ac5b 100644 --- a/onnxruntime/core/providers/webnn/builders/impl/split_op_builder.cc +++ b/onnxruntime/core/providers/webnn/builders/impl/split_op_builder.cc @@ -57,7 +57,7 @@ Status SplitOpBuilder::AddToModelBuilderImpl(ModelBuilder& model_builder, axis = SafeInt(HandleNegativeAxis(axis, rank)); options.set("axis", axis); - if (input_defs.size() == 2 && !GetTensorName(input_defs, 1).empty()) { + if (!GetTensorName(input_defs, 1).empty()) { // Inputs contains optional 'split' input std::vector splits; const auto& initializers(model_builder.GetInitializerTensors()); diff --git a/onnxruntime/core/providers/webnn/builders/impl/squeeze_unsqueeze_op_builder.cc b/onnxruntime/core/providers/webnn/builders/impl/squeeze_unsqueeze_op_builder.cc index 0192e33f22d8d..8e6feb62fa8c4 100644 --- a/onnxruntime/core/providers/webnn/builders/impl/squeeze_unsqueeze_op_builder.cc +++ b/onnxruntime/core/providers/webnn/builders/impl/squeeze_unsqueeze_op_builder.cc @@ -58,7 +58,7 @@ Status SqueezeUnsqueezeOpBuilder::AddToModelBuilderImpl(ModelBuilder& model_buil std::vector axes_data; auto rank = input_rank; - if (node.SinceVersion() >= 13 && input_defs.size() > 1 && !GetTensorName(input_defs, 1).empty()) { + if (node.SinceVersion() >= 13 && !GetTensorName(input_defs, 1).empty()) { // Input axes is provided, use axes initializer data. const auto& initializers = model_builder.GetInitializerTensors(); const auto& axes_tensor = *initializers.at(input_defs[1]->Name());