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

Exported Modules

module  Compute.MemoryResource
module  Dnn.TensorTypes
module  Compute.DeviceId
module  Compute.Device
module  Dnn.Tensor
module  Logging.Logger
module  Dnn.Components.Linear
module  Dnn.TensorDataTypeTraits
module  Serialization.ModelArchive
module  Compute.ExecutionContextFactory
module  Dnn.Component
module  Compute.CpuMemoryResource
module  Dnn.ComponentType
module  Compute.IExecutionContext
module  Compute.BinaryOperation
module  Compute.OperationTraits
module  Compute.UnaryOperation
module  Dnn.TensorDataType
module  Compute.DeviceType
module  Serialization.Mode
module  Dnn.ITensor
module  Dnn.Components.ResidualConfig
module  Compute.DeviceTypeTraits

Classes

class  Mila::Dnn::Residual< TDeviceType, TPrecision >
 Device-templated Residual connection component. More...

Typedefs

using ComponentBase = Component<TDeviceType, TPrecision>
using MR = typename DeviceTypeTraits<TDeviceType>::memory_resource
using OpType = typename OperationTraits<OperationType::ResidualOp, TDeviceType, TPrecision>::type
using TensorType = Tensor<TPrecision, MR>

Functions

 Residual (const std::string &name, const ResidualConfig &config, std::optional< DeviceId > device_id=std::nullopt)
 Construct Residual component with optional ExecutionContext ownership.
 ~Residual () override=default
std::pair< TensorType &, TensorType & > backward (const TensorType &input_a, const TensorType &input_b, const TensorType &output_grad)
 Execute the backward pass and return component-owned gradient for input_a.
void createOperation ()
 Create backend BinaryOperation from OperationRegistry.
TensorTypeforward (const TensorType &input_a, const TensorType &input_b)
 Execute the forward pass and return 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 onBuilding (const BuildContext &build_config) override
 Build the Residual component from the provided BuildContext.
void onExecutionContextSet () override
 Hook invoked after ExecutionContext is set on the base Component.
void onTrainingModeChanging (TrainingMode training_mode) override
 Hook invoked when training mode is about to change.
size_t parameterCount () const override
 Number of trainable parameters.
void save_ (ModelArchive &archive, SerializationMode mode) const override
 Serialize component parameters into the provided archive.
void synchronize () override
 Block until all device operations submitted by this component complete.
std::string toString () const override
 Return a human-readable description of the component.

Variables

ResidualConfig config_
std::unique_ptr< TensorTypeinput_a_grad_ { nullptr }
std::unique_ptr< TensorTypeinput_b_grad_ { nullptr }
shape_t leading_shape_
std::shared_ptr< OpTypeoperation_ { nullptr }
std::unique_ptr< TensorTypeoutput_ { nullptr }
std::unique_ptr< TensorTypeoutput_view_ { nullptr }
std::unique_ptr< IExecutionContextowned_exec_context_ { nullptr }

Files

file  /__w/Mila/Mila/Mila/Src/Dnn/Components/Connections/Residual.ixx
 Device-templated Residual connection component.