ClikaRT::nn::GroupNorm
class
Header: ClikaRT/nn/group_norm.h
Inherits: ClikaRT::nn::Module
Group normalization.
with mu_g / sigma_g^2 taken per (sample, group); num_groups must divide the channel count, and the channel axis is the last one. The module form of ops::group_norm.
auto gn = ClikaRT::nn::GroupNorm::make(32, 256);
gn->set_weights(gamma, beta);
auto y = (*gn)(x); // [N, H, W, 256] -> [N, H, W, 256]
Static member functions
make()
static std::shared_ptr<GroupNorm> make(
std::int64_t num_groups,
std::int64_t num_channels,
GroupNormOptions options = {}
)
Construct from config with storage-free slots: registers the [num_channels] parameter slots (weight, bias, when options.affine) on options.dtype / options.device; no weight memory is allocated. The first forward builds. Raises ClikaRT::Error when a count is not positive, when num_groups does not divide num_channels, or when eps is not positive.
Declared in ClikaRT/nn/group_norm.h, line 81
Member functions
set_weights()
void set_weights(Tensor weight, OptionalTensor bias = {})
Bind the affine parameters positionally: weight (scale, [C]) and bias (shift, [C]). The declared placement wins; shapes must match the declaration; the next forward rebuilds. Raises ClikaRT::Error on a geometry mismatch or on a module made with affine = false.
Declared in ClikaRT/nn/group_norm.h, line 92
~GroupNorm()
~GroupNorm() override
Declared in ClikaRT/nn/group_norm.h, line 96
to_impl(StreamOrDevice)
virtual Result<void> to_impl(StreamOrDevice where) override
Move to a placement (Device / Stream) or cast to a dtype. Rebuilds over the moved slots on the next forward.
Declared in ClikaRT/nn/group_norm.h, line 100
to_impl(DataType)
Declared in ClikaRT/nn/group_norm.h, line 101
forward()
Normalizes input [N, D1..Dn, C] per sample and group, applies the affine parameters when declared and the fused activation when set; output shape and dtype follow input. The first call builds (once, thread-safe). Raises ClikaRT::Error when a slot is still unbound or the channel count does not match.
Declared in ClikaRT/nn/group_norm.h, line 109
operator()()
Same as forward.
Declared in ClikaRT/nn/group_norm.h, line 113
num_groups()
std::int64_t num_groups() const noexcept
The group count the module was made with.
Declared in ClikaRT/nn/group_norm.h, line 118
num_channels()
std::int64_t num_channels() const noexcept
The channel count the module was made with.
Declared in ClikaRT/nn/group_norm.h, line 120
options()
const GroupNormOptions& options() const noexcept
The settings the module was made with.
Declared in ClikaRT/nn/group_norm.h, line 122
Protected member functions
initialize_impl()
virtual Result<void> initialize_impl() override
The pack hook (Module::initialize_impl): builds the normalization over the bound slots (idempotent, thread-safe). Every declared slot must hold a real (loaded) tensor; a still-unbound slot is a clean error naming it.
Declared in ClikaRT/nn/group_norm.h, line 133