-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Snippets] Added Buffer identification
- Loading branch information
1 parent
61ef97a
commit be72f40
Showing
23 changed files
with
829 additions
and
138 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
46 changes: 46 additions & 0 deletions
46
src/common/snippets/include/snippets/pass/lowered/buffer_identification.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,46 @@ | ||
// Copyright (C) 2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "linear_IR_transformation.hpp" | ||
|
||
namespace ngraph { | ||
namespace snippets { | ||
namespace pass { | ||
namespace lowered { | ||
|
||
/** | ||
* @interface BufferIdentification | ||
* @brief The pass set identifiers for Buffers in common Buffer system. | ||
* The buffers with the same identifier has the same data register. | ||
* The pass uses greedy graph coloring algorithm using adjacency matrix: | ||
* - Buffers - are vertices of graph | ||
* - Loops, Brgemm (the same other ops) - are "edges" between Buffers (hub of edges). | ||
* The buffers are connected to the same Loop - are adjacent in graph sense bounds. | ||
* - The vertices (buffers) are adjacent if they are connected to the same Loop and | ||
* their data pointers cannot be proportionally incremented in Loops: different ptr increments or data sizes. | ||
* - Firstly, create adjacency matrix using the definition above | ||
* - Secondly, color vertices of graph (buffers) using adjacency matrix | ||
* Note: should be called before ResetBuffer() pass to have correct offsets | ||
* @ingroup snippets | ||
*/ | ||
class BufferIdentification: public LinearIRTransformation { | ||
public: | ||
OPENVINO_RTTI("BufferIdentification", "LinearIRTransformation") | ||
BufferIdentification() = default; | ||
|
||
bool run(LoweredExprIR& linear_ir) override; | ||
|
||
private: | ||
using BufferSet = std::vector<LoweredExprPtr>; | ||
|
||
std::vector<bool> create_adjacency_matrix(const LoweredExprIR& linear_ir, const BufferSet& buffers) const; | ||
std::map<size_t, BufferSet> coloring(BufferSet& buffers, std::vector<bool>& adj); | ||
}; | ||
|
||
} // namespace lowered | ||
} // namespace pass | ||
} // namespace snippets | ||
} // namespace ngraph |
38 changes: 38 additions & 0 deletions
38
src/common/snippets/include/snippets/pass/lowered/buffer_reset.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,38 @@ | ||
// Copyright (C) 2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "linear_IR_transformation.hpp" | ||
|
||
namespace ngraph { | ||
namespace snippets { | ||
namespace pass { | ||
namespace lowered { | ||
|
||
/** | ||
* @interface BufferReset | ||
* @brief The pass `fuses` (reset) ptr increments and finalization offsets for ports of Loop | ||
* with the same Buffers (with the same ID) to avoid double ptr shifts | ||
* Note: Buffer always employ inplace logics by default. It means that if a loop has both | ||
* an input and an output connected to Buffers, the corresponding register should nevertheless be | ||
* incremented only once (because when the input reg is incremented, output incremented automatically). | ||
* This condition should be removed when Buffers stop being inplace by default. | ||
* @ingroup snippets | ||
*/ | ||
class BufferReset: public LinearIRTransformation { | ||
public: | ||
OPENVINO_RTTI("BufferReset", "LinearIRTransformation") | ||
BufferReset() = default; | ||
|
||
bool run(LoweredExprIR& linear_ir) override; | ||
|
||
private: | ||
bool reuse_buffer_increments(const LoweredExprIR& linear_ir, const LoweredExprPtr& loop_end_expr); | ||
}; | ||
|
||
} // namespace lowered | ||
} // namespace pass | ||
} // namespace snippets | ||
} // namespace ngraph |
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
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
Oops, something went wrong.