|
| virtual | ~PairedOperation ()=default |
| virtual void | backward (const ITensor &grad_out_a, const ITensor &grad_out_b, ITensor &grad_in_a, ITensor &grad_in_b) const =0 |
| | Backward pass: propagate upstream gradients to input gradients.
|
| virtual void | forward (const ITensor &in_a, const ITensor &in_b, ITensor &out_a, ITensor &out_b) const =0 |
| | Forward pass: (out_a, out_b) = f(in_a, in_b).
|
| 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::string | getName () const=0 |
| | Human-readable operation name.
|
| virtual OperationType | getOperationType () const=0 |
| | Operation type identifier.
|
| 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.
|
template<
DeviceType TDeviceType,
TensorDataType TPrecision,
TensorDataType TInputA = TPrecision,
TensorDataType TInputB = TInputA>
requires PrecisionSupportedOnDevice<TPrecision, TDeviceType>
class Mila::Dnn::Compute::PairedOperation< TDeviceType, TPrecision, TInputA, TInputB >
Abstract base for paired operations: two inputs -> two outputs.
Models symmetric transforms where two tensors are processed jointly and each produces an independent output (e.g. Q and K in RoPE).
The backward signature is symmetric with forward: 2-in / 2-out. Implementations that require saved forward activations for their backward pass must cache them internally during forward().
- Template Parameters
-
| TDeviceType | Device target (DeviceType::Cpu, DeviceType::Cuda, ...) |
| TPrecision | Canonical element precision for inputs and outputs (e.g. FP32) |
| TInputA | Element type for the first input tensor (defaults to TPrecision) |
| TInputB | Element type for the second input tensor (defaults to TInputA) |