Skip to content

Commit

Permalink
Remove loop_over_dims from insertLoops, since it's not used anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanNovoselov committed Nov 4, 2022
1 parent 574f24b commit a59b187
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
3 changes: 1 addition & 2 deletions src/common/snippets/include/snippets/pass/insert_loops.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ namespace pass {
class InsertLoops: public ngraph::pass::FunctionPass {
public:
OPENVINO_RTTI("InsertLoops", "0");
InsertLoops(ov::PartialShape master_shape, size_t loop_depth, size_t vector_size, std::vector<size_t> loop_over_dims = {});
InsertLoops(ov::PartialShape master_shape, size_t loop_depth, size_t vector_size);
bool run_on_model(const std::shared_ptr<ngraph::Function>& m) override;

private:
ov::PartialShape m_master_shape;
size_t m_loop_depth;
size_t m_vector_size;
std::vector<size_t> m_loop_over_dims;
};

} // namespace pass
Expand Down
24 changes: 6 additions & 18 deletions src/common/snippets/src/pass/insert_loops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,22 @@

#include <ngraph/rt_info.hpp>

ngraph::snippets::pass::InsertLoops::InsertLoops(ov::PartialShape master_shape, size_t loop_depth,
size_t vector_size,
std::vector<size_t> loop_over_dims)
ngraph::snippets::pass::InsertLoops::InsertLoops(ov::PartialShape master_shape, size_t loop_depth, size_t vector_size)
: m_master_shape(std::move(master_shape)), m_loop_depth(loop_depth), m_vector_size(vector_size) {
if (loop_over_dims.empty()) {
m_loop_over_dims.resize(m_loop_depth);
if (m_master_shape.size() <= m_loop_depth)
throw ngraph_error("InsertLoops can't insert loops: master shape rank is too small");
for (int i = 0; i < loop_depth; i++)
m_loop_over_dims[i] = m_master_shape.size() - m_loop_depth + i;
} else {
m_loop_over_dims = std::move(loop_over_dims);
if (m_loop_over_dims.size() > 2)
throw ngraph_error("InsertLoops currently supports loop_over_dims up to 2");
}
if (m_master_shape.size() <= m_loop_depth)
throw ngraph_error("InsertLoops can't insert loops: master shape rank is too small");
}

bool ngraph::snippets::pass::InsertLoops::run_on_model(const std::shared_ptr<ov::Model> &model) {
RUN_ON_FUNCTION_SCOPE(InsertLoops);
if (m_master_shape.is_dynamic())
throw ngraph_error("InsertLoops doesn't support dynamic shapes yet");


const auto inner_dim = m_loop_over_dims.back();
const auto inner_dim = m_master_shape.size() - 1;
// Note: outer_dim will not be used if m_master_shape.size() < 2
const auto outer_dim = m_loop_over_dims.size() == 2 ? m_loop_over_dims.front() : -1;
const auto outer_dim = m_loop_depth == 2 ? m_master_shape.size() - 2 : -1;
const auto inner_work_amount = m_master_shape[inner_dim].get_length();
const auto outer_work_amount = m_loop_over_dims.size() == 2 ? m_master_shape[outer_dim].get_length() : 1;
const auto outer_work_amount = m_loop_depth == 2 ? m_master_shape[outer_dim].get_length() : 1;

ParameterVector commonParams = model->get_parameters();
// Note that topological sort parses node arguments in reversed order, but results are added - in direct order
Expand Down

0 comments on commit a59b187

Please sign in to comment.