OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[Snippets] Share nodes in GroupNormalization decomposition (#37744)
Arseniy Obolenskiy18debd0c4198
diff --git a/src/common/snippets/src/pass/gn_decomposition.cpp b/src/common/snippets/src/pass/gn_decomposition.cppindex 901b9b75c12..c85f84dd5ec 100644--- a/src/common/snippets/src/pass/gn_decomposition.cpp+++ b/src/common/snippets/src/pass/gn_decomposition.cpp@@ -65,12 +65,7 @@ GNDecomposition::GNDecomposition() {ov::Shape group_shape = {orig_shape[0], num_groups, 1UL, c_in_group * spatial_dim};std::shared_ptr<ov::Node> reshaped_node_orig = std::make_shared<ov::snippets::op::Reshape>(data, group_shape);- std::shared_ptr<ov::Node> reshaped_node1 = reshaped_node_orig;- if (data.get_element_type() != element::f32) {- reshaped_node1 = std::make_shared<ov::snippets::op::ConvertSaturation>(reshaped_node_orig, element::f32);- }-- const auto reduce_sum = std::make_shared<ov::snippets::op::ReduceSum>(reshaped_node1, group_rank - 1);+ const auto reduce_sum = std::make_shared<ov::snippets::op::ReduceSum>(reshaped_node_orig, group_rank - 1);op::ReduceBase::compute_and_set_reduce_subtensors(reduce_sum);// reduceMean@@ -80,11 +75,7 @@ GNDecomposition::GNDecomposition() {const auto reduce_mean = std::make_shared<ov::op::v1::Multiply>(reduce_sum, group_size_inv_node);// x - mean- std::shared_ptr<ov::Node> reshaped_node2 = reshaped_node_orig;- if (data.get_element_type() != element::f32) {- reshaped_node2 = std::make_shared<ov::snippets::op::ConvertSaturation>(reshaped_node_orig, element::f32);- }- auto sub_mean = std::make_shared<ov::op::v1::Subtract>(reshaped_node2, reduce_mean);+ auto sub_mean = std::make_shared<ov::op::v1::Subtract>(reshaped_node_orig, reduce_mean);// (x - mean) ^ 2auto sqr_const = std::make_shared<ov::op::v0::Constant>(element::f32, Shape{1}, std::vector<float>{2});auto sqr = std::make_shared<ov::op::v1::Power>(sub_mean, sqr_const);