Skip to content

Commit

Permalink
[Snippets] Left only const iterator methods
Browse files Browse the repository at this point in the history
  • Loading branch information
a-sidorova committed Jul 4, 2023
1 parent 4e960a3 commit 05339e8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 57 deletions.
23 changes: 5 additions & 18 deletions src/common/snippets/include/snippets/lowered/linear_ir.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,13 @@ class LinearIR {
exprIt erase(exprIt pos);
exprIt erase(constExprIt pos);

template<typename iterator>
iterator find(iterator begin, iterator end, const ExpressionPtr& target);
template<typename const_iterator>
const_iterator find(const_iterator begin, const_iterator end, const ExpressionPtr& target) const;
exprIt find(const ExpressionPtr& target);
constExprIt find(const ExpressionPtr& target) const;
template<typename iterator>
iterator find_before(iterator it, const ExpressionPtr& target);
template<typename const_iterator>
const_iterator find_before(const_iterator it, const ExpressionPtr& target) const;
iterator find(iterator begin, iterator end, const ExpressionPtr& target) const;
template<typename iterator>
iterator find_before(iterator it, const ExpressionPtr& target) const;
template<typename iterator>
iterator find_after(iterator it, const ExpressionPtr& target);
template<typename const_iterator>
const_iterator find_after(const_iterator it, const ExpressionPtr& target) const;
iterator find_after(iterator it, const ExpressionPtr& target) const;

void init_emitters(const std::shared_ptr<TargetMachine>& target);
void serialize(const std::string& xml, const std::string& bin);
Expand All @@ -125,13 +118,7 @@ class LinearIR {
};

template<typename iterator>
iterator LinearIR::find(iterator begin, iterator end, const ExpressionPtr& target) {
auto found = std::find(begin, end, target);
OPENVINO_ASSERT(found != end, "Expression has not been found");
return found;
}
template<typename const_iterator>
const_iterator LinearIR::find(const_iterator begin, const_iterator end, const ExpressionPtr& target) const {
iterator LinearIR::find(iterator begin, iterator end, const ExpressionPtr& target) const {
auto found = std::find(begin, end, target);
OPENVINO_ASSERT(found != end, "Expression has not been found");
return found;
Expand Down
35 changes: 0 additions & 35 deletions src/common/snippets/src/lowered/linear_ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,57 +260,22 @@ void LinearIR::move(LinearIR::constExprIt from, LinearIR::constExprIt to) {
m_expressions.splice(to, m_expressions, from);
}

LinearIR::exprIt LinearIR::find(const ExpressionPtr& target) {
return find(begin(), end(), target);
}
LinearIR::constExprIt LinearIR::find(const ExpressionPtr& target) const {
return find(cbegin(), cend(), target);
}
template<>
LinearIR::exprIt LinearIR::find_before(LinearIR::exprIt it, const ExpressionPtr& target) {
return find(begin(), it, target);
}
template<>
LinearIR::constExprIt LinearIR::find_before(LinearIR::constExprIt it, const ExpressionPtr& target) {
return find(cbegin(), it, target);
}
template<>
LinearIR::constExprIt LinearIR::find_before(LinearIR::constExprIt it, const ExpressionPtr& target) const {
return find(cbegin(), it, target);
}
template<>
LinearIR::exprReverseIt LinearIR::find_before(LinearIR::exprReverseIt it, const ExpressionPtr& target) {
return find(rbegin(), it, target);
}
template<>
LinearIR::constExprReverseIt LinearIR::find_before(LinearIR::constExprReverseIt it, const ExpressionPtr& target) {
return find(crbegin(), it, target);
}
template<>
LinearIR::constExprReverseIt LinearIR::find_before(LinearIR::constExprReverseIt it, const ExpressionPtr& target) const {
return find(crbegin(), it, target);
}
template<>
LinearIR::exprIt LinearIR::find_after(LinearIR::exprIt it, const ExpressionPtr& target) {
return find(it, end(), target);
}
template<>
LinearIR::constExprIt LinearIR::find_after(LinearIR::constExprIt it, const ExpressionPtr& target) {
return find(it, cend(), target);
}
template<>
LinearIR::constExprIt LinearIR::find_after(LinearIR::constExprIt it, const ExpressionPtr& target) const {
return find(it, cend(), target);
}
template<>
LinearIR::exprReverseIt LinearIR::find_after(LinearIR::exprReverseIt it, const ExpressionPtr& target) {
return find(it, rend(), target);
}
template<>
LinearIR::constExprReverseIt LinearIR::find_after(LinearIR::constExprReverseIt it, const ExpressionPtr& target) {
return find(it, crend(), target);
}
template<>
LinearIR::constExprReverseIt LinearIR::find_after(LinearIR::constExprReverseIt it, const ExpressionPtr& target) const {
return find(it, crend(), target);
}
Expand Down
5 changes: 2 additions & 3 deletions src/common/snippets/src/lowered/pass/insert_tail_loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ void InsertTailLoop::tail_transformations(LinearIR& linear_ir,
// Skip inner Loops
const auto loop_begin = ov::as_type_ptr<op::LoopBegin>(expr_it->get()->get_node());
if (loop_begin) {
expr_it = std::find(expr_it, tail_end, linear_ir.get_expr_by_node(loop_begin->get_loop_end()));
OPENVINO_ASSERT(expr_it != tail_end, "LoopEnd has not been found");
expr_it = linear_ir.find(expr_it, tail_end, linear_ir.get_expr_by_node(loop_begin->get_loop_end()));
continue;
}
// We should fill vector regs by float_min and zero to have
Expand Down Expand Up @@ -198,7 +197,7 @@ bool InsertTailLoop::run(LinearIR& linear_ir) {
// finalization offsets which are supported by LoopEnd.
if (need_tail) {
const auto loop_begin = loop_end->get_loop_begin();
const auto begin_it = std::find(linear_ir.begin(), linear_ir.end(), linear_ir.get_expr_by_node(loop_begin));
const auto begin_it = linear_ir.find(linear_ir.get_expr_by_node(loop_begin));
LinearIR::constExprIt tail_begin, tail_end;
const auto tail_loop_end = create_tail_loop(linear_ir, begin_it, std::next(expr_it), tail_begin, tail_end,
loop_end, need_vector_loop, tail_size, tail_finalization_offsets);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ bool LoadMoveBroadcastToBroadcastLoad::run(LinearIR& linear_ir) {
const auto& loop_manager = linear_ir.get_loop_manager();
bool modified = false;

for (auto expr_it = linear_ir.begin(); expr_it != linear_ir.end(); expr_it++) {
for (auto expr_it = linear_ir.cbegin(); expr_it != linear_ir.cend(); expr_it++) {
const auto& expr = *expr_it;
const auto& op = expr->get_node();
// Match on MoveBroadcast because MoveBroadcast is rare node in bodies
Expand Down

0 comments on commit 05339e8

Please sign in to comment.