|
Mila 0.13.48
Deep Neural Network Library
|
CPU implementation of the Encoder operation. More...


Public Types | |
| using | ConfigType = LpeConfig |
| using | CpuExecutionContext = ExecutionContext<DeviceType::Cpu> |
| using | MR = CpuMemoryResource |
| using | OperationBase = UnaryOperation<DeviceType::Cpu, TensorDataType::INT32, TensorDataType::FP32> |
| using | TensorType = Tensor<TensorDataType::FP32, MR> |
| Public Types inherited from Mila::Dnn::Compute::UnaryOperation< DeviceType::Cpu, TensorDataType::INT32, TensorDataType::FP32 > | |
| using | MR |
| using | TensorInputType |
| using | TensorOutputType |
| Public Types inherited from Mila::Dnn::Compute::Operation< TDeviceType, TPrecision > | |
| using | DataTypeTraits |
Public Member Functions | |
| CpuEncoderOp (IExecutionContext *context, const LpeConfig &config) | |
| Construct with execution context and configuration. | |
| ~CpuEncoderOp () override=default | |
| void | backward (const ITensor &input, const ITensor &output_grad, ITensor &input_grad) const override |
| Backward pass: accumulates gradients into embedding tables. | |
| void | build (const BuildContext &config) override |
| Prepare internal caches for a concrete input shape. | |
| void | forward (const ITensor &input, ITensor &output) const override |
| Forward pass: combines token and positional embeddings. | |
| std::string | getName () const override |
| Human-readable operation name. | |
| OperationType | getOperationType () const override |
| Operation type identifier. | |
| void | setGradients (ITensor *wte_grad, ITensor *wpe_grad) override |
| Bind gradient tensors for training. | |
| void | setParameters (ITensor *wte, ITensor *wpe) override |
| Bind parameter tensors for forward execution. | |
| Public Member Functions inherited from Mila::Dnn::Compute::UnaryOperation< DeviceType::Cpu, TensorDataType::INT32, TensorDataType::FP32 > | |
| virtual | ~UnaryOperation ()=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 | setTrainingMode (TrainingMode training_mode) |
| Configure operation training-mode behavior. | |
Private Member Functions | |
| void | validateInputShape (const ITensor &input) const |
| void | validateInputShape (const shape_t &input_shape) const |
Private Attributes | |
| int64_t | batch_size_ { 0 } |
| LpeConfig | config_ |
| IExecutionContext * | context_ { nullptr } |
| int64_t | embedding_dim_ { 0 } |
| bool | is_built_ { false } |
| int64_t | seq_length_ { 0 } |
| const float * | wpe_ { nullptr } |
| float * | wpe_grad_ { nullptr } |
| const float * | wte_ { nullptr } |
| float * | wte_grad_ { nullptr } |
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::UnaryOperation< DeviceType::Cpu, TensorDataType::INT32, TensorDataType::FP32 > | |
| static const TensorInputType & | asInputTensor (const ITensor &t) |
| static TensorOutputType & | asOutputTensor (ITensor &t) |
| Protected Attributes inherited from Mila::Dnn::Compute::Operation< TDeviceType, TPrecision > | |
| bool | is_built_ |
| TrainingMode | training_mode_ |
CPU implementation of the Encoder operation.
Contract and behavior:
Threading and safety:
Parameter binding and ownership:
Edge-cases:
| using Mila::Dnn::Compute::CpuEncoderOp::OperationBase = UnaryOperation<DeviceType::Cpu, TensorDataType::INT32, TensorDataType::FP32> |
|
inlineexplicit |
Construct with execution context and configuration.
Preconditions:
Ownership:
|
overridedefault |
|
inlineoverridevirtual |
Backward pass: accumulates gradients into embedding tables.
Parameters:
Semantics:
Note:
Implements Mila::Dnn::Compute::UnaryOperation< DeviceType::Cpu, TensorDataType::INT32, TensorDataType::FP32 >.

|
inlineoverridevirtual |
Prepare internal caches for a concrete input shape.
Validates the input shape and caches B, T and C for hot-path loops. Must be called (via Module::build) before forward/backward.
Reimplemented from Mila::Dnn::Compute::Operation< TDeviceType, TPrecision >.

|
inlineoverridevirtual |
Forward pass: combines token and positional embeddings.
Parameters:
Preconditions:
Behavior:
Implements Mila::Dnn::Compute::UnaryOperation< DeviceType::Cpu, TensorDataType::INT32, 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 >.
|
inlineoverridevirtual |
Bind gradient tensors for training.
Preconditions:
Semantics:
Throws:
Reimplemented from Mila::Dnn::Compute::Operation< TDeviceType, TPrecision >.

|
inlineoverridevirtual |
Bind parameter tensors for forward execution.
Preconditions:
Ownership:
Throws:
Reimplemented from Mila::Dnn::Compute::Operation< TDeviceType, TPrecision >.

|
inlineprivate |


|
inlineprivate |

|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |