Mila 0.13.48
Deep Neural Network Library
Loading...
Searching...
No Matches
Mila::Dnn::Compute::Cuda::Residual::CudaResidualOp< TInputA, TInputB, TPrecision > Class Template Referenceexport

CUDA Residual operation implementing the BinaryOperation interface. More...

Inheritance diagram for Mila::Dnn::Compute::Cuda::Residual::CudaResidualOp< TInputA, TInputB, TPrecision >:
Collaboration diagram for Mila::Dnn::Compute::Cuda::Residual::CudaResidualOp< TInputA, TInputB, TPrecision >:

Public Types

using ConfigType = ResidualConfig
using CudaExecutionContext = ExecutionContext<DeviceType::Cuda>
using MR = CudaDeviceMemoryResource
using NativeType = typename Mila::Dnn::Compute::Cuda::TensorDataTypeMap<TPrecision>::device_type
Public Types inherited from Mila::Dnn::Compute::BinaryOperation< DeviceType::Cuda, TInputA, TInputA, TInputA >
using MR
using ParameterGradTensor
using ParameterTensor
using TensorLeftType
using TensorOutputType
using TensorRightType
Public Types inherited from Mila::Dnn::Compute::Operation< TDeviceType, TPrecision >
using DataTypeTraits

Public Member Functions

 CudaResidualOp (IExecutionContext *context, const ResidualConfig &config)
 Construct with a non-null CUDA execution context.
void backward (const ITensor &input_A, const ITensor &input_B, const ITensor &output_grad, ITensor &A_grad, ITensor &B_grad) const override
 Backward pass.
void build (const BuildContext &config) override
 Prepare the operation for a concrete input shape.
void forward (const ITensor &input_A, const ITensor &input_B, ITensor &output) const override
 Forward pass: element-wise addition Y = X1 + X2 using CUDA kernel.
std::string getName () const override
 Human-readable operation name.
OperationType getOperationType () const override
 Operation type identifier.
Public Member Functions inherited from Mila::Dnn::Compute::BinaryOperation< DeviceType::Cuda, TInputA, TInputA, TInputA >
virtual ~BinaryOperation ()=default
Public Member Functions inherited from Mila::Dnn::Compute::Operation< TDeviceType, TPrecision >
virtual ~Operation ()=default
virtual void clearGradients () noexcept
 Clear any cached gradient pointers held by the operation.
virtual TensorDataType getDataType () const
 Tensor data type for this operation.
virtual DeviceType getDeviceType () const
 Device type for this operation.
virtual std::size_t getStateMemorySize () const
 Returns the number of bytes of state memory allocated by this operation.
virtual bool isBuilt () const
 Whether build() completed successfully for a concrete input shape.
virtual bool isEvalMode () const
 Query whether operation is configured for training.
virtual void setGradients (ITensor *weight_grad, ITensor *bias_grad)
 Bind module-owned gradient tensors to the operation.
virtual void setParameters (ITensor *weight, ITensor *bias)
 Bind module-owned parameter tensors to the operation.
virtual void setTrainingMode (TrainingMode training_mode)
 Configure operation training-mode behavior.

Private Attributes

ResidualConfig config_
CudaExecutionContextcontext_ { nullptr }
int64_t max_size_ { 0 }
float scale_ { 1.0f }

Additional Inherited Members

Static Public Attributes inherited from Mila::Dnn::Compute::Operation< TDeviceType, TPrecision >
static constexpr TensorDataType data_type
static constexpr DeviceType device_type
Static Protected Member Functions inherited from Mila::Dnn::Compute::BinaryOperation< DeviceType::Cuda, TInputA, TInputA, TInputA >
static const TensorLeftTypeasLeftTensor (const ITensor &t)
static TensorOutputTypeasOutputTensor (ITensor &t)
static const TensorRightTypeasRightTensor (const ITensor &t)
Protected Attributes inherited from Mila::Dnn::Compute::Operation< TDeviceType, TPrecision >
bool is_built_
TrainingMode training_mode_

Detailed Description

template<TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TPrecision = TInputA>
class Mila::Dnn::Compute::Cuda::Residual::CudaResidualOp< TInputA, TInputB, TPrecision >

CUDA Residual operation implementing the BinaryOperation interface.

Template Parameters
TInputAPrecision of first input tensor
TInputBPrecision of second input tensor
TPrecisionComputation precision

Member Typedef Documentation

◆ ConfigType

