From 499a9694e5da76f5d46db96018e96c378cb4703a Mon Sep 17 00:00:00 2001 From: Pawel Raasz Date: Tue, 19 Dec 2023 08:06:33 +0100 Subject: [PATCH] Fix Coverity CID 1529136, 1529124 (#21733) * CID 1529136, fix auto makes a copy of PartialShape - minor updates to reduce redundant Rank object creation * CID 1529124 fix copy caused by auto --- src/core/reference/src/op/einsum.cpp | 2 +- src/core/src/op/mvn.cpp | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/core/reference/src/op/einsum.cpp b/src/core/reference/src/op/einsum.cpp index 25bebdf1dd8..e9f003f0ce7 100644 --- a/src/core/reference/src/op/einsum.cpp +++ b/src/core/reference/src/op/einsum.cpp @@ -759,7 +759,7 @@ void contract_two_inputs(ov::TensorVector& inputs, std::vector unsqueeze_axis2; for (const auto& sep_label2 : separate_labels2) { OPENVINO_ASSERT(label_to_dim_map2.find(sep_label2) != label_to_dim_map2.end()); - auto label_dims = label_to_dim_map2[sep_label2]; + const auto& label_dims = label_to_dim_map2[sep_label2]; for (size_t dim_ind = 0; dim_ind < label_dims.size(); ++dim_ind) { unsqueeze_axis1.push_back(unsqueeze_dim + static_cast(dim_ind)); } diff --git a/src/core/src/op/mvn.cpp b/src/core/src/op/mvn.cpp index b02c6eef550..fbffd1231ad 100644 --- a/src/core/src/op/mvn.cpp +++ b/src/core/src/op/mvn.cpp @@ -4,6 +4,7 @@ #include "openvino/op/mvn.hpp" +#include "compare.hpp" #include "itt.hpp" #include "openvino/reference/mvn.hpp" @@ -91,20 +92,20 @@ ov::op::v6::MVN::MVN(const Output& data, void ov::op::v6::MVN::validate_and_infer_types() { OV_OP_SCOPE(v6_MVN_validate_and_infer_types); - const auto data = get_input_partial_shape(0); - const auto axes = get_input_partial_shape(1); + const auto& data = get_input_partial_shape(0); + const auto& axes = get_input_partial_shape(1); if (axes.is_static()) { NODE_VALIDATION_CHECK(this, is_vector(axes.to_shape()), "Expected 1D tensor for the 'axes' input. Got: ", axes); - NODE_VALIDATION_CHECK( - this, - data.rank().is_dynamic() || data.rank().get_length() >= static_cast(axes.get_shape()[0]), - "Expected rank for the 'data' input to be higher than axes shape. Got: ", - data); + const auto data_rank = data.rank(); + NODE_VALIDATION_CHECK(this, + data_rank.is_dynamic() || cmp::ge(data_rank.get_length(), axes.get_shape()[0]), + "Expected rank for the 'data' input to be higher than axes shape. Got: ", + data); } - set_output_type(0, get_input_element_type(0), get_input_partial_shape(0)); + set_output_type(0, get_input_element_type(0), data); } std::shared_ptr ov::op::v6::MVN::clone_with_new_inputs(const OutputVector& new_args) const {