1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! # Normalization Layers
//!
//! Users who wish to provide an abstraction over swappable normalization
//! layers can use the [`Normalization`] wrapper, with support for:
//! * [`Normalization::Batch`] - [`BatchNorm`]
//! * [`Normalization::Group`] - [`GroupNorm`]
//! * [`Normalization::Instance`] - [`InstanceNorm`]
//! * [`Normalization::Layer`] - [`LayerNorm`]
//! * [`Normalization::Rms`] - [`RmsNorm`]
//!
//! [`NormalizationConfig`] can be used as a generic normalization policy:
//! * Construct a config with arbitrary input features (we suggest `0`).
//! * Clone and match that config to the target input layer,
//! using the [`NormalizationConfig::with_num_features()`] method.
use burn_core as burn;
use ;
/// The dtype a normalization must accumulate its statistics in, or `None` when
/// the input's own dtype is already wide enough.
///
/// Normalizing squares its input, and `f16` cannot hold the result: its 5-bit
/// exponent tops out at 65 504, so an activation past ~256 squares to `inf` and
/// the division that follows yields `NaN`. That is not a corner case for a
/// diffusion U-Net, whose activations routinely reach the hundreds — it turns
/// the generated image blank. Torch widens the reduction to f32 for the same
/// reason, which is why fp16 U-Nets work there.
///
/// `bf16` is deliberately left alone: it carries f32's 8-bit exponent, so it
/// does not overflow, and widening it would cost a cast for no correctness gain.
pub
pub
pub
pub
pub
pub
pub
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;