mr2.nn.RMSNorm

class mr2.nn.RMSNorm[source]

Bases: Module

RMSNorm over the channel dimension.

As used in the DCAE [DCAE].

References

[DCAE]

Chen, J., Cai, H., Chen, J., Xie, E., Yang, S., Tang, H., … & Han, S. Deep compression autoencoder for efficient high-resolution diffusion models. ICLR 2025. https://arxiv.org/abs/2410.10733

__init__(n_channels: int | None = None, eps: float = 1e-8, features_last: bool = False)[source]

Initialize RMSNorm.

Includes a learnable weight and bias if n_channels is provided.

Parameters:
  • n_channels (int | None, default: None) – Number of channels. If None, no learnable weight and bias are included.

  • eps (float, default: 1e-8) – Epsilon value to avoid division by zero.

  • features_last (bool, default: False) – If True, the channel dimension is the last dimension.

__call__(x: Tensor) → Tensor[source]

Apply RMSNorm over the channel dimension.

Parameters:

x (Tensor) – Input tensor.

Returns:

Normalized tensor.

forward(x: Tensor) → Tensor[source]

Apply RMSNorm over the channel dimension.