Mila 0.13.48
Deep Neural Network Library
Loading...
Searching...
No Matches
Dnn.Components.LayerNorm Module Reference

Exported Modules

module  Compute.IExecutionContext
module  Dnn.TensorDataTypeTraits
module  Serialization.ModelArchive
module  Dnn.TensorTypes
module  Dnn.TensorInitializers
module  Compute.OperationRegistry
module  Logging.Logger
module  Compute.DeviceId
module  Compute.Device
module  Dnn.Tensor
module  Dnn.TensorOps
module  Compute.ExecutionContextFactory
module  Serialization.Tensor
module  Dnn.Component
module  Compute.CpuMemoryResource
module  Dnn.TensorPartitioning
module  Dnn.ComponentType
module  Dnn.TensorDataType
module  Compute.UnaryOperation
module  Compute.DeviceType
module  Dnn.ITensor
module  Serialization.Mode
module  Compute.ExecutionContext
module  Compute.MemoryResource
module  Dnn.TensorHelpers
module  Compute.DeviceTypeTraits

Classes

class  Mila::Dnn::LayerNorm< TDeviceType, TPrecision >
 Device-templated Layer Normalization component. More...
class  Mila::Dnn::LayerNormConfig

Typedefs

using ComponentBase = Component<TDeviceType, TPrecision>
using MR = typename DeviceTypeTraits<TDeviceType>::memory_resource
using TensorType = Tensor<TPrecision, MR>

Functions

 LayerNorm (const std::string &name, const LayerNormConfig &config, std::optional< DeviceId > device_id=std::nullopt)
 Construct LayerNorm with optional ExecutionContext ownership.
 ~LayerNorm () override=default
TensorTypebackward (const TensorType &input, const TensorType &output_grad)
 Run backward pass and return a reference to the component-owned input-gradient tensor.
dim_t computeNormalizedFeatureCount (const shape_t &input_shape) const
void createOperation ()
TensorTypeforward (const TensorType &input)
 Run forward pass and return a reference to the component-owned output tensor.
DeviceId getDeviceId () const override
 Get the compute device id associated with this component.
std::vector< ITensor * > getGradients () const override
 Return non-owning pointers to parameter gradient tensors.
MemoryStats getMemoryStats () const override
 Return the current memory allocation breakdown for this component.
std::vector< ITensor * > getParameters () const override
 Return non-owning pointers to parameter tensors.
const ComponentType getType () const override
 Get the component type identifier.
void initializeGradients ()
void initializeParameters (const shape_t &input_shape)
 Single parameter allocation routine.
void loadParameter (const std::string &name, const ITensorBlob &blob) override
 Load a parameter from serialized tensor data.
void onBuilding (const BuildContext &context) override
 Hook invoked during build() to initialize component with input shape.
void onExecutionContextSet () override
 Hook invoked after ExecutionContext is set.
void onTrainingModeChanging (TrainingMode training_mode) override
 Hook invoked when training mode is about to change.
size_t parameterCount () const override
 Return number of trainable parameters.
void save_ (ModelArchive &archive, SerializationMode mode) const override
void synchronize () override
 Wait for outstanding device work submitted by this component.
std::string toString () const override
 Produce a short, human-readable description of the component.
void validateBuildContext (const BuildContext &context) const
void validateInputShape (const shape_t &input_shape) const
void zeroGradients () override
 Clear all model-owned gradients for this component.

Variables

std::shared_ptr< TensorTypebias_ { nullptr }
std::shared_ptr< TensorTypebias_grad_ { nullptr }
LayerNormConfig config_
std::unique_ptr< TensorTypeinput_grad_ { nullptr }
std::shared_ptr< UnaryOperation< TDeviceType, TPrecision > > operation_ { nullptr }
std::unique_ptr< TensorTypeoutput_ { nullptr }
std::optional< TensorTypeoutput_view_
std::unique_ptr< IExecutionContextowned_exec_context_ { nullptr }
std::shared_ptr< TensorTypeweight_ { nullptr }
std::shared_ptr< TensorTypeweight_grad_ { nullptr }

Files

file  /__w/Mila/Mila/Mila/Src/Dnn/Components/Normalization/LayerNorm/LayerNorm.ixx
 Layer Normalization component.
file  /__w/Mila/Mila/Mila/Src/Dnn/Components/Normalization/LayerNorm/LayerNorm.Config.ixx
 Configuration for Layer Normalization component.