|
Mila
Deep Neural Network Library
|
Configuration class for the gated feed-forward (GatedMLP) block. More...
Public Member Functions | |
| GatedMLPConfig (dim_t input_features, dim_t hidden_size) | |
| Construct GatedMLP configuration. | |
| void | fromMetadata (const SerializationMetadata &meta) override |
| Populate configuration from provided metadata. | |
| ActivationType | getGateActivation () const noexcept |
| dim_t | getHiddenSize () const noexcept |
| dim_t | getInputFeatures () const noexcept |
| bool | hasBias () const noexcept |
| SerializationMetadata | toMetadata () const override |
| Convert configuration into a SerializationMetadata object. | |
| std::string | toString () const override |
| Produce a short, human-readable summary of the configuration. | |
| void | validate () const override |
| Validate configuration parameters. | |
| template<typename Self> | |
| Self && | withBias (this Self &&self, bool has_bias) |
| template<typename Self> | |
| decltype(auto) | withGateActivation (this Self &&self, ActivationType gate_activation) |
| Set the gate activation function (serializable metadata). | |
| Public Member Functions inherited from Mila::Dnn::ComponentConfig | |
| virtual | ~ComponentConfig ()=default |
| Virtual destructor for polymorphic base. | |
Configuration class for the gated feed-forward (GatedMLP) block.
Block structure: Input -> fc_gate_up Linear(in -> 2H, fused) -> Swiglu gate (2H -> H) -> fc_down Linear(H -> in) -> Output
Gated FFNs are typically bias-free; has_bias defaults to false. gate_activation is serializable metadata; the model factory bridges it to the compile-time gate.
Construct GatedMLP configuration.
| input_features | Number of input (and output) features (must be > 0). |
| hidden_size | Size of the gated intermediate dimension H (must be > 0). |
|
inlineoverridevirtual |
Populate configuration from provided metadata.
Implementations should read available keys and leave missing keys at their current/default values to preserve forward/backward compatibility.
| meta | Metadata to read configuration values from. |
Implements Mila::Dnn::ComponentConfig.
|
inlineoverridevirtual |
Convert configuration into a SerializationMetadata object.
Implementations should include any fields required to fully reconstruct the configuration via fromMetadata.
Implements Mila::Dnn::ComponentConfig.
|
inlineoverridevirtual |
Produce a short, human-readable summary of the configuration.
Implementations should return a compact, single-line description suitable for logging and debugging.
Implements Mila::Dnn::ComponentConfig.
|
inlineoverridevirtual |
Validate configuration parameters.
Called by callers to ensure the configuration represents a valid, constructible component. Implementations must throw std::invalid_argument (or a derived exception) when validation fails.
| std::invalid_argument | If the configuration is invalid. |
Implements Mila::Dnn::ComponentConfig.