|
Mila 0.13.48
Deep Neural Network Library
|
CPU Residual operation (FP32) implementing BinaryOperation interface. More...


Public Types | |
| using | MR = CpuMemoryResource |
| Public Types inherited from Mila::Dnn::Compute::BinaryOperation< DeviceType::Cpu, TensorDataType::FP32 > | |
| 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 | |
| CpuResidualOp (IExecutionContext *context, const ResidualConfig &config) | |
| Construct with optional CPU execution context. | |
| void | backward (const ITensor &input_a, const ITensor &input_b, const ITensor &output_grad, ITensor &input_a_grad, ITensor &input_b_grad) const override |
| Backward pass: propagate output gradient equally to both inputs. | |
| void | forward (const ITensor &input_a, const ITensor &input_b, ITensor &output) const override |
| Forward pass: element-wise add inputA and inputB into output. | |
| 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::Cpu, TensorDataType::FP32 > | |
| virtual | ~BinaryOperation ()=default |
| Public Member Functions inherited from Mila::Dnn::Compute::Operation< TDeviceType, TPrecision > | |
| virtual | ~Operation ()=default |
| virtual void | build (const BuildContext &build_context) |
| Prepare the operation for a concrete input shape. | |
| 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_ |
| IExecutionContext * | context_ |
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::Cpu, TensorDataType::FP32 > | |
| static const TensorLeftType & | asLeftTensor (const ITensor &t) |
| static TensorOutputType & | asOutputTensor (ITensor &t) |
| static const TensorRightType & | asRightTensor (const ITensor &t) |
| Protected Attributes inherited from Mila::Dnn::Compute::Operation< TDeviceType, TPrecision > | |
| bool | is_built_ |
| TrainingMode | training_mode_ |
CPU Residual operation (FP32) implementing BinaryOperation interface.
This class implements forward and backward using ITensor raw data pointers and targets CPU execution. It follows the same interface style as other CPU operations (e.g., CpuGeluOp).
|
inline |
Construct with optional CPU execution context.
| context | Optional CPU execution context. If provided, it is validated. |
| config | Residual operation configuration. |

|
inlineoverridevirtual |
Backward pass: propagate output gradient equally to both inputs.
Adds output_gradient into both input gradients (in-place accumulation).
Implements Mila::Dnn::Compute::BinaryOperation< DeviceType::Cpu, TensorDataType::FP32 >.

|
inlineoverridevirtual |
Forward pass: element-wise add inputA and inputB into output.
Parameters and output_state are currently unused.
Implements Mila::Dnn::Compute::BinaryOperation< DeviceType::Cpu, TensorDataType::FP32 >.

|
inlineoverridevirtual |
Human-readable operation name.
Implements Mila::Dnn::Compute::Operation< TDeviceType, TPrecision >.
|
inlineoverridevirtual |
Operation type identifier.
Implements Mila::Dnn::Compute::Operation< TDeviceType, TPrecision >.
|
private |
|
private |