9#include <initializer_list>
70 void set_gamma(std::initializer_list<float> values);
72 void set_beta(std::initializer_list<float> values);
76 void set_beta(
const std::vector<float>& values);
79 [[nodiscard]]
const Tensor&
beta()
const {
return beta_; }
96 return {{
"weight", {&gamma_, &gamma_grad_}}, {
"bias", {&beta_, &beta_grad_}}};
108 int64_t num_channels_;
121 bool has_forwarded_ =
false;
Vendor-agnostic compute/memory backend. CPUBackend, CUDABackend (Phase 1.5), and HIPBackend (Phase 1....
Definition device_backend.hpp:219
Splits num_channels into num_groups equal-size groups; each group's mean/std is computed over every (...
Definition group_norm_module.hpp:32
Tensor propagate_relevance(const Tensor &relevance_out, const LRPRuleConfig &config) override
Identity-rule LRP relevance propagation (AttnLRP, Achtibat et al. 2024).
void set_beta(const std::vector< float > &values)
Vector overload for runtime-sized sources – see Tensor's own vector ctor.
GroupNormModule(int64_t num_groups, int64_t num_channels, DeviceBackend *backend, DeviceType device, float eps=1e-6f)
Constructs a GroupNorm layer with zero-initialized gamma and beta.
OpType op_type() const override
Normalization per charter's closed OpType set.
Definition group_norm_module.hpp:67
Tensor backward(const Tensor &grad_output) override
Computes the gradient w.r.t. this module's input, and accumulates gamma's/ beta's gradients internall...
std::vector< NamedParamRef > named_parameters() override
This module's trainable parameters, each with its hierarchical name – the one place a module declares...
Definition group_norm_module.hpp:95
GroupNormModule(int64_t num_groups, int64_t num_channels, DeviceBackend *backend)
On backend's own device (backend->device()), default eps. Previously the device defaulted to Cpu rega...
const Tensor & beta_grad() const
Definition group_norm_module.hpp:81
void set_gamma(std::initializer_list< float > values)
Overwrites the per-channel gamma buffer – test/initialization use only.
Tensor forward_impl(const Tensor &input) override
The actual forward computation. Called by forward() after precondition checks.
void set_gamma(const std::vector< float > &values)
Vector overload for runtime-sized sources – see Tensor's own vector ctor.
const Tensor & gamma_grad() const
Definition group_norm_module.hpp:80
void set_beta(std::initializer_list< float > values)
Overwrites the per-channel beta buffer – test/initialization use only.
const Tensor & beta() const
Definition group_norm_module.hpp:79
const Tensor & gamma() const
Definition group_norm_module.hpp:78
std::optional< DeviceType > compute_device() const override
Where this layer computes, so forward() rejects an input on another device (FND-8).
Definition group_norm_module.hpp:101
Base class for every layer type (LinearModule, Conv2DModule, activations, ...).
Definition module.hpp:58
N-dimensional tensor. Owns its data buffer exclusively; a DeviceBackend* is injected (not owned) – th...
Definition tensor.hpp:29
DeviceType device() const
Which device this tensor's buffer conceptually resides on.
Definition tensor.hpp:122
Abstract base every layer subclasses – NVI forward(), pure-virtual LRP contract.
Definition acquisition_functions.hpp:16
DeviceType
Which physical device a Tensor's buffer resides on.
Definition device_backend.hpp:17
OpType
The op-type tag a Node carries. Charter Part 2 §3: nodes are tagged by a small closed set of op types...
Definition op_type.hpp:19
Configuration for LRP relevance propagation: which rule a module applies and its hyperparameters....
Definition lrp_rule_config.hpp:57