template<TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TPrecision = TInputA>
using Mila::Dnn::Compute::Cuda::Residual::CudaResidualOp< TInputA, TInputB, TPrecision >::ConfigType = ResidualConfig

◆ CudaExecutionContext

template<TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TPrecision = TInputA>
using Mila::Dnn::Compute::Cuda::Residual::CudaResidualOp< TInputA, TInputB, TPrecision >::CudaExecutionContext = ExecutionContext<DeviceType::Cuda>

◆ MR

template<TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TPrecision = TInputA>
using Mila::Dnn::Compute::Cuda::Residual::CudaResidualOp< TInputA, TInputB, TPrecision >::MR = CudaDeviceMemoryResource

◆ NativeType

template<TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TPrecision = TInputA>
using Mila::Dnn::Compute::Cuda::Residual::CudaResidualOp< TInputA, TInputB, TPrecision >::NativeType = typename Mila::Dnn::Compute::Cuda::TensorDataTypeMap<TPrecision>::device_type

Constructor & Destructor Documentation

◆ CudaResidualOp()

template<TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TPrecision = TInputA>
Mila::Dnn::Compute::Cuda::Residual::CudaResidualOp< TInputA, TInputB, TPrecision >::CudaResidualOp ( IExecutionContext * context,
const ResidualConfig & config )
inline

Construct with a non-null CUDA execution context.

The context parameter is required and validated at runtime. Callers must pass a std::shared_ptr<ExecutionContext<DeviceType::Cuda>>.

Member Function Documentation

◆ backward()

template<TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TPrecision = TInputA>
void Mila::Dnn::Compute::Cuda::Residual::CudaResidualOp< TInputA, TInputB, TPrecision >::backward ( const ITensor & input_A,
const ITensor & input_B,
const ITensor & output_grad,
ITensor & A_grad,
ITensor & B_grad ) const
inlineoverridevirtual

◆ build()

template<TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TPrecision = TInputA>
void Mila::Dnn::Compute::Cuda::Residual::CudaResidualOp< TInputA, TInputB, TPrecision >::build ( const BuildContext & build_context)
inlineoverridevirtual

Prepare the operation for a concrete input shape.

Default implementation is a no-op. Operations requiring shape-dependent setup should override this method.

Reimplemented from Mila::Dnn::Compute::Operation< TDeviceType, TPrecision >.

◆ forward()

template<TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TPrecision = TInputA>
void Mila::Dnn::Compute::Cuda::Residual::CudaResidualOp< TInputA, TInputB, TPrecision >::forward ( const ITensor & input_A,
const ITensor & input_B,
ITensor & output ) const
inlineoverridevirtual

Forward pass: element-wise addition Y = X1 + X2 using CUDA kernel.

Input and output buffers are obtained from ITensor::rawData() and must be device pointers compatible with the CUDA kernels.

Implements Mila::Dnn::Compute::BinaryOperation< DeviceType::Cuda, TInputA, TInputA, TInputA >.

◆ getName()

template<TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TPrecision = TInputA>
std::string Mila::Dnn::Compute::Cuda::Residual::CudaResidualOp< TInputA, TInputB, TPrecision >::getName ( ) const
inlineoverridevirtual

Human-readable operation name.

Implements Mila::Dnn::Compute::Operation< TDeviceType, TPrecision >.

◆ getOperationType()

template<TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TPrecision = TInputA>
OperationType Mila::Dnn::Compute::Cuda::Residual::CudaResidualOp< TInputA, TInputB, TPrecision >::getOperationType ( ) const
inlineoverridevirtual

Member Data Documentation

◆ config_

template<TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TPrecision = TInputA>
ResidualConfig Mila::Dnn::Compute::Cuda::Residual::CudaResidualOp< TInputA, TInputB, TPrecision >::config_
private

◆ context_

template<TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TPrecision = TInputA>
CudaExecutionContext* Mila::Dnn::Compute::Cuda::Residual::CudaResidualOp< TInputA, TInputB, TPrecision >::context_ { nullptr }
private

◆ max_size_

template<TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TPrecision = TInputA>
int64_t Mila::Dnn::Compute::Cuda::Residual::CudaResidualOp< TInputA, TInputB, TPrecision >::max_size_ { 0 }
private

◆ scale_

template<TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TPrecision = TInputA>
float Mila::Dnn::Compute::Cuda::Residual::CudaResidualOp< TInputA, TInputB, TPrecision >::scale_ { 1.0f }
private

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