Mila
Deep Neural Network Library
|
Base configuration class for all neural network components. More...
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. | |
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.
|
virtualdefault |
Virtual destructor to support proper polymorphic destruction.
|
inline |
Gets the configured component name.
|
inline |
Gets the configured precision policy.
|
inline |
Gets the configured training mode.
|
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.
std::invalid_argument | If 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.
|
inline |
Sets the name of the component with fluent interface.
name | The name to assign to this component |
|
inline |
Sets the compute precision policy with fluent interface.
policy | The compute precision policy to use |
|
inline |
Sets the training mode with fluent interface.
is_training | True to put component in training mode, false for inference mode |
|
protected |
Training mode flag, defaults to false (inference mode)
|
protected |
Component name, defaults to "unnamed" if not explicitly set.
|
protected |
Precision policy for computation, defaults to Auto.