MCPcopy Index your code
hub / github.com/huggingface/diffusers / get_normalization

Function get_normalization

src/diffusers/models/normalization.py:632–647  ·  view source on GitHub ↗
(
    norm_type: str = "batch_norm",
    num_features: int | None = None,
    eps: float = 1e-5,
    elementwise_affine: bool = True,
    bias: bool = True,
)

Source from the content-addressed store, hash-verified

630
631
632def get_normalization(
633 norm_type: str = "batch_norm",
634 num_features: int | None = None,
635 eps: float = 1e-5,
636 elementwise_affine: bool = True,
637 bias: bool = True,
638) -> nn.Module:
639 if norm_type == "rms_norm":
640 norm = RMSNorm(num_features, eps=eps, elementwise_affine=elementwise_affine, bias=bias)
641 elif norm_type == "layer_norm":
642 norm = nn.LayerNorm(num_features, eps=eps, elementwise_affine=elementwise_affine, bias=bias)
643 elif norm_type == "batch_norm":
644 norm = nn.BatchNorm2d(num_features, eps=eps, affine=elementwise_affine)
645 else:
646 raise ValueError(f"{norm_type=} is not supported.")
647 return norm

Callers 2

__init__Method · 0.85
__init__Method · 0.85

Calls 1

RMSNormClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…