Skip to content

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

[Snippets][CPU] Replace std::tie with structured bindings (#31571)

Arseniy Obolenskiyae5d024c21e0
diff --git a/src/common/snippets/src/lowered/loop_manager.cpp b/src/common/snippets/src/lowered/loop_manager.cpp
index bdc9ffd9e13..88f366b2cd7 100644
--- a/src/common/snippets/src/lowered/loop_manager.cpp
+++ b/src/common/snippets/src/lowered/loop_manager.cpp
@@ -267,7 +267,7 @@ size_t LoopManager::replace_with_new_loop(const LinearIR& linear_ir,
}),
"Failed to replace with new Loop: this Loop already exists!");
- const auto old_loop_bounds = get_loop_bounds(linear_ir, old_id);
+ const auto [old_loop_begin, old_loop_end] = get_loop_bounds(linear_ir, old_id);
const auto loop_id = this->add_loop_info(loop_info);
const auto begin = explicit_loop_bounds ? std::next(loop_begin_pos) : loop_begin_pos;
@@ -278,7 +278,7 @@ size_t LoopManager::replace_with_new_loop(const LinearIR& linear_ir,
// If new bounds are equal to old loop bounds, this means that old Loop is removed totally from LIR
// In this case old loop info must be completely removed from loop manager
- if (loop_begin_pos == old_loop_bounds.first && end == old_loop_bounds.second) {
+ if (loop_begin_pos == old_loop_begin && end == old_loop_end) {
this->remove_loop_info(old_id);
}
return loop_id;
@@ -288,8 +288,8 @@ void LoopManager::fuse_loops(const LinearIR& linear_ir,
size_t loop_id_upper,
size_t loop_id_lower,
bool fuse_into_upper) {
- const auto loop_bounds = get_loop_bounds(linear_ir, fuse_into_upper ? loop_id_lower : loop_id_upper);
- fuse_loops(loop_bounds.first, loop_bounds.second, loop_id_upper, loop_id_lower, fuse_into_upper);
+ const auto [loop_begin, loop_end] = get_loop_bounds(linear_ir, fuse_into_upper ? loop_id_lower : loop_id_upper);
+ fuse_loops(loop_begin, loop_end, loop_id_upper, loop_id_lower, fuse_into_upper);
}
void LoopManager::fuse_loops(LinearIR::constExprIt loop_begin_target,
diff --git a/src/common/snippets/src/lowered/pass/define_buffer_clusters.cpp b/src/common/snippets/src/lowered/pass/define_buffer_clusters.cpp
index 02a0cf2e4b1..3bb4bded03a 100644
--- a/src/common/snippets/src/lowered/pass/define_buffer_clusters.cpp
+++ b/src/common/snippets/src/lowered/pass/define_buffer_clusters.cpp
@@ -12,7 +12,6 @@
#include <limits>
#include <memory>
#include <set>
-#include <tuple>
#include <utility>
#include <vector>
@@ -137,8 +136,7 @@ void DefineBufferClusters::parse_loop(const LoopManagerPtr& loop_manager, const
const auto& loop_end = ov::as_type_ptr<op::LoopEnd>(expr->get_node());
const auto& loop_info = loop_manager->get_loop_info<UnifiedLoopInfo>(loop_end->get_id());
- BufferMap input_buffers, output_buffers;
- std::tie(input_buffers, output_buffers) = get_direct_buffers(loop_info, expr);
+ auto [input_buffers, output_buffers] = get_direct_buffers(loop_info, expr);
for (const auto& in : input_buffers) {
create_new_cluster(in.first);
diff --git a/src/common/snippets/src/lowered/pass/extract_loop_invariants.cpp b/src/common/snippets/src/lowered/pass/extract_loop_invariants.cpp
index a24e32451ea..33d62edce30 100644
--- a/src/common/snippets/src/lowered/pass/extract_loop_invariants.cpp
+++ b/src/common/snippets/src/lowered/pass/extract_loop_invariants.cpp
@@ -8,7 +8,6 @@
#include <cstddef>
#include <cstdint>
#include <memory>
-#include <tuple>
#include <unordered_set>
#include <vector>
@@ -195,8 +194,7 @@ bool extract_from_loop(const size_t& inner_loop_id, LinearIR& linear_ir) {
for (const auto& port_expr : potential_extractable_exprs) {
if (is_extraction_applicable(port_expr, inner_loop_info, inner_loop_id)) {
status = true;
- LinearIR::constExprIt inner_loop_begin_pos, inner_loop_end_pos;
- std::tie(inner_loop_begin_pos, inner_loop_end_pos) =
+ auto [inner_loop_begin_pos, inner_loop_end_pos] =
loop_manager->get_loop_bounds(linear_ir, inner_loop_id);
// extract scalar on inputs if there are
diff --git a/src/common/snippets/src/lowered/pass/fuse_loops.cpp b/src/common/snippets/src/lowered/pass/fuse_loops.cpp
index 329fe41198a..e496160f729 100644
--- a/src/common/snippets/src/lowered/pass/fuse_loops.cpp
+++ b/src/common/snippets/src/lowered/pass/fuse_loops.cpp
@@ -9,7 +9,6 @@
#include <iterator>
#include <memory>
#include <set>
-#include <tuple>
#include <vector>
#include "openvino/core/except.hpp"
@@ -161,8 +160,7 @@ bool FuseLoops::fuse_upper_into_current(LinearIR& linear_ir,
return false;
}
- LinearIR::constExprIt target_loop_begin_pos, target_loop_end_pos;
- std::tie(target_loop_begin_pos, target_loop_end_pos) = loop_manager->get_loop_bounds(linear_ir, target_loop_id);
+ auto [target_loop_begin_pos, target_loop_end_pos] = loop_manager->get_loop_bounds(linear_ir, target_loop_id);
loop_manager->fuse_loops(target_loop_begin_pos, target_loop_end_pos, target_loop_id, current_loop_id, false);
const auto insertion_place = current_loop_begin_pos;
const auto is_move_needed = target_loop_end_pos != current_loop_begin_pos;
@@ -210,8 +208,7 @@ bool FuseLoops::fuse_lower_into_current(LinearIR& linear_ir,
return false;
}
- LinearIR::constExprIt target_loop_begin_pos, target_loop_end_pos;
- std::tie(target_loop_begin_pos, target_loop_end_pos) = loop_manager->get_loop_bounds(linear_ir, target_loop_id);
+ auto [target_loop_begin_pos, target_loop_end_pos] = loop_manager->get_loop_bounds(linear_ir, target_loop_id);
loop_manager->fuse_loops(target_loop_begin_pos, target_loop_end_pos, current_loop_id, target_loop_id);
const auto insertion_place = current_loop_end_pos;
@@ -253,8 +250,7 @@ bool FuseLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, l
bool need_fusion_checks = true;
while (need_fusion_checks) {
auto current_loop_info = loop_manager->get_loop_info(current_loop_id);
- LinearIR::constExprIt current_loop_begin_pos, current_loop_end_pos;
- std::tie(current_loop_begin_pos, current_loop_end_pos) =
+ auto [current_loop_begin_pos, current_loop_end_pos] =
loop_manager->get_loop_bounds(linear_ir, current_loop_id);
// Loop_0 (Upper) |
diff --git a/src/common/snippets/src/lowered/pass/insert_loops.cpp b/src/common/snippets/src/lowered/pass/insert_loops.cpp
index 5ff4d8b461c..3271fa92f21 100644
--- a/src/common/snippets/src/lowered/pass/insert_loops.cpp
+++ b/src/common/snippets/src/lowered/pass/insert_loops.cpp
@@ -52,14 +52,14 @@ void InsertLoops::insertion(LinearIR& linear_ir, const LoopManagerPtr& loop_mana
out_num,
loop_id);
- const auto loop_bounds = loop_manager->get_loop_bounds(linear_ir, loop_id);
- const auto outer_loop_ids = loop_manager->get_outer_expr_loops(*loop_bounds.first, loop_id);
+ const auto [loop_begin_bound, loop_end_bound] = loop_manager->get_loop_bounds(linear_ir, loop_id);
+ const auto outer_loop_ids = loop_manager->get_outer_expr_loops(*loop_begin_bound, loop_id);
const auto loop_begin_expr =
- *linear_ir.insert_node(loop_begin, std::vector<PortConnectorPtr>{}, outer_loop_ids, false, loop_bounds.first);
+ *linear_ir.insert_node(loop_begin, std::vector<PortConnectorPtr>{}, outer_loop_ids, false, loop_begin_bound);
// Add LoopBegin port connector
loop_end_inputs.push_back(loop_begin_expr->get_output_port_connector(0));
- linear_ir.insert_node(loop_end, loop_end_inputs, outer_loop_ids, false, loop_bounds.second);
+ linear_ir.insert_node(loop_end, loop_end_inputs, outer_loop_ids, false, loop_end_bound);
}
bool InsertLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) {
diff --git a/src/common/snippets/src/lowered/pass/insert_specific_iterations.cpp b/src/common/snippets/src/lowered/pass/insert_specific_iterations.cpp
index b17ebe1d190..7b4b8bfb04e 100644
--- a/src/common/snippets/src/lowered/pass/insert_specific_iterations.cpp
+++ b/src/common/snippets/src/lowered/pass/insert_specific_iterations.cpp
@@ -141,9 +141,7 @@ LoopManager::LoopBounds InsertSpecificIterations::insert_copy_loop(LinearIR& lin
std::vector<LoopPort>& new_entry_ports,
std::vector<LoopPort>& new_exit_ports) {
const auto& loop_manager = linear_ir.get_loop_manager();
- const auto loop_bounds = loop_manager->get_loop_bounds(linear_ir, loop_id);
- const auto loop_begin_pos = loop_bounds.first;
- const auto loop_end_pos = loop_bounds.second;
+ const auto [loop_begin_pos, loop_end_pos] = loop_manager->get_loop_bounds(linear_ir, loop_id);
ExpressionMap expression_map;
const auto& cloning_config = LinearIRBuilder::Config(false);
diff --git a/src/common/snippets/src/lowered/pass/solve_buffer_memory.cpp b/src/common/snippets/src/lowered/pass/solve_buffer_memory.cpp
index 235c095a478..2e5718de546 100644
--- a/src/common/snippets/src/lowered/pass/solve_buffer_memory.cpp
+++ b/src/common/snippets/src/lowered/pass/solve_buffer_memory.cpp
@@ -168,8 +168,7 @@ bool SolveBufferMemory::run(LinearIR& linear_ir) {
// TODO [143395] : MemoryManager will be able to return two containers with dynamic and static buffers
// without additional `extract` functions in all passes
- Buffers static_buffer_exprs, dynamic_buffer_exprs;
- std::tie(static_buffer_exprs, dynamic_buffer_exprs) = extract_static_and_dynamic_buffers(linear_ir.get_buffers());
+ auto [static_buffer_exprs, dynamic_buffer_exprs] = extract_static_and_dynamic_buffers(linear_ir.get_buffers());
if (!static_buffer_exprs.empty()) {
solve_static_buffer_memory(static_buffer_exprs, linear_ir);
diff --git a/src/common/snippets/src/lowered/pass/split_loops.cpp b/src/common/snippets/src/lowered/pass/split_loops.cpp
index 9a5d2e0c5c2..8e689ad6ae2 100644
--- a/src/common/snippets/src/lowered/pass/split_loops.cpp
+++ b/src/common/snippets/src/lowered/pass/split_loops.cpp
@@ -95,12 +95,12 @@ void SplitLoops::split(LinearIR& linear_ir, size_t loop_to_split_id, size_t oute
const auto& loop_manager = linear_ir.get_loop_manager();
const auto& inner_loop_info = loop_manager->get_loop_info<UnifiedLoopInfo>(loop_to_split_id);
- const auto loop_bounds = LoopManager::get_loop_bounds(linear_ir,
- loop_to_split_id,
- inner_loop_info->get_input_ports(),
- inner_loop_info->get_output_ports());
- const auto outer_loop_id = loop_manager->mark_loop(loop_bounds.first,
- loop_bounds.second,
+ const auto [loop_begin, loop_end] = LoopManager::get_loop_bounds(linear_ir,
+ loop_to_split_id,
+ inner_loop_info->get_input_ports(),
+ inner_loop_info->get_output_ports());
+ const auto outer_loop_id = loop_manager->mark_loop(loop_begin,
+ loop_end,
inner_loop_info->get_work_amount(),
outer_increment,
inner_loop_info->get_dim_idx(),
@@ -117,11 +117,7 @@ void SplitLoops::split(LinearIR& linear_ir, size_t loop_to_split_id, size_t oute
inner_loop_info->get_output_port_descs(),
inner_loop_info->get_handlers(),
outer_loop_info);
- loop_manager->replace_with_new_loop(linear_ir,
- loop_bounds.first,
- loop_bounds.second,
- inner_splitted_loop_info,
- loop_to_split_id);
+ loop_manager->replace_with_new_loop(linear_ir, loop_begin, loop_end, inner_splitted_loop_info, loop_to_split_id);
if (!outer_loop_info->get_handlers().get_passes<SpecificLoopIterType::FIRST_ITER>().empty()) {
outer_loop_info->register_pass_to_handler<SpecificLoopIterType::FIRST_ITER, TransformInnerSplitLoop>();
diff --git a/src/plugins/intel_cpu/src/nodes/color_convert.cpp b/src/plugins/intel_cpu/src/nodes/color_convert.cpp
index dd03023585e..97fab1a0e95 100644
--- a/src/plugins/intel_cpu/src/nodes/color_convert.cpp
+++ b/src/plugins/intel_cpu/src/nodes/color_convert.cpp
@@ -365,10 +365,7 @@ void RefConverter::convert(const T* y,
auto uv_index = (h / 2) * width + (w / 2) * 2;
auto u_val = static_cast<float>(uv_ptr[uv_index]);
auto v_val = static_cast<float>(uv_ptr[uv_index + 1]);
- T r;
- T g;
- T b;
- std::tie(r, g, b) = yuv_to_rgb<T>(y_val, u_val, v_val);
+ auto [r, g, b] = yuv_to_rgb<T>(y_val, u_val, v_val);
out[y_index * 3 + _colorFormat[0]] = r;
out[y_index * 3 + _colorFormat[1]] = g;
out[y_index * 3 + _colorFormat[2]] = b;
@@ -700,10 +697,7 @@ void RefConverter::convert(const T* y,
auto uv_index = (h / 2) * (width / 2) + w / 2;
auto u_val = static_cast<float>(u_ptr[uv_index]);
auto v_val = static_cast<float>(v_ptr[uv_index]);
- T r;
- T g;
- T b;
- std::tie(r, g, b) = yuv_to_rgb<T>(y_val, u_val, v_val);
+ auto [r, g, b] = yuv_to_rgb<T>(y_val, u_val, v_val);
out[y_index * 3 + _colorFormat[0]] = r;
out[y_index * 3 + _colorFormat[1]] = g;
out[y_index * 3 + _colorFormat[2]] = b;
diff --git a/src/plugins/intel_cpu/src/nodes/deconv.cpp b/src/plugins/intel_cpu/src/nodes/deconv.cpp
index 5c1e7d1b122..520d2062fb1 100644
--- a/src/plugins/intel_cpu/src/nodes/deconv.cpp
+++ b/src/plugins/intel_cpu/src/nodes/deconv.cpp
@@ -1300,9 +1300,7 @@ void Deconvolution::initSupportedPrimitiveDescriptors() {
return;
}
- VectorDims inDims;
- VectorDims outDims;
- std::tie(inDims, outDims) = makeDummyInOutShape();
+ auto [inDims, outDims] = makeDummyInOutShape();
auto tmpInShape = Shape(inDims);
auto tmpOutShape = Shape(outDims);
initPaddingR(tmpInShape, tmpOutShape);
diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_matmul_to_fc.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_matmul_to_fc.cpp
index deb540f4ebe..730720e575c 100644
--- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_matmul_to_fc.cpp
+++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_matmul_to_fc.cpp
@@ -151,10 +151,7 @@ ov::intel_cpu::ConvertMatMulToFC::ConvertMatMulToFC() {
return transpose;
};
- bool success = true;
- ov::PartialShape shape_a_aligned;
- ov::PartialShape shape_b_aligned;
- std::tie(success, shape_a_aligned, shape_b_aligned) = get_aligned_shapes();
+ auto [success, shape_a_aligned, shape_b_aligned] = get_aligned_shapes();
if (!success) {
return false;
}