diff --git a/src/core/shape_inference/include/variadic_split_shape_inference.hpp b/src/core/shape_inference/include/variadic_split_shape_inference.hpp index 77023a61641725..2694ee5e4594c6 100644 --- a/src/core/shape_inference/include/variadic_split_shape_inference.hpp +++ b/src/core/shape_inference/include/variadic_split_shape_inference.hpp @@ -75,7 +75,7 @@ std::vector shape_infer(const VariadicSplit* op, sum_of_splits += (*split_lengths)[i]; } } - const auto dimension_at_axis = data_shape[axis]; + const auto& dimension_at_axis = data_shape[axis]; if (negative_one_idx >= 0 && dimension_at_axis.is_static()) { (*split_lengths)[negative_one_idx] = dimension_at_axis.get_length() - sum_of_splits; diff --git a/src/core/src/evaluator.hpp b/src/core/src/evaluator.hpp index 3e9408219b2522..eaa714f53f00d7 100644 --- a/src/core/src/evaluator.hpp +++ b/src/core/src/evaluator.hpp @@ -135,7 +135,7 @@ class Evaluator { // Request to execute the handleer. Pass what we know about the inputs to the // handler and associate the results with the outputs std::vector inputs; - for (auto v : node->input_values()) { + for (const auto& v : node->input_values()) { inputs.push_back(evaluator.get_value_map().at(v)); } std::vector outputs = m_handler(node, inputs); diff --git a/src/core/src/layout.cpp b/src/core/src/layout.cpp index 2bec5d0b0e76d4..7c3c29909088fd 100644 --- a/src/core/src/layout.cpp +++ b/src/core/src/layout.cpp @@ -448,7 +448,7 @@ std::tuple LayoutUtils::find_squeeze(const Layout& src_lay res.m_left_size = dst_layout.m_left_size; int64_t dst_idx = 0; for (int64_t src_idx = 0; src_idx < src_layout.m_left_size; src_idx++) { - auto src_dim_name = src_layout.m_index_map.at(src_idx); + const auto& src_dim_name = src_layout.m_index_map.at(src_idx); if (dst_layout.has_name(src_dim_name)) { if (!rank_dynamic) { res_dims[dst_idx] = src_shape[src_idx]; @@ -496,7 +496,7 @@ std::tuple LayoutUtils::find_unsqueeze(const Layou res.m_left_size = dst_layout.m_left_size; int64_t unset_idx = 0; for (auto i = 0; i < dst_layout.m_left_size; i++) { - auto dim_name = dst_layout.m_index_map.at(i); + const auto& dim_name = dst_layout.m_index_map.at(i); if (src_layout.has_name(dim_name)) { auto src_idx = src_layout.get_index_by_name(dim_name); res.m_names[dim_name] = src_idx + dims_cnt; diff --git a/src/core/src/op/adaptive_avg_pool.cpp b/src/core/src/op/adaptive_avg_pool.cpp index cd7ef6f4d32a15..810be9208bb8e3 100644 --- a/src/core/src/op/adaptive_avg_pool.cpp +++ b/src/core/src/op/adaptive_avg_pool.cpp @@ -17,8 +17,8 @@ op::v8::AdaptiveAvgPool::AdaptiveAvgPool(const Output& data, const Output< void op::v8::AdaptiveAvgPool::validate_and_infer_types() { OV_OP_SCOPE(v8_AdaptiveAvgPool_validate_and_infer_types); - const auto output_shape = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)).front(); - set_output_type(0, get_input_element_type(0), output_shape); + const auto output_shapes = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)); + set_output_type(0, get_input_element_type(0), output_shapes[0]); } std::shared_ptr op::v8::AdaptiveAvgPool::clone_with_new_inputs(const OutputVector& new_args) const { diff --git a/src/core/src/op/batch_to_space.cpp b/src/core/src/op/batch_to_space.cpp index a70c2af3a671eb..1d1d8b8b85e2f3 100644 --- a/src/core/src/op/batch_to_space.cpp +++ b/src/core/src/op/batch_to_space.cpp @@ -50,8 +50,8 @@ void BatchToSpace::validate_and_infer_types() { "block_shape and crops inputs must have integer element type. Got: ", inputs_integer_et); - const auto output_shape = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)).front(); - set_output_type(0, data_et, output_shape); + const auto output_shapes = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)); + set_output_type(0, data_et, output_shapes[0]); } std::shared_ptr BatchToSpace::clone_with_new_inputs(const OutputVector& new_args) const { diff --git a/src/core/src/op/broadcast.cpp b/src/core/src/op/broadcast.cpp index c7df0553d0b832..176e06aeec1e1f 100644 --- a/src/core/src/op/broadcast.cpp +++ b/src/core/src/op/broadcast.cpp @@ -48,8 +48,8 @@ std::pair ov::op::v3::Broadcast::get_broadcast_axes() const { bool axes_known = false; if (get_input_partial_shape(0).is_static() && get_output_partial_shape(0).is_static()) { - const auto arg_shape = get_input_shape(0); - const auto result_shape = get_output_shape(0); + const auto& arg_shape = get_input_shape(0); + const auto& result_shape = get_output_shape(0); return get_broadcast_axes_bidirectional(arg_shape, result_shape); } return std::make_pair(axes_known, broadcast_axes); @@ -108,7 +108,7 @@ ov::PartialShape get_result_shape_bidirectional(const ov::Node* this_ptr, bool ov::op::v3::Broadcast::broadcast_evaluate(ov::TensorVector& outputs, const ov::TensorVector& inputs) const { if (get_broadcast_spec().m_type == op::BroadcastType::BIDIRECTIONAL) { - auto arg_shape = inputs[0].get_shape(); + const auto& arg_shape = inputs[0].get_shape(); ov::Shape target_shape = op::util::BroadcastBase::get_target_shape(inputs[1]); ov::PartialShape result_shape = get_result_shape_bidirectional(this, ov::PartialShape{arg_shape}, ov::PartialShape{target_shape}); diff --git a/src/core/src/op/concat.cpp b/src/core/src/op/concat.cpp index ccccb7c4f4bdcd..61c49d258b28a3 100644 --- a/src/core/src/op/concat.cpp +++ b/src/core/src/op/concat.cpp @@ -39,7 +39,8 @@ void Concat::validate_and_infer_types() { input_shapes.push_back(get_input_partial_shape(i)); } - const auto output_shape = shape_infer(this, input_shapes).front(); + const auto output_shapes = shape_infer(this, input_shapes); + const auto& output_shape = output_shapes[0]; if (output_shape.rank().is_static() && (get_concatenation_axis() < 0)) { set_concatenation_axis(ov::util::normalize(get_axis(), output_shape.size())); } diff --git a/src/core/src/op/ctc_loss.cpp b/src/core/src/op/ctc_loss.cpp index a920e3b9c79c9f..6c82baa9a93490 100644 --- a/src/core/src/op/ctc_loss.cpp +++ b/src/core/src/op/ctc_loss.cpp @@ -59,8 +59,8 @@ void op::v4::CTCLoss::validate_and_infer_types() { input_et); } - const auto output_shape = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)).front(); - set_output_type(0, logits_type, output_shape); + const auto output_shapes = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)); + set_output_type(0, logits_type, output_shapes[0]); } bool op::v4::CTCLoss::visit_attributes(AttributeVisitor& visitor) { diff --git a/src/core/src/op/depth_to_space.cpp b/src/core/src/op/depth_to_space.cpp index 0837897dac5604..b2f731d8666494 100644 --- a/src/core/src/op/depth_to_space.cpp +++ b/src/core/src/op/depth_to_space.cpp @@ -42,8 +42,8 @@ std::shared_ptr DepthToSpace::clone_with_new_inputs(const OutputVector& ne void DepthToSpace::validate_and_infer_types() { OV_OP_SCOPE(v0_DepthToSpace_validate_and_infer_types); - const auto output_shape = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)).front(); - set_output_type(0, get_input_element_type(0), output_shape); + const auto output_shapes = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)); + set_output_type(0, get_input_element_type(0), output_shapes[0]); } bool DepthToSpace::evaluate(TensorVector& outputs, const TensorVector& inputs) const { diff --git a/src/core/src/op/gather_tree.cpp b/src/core/src/op/gather_tree.cpp index a1618b598348da..f668fafbd8c72e 100644 --- a/src/core/src/op/gather_tree.cpp +++ b/src/core/src/op/gather_tree.cpp @@ -50,7 +50,7 @@ void op::v1::GatherTree::validate_and_infer_types() { "Element type of inputs must be numeric. Got: ", result_et); - const auto output_shape = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)).front(); - set_output_type(0, result_et, output_shape); + const auto output_shapes = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)); + set_output_type(0, result_et, output_shapes[0]); } } // namespace ov diff --git a/src/core/src/op/loop.cpp b/src/core/src/op/loop.cpp index 3ad4e940012481..2d2ed726cea339 100644 --- a/src/core/src/op/loop.cpp +++ b/src/core/src/op/loop.cpp @@ -169,8 +169,8 @@ void Loop::validate_and_infer_types() { auto body_parameter = m_bodies[0]->get_parameters().at(merged_input_description->m_body_parameter_index); - auto input_partial_shape = input(index).get_partial_shape(); - auto input_type = input(index).get_element_type(); + const auto& input_partial_shape = input(index).get_partial_shape(); + const auto& input_type = input(index).get_element_type(); body_parameter->set_partial_shape(input_partial_shape); body_parameter->set_element_type(input_type); diff --git a/src/core/src/op/max_pool.cpp b/src/core/src/op/max_pool.cpp index 5ce63acfd9ac50..78df2bf78b8664 100644 --- a/src/core/src/op/max_pool.cpp +++ b/src/core/src/op/max_pool.cpp @@ -421,9 +421,9 @@ bool MaxPool::evaluate(TensorVector& outputs, const TensorVector& inputs) const const auto input_shapes = std::vector{inputs[0].get_shape()}; auto pads_begin = m_pads_begin; auto pads_end = m_pads_end; - const auto output_shape = shape_infer(this, input_shapes, pads_begin, pads_end).front(); + const auto output_shapes = shape_infer(this, input_shapes, pads_begin, pads_end); - outputs[0].set_shape(output_shape.get_shape()); + outputs[0].set_shape(output_shapes[0].get_shape()); return ov::op::maxpool::evaluate_util(this, outputs, inputs, get_dilations(), get_axis()); } diff --git a/src/core/src/op/paged_attention.cpp b/src/core/src/op/paged_attention.cpp index 909ed9b3ae7ea9..a9f5d8c0c6c459 100644 --- a/src/core/src/op/paged_attention.cpp +++ b/src/core/src/op/paged_attention.cpp @@ -14,15 +14,15 @@ PagedAttentionExtension::PagedAttentionExtension(const ov::OutputVector& args) : } void PagedAttentionExtension::validate_and_infer_types() { - auto value_cache_shape = get_input_partial_shape(4); + // const auto& value_cache_shape = get_input_partial_shape(4); // m_num_kv_heads = value_cache_shape[1]; // m_head_size = value_cache_shape[2]; // m_block_size = value_cache_shape[3]; // Do not check shapes for cache K and cache V inputs, because they are hardware dependent // query: shape [batch_size, seq_len, num_heads * head_size] - auto query_type = get_input_element_type(0); - auto query_shape = get_input_partial_shape(0); + const auto& query_type = get_input_element_type(0); + const auto& query_shape = get_input_partial_shape(0); NODE_VALIDATION_CHECK(this, // query_type.is_real() && query_shape.size() == 3, @@ -34,8 +34,8 @@ void PagedAttentionExtension::validate_and_infer_types() { query_shape); // key: shape [batch_size, seq_len, num_kv_heads * head_size] - auto key_type = get_input_element_type(1); - auto key_shape = get_input_partial_shape(1); + const auto& key_type = get_input_element_type(1); + const auto& key_shape = get_input_partial_shape(1); NODE_VALIDATION_CHECK(this, // query_type == key_type && key_shape.size() == 3, @@ -47,7 +47,6 @@ void PagedAttentionExtension::validate_and_infer_types() { // value: shape [batch_size, seq_len, num_kv_heads * head_size] // auto value_type = get_input_element_type(2); - auto value_shape = get_input_partial_shape(2); // is_prompt: boolean scalar NODE_VALIDATION_CHECK(this, @@ -60,7 +59,7 @@ void PagedAttentionExtension::validate_and_infer_types() { get_input_shape(5)); // slot_mapping: shape [batch_size, max_context_len] - auto slot_mapping_shape = get_input_partial_shape(6); + const auto& slot_mapping_shape = get_input_partial_shape(6); NODE_VALIDATION_CHECK(this, // get_input_element_type(6) == ov::element::i64 && slot_mapping_shape.size() == 2, @@ -81,7 +80,7 @@ void PagedAttentionExtension::validate_and_infer_types() { get_input_shape(7)); // context_lens: shape [batch_size] - auto context_lens_shape = get_input_partial_shape(8); + const auto& context_lens_shape = get_input_partial_shape(8); NODE_VALIDATION_CHECK(this, // get_input_element_type(8) == ov::element::i32 && context_lens_shape.size() == 1, @@ -139,4 +138,4 @@ std::shared_ptr PagedAttentionExtension::clone_with_new_inputs(const o } } // namespace op -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/core/src/op/reverse.cpp b/src/core/src/op/reverse.cpp index b778e204e2bb65..8763e2d116235e 100644 --- a/src/core/src/op/reverse.cpp +++ b/src/core/src/op/reverse.cpp @@ -63,8 +63,8 @@ void Reverse::validate_and_infer_types() { "In 'index' mode the second input must contain integer values."); } - const auto output_shape = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)).front(); - set_output_type(0, get_input_element_type(0), output_shape); + const auto output_shapes = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)); + set_output_type(0, get_input_element_type(0), output_shapes[0]); } std::shared_ptr Reverse::clone_with_new_inputs(const OutputVector& new_args) const { diff --git a/src/core/src/op/reverse_sequence.cpp b/src/core/src/op/reverse_sequence.cpp index 36d7dec3f151ba..2b584996d3fa7d 100644 --- a/src/core/src/op/reverse_sequence.cpp +++ b/src/core/src/op/reverse_sequence.cpp @@ -38,8 +38,8 @@ void op::v0::ReverseSequence::validate_and_infer_types() { "Sequence lengths element type must be numeric type. Got: ", seq_lengths_et); - const auto output_shape = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)).front(); - set_output_type(0, get_input_element_type(0), output_shape); + const auto output_shapes = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)); + set_output_type(0, get_input_element_type(0), output_shapes[0]); m_normalized_seq_axis = ov::util::normalize_axis(this, m_seq_axis, get_input_partial_shape(0).rank()); } diff --git a/src/core/src/op/roll.cpp b/src/core/src/op/roll.cpp index d4ec7fdb0ecaa1..4ce4e57d527c52 100644 --- a/src/core/src/op/roll.cpp +++ b/src/core/src/op/roll.cpp @@ -28,8 +28,8 @@ void Roll::validate_and_infer_types() { axes_et.is_dynamic() || axes_et == element::i32 || axes_et == element::i64, "Axes must have int32 or int64 element type."); - const auto output_shape = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)).front(); - set_output_type(0, get_input_element_type(0), output_shape); + const auto output_shapes = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)); + set_output_type(0, get_input_element_type(0), output_shapes[0]); } bool Roll::visit_attributes(AttributeVisitor& visitor) { diff --git a/src/core/src/op/scaled_dot_product_attention.cpp b/src/core/src/op/scaled_dot_product_attention.cpp index 61bdde3324d3d5..cdce3bfbd5ff4b 100644 --- a/src/core/src/op/scaled_dot_product_attention.cpp +++ b/src/core/src/op/scaled_dot_product_attention.cpp @@ -64,7 +64,7 @@ void op::v13::ScaledDotProductAttention::validate_and_infer_types() { "The element type of the input tensor must be a floating-point."); const auto& input_shapes = ov::util::get_node_input_partial_shapes(*this); - const auto& output_shapes = shape_infer(this, input_shapes); + const auto output_shapes = shape_infer(this, input_shapes); set_output_type(0, out_type, output_shapes[0]); } diff --git a/src/core/src/op/shape_of.cpp b/src/core/src/op/shape_of.cpp index 07138610a4cc12..1c12b54b1fdbe9 100644 --- a/src/core/src/op/shape_of.cpp +++ b/src/core/src/op/shape_of.cpp @@ -120,7 +120,7 @@ void ShapeOf::validate_and_infer_types() { m_output_type == element::i64 || m_output_type == element::i32, "Output type must be i32 or i64"); set_input_is_relevant_to_value(0, false); - const auto input_partial_shape = get_input_partial_shape(0); + const auto& input_partial_shape = get_input_partial_shape(0); set_output_type(0, m_output_type, PartialShape{input_partial_shape.rank()}); } diff --git a/src/core/src/op/shuffle_channels.cpp b/src/core/src/op/shuffle_channels.cpp index 80658a696e3585..3927d260309b15 100644 --- a/src/core/src/op/shuffle_channels.cpp +++ b/src/core/src/op/shuffle_channels.cpp @@ -41,8 +41,8 @@ size_t ShuffleChannels::get_zero_based_axis() const { void ShuffleChannels::validate_and_infer_types() { OV_OP_SCOPE(v0_ShuffleChannels_validate_and_infer_types); - const auto output_shape = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)).front(); - set_output_type(0, get_input_element_type(0), output_shape); + const auto output_shapes = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)); + set_output_type(0, get_input_element_type(0), output_shapes[0]); } std::shared_ptr ShuffleChannels::clone_with_new_inputs(const OutputVector& new_args) const { diff --git a/src/core/src/op/slice.cpp b/src/core/src/op/slice.cpp index a1143da2afa5ae..519663a083ccc8 100644 --- a/src/core/src/op/slice.cpp +++ b/src/core/src/op/slice.cpp @@ -125,7 +125,7 @@ bool Slice::evaluate(TensorVector& outputs, const TensorVector& inputs) const { const auto starts = ov::get_tensor_data_as(inputs[1]); const auto steps = ov::get_tensor_data_as(inputs[3]); - const auto axes = slice_no_axes(this) ? default_axes(starts.size()) : ov::get_tensor_data_as(inputs[4]); + const auto& axes = slice_no_axes(this) ? default_axes(starts.size()) : ov::get_tensor_data_as(inputs[4]); reference::slice(static_cast(inputs[0].data()), inputs[0].get_shape(), diff --git a/src/core/src/op/space_to_batch.cpp b/src/core/src/op/space_to_batch.cpp index 7d7237a4e0a25a..a641586c6879aa 100644 --- a/src/core/src/op/space_to_batch.cpp +++ b/src/core/src/op/space_to_batch.cpp @@ -55,8 +55,8 @@ void SpaceToBatch::validate_and_infer_types() { "pads_end must be an integral number but got (", pads_end_type, ")."); - const auto output_shape = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)).front(); - set_output_type(0, data_type, output_shape); + const auto output_shapes = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)); + set_output_type(0, data_type, output_shapes[0]); } std::shared_ptr SpaceToBatch::clone_with_new_inputs(const OutputVector& new_args) const { diff --git a/src/core/src/op/space_to_depth.cpp b/src/core/src/op/space_to_depth.cpp index 43ef62906a2dee..e1a5b8997127fd 100644 --- a/src/core/src/op/space_to_depth.cpp +++ b/src/core/src/op/space_to_depth.cpp @@ -46,8 +46,8 @@ std::shared_ptr SpaceToDepth::clone_with_new_inputs(const OutputVector& ne void SpaceToDepth::validate_and_infer_types() { OV_OP_SCOPE(v0_SpaceToDepth_validate_and_infer_types); - const auto output_shape = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)).front(); - set_output_type(0, get_input_element_type(0), output_shape); + const auto output_shapes = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)); + set_output_type(0, get_input_element_type(0), output_shapes[0]); } bool SpaceToDepth::evaluate(TensorVector& outputs, const TensorVector& inputs) const { diff --git a/src/core/src/op/strided_slice.cpp b/src/core/src/op/strided_slice.cpp index 62049ba8938f8a..deb89fa9a531d4 100644 --- a/src/core/src/op/strided_slice.cpp +++ b/src/core/src/op/strided_slice.cpp @@ -48,8 +48,8 @@ StridedSlice::StridedSlice(const Output& data, namespace { std::shared_ptr calculate_default_strides(const Output& begin, const Output& end) { - const auto begin_pshape = begin.get_partial_shape(); - const auto end_pshape = end.get_partial_shape(); + const auto& begin_pshape = begin.get_partial_shape(); + const auto& end_pshape = end.get_partial_shape(); size_t strides_length = 0; if (begin_pshape.rank().is_static() && begin_pshape.rank().get_length() == 1 && begin_pshape[0].is_static()) { diff --git a/src/core/src/op/tensor_iterator.cpp b/src/core/src/op/tensor_iterator.cpp index 255b49b536070b..0c98ffd61d3e72 100644 --- a/src/core/src/op/tensor_iterator.cpp +++ b/src/core/src/op/tensor_iterator.cpp @@ -106,14 +106,12 @@ void op::v0::TensorIterator::validate_and_infer_types() { auto body_parameter = m_bodies[0]->get_parameters().at(merged_input_description->m_body_parameter_index); - auto body_param_partial_shape = body_parameter->get_partial_shape(); - auto input_partial_shape = inputs().at(index).get_source_output().get_partial_shape(); + const auto& input_partial_shape = inputs().at(index).get_source_output().get_partial_shape(); body_parameter->set_partial_shape(input_partial_shape); } else if (auto invariant_input_description = ov::as_type_ptr(input_description)) { auto body_parameter = m_bodies[0]->get_parameters().at(invariant_input_description->m_body_parameter_index); - auto body_param_partial_shape = body_parameter->get_partial_shape(); - auto input_partial_shape = inputs().at(index).get_source_output().get_partial_shape(); + const auto& input_partial_shape = inputs().at(index).get_source_output().get_partial_shape(); body_parameter->set_partial_shape(input_partial_shape); } } diff --git a/src/core/src/op/unique.cpp b/src/core/src/op/unique.cpp index e11a73381a347a..8088f1fa7098d4 100644 --- a/src/core/src/op/unique.cpp +++ b/src/core/src/op/unique.cpp @@ -142,7 +142,7 @@ void op::v10::Unique::validate_and_infer_types() { if (input_shape.rank().is_static()) { const auto normalized_axis = ov::util::normalize_axis(this, axis, input_shape.rank()); - const auto dim_at_axis = input_shape[normalized_axis]; + const auto& dim_at_axis = input_shape[normalized_axis]; Dimension output_dim_at_axis; Dimension rev_idx_size; diff --git a/src/core/src/op/util/broadcast_base.cpp b/src/core/src/op/util/broadcast_base.cpp index 48ca06dbd97f06..1d4f7c1541ae1f 100644 --- a/src/core/src/op/util/broadcast_base.cpp +++ b/src/core/src/op/util/broadcast_base.cpp @@ -218,8 +218,8 @@ void ov::op::util::BroadcastBase::validate_and_infer_types() { // Validate axes_mapping if (get_input_partial_shape(0).is_static() && get_input_partial_shape(1).is_static() && get_input_partial_shape(2).is_static()) { - auto arg_shape = get_input_shape(0); - auto axes_shape = get_input_shape(2); + const auto& arg_shape = get_input_shape(0); + const auto& axes_shape = get_input_shape(2); auto input_rank = (arg_shape.size() == 0 && shape_size(axes_shape) > 0) ? 1 : arg_shape.size(); // Rank(arg_shape) == shape_size(axes_mapping) @@ -297,8 +297,8 @@ std::pair ov::op::util::BroadcastBase::get_broadcast_axes() c } } else if (m_mode.m_type == BroadcastType::NUMPY || m_mode.m_type == BroadcastType::PDPD) { if (get_input_partial_shape(0).is_static() && get_output_partial_shape(0).is_static()) { - auto arg_shape = get_input_shape(0); - auto result_shape = get_output_shape(0); + const auto& arg_shape = get_input_shape(0); + const auto& result_shape = get_output_shape(0); return get_broadcast_axes_numpy_pdpd(arg_shape, result_shape, m_mode); } } else { @@ -435,7 +435,7 @@ bool ov::op::util::BroadcastBase::evaluate(ov::TensorVector& outputs, const ov:: PartialShape result_shape; std::pair pair_broadcast_axes; - auto arg_shape = inputs[0].get_shape(); + const auto& arg_shape = inputs[0].get_shape(); if (m_mode.m_type == BroadcastType::NONE) { AxisVector axes_mapping_val; diff --git a/src/core/src/op/util/gather_base.cpp b/src/core/src/op/util/gather_base.cpp index 8e7b9fe4531343..92e41781b1de55 100644 --- a/src/core/src/op/util/gather_base.cpp +++ b/src/core/src/op/util/gather_base.cpp @@ -49,7 +49,7 @@ bool cf_gather_with_subgraph(OutputVector& output_values, return false; } // only single indices are accepted - const auto indices_shape = indices->get_shape(); + const auto& indices_shape = indices->get_shape(); if (indices_shape.size() > 1 || (indices_shape.size() == 1 && indices_shape[0] > 1)) { return false; } diff --git a/src/core/src/op/util/multi_subgraph_base.cpp b/src/core/src/op/util/multi_subgraph_base.cpp index 43cd61e6645b2b..144cf167057543 100644 --- a/src/core/src/op/util/multi_subgraph_base.cpp +++ b/src/core/src/op/util/multi_subgraph_base.cpp @@ -152,7 +152,7 @@ void ov::op::util::MultiSubGraphOp::validate_and_infer_type_body( auto index = input_description->m_input_index; auto body_parameter = params.at(input_description->m_body_parameter_index); - auto input_partial_shape = input_value(index).get_partial_shape(); + const auto& input_partial_shape = input_value(index).get_partial_shape(); auto dtype = input_value(index).get_element_type(); body_parameter->set_partial_shape(input_partial_shape); body_parameter->set_element_type(dtype); diff --git a/src/core/src/op/util/scatter_elements_update_base.cpp b/src/core/src/op/util/scatter_elements_update_base.cpp index 9126e5cda930b4..75be89e6c5bd99 100644 --- a/src/core/src/op/util/scatter_elements_update_base.cpp +++ b/src/core/src/op/util/scatter_elements_update_base.cpp @@ -44,11 +44,11 @@ void util::ScatterElementsUpdateBase::validate_and_infer_types() { data_et, " and: ", updates_et); - const auto output_shape = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)).front(); + const auto output_shapes = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)); auto out_et = get_input_element_type(0); std::ignore = element::Type::merge(out_et, get_input_element_type(0), get_input_element_type(2)); - set_output_type(0, out_et, output_shape); - if (output_shape.is_dynamic()) { + set_output_type(0, out_et, output_shapes[0]); + if (output_shapes[0].is_dynamic()) { set_input_is_relevant_to_shape(0); } } diff --git a/src/core/src/partial_shape.cpp b/src/core/src/partial_shape.cpp index 6f503aa608833f..af346407e32636 100644 --- a/src/core/src/partial_shape.cpp +++ b/src/core/src/partial_shape.cpp @@ -314,8 +314,8 @@ bool ov::PartialShape::broadcast_merge_into(PartialShape& dst, std::vector dims(new_rank); bool success = true; for (int64_t i = 0; i < new_rank; i++) { - auto dsti = i < (new_rank - dst_rank) ? Dimension(1) : dst[i - (new_rank - dst_rank)]; - auto srci = i < (new_rank - src_rank) ? Dimension(1) : src[i - (new_rank - src_rank)]; + const auto& dsti = i < (new_rank - dst_rank) ? Dimension(1) : dst[i - (new_rank - dst_rank)]; + const auto& srci = i < (new_rank - src_rank) ? Dimension(1) : src[i - (new_rank - src_rank)]; success &= Dimension::broadcast_merge(dims[i], dsti, srci); } dst = PartialShape(std::move(dims)); diff --git a/src/core/src/pass/constant_folding.cpp b/src/core/src/pass/constant_folding.cpp index c691c818a9ce7b..3de91829f91b0c 100644 --- a/src/core/src/pass/constant_folding.cpp +++ b/src/core/src/pass/constant_folding.cpp @@ -39,14 +39,13 @@ const auto is_output_foldable = [](const ov::Output& output) { * * \return std::string with new friendly name. */ -const auto friendly_name_from = [](const ov::Node& node, const size_t output_count, const size_t idx) { +const auto friendly_name_from = [](const ov::Node& node, const size_t output_count, const size_t idx) -> std::string { constexpr auto single_output = static_cast(1); - - if (single_output == output_count) { - return node.get_friendly_name(); - } else { - return node.get_friendly_name() + "." + std::to_string(idx); + auto name = node.get_friendly_name(); + if (single_output != output_count) { + name.append(".").append(std::to_string(idx)); } + return name; }; static bool restore_original_input_precision(const std::shared_ptr& node) { @@ -128,7 +127,7 @@ bool ov::pass::ConstantFolding::run_on_model(const std::shared_ptr& m for (size_t i = 0; i < replacements.size(); ++i) { auto node_output = original_node->output(i); - auto replacement = replacements.at(i); + const auto& replacement = replacements.at(i); auto replacement_ptr = replacement.get_node_shared_ptr(); if (replacement_ptr && (node_output != replacement)) { replacement_ptr->set_friendly_name(friendly_name_from(*original_node, replacements.size(), i)); diff --git a/src/core/src/pass/low_latency.cpp b/src/core/src/pass/low_latency.cpp index 4590f8c876aaef..2dd75aa072e4fb 100644 --- a/src/core/src/pass/low_latency.cpp +++ b/src/core/src/pass/low_latency.cpp @@ -128,7 +128,7 @@ std::vector> replace_with_memory(const std:: } bool need_unroll(const std::shared_ptr& op) { - const auto p_shape = op->get_input_partial_shape(0); + const auto& p_shape = op->get_input_partial_shape(0); if (p_shape.rank().is_dynamic() || p_shape[1].is_dynamic() || p_shape[1].get_length() != 1) { return false; } diff --git a/src/core/src/pass/serialize.cpp b/src/core/src/pass/serialize.cpp index c82c5a806578f9..f38500bc3541e8 100644 --- a/src/core/src/pass/serialize.cpp +++ b/src/core/src/pass/serialize.cpp @@ -1033,7 +1033,7 @@ void ngfunction_2_ir(pugi::xml_node& netXml, pugi::xml_node port = output.append_child("port"); port.append_attribute("id").set_value(port_id++); - auto rt_info = o.get_tensor().get_rt_info(); + const auto& rt_info = o.get_tensor().get_rt_info(); auto port_element_type = is_fp16_compression_postponed(rt_info) ? ov::element::f16 : o.get_element_type(); @@ -1054,7 +1054,7 @@ void ngfunction_2_ir(pugi::xml_node& netXml, port.append_attribute("names").set_value(names.c_str()); } - for (auto d : o.get_partial_shape()) { + for (const auto& d : o.get_partial_shape()) { pugi::xml_node dim = port.append_child("dim"); if (d.is_dynamic()) { dim.append_child(pugi::xml_node_type::node_pcdata).set_value("-1"); diff --git a/src/core/src/pass/visualize_tree.cpp b/src/core/src/pass/visualize_tree.cpp index c8656e368cf5e5..61446c416d132d 100644 --- a/src/core/src/pass/visualize_tree.cpp +++ b/src/core/src/pass/visualize_tree.cpp @@ -611,7 +611,7 @@ std::string ov::pass::VisualizeTree::get_node_name(std::shared_ptr node) { if (node->get_friendly_name() != node->get_name()) { rc += "\\n" + (nvtmn ? std::string("name: ") : "") + node->get_name(); } - const auto type_info = node->get_type_info(); + const auto& type_info = node->get_type_info(); rc += "\\n" + (nvtmn ? std::string("type_name: ") : "") + std::string(type_info.version_id) + "::" + std::string(type_info.name); @@ -655,7 +655,7 @@ std::string ov::pass::VisualizeTree::get_node_name(std::shared_ptr node) { static const bool nvtrti = ov::util::getenv_bool("OV_VISUALIZE_TREE_RUNTIME_INFO"); if (nvtrti) { - const auto rt = node->get_rt_info(); + const auto& rt = node->get_rt_info(); if (!rt.empty()) { rc += "\\nrt info: " + get_attribute_values(rt, "\\n"); } diff --git a/src/core/src/preprocess/preprocess_impls.cpp b/src/core/src/preprocess/preprocess_impls.cpp index bcc511332a06bc..a3a3c36291fc22 100644 --- a/src/core/src/preprocess/preprocess_impls.cpp +++ b/src/core/src/preprocess/preprocess_impls.cpp @@ -44,7 +44,7 @@ InputInfo::InputInfoImpl::InputInfoData InputInfo::InputInfoImpl::create_new_par } } - auto model_shape = res.m_param->get_partial_shape(); + const auto& model_shape = res.m_param->get_partial_shape(); auto new_param_shape = model_shape; if (get_tensor_data()->is_shape_set()) { new_param_shape = get_tensor_data()->get_shape(); @@ -63,9 +63,12 @@ InputInfo::InputInfoImpl::InputInfoData InputInfo::InputInfoImpl::create_new_par auto net_to_tensor = layout::utils::find_permutation(sq_layout, new_param_shape, res.m_tensor_layout); if (!net_to_tensor.empty() && new_param_shape.rank().is_static()) { std::vector dims(new_param_shape.size()); - std::transform(net_to_tensor.begin(), net_to_tensor.end(), dims.begin(), [&](int64_t v) { - return new_param_shape[v]; - }); + std::transform(net_to_tensor.begin(), + net_to_tensor.end(), + dims.begin(), + [&](int64_t v) -> const Dimension& { + return new_param_shape[v]; + }); new_param_shape = PartialShape(dims); } } else { @@ -191,7 +194,7 @@ bool InputInfo::InputInfoImpl::build(const std::shared_ptr& model, nodes = std::get<0>(action_result); } - auto node = nodes[0]; + const auto& node = nodes[0]; if (node.get_partial_shape() != context.model_shape()) { need_validate = true; // Trigger revalidation if input parameter shape is changed } @@ -324,7 +327,7 @@ void InputInfo::InputInfoImpl::dump(std::ostream& str, void OutputInfo::OutputInfoImpl::build(ov::ResultVector& results) { std::shared_ptr result; auto node = m_output_node; - auto start_out_node_names = node.get_tensor().get_names(); + const auto start_out_node_names = node.get_tensor().get_names(); node.get_tensor().set_names({}); result = std::dynamic_pointer_cast(node.get_node_shared_ptr()); // Set result layout from 'model' information @@ -422,7 +425,7 @@ void OutputInfo::OutputInfoImpl::build(ov::ResultVector& results) { void OutputInfo::OutputInfoImpl::dump(std::ostream& str) const { std::shared_ptr result; auto node = m_output_node; - auto start_out_node_names = node.get_tensor().get_names(); + const auto& start_out_node_names = node.get_tensor().get_names(); result = std::dynamic_pointer_cast(node.get_node_shared_ptr()); auto model_layout = get_model_data()->is_layout_set() ? get_model_data()->get_layout() : result->get_layout(); PostprocessingContext context(model_layout); diff --git a/src/core/src/runtime/string_aligned_buffer.cpp b/src/core/src/runtime/string_aligned_buffer.cpp index 98503e0fb507f6..cc2bcdd5b0eac7 100644 --- a/src/core/src/runtime/string_aligned_buffer.cpp +++ b/src/core/src/runtime/string_aligned_buffer.cpp @@ -58,7 +58,7 @@ void aux_get_header(const std::shared_ptr& string_align size_t current_symbols_pos = 0; for (size_t ind = 0; ind < num_elements; ++ind) { - auto str = strings[ind]; + const auto& str = strings[ind]; current_symbols_pos += str.size(); *pindices = int32_t(current_symbols_pos); ++pindices; diff --git a/src/core/template_extension/identity.cpp b/src/core/template_extension/identity.cpp index f3cf38ba1b2141..4b6f6f12bafcde 100644 --- a/src/core/template_extension/identity.cpp +++ b/src/core/template_extension/identity.cpp @@ -35,8 +35,8 @@ bool Identity::visit_attributes(ov::AttributeVisitor& visitor) { //! [op:evaluate] bool Identity::evaluate(ov::TensorVector& outputs, const ov::TensorVector& inputs) const { - auto in = inputs[0]; - auto out = outputs[0]; + const auto& in = inputs[0]; + auto& out = outputs[0]; if (out.data() == in.data()) // Nothing to do return true; out.set_shape(in.get_shape()); diff --git a/src/core/tests/visitors/visitors.hpp b/src/core/tests/visitors/visitors.hpp index 2d78c466b9a146..d4c3c54994ef60 100644 --- a/src/core/tests/visitors/visitors.hpp +++ b/src/core/tests/visitors/visitors.hpp @@ -489,7 +489,6 @@ class NodeBuilder : public ValueMap, public DeserializeAttributeVisitor { } // namespace test } // namespace ov - #ifdef __GNUC__ # pragma GCC diagnostic pop #endif