forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Snippets] Specific loop iterations handler
- Loading branch information
Showing
35 changed files
with
1,159 additions
and
344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/common/snippets/include/snippets/lowered/pass/insert_specific_iterations.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (C) 2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "pass.hpp" | ||
|
||
namespace ov { | ||
namespace snippets { | ||
namespace lowered { | ||
namespace pass { | ||
|
||
class InsertSpecificIterations : public Pass { | ||
public: | ||
OPENVINO_RTTI("InsertSpecificIterations", "Pass") | ||
bool run(LinearIR& linear_ir) override; | ||
|
||
static LinearIR::container copy_loop(const LinearIR& linear_ir, const size_t loop_id); | ||
}; | ||
|
||
} // namespace pass | ||
} // namespace lowered | ||
} // namespace snippets | ||
} // namespace ov |
76 changes: 76 additions & 0 deletions
76
src/common/snippets/include/snippets/lowered/pass/iter_handler.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright (C) 2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "snippets/lowered/linear_ir.hpp" | ||
#include "snippets/lowered/pass/pass.hpp" | ||
#include "snippets/lowered/pass/pass_pipeline.hpp" | ||
#include "snippets/op/loop.hpp" | ||
|
||
namespace ov { | ||
namespace snippets { | ||
namespace lowered { | ||
namespace pass { | ||
|
||
class SetSingleIterationWithWorkAmount : public pass::SubgraphPass { | ||
public: | ||
SetSingleIterationWithWorkAmount(size_t work_amount); | ||
OPENVINO_RTTI("SetSingleIterationWithWorkAmount", "SubgraphPass") | ||
bool run(const LinearIR& linear_ir, LinearIR::constExprIt begin, LinearIR::constExprIt end) override; | ||
|
||
private: | ||
size_t m_work_amount; | ||
}; | ||
|
||
class UpdateMemoryAccessOps : public pass::SubgraphPass { | ||
public: | ||
UpdateMemoryAccessOps(size_t count); | ||
OPENVINO_RTTI("UpdateMemoryAccessOps", "SubgraphPass") | ||
bool run(const LinearIR& linear_ir, LinearIR::constExprIt begin, LinearIR::constExprIt end) override; | ||
|
||
private: | ||
size_t m_count; | ||
}; | ||
|
||
class ReduceWorkAmount : public pass::SubgraphPass { | ||
public: | ||
ReduceWorkAmount(size_t reduce_value); | ||
OPENVINO_RTTI("ReduceWorkAmount", "SubgraphPass") | ||
bool run(const LinearIR& linear_ir, LinearIR::constExprIt begin, LinearIR::constExprIt end) override; | ||
|
||
private: | ||
size_t m_reduce_value; | ||
}; | ||
|
||
class ZeroFinalizationOffsets : public pass::SubgraphPass { | ||
public: | ||
OPENVINO_RTTI("ZeroFinalizationOffsets", "SubgraphPass") | ||
bool run(const LinearIR& linear_ir, LinearIR::constExprIt begin, LinearIR::constExprIt end) override; | ||
}; | ||
|
||
class SetFillOffset : public pass::SubgraphPass { | ||
public: | ||
SetFillOffset(size_t offset); | ||
OPENVINO_RTTI("SetFillOffset", "SubgraphPass") | ||
bool run(const LinearIR& linear_ir, LinearIR::constExprIt begin, LinearIR::constExprIt end) override; | ||
|
||
private: | ||
size_t m_offset; | ||
}; | ||
|
||
class TransformInnerSplitLoop : public pass::SubgraphPass { | ||
public: | ||
TransformInnerSplitLoop(size_t tail_size); | ||
OPENVINO_RTTI("TransformInnerSplitLoop", "SubgraphPass") | ||
bool run(const LinearIR& linear_ir, LinearIR::constExprIt begin, LinearIR::constExprIt end) override; | ||
|
||
private: | ||
size_t m_tail_size; | ||
}; | ||
|
||
} // namespace pass | ||
} // namespace lowered | ||
} // namespace snippets | ||
} // namespace ov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
src/common/snippets/include/snippets/lowered/pass/pass_pipeline.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// Copyright (C) 2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "pass.hpp" | ||
#include "snippets/pass/pass_position.hpp" | ||
|
||
namespace ov { | ||
namespace snippets { | ||
namespace lowered { | ||
namespace pass { | ||
class PassPipeline { | ||
public: | ||
PassPipeline() = default; | ||
|
||
void run(lowered::LinearIR& linear_ir) const; | ||
void register_pass(const std::shared_ptr<Pass>& pass); | ||
|
||
template<typename T, class... Args> | ||
void register_pass(Args&&... args) { | ||
static_assert(std::is_base_of<Pass, T>::value, "Pass not derived from lowered::Pass"); | ||
auto pass = std::make_shared<T>(std::forward<Args>(args)...); | ||
register_pass(pass); | ||
} | ||
|
||
struct PositionedPass { | ||
ov::snippets::pass::PassPosition position; | ||
std::shared_ptr<Pass> pass; | ||
PositionedPass(ov::snippets::pass::PassPosition arg_pos, std::shared_ptr<Pass> arg_pass) | ||
: position(std::move(arg_pos)), pass(std::move(arg_pass)) { | ||
} | ||
}; | ||
|
||
template <typename T, class Pos, class... Args, std::enable_if<std::is_same<ov::snippets::pass::PassPosition, Pos>::value, bool>() = true> | ||
void register_pass(const ov::snippets::pass::PassPosition& position, Args&&... args) { | ||
static_assert(std::is_base_of<Pass, T>::value, "Attempt to insert pass that is not derived from Pass"); | ||
auto pass = std::make_shared<T>(std::forward<Args>(args)...); | ||
insert_pass_instance(position, pass); | ||
} | ||
|
||
void register_positioned_passes(const std::vector<PositionedPass>& pos_passes); | ||
|
||
protected: | ||
void insert_pass_instance(const ov::snippets::pass::PassPosition& position, const std::shared_ptr<Pass>& pass); | ||
|
||
private: | ||
std::vector<std::shared_ptr<Pass>> m_passes; | ||
}; | ||
|
||
class SubgraphPassPipeline { | ||
public: | ||
SubgraphPassPipeline() = default; | ||
|
||
void run(const lowered::LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) const; | ||
const std::vector<std::shared_ptr<SubgraphPass>>& get_passes() const; | ||
void register_pass(const std::shared_ptr<SubgraphPass>& pass); | ||
bool empty() const { return m_passes.empty(); } | ||
|
||
template<typename T, class... Args> | ||
void register_pass(Args&&... args) { | ||
static_assert(std::is_base_of<SubgraphPass, T>::value, "Pass not derived from lowered::SubgraphPass"); | ||
auto pass = std::make_shared<T>(std::forward<Args>(args)...); | ||
register_pass(pass); | ||
} | ||
|
||
struct PositionedPass { | ||
ov::snippets::pass::PassPosition position; | ||
std::shared_ptr<SubgraphPass> pass; | ||
PositionedPass(ov::snippets::pass::PassPosition arg_pos, std::shared_ptr<SubgraphPass> arg_pass) | ||
: position(std::move(arg_pos)), pass(std::move(arg_pass)) { | ||
} | ||
}; | ||
|
||
template <typename T, class Pos, class... Args, std::enable_if<std::is_same<ov::snippets::pass::PassPosition, Pos>::value, bool>() = true> | ||
void register_pass(const ov::snippets::pass::PassPosition& position, Args&&... args) { | ||
static_assert(std::is_base_of<SubgraphPass, T>::value, "Attempt to insert pass that is not derived from SubgraphPass"); | ||
auto pass = std::make_shared<T>(std::forward<Args>(args)...); | ||
insert_pass_instance(position, pass); | ||
} | ||
|
||
void register_positioned_passes(const std::vector<PositionedPass>& pos_passes); | ||
|
||
protected: | ||
void insert_pass_instance(const ov::snippets::pass::PassPosition& position, const std::shared_ptr<SubgraphPass>& pass); | ||
|
||
private: | ||
std::vector<std::shared_ptr<SubgraphPass>> m_passes; | ||
}; | ||
|
||
} // namespace pass | ||
} // namespace lowered | ||
} // namespace snippets | ||
} // namespace ov |
Oops, something went wrong.