-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Snippets] Introduced BufferExpression #26413
Merged
a-sidorova
merged 7 commits into
openvinotoolkit:master
from
a-sidorova:feature/snippets/buffer_expr
Sep 17, 2024
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f5b8907
[Snippets] Created BufferExpression
a-sidorova 75da954
[Snippets] Applied Vladislav comments
a-sidorova 039fd27
[Snippets] Implemented BaseImpl in op::Buffer
a-sidorova 2497cff
[Snippets] Added the method
a-sidorova 3418eec
[Snippets] fixed build
a-sidorova 9b9c016
[Snippets] Applied Vladislav comments 2
a-sidorova 16568a6
[Snippets] Applied Ivan comments
a-sidorova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
69 changes: 69 additions & 0 deletions
69
src/common/snippets/include/snippets/lowered/expressions/buffer_expression.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,69 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "snippets/lowered/expression.hpp" | ||
|
||
#include "snippets/utils/utils.hpp" | ||
|
||
|
||
namespace ov { | ||
namespace snippets { | ||
namespace lowered { | ||
|
||
// To avoid cycle-dependancy of includes, we forward-declare LoopManager | ||
class LoopManager; | ||
/** | ||
* @interface BufferExpression | ||
* @brief This is a base class for memory storage. | ||
* Note that Buffer should be a single consumer for operation output port | ||
* @param m_allocation_size - memory size for allocation in bytes. Dynamic value means undefined size. | ||
* @param m_offset - offset in common Buffer scratchpad | ||
* @param m_reg_group - number of register group. The Buffers from the same register group will have the same GPR | ||
* @param m_cluster_id - number of cluster. The Buffers from the same cluster shares memory between them and will have the same offset. | ||
* @ingroup snippets | ||
*/ | ||
class BufferExpression : public Expression { | ||
friend class ExpressionFactory; | ||
public: | ||
OPENVINO_RTTI("BufferExpression", "0", Expression) | ||
BufferExpression() = default; | ||
|
||
bool visit_attributes(AttributeVisitor &visitor) override; | ||
|
||
size_t get_reg_group() const { return m_reg_group; } | ||
size_t get_cluster_id() const { return m_cluster_id; } | ||
size_t get_offset() const { return m_offset; } | ||
size_t get_allocation_size() const { return m_allocation_size; } | ||
size_t get_byte_size() const; | ||
|
||
void set_reg_group(size_t reg_group) { m_reg_group = reg_group; } | ||
void set_cluster_id(size_t cluster) { m_cluster_id = cluster; } | ||
void set_allocation_size(size_t size) { m_allocation_size = size; } | ||
void set_offset(size_t offset) { m_offset = offset; } | ||
|
||
virtual void init_allocation_size(const std::shared_ptr<LoopManager>& loop_manager, size_t allocation_rank); | ||
|
||
// Returns True, if allocation size is known. Otherwise returns False - allocation size is undefined | ||
bool is_defined() const; | ||
|
||
// Returns True, if the memory is independent - expression doesn't have parents (source) | ||
bool is_independent_memory() const { return get_input_count() == 0; } | ||
|
||
protected: | ||
BufferExpression(const std::shared_ptr<Node>& n, const std::shared_ptr<IShapeInferSnippetsFactory>& factory); | ||
|
||
ExpressionPtr clone() const override; | ||
|
||
size_t m_allocation_size = utils::get_dynamic_value<size_t>(); | ||
size_t m_reg_group = 0; | ||
size_t m_cluster_id = 0; | ||
size_t m_offset = utils::get_dynamic_value<size_t>(); | ||
}; | ||
using BufferExpressionPtr = std::shared_ptr<BufferExpression>; | ||
|
||
} // 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
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open question for discussion: can we move this ctor to public section to avoid writing
friend class ExpressionFactory;
in eachSpecialExpression
🤔