Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[core] Fix issue reported by Coverity in core sub-component (#30753)

Pawel Raaszef9c8d900030
diff --git a/src/core/include/openvino/core/descriptor/input.hpp b/src/core/include/openvino/core/descriptor/input.hpp
index 5d6559f79f4..876396bf0f1 100644
--- a/src/core/include/openvino/core/descriptor/input.hpp
+++ b/src/core/include/openvino/core/descriptor/input.hpp
@@ -104,6 +104,7 @@ public:
Input(const Input&) = default;
Input(Input&&) = default;
Input& operator=(const Input&) = default;
+ Input& operator=(Input&&) = default;
protected:
// owner of an argument node (in lieu of m_arguments)
diff --git a/src/core/include/openvino/core/enum_names.hpp b/src/core/include/openvino/core/enum_names.hpp
index 97edc8cf79a..6f9552e33bd 100644
--- a/src/core/include/openvino/core/enum_names.hpp
+++ b/src/core/include/openvino/core/enum_names.hpp
@@ -48,7 +48,7 @@ private:
/// Creates the mapping.
EnumNames(const std::string& enum_name, const std::vector<std::pair<std::string, EnumType>> string_enums)
: m_enum_name(enum_name),
- m_string_enums(string_enums) {}
+ m_string_enums(std::move(string_enums)) {}
/// Must be defined to returns a singleton for each supported enum class
static EnumNames<EnumType>& get();
diff --git a/src/core/include/openvino/core/type.hpp b/src/core/include/openvino/core/type.hpp
index 4cd6fc77c0d..615903e17c8 100644
--- a/src/core/include/openvino/core/type.hpp
+++ b/src/core/include/openvino/core/type.hpp
@@ -98,9 +98,9 @@ is_type(Value value) {
}
/// \brief Tests if value is a pointer/shared_ptr that can be statically cast to any of the specified types
-template <typename Type, typename... Types, typename Value>
-bool is_type_any_of(Value value) {
- return is_type<Type>(value) || (is_type_any_of<Types>(value) || ...);
+template <typename... Types, typename Value>
+bool is_type_any_of(Value&& value) {
+ return (is_type<Types>(std::forward<Value>(value)) || ...);
}
/// Casts a Value* to a Type* if it is of type Type, nullptr otherwise
diff --git a/src/core/include/openvino/op/interpolate.hpp b/src/core/include/openvino/op/interpolate.hpp
index 427f86ba97e..b7566f1879a 100644
--- a/src/core/include/openvino/op/interpolate.hpp
+++ b/src/core/include/openvino/op/interpolate.hpp
@@ -63,7 +63,8 @@ public:
return m_attrs;
}
- void set_attrs(Attributes attrs);
+ void set_attrs(Attributes&& attrs);
+ void set_attrs(const Attributes& attrs);
private:
Attributes m_attrs;
diff --git a/src/core/include/openvino/op/prior_box.hpp b/src/core/include/openvino/op/prior_box.hpp
index 6680db750e0..5902130f60e 100644
--- a/src/core/include/openvino/op/prior_box.hpp
+++ b/src/core/include/openvino/op/prior_box.hpp
@@ -56,7 +56,8 @@ public:
const Attributes& get_attrs() const {
return m_attrs;
}
- void set_attrs(Attributes attrs);
+ void set_attrs(Attributes&& attrs);
+ void set_attrs(const Attributes& attrs);
bool visit_attributes(AttributeVisitor& visitor) override;
bool evaluate(TensorVector& outputs, const TensorVector& inputs) const override;
@@ -117,7 +118,8 @@ public:
const Attributes& get_attrs() const {
return m_attrs;
}
- void set_attrs(Attributes attrs);
+ void set_attrs(Attributes&& attrs);
+ void set_attrs(const Attributes& attrs);
bool visit_attributes(AttributeVisitor& visitor) override;
bool evaluate(TensorVector& outputs, const TensorVector& inputs) const override;
diff --git a/src/core/include/openvino/op/proposal.hpp b/src/core/include/openvino/op/proposal.hpp
index b8f77eebd5e..00625ec84bb 100644
--- a/src/core/include/openvino/op/proposal.hpp
+++ b/src/core/include/openvino/op/proposal.hpp
@@ -68,8 +68,11 @@ public:
/**
* @brief Set the Proposal operator attributes.
* @param attrs Attributes to be set.
+ * @{
*/
- void set_attrs(Attributes attrs);
+ void set_attrs(Attributes&& attrs);
+ void set_attrs(const Attributes& attrs);
+ /** @} */
bool visit_attributes(AttributeVisitor& visitor) override;
diff --git a/src/core/include/openvino/pass/manager.hpp b/src/core/include/openvino/pass/manager.hpp
index 316c38b0329..49f2f49cc9a 100644
--- a/src/core/include/openvino/pass/manager.hpp
+++ b/src/core/include/openvino/pass/manager.hpp
@@ -90,8 +90,7 @@ protected:
std::shared_ptr<T> push_pass(Args&&... args) {
static_assert(std::is_base_of<pass::PassBase, T>::value, "pass not derived from pass base");
auto pass = std::make_shared<T>(std::forward<Args>(args)...);
- auto pass_base = std::static_pointer_cast<PassBase>(pass);
- m_pass_list.push_back(pass_base);
+ m_pass_list.push_back(pass);
return pass;
}
diff --git a/src/core/reference/include/openvino/reference/reduce_mean.hpp b/src/core/reference/include/openvino/reference/reduce_mean.hpp
index 570c944218b..4d6eb2be050 100644
--- a/src/core/reference/include/openvino/reference/reduce_mean.hpp
+++ b/src/core/reference/include/openvino/reference/reduce_mean.hpp
@@ -10,8 +10,7 @@
#include "openvino/core/shape_util.hpp"
#include "openvino/reference/reduce_sum.hpp"
-namespace ov {
-namespace reference {
+namespace ov::reference {
/**
* @brief Reference implementation of ReduceMean operator.
@@ -25,16 +24,13 @@ template <class T>
void reduce_mean(const T* in, T* out, const Shape& in_shape, const AxisSet& reduction_axes) {
reduce_sum(in, out, in_shape, reduction_axes);
- const auto out_shape = util::reduce(in_shape, reduction_axes);
- if (shape_size(in_shape) == 0) {
- return;
+ if (const auto input_size = shape_size(in_shape); input_size != 0) {
+ const auto out_shape = util::reduce(in_shape, reduction_axes);
+ const auto out_size = shape_size(out_shape);
+ const auto count = input_size / out_size;
+ std::transform(out, std::next(out, out_size), out, [count = static_cast<T>(count)](auto&& value) -> T {
+ return value / count;
+ });
}
-
- const auto out_size = shape_size(out_shape);
- const auto count = static_cast<T>(shape_size(in_shape) / out_size);
- std::transform(out, std::next(out, out_size), out, [count](const T value) {
- return value / count;
- });
}
-} // namespace reference
-} // namespace ov
+} // namespace ov::reference
diff --git a/src/core/reference/include/openvino/reference/rounding_guard.hpp b/src/core/reference/include/openvino/reference/rounding_guard.hpp
index 69651b93c03..4c6630e42ce 100644
--- a/src/core/reference/include/openvino/reference/rounding_guard.hpp
+++ b/src/core/reference/include/openvino/reference/rounding_guard.hpp
@@ -23,6 +23,9 @@ public:
RoundingGuard(int mode);
~RoundingGuard();
+ RoundingGuard(const RoundingGuard&) = delete;
+ RoundingGuard& operator=(const RoundingGuard&) = delete;
+
private:
int m_prev_round_mode;
};
diff --git a/src/core/reference/include/openvino/reference/scatter_elements_update.hpp b/src/core/reference/include/openvino/reference/scatter_elements_update.hpp
index 9842bea97bc..a075b802b90 100644
--- a/src/core/reference/include/openvino/reference/scatter_elements_update.hpp
+++ b/src/core/reference/include/openvino/reference/scatter_elements_update.hpp
@@ -7,10 +7,12 @@
#include <cfenv>
#include <cstring>
#include <iterator>
+#include <optional>
#include "openvino/core/except.hpp"
#include "openvino/core/shape.hpp"
#include "openvino/op/scatter_elements_update.hpp"
+#include "openvino/reference/rounding_guard.hpp"
#include "openvino/reference/utils/coordinate_index.hpp"
#include "openvino/reference/utils/coordinate_transform.hpp"
@@ -133,25 +135,6 @@ typename std::enable_if<std::is_integral<T>::value, T>::type arithmetic_mean(con
return value;
}
-template <typename T>
-struct RoundingDirectionGuard {
- RoundingDirectionGuard() {
- if (std::is_integral<T>::value) {
- m_original_mode = std::fegetround();
- std::fesetround(FE_DOWNWARD);
- }
- }
-
- ~RoundingDirectionGuard() {
- if (std::is_integral<T>::value) {
- std::fesetround(m_original_mode);
- }
- }
-
-private:
- decltype(std::fegetround()) m_original_mode;
-};
-
template <typename DataType>
void scatter_elem_update_with_reduction(const int64_t* indices,
const DataType* updates,
@@ -210,11 +193,14 @@ void scatter_elem_update_with_reduction(const int64_t* indices,
if (reduction_type == ov::op::v12::ScatterElementsUpdate::Reduction::MEAN) {
// this object will change the rounding mode only for integer types which is required to match torch
// upon destruction the previously used rounding mode will be restored
- RoundingDirectionGuard<DataType> rounding_guard;
- for (const auto& counter : mean_reduction_counters) {
+ std::optional<RoundingGuard> r_guard;
+ if constexpr (std::is_integral_v<DataType>) {
+ r_guard.emplace(FE_DOWNWARD);
+ }
+ for (const auto& [idx, count] : mean_reduction_counters) {
// include the initial value in the arithmetic mean divisor (if needed)
- const auto N = counter.second + static_cast<int32_t>(use_init_val);
- out_buf[counter.first] = arithmetic_mean<DataType>(out_buf[counter.first], N);
+ const auto N = count + static_cast<int32_t>(use_init_val);
+ out_buf[idx] = arithmetic_mean<DataType>(out_buf[idx], N);
}
}
}
diff --git a/src/core/reference/src/op/einsum.cpp b/src/core/reference/src/op/einsum.cpp
index 505f92c88c7..e83a8292b0d 100644
--- a/src/core/reference/src/op/einsum.cpp
+++ b/src/core/reference/src/op/einsum.cpp
@@ -520,7 +520,8 @@ ov::Tensor build_multi_identity(const ov::Tensor& input,
ov::Tensor identity = build_identity<T>(input, repeated_label_dims);
PartialShape output_shape = multi_identity.get_shape();
- PartialShape::broadcast_merge_into(output_shape, identity.get_shape(), ov::op::AutoBroadcastType::NUMPY);
+ std::ignore =
+ PartialShape::broadcast_merge_into(output_shape, identity.get_shape(), ov::op::AutoBroadcastType::NUMPY);
auto mul_output = ov::Tensor(identity.get_element_type(), output_shape.get_shape());
reference::multiply<T>(multi_identity.data<T>(),
identity.data<T>(),
@@ -823,9 +824,9 @@ void contract_two_inputs(ov::TensorVector& inputs,
// multiply both operands with broadcasting
PartialShape output_shape = unsqueeze_output1.get_shape();
- PartialShape::broadcast_merge_into(output_shape,
- unsqueeze_output2.get_shape(),
- ov::op::AutoBroadcastType::NUMPY);
+ std::ignore = PartialShape::broadcast_merge_into(output_shape,
+ unsqueeze_output2.get_shape(),
+ ov::op::AutoBroadcastType::NUMPY);
auto mul_output = ov::Tensor(unsqueeze_output1.get_element_type(), output_shape.get_shape());
reference::multiply<T>(unsqueeze_output1.data<T>(),
unsqueeze_output2.data<T>(),
@@ -906,8 +907,10 @@ void contract_two_inputs(ov::TensorVector& inputs,
// broadcast both inputs to have common sub-shape broadcasted that is needed
// in case of ellipsis among the common labels
// reference::broadcast()
- PartialShape::broadcast_merge_into(common_sub_shape1, common_sub_shape2, op::AutoBroadcastType::NUMPY);
- PartialShape::broadcast_merge_into(reduced_sub_shape, reduced_sub_shape2, op::AutoBroadcastType::NUMPY);
+ std::ignore =
+ PartialShape::broadcast_merge_into(common_sub_shape1, common_sub_shape2, op::AutoBroadcastType::NUMPY);
+ std::ignore =
+ PartialShape::broadcast_merge_into(reduced_sub_shape, reduced_sub_shape2, op::AutoBroadcastType::NUMPY);
Shape reduced_sub_shape_prod = {shape_size(reduced_sub_shape.get_shape())};
Shape common_sub_shape = common_sub_shape1.get_shape();
broadcast_input<T>(inputs,
diff --git a/src/core/reference/src/op/fft.cpp b/src/core/reference/src/op/fft.cpp
index 1e0c04eb4c4..f8d244fc8d2 100644
--- a/src/core/reference/src/op/fft.cpp
+++ b/src/core/reference/src/op/fft.cpp
@@ -311,32 +311,26 @@ InfoForFFTCalculation get_info_for_calculation(const Shape& input_data_shape,
fft_axes = fft_common::reverse_fft_axes(fft_axes, complex_data_rank);
const int64_t fft_rank = fft_axes.size();
- const auto fft_lengths = get_lengths(reversed_output_shape, fft_axes);
- const auto fft_strides = fft_common::compute_strides(fft_lengths);
- const int64_t fft_size = fft_strides[fft_rank];
-
const auto outer_axes = get_outer_axes(fft_axes, complex_data_rank);
const int64_t outer_rank = outer_axes.size();
const auto outer_lengths = get_lengths(reversed_output_shape, outer_axes);
- const auto outer_strides = fft_common::compute_strides(outer_lengths);
- const int64_t outer_size = outer_strides[outer_rank];
const auto output_strides = fft_common::compute_strides(reversed_output_shape);
const auto reversed_input_shape = fft_common::reverse_shape_of_emulated_complex_tensor(input_data_shape);
const auto input_strides = fft_common::compute_strides(reversed_input_shape);
- result.fft_lengths = fft_lengths;
- result.fft_strides = fft_strides;
- result.outer_strides = outer_strides;
+ result.fft_lengths = get_lengths(reversed_output_shape, fft_axes);
+ result.fft_strides = fft_common::compute_strides(result.fft_lengths);
+ result.outer_strides = fft_common::compute_strides(outer_lengths);
result.output_fft_strides = get_lengths(output_strides, fft_axes);
result.output_outer_strides = get_lengths(output_strides, outer_axes);
result.input_fft_lengths = get_lengths(reversed_input_shape, fft_axes);
result.input_fft_strides = get_lengths(input_strides, fft_axes);
result.input_outer_strides = get_lengths(input_strides, outer_axes);
result.fft_rank = fft_rank;
- result.fft_size = fft_size;
- result.outer_size = outer_size;
- result.buffer_size = compute_buffer_size(fft_lengths);
+ result.fft_size = result.fft_strides[fft_rank];
+ result.outer_size = result.outer_strides[outer_rank];
+ result.buffer_size = compute_buffer_size(result.fft_lengths);
return result;
}
diff --git a/src/core/shape_inference/include/einsum_shape_inference.hpp b/src/core/shape_inference/include/einsum_shape_inference.hpp
index be67686c96a..ff25d8c9eaf 100644
--- a/src/core/shape_inference/include/einsum_shape_inference.hpp
+++ b/src/core/shape_inference/include/einsum_shape_inference.hpp
@@ -81,7 +81,7 @@ std::vector<TRShape> shape_infer(const Einsum* op, const std::vector<T>& input_s
++dim_ind;
}
}
- for (auto label_it : single_input_label_to_shape) {
+ for (const auto& label_it : single_input_label_to_shape) {
// Repeated labels in single input node are eliminated, so we can merge them into the global
// label_to_shape.
if (label_to_shape.find(label_it.first) == label_to_shape.end()) {
diff --git a/src/core/shape_inference/include/reshape_shape_inference.hpp b/src/core/shape_inference/include/reshape_shape_inference.hpp
index 932d2cc8b16..cdd97097bc4 100644
--- a/src/core/shape_inference/include/reshape_shape_inference.hpp
+++ b/src/core/shape_inference/include/reshape_shape_inference.hpp
@@ -244,7 +244,7 @@ template <class TDim,
typename std::enable_if<std::is_same<typename std::decay<TDim>::type, Dimension>::value>::type* = nullptr>
void deduce_symbol_relations(const Product<TDim>& product) {
auto dyn_in = product.get_dynamic_in();
- auto dyn_out = product.get_dynamic_out();
+ const auto& dyn_out = product.get_dynamic_out();
dyn_in.merge(dyn_in, dyn_in, dyn_out);
}
diff --git a/src/core/shape_inference/include/slice_scatter_shape_inference.hpp b/src/core/shape_inference/include/slice_scatter_shape_inference.hpp
index 4fdbcce393a..2ac4d9665ec 100644
--- a/src/core/shape_inference/include/slice_scatter_shape_inference.hpp
+++ b/src/core/shape_inference/include/slice_scatter_shape_inference.hpp
@@ -99,8 +99,8 @@ std::vector<TRShape> shape_infer(const SliceScatter* op,
auto axis_it = axes_map.m.cbegin();
if (output_shape.rank().is_static()) {
- std::vector<DimType> expected_updates_shape_vector;
- expected_updates_shape_vector.reserve(output_shape.size());
+ TRShape expected_updates_shape;
+ expected_updates_shape.reserve(output_shape.size());
for (size_t dim_idx = 0; dim_idx < output_shape.size(); ++dim_idx) {
const DimType& input_dim = output_shape[dim_idx];
@@ -108,20 +108,19 @@ std::vector<TRShape> shape_infer(const SliceScatter* op,
const auto& i = axis_it->second;
if (start && stop && steps) {
const auto& step = (*steps)[i];
- expected_updates_shape_vector.push_back(slice::make_dim(input_dim, (*start)[i], (*stop)[i], step));
+ expected_updates_shape.push_back(slice::make_dim(input_dim, (*start)[i], (*stop)[i], step));
} else {
- expected_updates_shape_vector.push_back(DimType{0, input_dim.get_max_length()});
+ expected_updates_shape.push_back(DimType{0, input_dim.get_max_length()});
}
++axis_it;
} else if (axes_map.is_valid) {
// dimension not on axes list, no change
- expected_updates_shape_vector.push_back(input_dim);
+ expected_updates_shape.push_back(input_dim);
} else {
// axes are unknow so any dimension can be sliced
- expected_updates_shape_vector.push_back(DimType{0, input_dim.get_max_length()});
+ expected_updates_shape.push_back(DimType{0, input_dim.get_max_length()});
}
}
- TRShape expected_updates_shape{expected_updates_shape_vector};
NODE_SHAPE_INFER_CHECK(op,
input_shapes,
input_shapes[1].compatible(expected_updates_shape),
diff --git a/src/core/shape_inference/include/strided_slice_shape_inference.hpp b/src/core/shape_inference/include/strided_slice_shape_inference.hpp
index a72cc74e57f..5a81a1f420a 100644
--- a/src/core/shape_inference/include/strided_slice_shape_inference.hpp
+++ b/src/core/shape_inference/include/strided_slice_shape_inference.hpp
@@ -203,6 +203,10 @@ std::vector<TRShape> shape_infer(const StridedSlice* op,
out.push_back(std::move(sliced_dim));
} else {
+ NODE_SHAPE_INFER_CHECK(op,
+ input_shapes,
+ start && stop,
+ "Requires both start and stop to be defined for static shapes.");
auto sliced_dim = slice::make_dim(input_dim, *start, *stop, stride);
out.push_back(std::move(sliced_dim));
}
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 d7474c0000e..3d140720c81 100644
--- a/src/core/shape_inference/include/variadic_split_shape_inference.hpp
+++ b/src/core/shape_inference/include/variadic_split_shape_inference.hpp
@@ -89,14 +89,11 @@ std::vector<TRShape> shape_infer(const Node* op,
}
for (uint64_t output = 0; output < static_cast<uint64_t>(num_outputs); ++output) {
+ auto& out_shape = output_shapes.emplace_back(data_shape);
if (split_lengths->at(output) == -1) {
- TRShape out_shape = data_shape;
out_shape[axis] = Dimension::dynamic();
- output_shapes.push_back(out_shape);
} else {
- TRShape out_shape = data_shape;
out_shape[axis] = split_lengths->at(output);
- output_shapes.push_back(out_shape);
}
}
} else {
diff --git a/src/core/src/bound_evaluate.cpp b/src/core/src/bound_evaluate.cpp
index 1c90c54d77f..bbadd1c585b 100644
--- a/src/core/src/bound_evaluate.cpp
+++ b/src/core/src/bound_evaluate.cpp
@@ -281,8 +281,8 @@ bool default_bound_evaluator(const ov::Node* node,
ov::TensorVector inputs;
inputs.reserve(size);
for (size_t i = 0; i < size; ++i) {
- if (auto bound = (node->get_input_tensor(i).*get_bound)()) {
- inputs.push_back(bound);
+ if (auto&& bound = (node->get_input_tensor(i).*get_bound)()) {
+ inputs.push_back(std::move(bound));
} else {
return false;
}
@@ -479,7 +479,7 @@ bool ov::interval_bound_evaluator(const Node* node,
return false;
};
- TensorVector vector_of_unsqueezed_output_variants;
+ auto& vector_of_unsqueezed_output_variants = unsqueezed_output_variants.emplace_back();
for (const auto& output : vector_of_output_variants) {
auto unsqueezed_shape = output.get_shape();
unsqueezed_shape.insert(unsqueezed_shape.begin(), 1);
@@ -490,7 +490,6 @@ bool ov::interval_bound_evaluator(const Node* node,
op::v0::Unsqueeze().evaluate(unsqueezed_outputs, TensorVector{output, zero_t});
vector_of_unsqueezed_output_variants.push_back(unsqueezed);
}
- unsqueezed_output_variants.push_back(vector_of_unsqueezed_output_variants);
}
const auto input_0_maximum_value = ov::util::make_tensor_of_max_value(low_0.get_element_type());
const auto input_1_maximum_value = ov::util::make_tensor_of_max_value(low_1.get_element_type());
@@ -531,9 +530,10 @@ bool ov::interval_bound_evaluator(const Node* node,
if (!upper_output_values[i]) {
fully_defined = false;
} else {
- const auto output_maximum_value = make_tensor_max_of_type(upper_output_values[i].get_element_type());
+ auto output_maximum_value = make_tensor_max_of_type(upper_output_values[i].get_element_type());
- op::v1::Select().evaluate(upper_out, {final_input_dyn_mask, output_maximum_value, upper_output_values[i]});
+ op::v1::Select().evaluate(upper_out,
+ {final_input_dyn_mask, std::move(output_maximum_value), upper_output_values[i]});
node->get_output_tensor(i).set_upper_value(upper_output_values[i]);
}
@@ -541,10 +541,8 @@ bool ov::interval_bound_evaluator(const Node* node,
fully_defined = false;
} else {
// Can not set to make_tensor_of_min_value(lower_output_values[i]->get_element_type()) yet
- auto then = Tensor{lower_out[0].get_element_type(), Shape{}};
- auto then_data = static_cast<char*>(then.data());
- std::memset(then_data, 0, then.get_byte_size());
- op::v1::Select().evaluate(lower_out, {final_input_dyn_mask, then, lower_out[0]});
+ auto then = std::make_shared<op::v0::Constant>(lower_out[0].get_element_type(), Shape{}, 0);
+ op::v1::Select().evaluate(lower_out, {final_input_dyn_mask, then->get_tensor_view(), lower_out[0]});
node->get_output_tensor(i).set_lower_value(lower_out[0]);
}
}
diff --git a/src/core/src/graph_util.cpp b/src/core/src/graph_util.cpp
index 309ef3dc74d..0655eef1d2c 100644
--- a/src/core/src/graph_util.cpp
+++ b/src/core/src/graph_util.cpp
@@ -158,11 +158,11 @@ void replace_node(const std::shared_ptr<Node>& target, const OutputVector& repla
// Change I's connected upstream output to O_rep
for (size_t i = 0; i < target->get_output_size(); i++) {
auto& replacement_value = replacement_values.at(i);
- auto replacement_node = replacement_value.get_node_shared_ptr();
- if (replacement_nodes.find(replacement_node) == replacement_nodes.end()) {
+ if (auto&& replacement_node = replacement_value.get_node_shared_ptr();
+ replacement_nodes.find(replacement_node) == replacement_nodes.end()) {
replacement_node->add_node_control_dependents(target);
replacement_node->add_node_control_dependencies(target);
- replacement_nodes.insert(replacement_node);
+ replacement_nodes.insert(std::move(replacement_node));
}
target->output(i).replace(replacement_values.at(i));
}
@@ -227,7 +227,7 @@ std::shared_ptr<Model> clone_ov_model(const Model& func, std::unordered_map<Node
if (!result) {
OPENVINO_THROW("Results should be of type ov::op::v0::Result");
}
- cloned_results.push_back(result);
+ cloned_results.push_back(std::move(result));
}
SinkVector cloned_sinks;
for (const auto& node : func.get_sinks()) {
diff --git a/src/core/src/op/convert.cpp b/src/core/src/op/convert.cpp
index c3acf6caeaf..bc7d89d3745 100644
--- a/src/core/src/op/convert.cpp
+++ b/src/core/src/op/convert.cpp
@@ -156,8 +156,8 @@ bool evaluate_bound(const Node* const node, TensorVector& output_values, const T
}
// constants for dynamic values translation
- const auto input_max = ov::util::make_tensor_of_max_value(input_et);
- const auto output_max = ov::util::make_tensor_of_max_value(output_et);
+ auto input_max = ov::util::make_tensor_of_max_value(input_et);
+ auto output_max = ov::util::make_tensor_of_max_value(output_et);
if (!input_max || !output_max)
return false;
@@ -165,8 +165,8 @@ bool evaluate_bound(const Node* const node, TensorVector& output_values, const T
auto outputs = TensorVector{{element::boolean, in_bound_shape}};
const auto& input_dynamic_mask = outputs[0];
- return v1::Equal().evaluate(outputs, {input_bound, input_max}) &&
- v1::Select().evaluate(output_values, {input_dynamic_mask, output_max, output_values[0]});
+ return v1::Equal().evaluate(outputs, {input_bound, std::move(input_max)}) &&
+ v1::Select().evaluate(output_values, {input_dynamic_mask, std::move(output_max), output_values[0]});
} else {
return false;
}
@@ -280,11 +280,10 @@ bool Convert::evaluate_upper(TensorVector& output_values) const {
}
bool Convert::evaluate_symbol(TensorSymbolVector& output_symbols) const {
- const auto input_symbols = get_input_tensor(0).get_value_symbol();
- if (input_symbols.empty()) {
+ if (auto input_symbols = get_input_tensor(0).get_value_symbol(); input_symbols.empty()) {
return false;
} else {
- output_symbols[0] = input_symbols;
+ output_symbols[0] = std::move(input_symbols);
return true;
}
}
diff --git a/src/core/src/op/deformable_psroi_pooling.cpp b/src/core/src/op/deformable_psroi_pooling.cpp
index f36281513f7..96b3945a04d 100644
--- a/src/core/src/op/deformable_psroi_pooling.cpp
+++ b/src/core/src/op/deformable_psroi_pooling.cpp
@@ -24,7 +24,7 @@ op::v1::DeformablePSROIPooling::DeformablePSROIPooling(const Output<Node>& input
m_output_dim(output_dim),
m_spatial_scale(spatial_scale),
m_group_size(group_size),
- m_mode(mode),
+ m_mode(std::move(mode)),
m_spatial_bins_x(spatial_bins_x),
m_spatial_bins_y(spatial_bins_y),
m_trans_std(trans_std),
@@ -46,7 +46,7 @@ op::v1::DeformablePSROIPooling::DeformablePSROIPooling(const Output<Node>& input
m_output_dim(output_dim),
m_spatial_scale(spatial_scale),
m_group_size(group_size),
- m_mode(mode),
+ m_mode(std::move(mode)),
m_spatial_bins_x(spatial_bins_x),
m_spatial_bins_y(spatial_bins_y),
m_trans_std(trans_std),
diff --git a/src/core/src/op/divide.cpp b/src/core/src/op/divide.cpp
index 1cc9a66c771..4af41dda665 100644
--- a/src/core/src/op/divide.cpp
+++ b/src/core/src/op/divide.cpp
@@ -80,38 +80,31 @@ bool evaluate_bound(const Node* node, TensorVector& output_values, bool is_upper
OPENVINO_ASSERT(PartialShape::broadcast_merge_into(input_shape, input2.get_partial_shape(), node->get_autob()),
"Argument shapes in divide operation are inconsistent.");
- const auto input1_low = ov::util::evaluate_lower_bound(input1);
- if (!input1_low)
+ const auto& [input1_low, input1_up] = ov::util::evaluate_both_bounds(input1);
+ if (!input1_low || !input1_up)
return false;
- const auto input1_up = ov::util::evaluate_upper_bound(input1);
- if (!input1_up)
- return false;
- const auto input2_low = ov::util::evaluate_lower_bound(input2);
- if (!input2_low)
- return false;
- const auto input2_up = ov::util::evaluate_upper_bound(input2);
- if (!input2_up)
+
+ const auto& [input2_low, input2_up] = ov::util::evaluate_both_bounds(input2);
+ if (!input2_low || !input2_up)
return false;
const auto zeros_const = Constant::create(input2.get_element_type(), {}, {0});
- auto zero_t = Tensor(input2.get_element_type(), Shape{});
- memcpy(zero_t.data(), zeros_const->get_data_ptr(), zero_t.get_byte_size());
const auto max_value = ov::util::make_tensor_of_max_value(input2.get_element_type());
- const auto dynamic_mask = or_tensor(equality_mask(input1_up, max_value), equality_mask(input2_up, max_value));
+ const auto& dynamic_mask = or_tensor(equality_mask(input1_up, max_value), equality_mask(input2_up, max_value));
// mask to find out positive values for arg2
auto less_up_outputs = TensorVector{{element::boolean, input2.get_shape()}};
auto& input2_positive_up_mask = less_up_outputs.front();
- bool status = Less().evaluate(less_up_outputs, TensorVector{zero_t, input2_up});
+ bool status = Less().evaluate(less_up_outputs, TensorVector{zeros_const->get_tensor_view(), input2_up});
if (!status)
return status;
// mask to find out negative values for arg2
auto less_low_outputs = TensorVector{{element::boolean, input2.get_shape()}};
auto& input2_negative_low_mask = less_low_outputs.front();
- status = Less().evaluate(less_low_outputs, {input2_low, zero_t});
+ status = Less().evaluate(less_low_outputs, {input2_low, zeros_const->get_tensor_view()});
if (!status)
return status;
@@ -142,7 +135,7 @@ bool evaluate_bound(const Node* node, TensorVector& output_values, bool is_upper
return status;
// replace values where zeros inside range of second arg to maximum values
- const auto output_min_value = ov::util::make_tensor_of_min_value(output_values[0].get_element_type());
+ const auto& output_min_value = ov::util::make_tensor_of_min_value(output_values[0].get_element_type());
if (!output_min_value)
return false;
@@ -151,7 +144,7 @@ bool evaluate_bound(const Node* node, TensorVector& output_values, bool is_upper
if (!status)
return status;
- status = Select().evaluate(output_values, {dynamic_mask, zero_t, output_values[0]});
+ status = Select().evaluate(output_values, {dynamic_mask, zeros_const->get_tensor_view(), output_values[0]});
if (!status)
return status;
} else {
@@ -166,16 +159,13 @@ bool evaluate_bound(const Node* node, TensorVector& output_values, bool is_upper
// create mask where zeros in the second argument are placed
auto eq_zero_mask = TensorVector{{element::boolean, input2.get_shape()}};
auto& input2_zeros_mask = eq_zero_mask.front();
- bool status = Equal().evaluate(eq_zero_mask, {value2, zero_t});
+ bool status = Equal().evaluate(eq_zero_mask, {value2, zeros_const->get_tensor_view()});
if (!status)
return status;
// replace zeros by 1 values to get result of divide for other values of arguments
const auto ones = Constant::create(input2.get_element_type(), input2.get_shape(), {1});
- auto ones_t = Tensor(ones->get_element_type(), ones->get_shape());
- memcpy(ones_t.data(), ones->get_data_ptr(), ones_t.get_byte_size());
-
- status = Select().evaluate(value2_outs, {input2_zeros_mask, ones_t, value2});
+ status = Select().evaluate(value2_outs, {input2_zeros_mask, ones->get_tensor_view(), value2});
if (!status)
return status;
@@ -184,7 +174,7 @@ bool evaluate_bound(const Node* node, TensorVector& output_values, bool is_upper
return status;
// replace values where zeros were found in the second argument to maximum values
- const auto out_max_value = ov::util::make_tensor_of_max_value(output_values[0].get_element_type());
+ const auto& out_max_value = ov::util::make_tensor_of_max_value(output_values[0].get_element_type());
if (!out_max_value)
return false;
diff --git a/src/core/src/op/group_query_attention.cpp b/src/core/src/op/group_query_attention.cpp
index e41d408d54d..5ed6ab70148 100644
--- a/src/core/src/op/group_query_attention.cpp
+++ b/src/core/src/op/group_query_attention.cpp
@@ -38,10 +38,10 @@ void GroupQueryAttention::validate_and_infer_types() {
const auto& batch_size = q_shape[0];
const auto& sequence_len = q_shape[2];
const auto& head_size = q_shape[3];
- const auto& past_sequence_len = get_input_partial_shape(3)[2];
+ auto kv_shape = PartialShape{batch_size, m_kv_num_heads, get_input_partial_shape(3)[2], head_size};
+ auto& output_kv_len = kv_shape[2];
- auto output_kv_len = past_sequence_len;
- if (past_sequence_len.is_dynamic() || sequence_len.is_dynamic()) {
+ if (output_kv_len.is_dynamic() || sequence_len.is_dynamic()) {
// For dynamic shapes, concatenate the past and current sequence lengths.
output_kv_len += sequence_len;
}
@@ -52,8 +52,9 @@ void GroupQueryAttention::validate_and_infer_types() {
"GroupQueryAttention only suuports f32 and f16");
set_output_type(0, element_type, PartialShape{batch_size, sequence_len, head_size * m_num_heads});
- set_output_type(1, element_type, PartialShape{batch_size, m_kv_num_heads, output_kv_len, head_size});
- set_output_type(2, element_type, PartialShape{batch_size, m_kv_num_heads, output_kv_len, head_size});
+ for (auto&& port : {1, 2}) {
+ set_output_type(port, element_type, kv_shape);
+ }
}
bool GroupQueryAttention::visit_attributes(AttributeVisitor& visitor) {
diff --git a/src/core/src/op/interpolate.cpp b/src/core/src/op/interpolate.cpp
index 0abea4d138c..7c015158b8a 100644
--- a/src/core/src/op/interpolate.cpp
+++ b/src/core/src/op/interpolate.cpp
@@ -69,10 +69,14 @@ EnumNames<ov::op::v0::Interpolate::InterpolateMode>::get() {
return enum_names;
}
-void op::v0::Interpolate::set_attrs(Attributes attrs) {
+void op::v0::Interpolate::set_attrs(Attributes&& attrs) {
m_attrs = std::move(attrs);
}
+void op::v0::Interpolate::set_attrs(const Attributes& attrs) {
+ m_attrs = attrs;
+}
+
} // namespace ov
// Interpolate v4
diff --git a/src/core/src/op/max_pool.cpp b/src/core/src/op/max_pool.cpp
index e2df670bee3..415a62510b8 100644
--- a/src/core/src/op/max_pool.cpp
+++ b/src/core/src/op/max_pool.cpp
@@ -312,9 +312,9 @@ bool MaxPool::evaluate(TensorVector& outputs, const TensorVector& inputs) const
const auto input_shapes = std::vector<PartialShape>{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/mod.cpp b/src/core/src/op/mod.cpp
index cd7a3b9cdaf..028de37bc3d 100644
--- a/src/core/src/op/mod.cpp
+++ b/src/core/src/op/mod.cpp
@@ -110,8 +110,8 @@ Tensor evaluate_undefined_result_mask(const TensorVector& bounds) {
const auto& in_et = bounds.front().get_element_type();
- const auto zero_t = ov::util::make_tensor_of_value(in_et, 0);
- const auto max_t = ov::util::make_tensor_of_max_value(in_et);
+ const auto& zero_t = ov::util::make_tensor_of_value(in_et, 0);
+ const auto& max_t = ov::util::make_tensor_of_max_value(in_et);
const auto& v_ub = bounds[1];
const auto& m_lb = bounds[2];
@@ -180,7 +180,7 @@ bool evaluate_bound(const Node* const op, TensorVector& outputs, bool is_lower)
if (mod::are_bounds_valid(bounds)) {
const auto& in_et = bounds[0].get_element_type();
- const auto undefined_result_mask = mod::evaluate_undefined_result_mask(bounds);
+ const auto& undefined_result_mask = mod::evaluate_undefined_result_mask(bounds);
if (!undefined_result_mask) {
return false;
}
diff --git a/src/core/src/op/prior_box.cpp b/src/core/src/op/prior_box.cpp
index 9eb39bf2ef6..5c95e3086f6 100644
--- a/src/core/src/op/prior_box.cpp
+++ b/src/core/src/op/prior_box.cpp
@@ -161,9 +161,13 @@ bool op::v0::PriorBox::has_evaluate() const {
}
}
-void PriorBox::set_attrs(Attributes attrs) {
+void PriorBox::set_attrs(Attributes&& attrs) {
m_attrs = std::move(attrs);
}
+
+void PriorBox::set_attrs(const Attributes& attrs) {
+ m_attrs = attrs;
+}
} // namespace v0
} // namespace op
} // namespace ov
@@ -305,9 +309,13 @@ bool PriorBox::has_evaluate() const {
return false;
}
-void PriorBox::set_attrs(Attributes attrs) {
+void PriorBox::set_attrs(Attributes&& attrs) {
m_attrs = std::move(attrs);
}
+
+void PriorBox::set_attrs(const Attributes& attrs) {
+ m_attrs = attrs;
+}
} // namespace v8
} // namespace op
} // namespace ov
diff --git a/src/core/src/op/proposal.cpp b/src/core/src/op/proposal.cpp
index 35a092a932f..a58845f8b7f 100644
--- a/src/core/src/op/proposal.cpp
+++ b/src/core/src/op/proposal.cpp
@@ -72,10 +72,14 @@ bool op::v0::Proposal::visit_attributes(AttributeVisitor& visitor) {
return true;
}
-void op::v0::Proposal::set_attrs(Attributes attrs) {
+void op::v0::Proposal::set_attrs(Attributes&& attrs) {
m_attrs = std::move(attrs);
}
+void op::v0::Proposal::set_attrs(const Attributes& attrs) {
+ m_attrs = attrs;
+}
+
// --- v4 ---
op::v4::Proposal::Proposal(const Output<Node>& class_probs,
const Output<Node>& class_bbox_deltas,
diff --git a/src/core/src/op/shape_of.cpp b/src/core/src/op/shape_of.cpp
index 8003b608849..139c48be9b0 100644
--- a/src/core/src/op/shape_of.cpp
+++ b/src/core/src/op/shape_of.cpp
@@ -75,14 +75,17 @@ bool evaluate_bound(const Node* const node, ov::TensorVector& outputs, const boo
const auto get_val = is_upper ? &Interval::get_max_val : &Interval::get_min_val;
auto limit_val = is_upper ? max_et_val : static_cast<decltype(max_et_val)>(0);
- auto dynamic_mask = std::vector<char>(in_shape_rank);
- std::transform(in_shape.begin(), in_shape.end(), dynamic_mask.begin(), [&](const Dimension& d) {
+ const TensorVector inputs{
+ {element::boolean, Shape{in_shape_rank}}, // mask
+ {out_et, Shape{}, &limit_val}, // limit
+ outputs[0] // output
+ };
+ auto& dynamic_mask = inputs[0];
+ std::transform(in_shape.begin(), in_shape.end(), dynamic_mask.data<char>(), [&](const Dimension& d) {
return static_cast<char>((d.get_interval().*get_val)() >= max_et_val);
});
- const auto limit = Tensor(out_et, Shape{}, &limit_val);
- const auto mask = Tensor(element::boolean, Shape{in_shape_rank}, dynamic_mask.data());
- eval_status = v1::Select().evaluate(outputs, {mask, limit, outputs[0]});
+ eval_status = v1::Select().evaluate(outputs, inputs);
}
return eval_status;
} else {
diff --git a/src/core/src/pass/sdpa_to_paged_attention.cpp b/src/core/src/pass/sdpa_to_paged_attention.cpp
index 94cde87cde1..b5d6c3dd70a 100644
--- a/src/core/src/pass/sdpa_to_paged_attention.cpp
+++ b/src/core/src/pass/sdpa_to_paged_attention.cpp
@@ -58,9 +58,8 @@ bool ov::pass::SDPAToPagedAttention::run_on_model(const std::shared_ptr<ov::Mode
}
if (m_allow_score_aggregation) {
- auto score_aggregation_window =
+ optional_model_wide_params["score_aggregation_window"] =
setName(std::make_shared<v0::Parameter>(element::i32, PartialShape{-1}), "score_aggregation_window");
- optional_model_wide_params["score_aggregation_window"] = score_aggregation_window;
}
std::shared_ptr<v0::Parameter> model_rotation_trig_lut;
@@ -218,7 +217,7 @@ bool ov::pass::SDPAToPagedAttention::run_on_model(const std::shared_ptr<ov::Mode
if (m_allow_cache_rotation) {
model->add_parameters(rotated_block_indices_inputs_for_each_layer);
model->add_parameters(rotation_deltas_inputs_for_each_layer);
- model->add_parameters({model_rotation_trig_lut});
+ model->add_parameters({std::move(model_rotation_trig_lut)});
}
model->add_parameters(kv_parameters);
diff --git a/src/core/src/pass/stateful_to_stateless.cpp b/src/core/src/pass/stateful_to_stateless.cpp
index c9eea80fcce..2d24cf55f6d 100644
--- a/src/core/src/pass/stateful_to_stateless.cpp
+++ b/src/core/src/pass/stateful_to_stateless.cpp
@@ -146,8 +146,8 @@ bool ov::pass::StatefulToStateless::run_on_model(const std::shared_ptr<ov::Model
model->remove_sink(assign); // Don't do replace_node(assign, result)! It will lead to silently incorrect model.
model->remove_variable(model->get_variable_by_id(variable_id.variable_name));
- new_parameters.push_back(parameter);
- new_results.push_back(result);
+ new_parameters.push_back(std::move(parameter));
+ new_results.push_back(std::move(result));
}
model->add_parameters(new_parameters);
diff --git a/src/core/src/pattern/matcher.cpp b/src/core/src/pattern/matcher.cpp
index 948e4f7dde0..9984d5ec691 100644
--- a/src/core/src/pattern/matcher.cpp
+++ b/src/core/src/pattern/matcher.cpp
@@ -48,8 +48,8 @@ MatcherState::~MatcherState() {
}
if (!m_matcher->m_pattern_value_maps.empty()) {
- m_matcher->m_pattern_value_maps.erase(m_pattern_value_maps.begin() + m_capture_size,
- m_pattern_value_maps.end());
+ m_matcher->m_pattern_value_maps.erase(m_matcher->m_pattern_value_maps.begin() + m_capture_size,
+ m_matcher->m_pattern_value_maps.end());
}
m_matcher->m_pattern_map = m_pattern_value_map;
@@ -83,9 +83,9 @@ Output<Node> Matcher::get_match_value() {
void Matcher::capture(const std::set<Node*>& static_nodes) {
m_pattern_value_maps.push_back(m_pattern_map);
m_pattern_map.clear();
- for (auto key_value : m_pattern_value_maps.back()) {
- if (static_nodes.count(key_value.first.get()) > 0) {
- m_pattern_map.insert(key_value);
+ for (const auto& [key, value] : m_pattern_value_maps.back()) {
+ if (static_nodes.count(key.get()) > 0) {
+ m_pattern_map.insert(std::make_pair(key, value));
}
}
}
diff --git a/src/core/src/pattern/op/pattern.cpp b/src/core/src/pattern/op/pattern.cpp
index b6d0bf60f7e..ffbdab98a3f 100644
--- a/src/core/src/pattern/op/pattern.cpp
+++ b/src/core/src/pattern/op/pattern.cpp
@@ -338,15 +338,12 @@ std::pair<std::vector<std::pair<int64_t, std::string>>, int64_t> parse_notation(
std::vector<std::string> parsed;
size_t pos = 0, pos_next;
- std::string token;
while ((pos_next = s.find(',', pos)) != std::string::npos) {
- token = s.substr(pos, pos_next - pos);
- parsed.push_back(token);
+ parsed.push_back(s.substr(pos, pos_next - pos));
pos = pos_next + 1;
}
// collect whole string if no delimiter is found
- token = s.substr(pos, pos_next);
- parsed.push_back(token);
+ parsed.push_back(s.substr(pos, pos_next));
std::vector<std::pair<int64_t, std::string>> idx_to_name;
diff --git a/src/core/src/preprocess/preprocess_impls.cpp b/src/core/src/preprocess/preprocess_impls.cpp
index 3e61a0bf7b6..9156bbeffb2 100644
--- a/src/core/src/preprocess/preprocess_impls.cpp
+++ b/src/core/src/preprocess/preprocess_impls.cpp
@@ -116,7 +116,7 @@ InputInfo::InputInfoImpl::InputInfoData InputInfo::InputInfoImpl::create_new_par
"Error while trying to create plane input with name '",
new_name,
"' - name already exists in model. Please specify another sub-name for set_color_format");
- plane_tensor_names.insert(new_name);
+ plane_tensor_names.insert(std::move(new_name));
}
plane_param->get_default_output().get_tensor().set_names(plane_tensor_names);
plane_param->set_friendly_name(res.m_param->get_friendly_name() + sub_name);
@@ -139,7 +139,7 @@ InputInfo::InputInfoImpl::InputInfoData InputInfo::InputInfoImpl::create_new_par
TensorInfoMemoryType(get_tensor_data()->get_memory_type());
}
}
- res.m_new_params.push_back(plane_param);
+ res.m_new_params.push_back(std::move(plane_param));
}
return res;
}
@@ -371,10 +371,12 @@ void OutputInfo::OutputInfoImpl::build(ov::ResultVector& results) {
auto orig_parent = result->get_input_source_output(0).get_node_shared_ptr();
if (get_tensor_data()->get_names_compatibility_mode()) {
- // Move result tensor names from previous input to new
- const auto result_input_names = result->get_input_tensor(0).get_names();
- result->get_input_tensor(0).set_names({});
- node.get_tensor().set_names(result_input_names);
+ if (auto& res_tensor = result->get_input_tensor(0); &res_tensor != &node.get_tensor()) {
+ // If result input tensor is not the same as node tensor, then we need to move names
+ // from result input tensor to node tensor
+ node.get_tensor().set_names(res_tensor.get_names());
+ res_tensor.set_names({});
+ }
if (!post_processing_applied) {
return;
diff --git a/src/core/src/preprocess/preprocess_steps_impl.cpp b/src/core/src/preprocess/preprocess_steps_impl.cpp
index 628620fa732..7e9a12554ef 100644
--- a/src/core/src/preprocess/preprocess_steps_impl.cpp
+++ b/src/core/src/preprocess/preprocess_steps_impl.cpp
@@ -352,14 +352,14 @@ void PreStepsList::add_convert_layout_impl(const Layout& layout) {
m_last_explicit_layout = layout;
m_last_explicit_layout_set = true;
m_actions.emplace_back(
- [layout](const std::vector<Output<Node>>& nodes,
- const std::shared_ptr<Model>& function,
- PreprocessingContext& context) {
+ [layout = std::make_shared<Layout>(layout)](const std::vector<Output<Node>>& nodes,
+ const std::shared_ptr<Model>& function,
+ PreprocessingContext& context) {
OPENVINO_ASSERT(!nodes.empty(), "Internal error: Can't convert layout for empty input.");
OPENVINO_ASSERT(nodes.size() == 1,
"Can't convert layout for multi-plane input. Suggesting to convert current image to "
"RGB/BGR color format using 'convert_color'");
- Layout dst_layout = layout.empty() ? context.target_layout() : layout;
+ const auto& dst_layout = layout->empty() ? context.target_layout() : *layout;
auto node = nodes[0];
auto shape = node.get_partial_shape();
size_t add_cnt;
@@ -381,15 +381,15 @@ void PreStepsList::add_convert_layout_impl(const Layout& layout) {
auto permutation = layout::utils::find_permutation(unsqueeze_layout, shape, dst_layout);
if (permutation.empty()) {
// No transpose is needed, just update layout
- if (!layout.empty()) {
- context.layout() = layout;
+ if (!layout->empty()) {
+ context.layout() = *layout;
}
return std::make_tuple(nodes, false);
}
auto perm_constant =
op::v0::Constant::create<int64_t>(element::i64, Shape{permutation.size()}, permutation);
auto transpose = std::make_shared<op::v1::Transpose>(node, perm_constant);
- context.layout() = std::move(dst_layout); // Update context's current layout
+ context.layout() = dst_layout; // Update context's current layout
// return false to avoid excess function revalidations as layout conversion
// doesn't require shape or type propagation.
return std::make_tuple(std::vector<Output<Node>>{transpose}, false);
@@ -761,20 +761,20 @@ void PostStepsList::add_convert_impl(const element::Type& type) {
void PostStepsList::add_convert_layout_impl(const Layout& layout) {
m_actions.emplace_back(
- [layout](const Output<Node>& node, PostprocessingContext& context) {
- Layout dst_layout = layout.empty() ? context.target_layout() : layout;
+ [layout = std::make_shared<Layout>(layout)](const Output<Node>& node, PostprocessingContext& context) {
+ const auto& dst_layout = layout->empty() ? context.target_layout() : *layout;
auto permutation = layout::utils::find_permutation(context.layout(), node.get_partial_shape(), dst_layout);
if (permutation.empty()) {
// No transpose is needed, just update layout
- if (!layout.empty()) {
- context.layout() = layout;
+ if (!layout->empty()) {
+ context.layout() = *layout;
}
return std::make_tuple(node, false);
}
auto perm_constant =
op::v0::Constant::create<int64_t>(element::i64, Shape{permutation.size()}, permutation);
auto transpose = std::make_shared<op::v1::Transpose>(node, perm_constant);
- context.layout() = std::move(dst_layout); // Update context's current layout
+ context.layout() = dst_layout; // Update context's current layout
return std::make_tuple(Output<Node>(transpose), true);
},
"convert layout " + layout.to_string());
diff --git a/src/core/src/preprocess/preprocess_steps_impl.hpp b/src/core/src/preprocess/preprocess_steps_impl.hpp
index fe7a3873f9c..8edf0a8e975 100644
--- a/src/core/src/preprocess/preprocess_steps_impl.hpp
+++ b/src/core/src/preprocess/preprocess_steps_impl.hpp
@@ -63,7 +63,7 @@ inline size_t get_and_check_channels_idx(const Layout& layout, const PartialShap
/// This is internal structure which is not shared to custom operations yet.
class PrePostProcessingContextBase {
public:
- explicit PrePostProcessingContextBase(Layout layout) : m_layout(std::move(layout)) {}
+ explicit PrePostProcessingContextBase(const Layout& layout) : m_layout(layout) {}
const Layout& layout() const {
return m_layout;
diff --git a/src/core/src/rt_info.cpp b/src/core/src/rt_info.cpp
index 51a1bf60392..f01bdab0672 100644
--- a/src/core/src/rt_info.cpp
+++ b/src/core/src/rt_info.cpp
@@ -92,7 +92,7 @@ ov::NodeVector list_with_constants(const ov::NodeVector& to) {
auto source_node = input.get_source_output().get_node_shared_ptr();
if (ov::op::util::is_constant(source_node) && (0 == source_node->get_rt_info().size())) {
if (std::find(ops.begin(), ops.end(), source_node) == ops.end()) {
- ops.push_back(source_node);
+ ops.push_back(std::move(source_node));
}
}
}
@@ -108,7 +108,7 @@ ov::OutputVector list_with_constants(const ov::OutputVector& to) {
if (ov::op::util::is_constant(source_node.get_node_shared_ptr()) &&
(0 == source_node.get_rt_info().size())) {
if (std::find(ops.begin(), ops.end(), source_node) == ops.end()) {
- ops.push_back(source_node);
+ ops.push_back(std::move(source_node));
}
}
}
diff --git a/src/core/src/runtime/compute_hash.cpp b/src/core/src/runtime/compute_hash.cpp
index b1b50df69c9..9569dbaedbb 100644
--- a/src/core/src/runtime/compute_hash.cpp
+++ b/src/core/src/runtime/compute_hash.cpp
@@ -111,9 +111,9 @@ class HashBase : public Generator {
protected:
void (*ker_fn)(const ComputeHashCallArgs*);
-public:
- HashBase(cpu_isa_t isa) : Generator(isa) {}
+ HashBase(cpu_isa_t isa) : Generator(isa), ker_fn{} {}
+public:
virtual void generate() = 0;
void operator()(const ComputeHashCallArgs* args) {
diff --git a/src/core/src/runtime/tensor.cpp b/src/core/src/runtime/tensor.cpp
index 1c1cffec7dc..f5fb6cd5ba4 100644
--- a/src/core/src/runtime/tensor.cpp
+++ b/src/core/src/runtime/tensor.cpp
@@ -149,7 +149,7 @@ ov::Shape calc_static_shape_for_file(const std::filesystem::path& file_name,
auto rank = partial_shape_copy.rank();
OPENVINO_ASSERT(rank.is_static(), "Rank cannot be dynamic");
std::vector<size_t> dynamic_dimension_numbers;
- size_t slice_size = 1;
+ typename Dimension::value_type slice_size = 1;
for (size_t id = 0; id < partial_shape_copy.size(); ++id) {
if (partial_shape_copy[id].is_dynamic()) {
dynamic_dimension_numbers.push_back(id);
diff --git a/src/core/src/validation_util.cpp b/src/core/src/validation_util.cpp
index 38659b115d3..0f6ae852ba3 100644
--- a/src/core/src/validation_util.cpp
+++ b/src/core/src/validation_util.cpp
@@ -44,11 +44,10 @@ ov::OutputVector get_inputs_from_map(const std::shared_ptr<ov::Node>& node,
inputs.reserve(num_inputs);
for (size_t i = 0; i < num_inputs; i++) {
- auto input = node->input_value(i);
- if (node_map.count(input) > 0) {
+ if (auto input = node->input_value(i); node_map.count(input) > 0) {
inputs.push_back(node_map.at(input));
} else {
- inputs.push_back(input);
+ inputs.push_back(std::move(input));
}
}