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

Configuration class for GELU module. More...

Inheritance diagram for Mila::Dnn::GeluConfig:
Collaboration diagram for Mila::Dnn::GeluConfig:

Public Types

enum class  ApproximationMethod { Exact , Tanh , Sigmoid }
 Approximation methods for the GELU activation function. More...
 

Public Member Functions

 GeluConfig ()=default
 Default constructor.
 
ApproximationMethod getApproximationMethod () const
 Get the configured approximation method.
 
void validate () const
 Validate configuration parameters.
 
GeluConfigwithApproximationMethod (ApproximationMethod method)
 Configure the approximation method for GELU computation.
 
- Public Member Functions inherited from Mila::Dnn::ComponentConfig
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.
 
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.
 

Private Attributes

ApproximationMethod approximation_method_ = ApproximationMethod::Tanh
 

Additional Inherited Members

- Protected Attributes inherited from Mila::Dnn::ComponentConfig
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

Configuration class for GELU module.

Provides a type-safe fluent interface for configuring GELU modules.

Member Enumeration Documentation

◆ ApproximationMethod

Approximation methods for the GELU activation function.

Enumerator
Exact 

Exact implementation using error function.

Tanh 

Fast approximation using tanh.

Sigmoid 

Fast approximation using sigmoid.

Constructor & Destructor Documentation

◆ GeluConfig()

Mila::Dnn::GeluConfig::GeluConfig ( )
default

Default constructor.

Member Function Documentation

◆ getApproximationMethod()

ApproximationMethod Mila::Dnn::GeluConfig::getApproximationMethod ( ) const
inline

Get the configured approximation method.

Returns
ApproximationMethod The approximation method
Here is the caller graph for this function:

◆ validate()

void Mila::Dnn::GeluConfig::validate ( ) const
inlinevirtual

Validate configuration parameters.

Currently, only the Tanh approximation method is supported for GELU computation. Setting other approximation methods will cause validation to fail.

Exceptions
std::invalid_argumentIf validation fails or an unsupported approximation method is selected

Reimplemented from Mila::Dnn::ComponentConfig.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ withApproximationMethod()

GeluConfig & Mila::Dnn::GeluConfig::withApproximationMethod ( ApproximationMethod  method)
inline

Configure the approximation method for GELU computation.

Note: Currently, only the Tanh approximation method is supported. Setting other methods will cause validation to fail when the configuration is used.

Parameters
methodThe approximation method to use (only ApproximationMethod::Tanh is currently supported)
Returns
GeluConfig& Reference to this for method chaining

Member Data Documentation

◆ approximation_method_

ApproximationMethod Mila::Dnn::GeluConfig::approximation_method_ = ApproximationMethod::Tanh
private

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