For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo function
group_norm_cpu
def group_norm_cpu[dtype: DType, rank: Int, //, InputFn: def[width: Int](Coord[*?]) -> SIMD[dtype, width] & RegisterPassable & ImplicitlyCopyable, GammaFn: def[width: Int](Coord[*?]) -> SIMD[dtype, width] & RegisterPassable & ImplicitlyCopyable, BetaFn: def[width: Int](Coord[*?]) -> SIMD[dtype, width] & RegisterPassable & ImplicitlyCopyable](input_fn: InputFn, gamma_fn: GammaFn, beta_fn: BetaFn, shape: Coord, epsilon: Float32, output: TileTensor[dtype, Engine=output.Engine, address_space=output.address_space, linear_idx_type=output.linear_idx_type], num_groups: Int, ctx: Optional[DeviceContext] = None)
Computes group normalization on CPU.
Reduces a single-pass Welford mean/variance over each (batch, group)
block of channels_per_group * spatial elements, then applies the
per-channel gamma/beta affine transform. Parallelizes across
N * num_groups blocks.
Parameters:
- dtype (
DType): Element type of the input and output tensors. - rank (
Int): Tensor rank of the input and output tensors (3 or 4). - InputFn (
def[width: Int](Coord[*?]) -> SIMD[dtype, width]&RegisterPassable&ImplicitlyCopyable): Type of the input load closure. - GammaFn (
def[width: Int](Coord[*?]) -> SIMD[dtype, width]&RegisterPassable&ImplicitlyCopyable): Type of the gamma load closure. - BetaFn (
def[width: Int](Coord[*?]) -> SIMD[dtype, width]&RegisterPassable&ImplicitlyCopyable): Type of the beta load closure.
Args:
- input_fn (
InputFn): Function called to generate an input value. - gamma_fn (
GammaFn): Function called to generate a gamma value. - beta_fn (
BetaFn): Function called to generate a beta value. - shape (
Coord): The shape of the input/output tensor. - epsilon (
Float32): Small constant for numerical stability. - output (
TileTensor[dtype, Engine=output.Engine, address_space=output.address_space, linear_idx_type=output.linear_idx_type]): Output tensor receiving the normalized result. - num_groups (
Int): Number of groups the channel dimension is split into. - ctx (
Optional[DeviceContext]): Optional device context used to size the CPU thread pool.