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.
tokenize only single groupNorm to subgraph
- Loading branch information
1 parent
d30d70b
commit d24e71d
Showing
5 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/common/snippets/include/snippets/pass/group_norm_tokenization.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,27 @@ | ||
// Copyright (C) 2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "openvino/pass/graph_rewrite.hpp" | ||
#include "openvino/pass/pattern/matcher.hpp" | ||
|
||
namespace ov { | ||
namespace snippets { | ||
namespace pass { | ||
|
||
/** | ||
* @interface TokenizeGroupNormSnippets | ||
* @brief Tokenize GroupNormalization to a subgraph | ||
* @ingroup snippets | ||
*/ | ||
class TokenizeGroupNormSnippets: public ov::pass::MatcherPass { | ||
public: | ||
OPENVINO_RTTI("TokenizeGroupNormSnippets", "0"); | ||
TokenizeGroupNormSnippets(); | ||
}; | ||
|
||
} // namespace pass | ||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (C) 2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "snippets/pass/group_norm_tokenization.hpp" | ||
|
||
#include "snippets/itt.hpp" | ||
#include "snippets/op/subgraph.hpp" | ||
#include "snippets/utils.hpp" | ||
|
||
#include "openvino/core/rt_info.hpp" | ||
#include "openvino/pass/pattern/op/wrap_type.hpp" | ||
|
||
ov::snippets::pass::TokenizeGroupNormSnippets::TokenizeGroupNormSnippets() { | ||
MATCHER_SCOPE(TokenizeGroupNormSnippets); | ||
|
||
auto group_norm_pattern = ov::pass::pattern::wrap_type<ov::op::v12::GroupNormalization>(); | ||
|
||
ov::matcher_pass_callback callback = [=](ov::pass::pattern::Matcher& m) { | ||
OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::pass::TokenizeGroupNormSnippets") | ||
auto group_norm_node = ov::as_type_ptr<ov::op::v12::GroupNormalization>(m.get_match_root()); | ||
|
||
auto subgraph = op::Subgraph::wrap_node_as_subgraph(group_norm_node); | ||
subgraph->get_rt_info()["originalLayersNames"] = group_norm_node->get_friendly_name(); | ||
ov::replace_node(group_norm_node, subgraph); | ||
op::update_out_tensor_name(subgraph); | ||
|
||
return true; | ||
}; | ||
auto m = std::make_shared<ov::pass::pattern::Matcher>(group_norm_pattern, matcher_name); | ||
register_matcher(m, callback); | ||
} | ||
|
||
|
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