|
| | CpuResidualOp (const ResidualConfig &config) |
| | Constructs a new CPU Residual operation with the default device context.
|
| |
| | CpuResidualOp (std::shared_ptr< DeviceContext > context, const ResidualConfig &config) |
| | Constructs a new CPU Residual operation with a specific device context.
|
| |
| void | backward (const Tensor< float, MR > &input_a, const Tensor< float, MR > &input_b, const Tensor< float, MR > &output, const Tensor< float, MR > &output_gradient, const std::vector< std::shared_ptr< Tensor< float, MR > > > ¶meters, std::vector< std::shared_ptr< Tensor< float, MR > > > ¶meter_gradients, Tensor< float, MR > &input_a_gradient, Tensor< float, MR > &input_b_gradient, const OperationAttributes &attributes, const std::vector< std::shared_ptr< Tensor< float, MR > > > &output_state) const |
| | Performs the backward pass of the residual operation.
|
| |
| void | backward_impl (float *dinp1, float *dinp2, const float *dout, int N) const |
| | Helper method for backward pass implementation.
|
| |
| void | forward (const Tensor< float, MR > &input_a, const Tensor< float, MR > &input_b, const std::vector< std::shared_ptr< Tensor< float, MR > > > ¶meters, const OperationAttributes &attributes, Tensor< float, MR > &output, std::vector< std::shared_ptr< Tensor< float, MR > > > &output_state) const override |
| | Performs the forward pass of the residual operation.
|
| |
| std::string | getName () const override |
| | Gets the name of this operation.
|
| |
| | BinaryOperation (OperationType operation_type) |
| | Constructs a BinaryOperation with the specified operation type and precision policy.
|
| |
| | BinaryOperation (OperationType operation_type, std::shared_ptr< DeviceContext > context) |
| | Constructs a BinaryOperation with the specified operation type, device context, and precision policy.
|
| |
| virtual | ~BinaryOperation ()=default |
| | Virtual destructor for proper cleanup of derived classes.
|
| |
| virtual void | backward (const Tensor< float, MR > &input1, const Tensor< float, MR > &input2, const Tensor< float, MR > &output, const Tensor< float, MR > &output_gradient, const std::vector< std::shared_ptr< Tensor< float, MR > > > ¶meters, std::vector< std::shared_ptr< Tensor< float, MR > > > ¶meter_gradients, Tensor< float, MR > &input1_gradient, Tensor< float, MR > &input2_gradient, const OperationAttributes &attributes, const std::vector< std::shared_ptr< Tensor< float, MR > > > &output_state) const |
| | Executes the backward pass of a binary operation.
|
| |
| virtual void | forward (const Tensor< float, MR > &input1, const Tensor< float, MR > &input2, const std::vector< std::shared_ptr< Tensor< float, MR > > > ¶meters, const OperationAttributes &attributes, Tensor< float, MR > &output, std::vector< std::shared_ptr< Tensor< float, MR > > > &output_state) const=0 |
| | Executes the forward pass of a binary operation.
|
| |
| | OperationBase (OperationType operation_type, std::shared_ptr< DeviceContext > context) |
| | Constructs an OperationBase object with a specific device context and compute precision.
|
| |
| virtual | ~OperationBase ()=default |
| | Virtual destructor for the OperationBase class.
|
| |
| std::shared_ptr< DeviceContext > | getDeviceContext () const |
| | Gets the device context associated with this operation.
|
| |
| DeviceType | getDeviceType () const |
| | Gets the device type for this operation.
|
| |
| OperationType | getOperationType () const |
| | Gets the operation type enumeration value.
|
| |
CPU implementation of the residual operation for neural networks.
This class provides a CPU-based implementation of the residual operation, which performs element-wise addition of two input tensors. It is commonly used in residual connections in neural network architectures such as ResNet and Transformers to help with gradient flow.
- Template Parameters
-
| TInput | The data type of the input tensor elements. |
| TDataType | The data type used for computation and output (defaults to the input type). |