Mila
Deep Neural Network Library
|
Configuration class for GELU module. More...
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. | |
GeluConfig & | withApproximationMethod (ApproximationMethod method) |
Configure the approximation method for GELU computation. | |
![]() | |
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 | |
![]() | |
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. | |
Configuration class for GELU module.
Provides a type-safe fluent interface for configuring GELU modules.
|
strong |
|
default |
Default constructor.
|
inline |
Get the configured approximation method.
|
inlinevirtual |
Validate configuration parameters.
Currently, only the Tanh approximation method is supported for GELU computation. Setting other approximation methods will cause validation to fail.
std::invalid_argument | If validation fails or an unsupported approximation method is selected |
Reimplemented from Mila::Dnn::ComponentConfig.
|
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.
method | The approximation method to use (only ApproximationMethod::Tanh is currently supported) |
|
private |