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

Base configuration class for all neural network components. More...

Inheritance diagram for Mila::Dnn::ComponentConfig:

Public Member Functions

virtual ~ComponentConfig ()=default
 Virtual destructor to support proper polymorphic destruction.
 
const std::string & getName () const
 Gets the configured component name.
 
ComputePrecision::Policy getPrecision () const
 Gets the configured precision policy.
 
bool isTraining () const
 Gets the configured training mode.
 
virtual void validate () const
 Validates the configuration.
 
template<typename Self >
auto & withName (this Self &&self, std::string name)
 Sets the name of the component with fluent interface.
 
template<typename Self >
auto & withPrecision (this Self &&self, ComputePrecision::Policy policy)
 Sets the compute precision policy with fluent interface.
 
template<typename Self >
auto & withTraining (this Self &&self, bool is_training)
 Sets the training mode with fluent interface.
 

Protected Attributes

bool is_training_ = false
 Training mode flag, defaults to false (inference mode)
 
std::string name_ = "unnamed"
 Component name, defaults to "unnamed" if not explicitly set.
 
ComputePrecision::Policy precision_ = ComputePrecision::Policy::Auto
 Precision policy for computation, defaults to Auto.
 

Detailed Description

Base configuration class for all neural network components.

ComponentConfig serves as the foundation for all configuration classes in the Mila DNN framework. It provides common configuration properties like name, precision policy, and training mode that are shared across different neural network components.

Derived configuration classes should extend this base with component-specific configuration options and override validate() when needed.

See also
GeluConfig
LinearConfig

Constructor & Destructor Documentation

◆ ~ComponentConfig()

virtual Mila::Dnn::ComponentConfig::~ComponentConfig ( )
virtualdefault

Virtual destructor to support proper polymorphic destruction.

Member Function Documentation

◆ getName()

const std::string & Mila::Dnn::ComponentConfig::getName ( ) const
inline

Gets the configured component name.

Returns
const std::string& The component name
Here is the caller graph for this function:

◆ getPrecision()

ComputePrecision::Policy Mila::Dnn::ComponentConfig::getPrecision ( ) const
inline

Gets the configured precision policy.

Returns
ComputePrecision::Policy The precision policy
Here is the caller graph for this function:

◆ isTraining()

bool Mila::Dnn::ComponentConfig::isTraining ( ) const
inline

Gets the configured training mode.

Returns
bool True if in training mode, false if in inference mode

◆ validate()

virtual void Mila::Dnn::ComponentConfig::validate ( ) const
inlinevirtual

Validates the configuration.

Base implementation validates that the component name is not empty. Derived classes should call this base implementation and add their own validation logic.

Exceptions
std::invalid_argumentIf the configuration is invalid

Reimplemented in Mila::Dnn::GeluConfig, Mila::Dnn::MLPConfig, Mila::Dnn::TransformerBlockConfig, Mila::Dnn::EncoderConfig, Mila::Dnn::LinearConfig, Mila::Dnn::MultiHeadAttentionConfig, Mila::Dnn::ResidualConfig, Mila::Dnn::SoftmaxConfig, Mila::Dnn::CrossEntropyConfig, Mila::Dnn::LayerNormConfig, and Mila::Dnn::DropoutConfig.

Here is the caller graph for this function:

◆ withName()

template<typename Self >
auto & Mila::Dnn::ComponentConfig::withName ( this Self &&  self,
std::string  name 
)
inline

Sets the name of the component with fluent interface.

Parameters
nameThe name to assign to this component
Returns
Reference to self for method chaining
Note
Names are validated during the validate() call, not at assignment time
Here is the caller graph for this function:

◆ withPrecision()

template<typename Self >
auto & Mila::Dnn::ComponentConfig::withPrecision ( this Self &&  self,
ComputePrecision::Policy  policy 
)
inline

Sets the compute precision policy with fluent interface.

Parameters
policyThe compute precision policy to use
Returns
Reference to self for method chaining

◆ withTraining()

template<typename Self >
auto & Mila::Dnn::ComponentConfig::withTraining ( this Self &&  self,
bool  is_training 
)
inline

Sets the training mode with fluent interface.

Parameters
is_trainingTrue to put component in training mode, false for inference mode
Returns
Reference to self for method chaining

Member Data Documentation

◆ is_training_

bool Mila::Dnn::ComponentConfig::is_training_ = false
protected

Training mode flag, defaults to false (inference mode)

◆ name_

std::string Mila::Dnn::ComponentConfig::name_ = "unnamed"
protected

Component name, defaults to "unnamed" if not explicitly set.

◆ precision_

ComputePrecision::Policy Mila::Dnn::ComponentConfig::precision_ = ComputePrecision::Policy::Auto
protected

Precision policy for computation, defaults to Auto.


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