Mila 0.13.48
Deep Neural Network Library
Loading...
Searching...
No Matches
Mila::Dnn::ResidualConfig Class Referenceexport

Configuration class for Residual connection component. More...

Inheritance diagram for Mila::Dnn::ResidualConfig:
Collaboration diagram for Mila::Dnn::ResidualConfig:

Public Member Functions

void fromMetadata (const SerializationMetadata &meta) override
 Populate configuration from serialization metadata.
ConnectionType getConnectionType () const noexcept
 Get the configured connection type.
float getScalingFactor () const noexcept
 Get the configured scaling factor.
SerializationMetadata toMetadata () const override
 Convert configuration to serialization metadata.
std::string toString () const override
 Produce a brief human-readable summary of the configuration.
void validate () const override
 Validate configuration parameters.
template<typename Self>
decltype(auto) withConnectionType (this Self &&self, ConnectionType ct)
 Set the connection type.
template<typename Self>
decltype(auto) withScalingFactor (this Self &&self, float factor)
 Set the scaling factor applied to the residual branch.
Public Member Functions inherited from Mila::Dnn::ComponentConfig
virtual ~ComponentConfig ()=default
 Virtual destructor for polymorphic base.

Static Private Member Functions

static const char * connectionTypeToString (ConnectionType ct) noexcept

Private Attributes

ConnectionType connection_type_ = ConnectionType::Addition
float scaling_factor_ = 1.0f

Detailed Description

Configuration class for Residual connection component.

ResidualConfig is a lightweight, fluent configuration object consumed by Residual components and by compute-backend factories.

Member Function Documentation

◆ connectionTypeToString()

const char * Mila::Dnn::ResidualConfig::connectionTypeToString ( ConnectionType ct)
inlinestaticprivatenoexcept
Here is the caller graph for this function:

◆ fromMetadata()

void Mila::Dnn::ResidualConfig::fromMetadata ( const SerializationMetadata & meta)
inlineoverridevirtual

Populate configuration from serialization metadata.

Reads available fields from the provided metadata and updates the configuration object accordingly.

Implements Mila::Dnn::ComponentConfig.

Here is the call graph for this function:

◆ getConnectionType()

ConnectionType Mila::Dnn::ResidualConfig::getConnectionType ( ) const
inlinenoexcept

Get the configured connection type.

Returns
ConnectionType The connection type

◆ getScalingFactor()

float Mila::Dnn::ResidualConfig::getScalingFactor ( ) const
inlinenoexcept

Get the configured scaling factor.

Returns
float Scaling factor

◆ toMetadata()

SerializationMetadata Mila::Dnn::ResidualConfig::toMetadata ( ) const
inlineoverridevirtual

Convert configuration to serialization metadata.

Produces a SerializationMetadata object containing the configuration fields suitable for writing into an archive by the caller.

Implements Mila::Dnn::ComponentConfig.

Here is the call graph for this function:

◆ toString()

std::string Mila::Dnn::ResidualConfig::toString ( ) const
inlineoverridevirtual

Produce a brief human-readable summary of the configuration.

Implements Mila::Dnn::ComponentConfig.

Here is the call graph for this function:

◆ validate()

void Mila::Dnn::ResidualConfig::validate ( ) const
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.

Exceptions
std::invalid_argumentIf the configuration is invalid.

Implements Mila::Dnn::ComponentConfig.

Here is the caller graph for this function:

◆ withConnectionType()

template<typename Self>
decltype(auto) Mila::Dnn::ResidualConfig::withConnectionType ( this Self && self,
ConnectionType ct )
inline

Set the connection type.

Currently only Addition is supported.

Returns
Self&& for method chaining

◆ withScalingFactor()

template<typename Self>
decltype(auto) Mila::Dnn::ResidualConfig::withScalingFactor ( this Self && self,
float factor )
inline

Set the scaling factor applied to the residual branch.

Parameters
factorScaling factor (positive)
Returns
Self&& for method chaining
Here is the caller graph for this function:

Member Data Documentation

◆ connection_type_

ConnectionType Mila::Dnn::ResidualConfig::connection_type_ = ConnectionType::Addition
private

◆ scaling_factor_

float Mila::Dnn::ResidualConfig::scaling_factor_ = 1.0f
private

The documentation for this class was generated from the following file: