Skip to content
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

[TRANSFORMATIONS][GPU] Add GroupNormalization fusion to common optimizations #28387

Open
wants to merge 25 commits into
base: master
Choose a base branch
from

Conversation

jhajducz
Copy link
Contributor

@jhajducz jhajducz commented Jan 11, 2025

Details:

  • Added GroupNormalization fusion pass that can handle pattern observed in many customer models that were exported via ONNX in a way that uses InstanceNormalization as a proxy for GroupNormalization. It covers also more traditional cases without additional instance norm related parameters.
  • Per suggestion from @vladimir-paramuzov, for now enabled GroupNormalization fusion only for GPU plugin. Once it will be verified that it doesn't cause regressions in other backends, we can enable it for them as well.

Tickets:

  • 160436

@github-actions github-actions bot added category: Core OpenVINO Core (aka ngraph) category: GPU OpenVINO GPU plugin category: transformations OpenVINO Runtime library - Transformations category: CPP API OpenVINO CPP API bindings labels Jan 11, 2025
@sys-openvino-ci sys-openvino-ci added the ExternalIntelPR External contributor from Intel label Jan 11, 2025
@jhajducz jhajducz force-pushed the private/jhajducz/gpu_gn_fusion branch from 3a67c81 to ba87e35 Compare January 12, 2025 17:37
@jhajducz jhajducz marked this pull request as ready for review January 13, 2025 00:38
@jhajducz jhajducz requested review from a team as code owners January 13, 2025 00:38
@jhajducz jhajducz requested review from itikhono and removed request for a team January 13, 2025 00:38
@mlukasze
Copy link
Contributor

build_jenkins

Copy link
Contributor

@t-jankowski t-jankowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm regarding Core part.

@jhajducz jhajducz force-pushed the private/jhajducz/gpu_gn_fusion branch from ba87e35 to 3bd623d Compare January 13, 2025 10:49
@praasz
Copy link
Contributor

praasz commented Jan 13, 2025

build_jenkins

@jhajducz jhajducz force-pushed the private/jhajducz/gpu_gn_fusion branch from 3bd623d to d69391b Compare January 14, 2025 13:05
@github-actions github-actions bot removed category: Core OpenVINO Core (aka ngraph) category: CPP API OpenVINO CPP API bindings labels Jan 14, 2025
@jhajducz jhajducz requested a review from praasz January 14, 2025 15:39
@jhajducz jhajducz force-pushed the private/jhajducz/gpu_gn_fusion branch from d69391b to b1ac67d Compare January 14, 2025 20:29
@jhajducz jhajducz force-pushed the private/jhajducz/gpu_gn_fusion branch 3 times, most recently from 9cf1017 to 8382572 Compare January 16, 2025 20:23
{has_real_not_quantized_type, has_at_least_2d_shape, ov::pass::pattern::has_static_dim(1)}));

auto pre_mvn_shape_const_m = ov::pass::pattern::wrap_type<ov::op::v0::Constant>(ov::pass::pattern::all_of(
{has_integral_type, ov::pass::pattern::rank_equals(1), ov::pass::pattern::has_static_dim(0)}));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of those checks may be redundant as an operation will fail on validation pass if parameters are incorrect. For instance, this has_integral_type is not needed as Reshape op can't be created with non-integral type of target pattern

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed has_integral_type predicate (it was used only for making sure that T_SHAPE for Reshape and T_IND for MVN will be of integral type, which is indeed redundant)

}

if (pattern_map.count(instance_norm_gamma_m) > 0) {
const auto& instance_norm_gamma = pattern_map.at(instance_norm_gamma_m);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think this instance/group norm prefix can be removed in most of the cases to make the names shorter and easier to read

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, in worst case pattern will have gamma and beta parameters for both instance norm and group norm, so I prefer to keep these prefixes to distinguish them

@jhajducz jhajducz force-pushed the private/jhajducz/gpu_gn_fusion branch 2 times, most recently from 215c308 to 75e1dce Compare January 19, 2025 22:32
@jhajducz jhajducz force-pushed the private/jhajducz/gpu_gn_fusion branch from 75e1dce to c163002 Compare January 19, 2025 23:30
@e-ddykim
Copy link
Contributor

I checked that it works fine for SD 1.5 on GPU.

@jhajducz
Copy link
Contributor Author

I on the other hand may have found potential accuracy issue, let me investigate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: GPU OpenVINO GPU plugin category: transformations OpenVINO Runtime library - Transformations ExternalIntelPR External contributor from Intel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants