|
| | CpuCrossEntropyOp (const CrossEntropyConfig &config) |
| | Constructs a new CPU Cross Entropy operation with the default device context.
|
| |
| | CpuCrossEntropyOp (std::shared_ptr< DeviceContext > context, const CrossEntropyConfig &config) |
| | Constructs a new CPU Cross Entropy operation with a specific device context.
|
| |
| void | backward (const Tensor< int, MR > &input, 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< int, MR > &input_gradient, const OperationAttributes &attributes, const std::vector< std::shared_ptr< Tensor< float, MR > > > &output_state) const |
| | Performs the backward pass of the cross entropy operation.
|
| |
| void | backward_impl (float *dlogits, const float *dlosses, const float *probs, const Tensor< int, CpuMemoryResource > &targets, int B, int T, int V, int Vp) const |
| | Helper method for the backward pass implementation.
|
| |
| void | forward (const Tensor< int, MR > &input, 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 cross entropy operation.
|
| |
| std::string | getName () const override |
| | Gets the name of this operation.
|
| |
| | UnaryOperation (OperationType operation_type) |
| | Constructs a UnaryOperation with the specified operation type.
|
| |
| | UnaryOperation (OperationType operation_type, std::shared_ptr< DeviceContext > context) |
| | Constructs a UnaryOperation with the specified operation type and device context.
|
| |
| virtual | ~UnaryOperation ()=default |
| | Virtual destructor for proper cleanup of derived classes.
|
| |
| virtual void | backward (const Tensor< int, MR > &grad, const std::vector< std::shared_ptr< Tensor< float, MR > > > ¶meters, std::vector< std::shared_ptr< Tensor< float, MR > > > &output_grads) const |
| | Executes the backward pass of a unary operation.
|
| |
| virtual void | backward (const Tensor< int, MR > &input, const Tensor< float, MR > &output_grad, const std::vector< std::shared_ptr< Tensor< float, MR > > > ¶meters, std::vector< std::shared_ptr< Tensor< float, MR > > > ¶meter_grads, Tensor< int, MR > &input_grad, const OperationAttributes &properties, const std::vector< std::shared_ptr< Tensor< float, MR > > > &output_state) const |
| | Executes the comprehensive backward pass of a unary operation.
|
| |
| virtual void | forward (const Tensor< int, MR > &input, const std::vector< std::shared_ptr< Tensor< float, MR > > > ¶meters, const OperationAttributes &properties, Tensor< float, MR > &output, std::vector< std::shared_ptr< Tensor< float, MR > > > &output_state) const=0 |
| | Executes the forward pass of a unary 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 cross entropy loss operation for neural networks.
This class provides a CPU-based implementation of the cross entropy loss function, which is commonly used in classification tasks. It computes the negative log likelihood of the correct class given the predicted probabilities.
- Template Parameters
-
| TInput | The data type of the input tensor elements (typically int for class indices). |
| TDataType | The data type used for computation and output (typically float). |