|
template<typename TInput = int, typename TOutput = float> |
using | Mila::Dnn::CpuEncoder = Encoder< DeviceType::Cpu, TInput, TOutput > |
| Type alias for CPU-based encoder module with customizable tensor types.
|
|
template<typename TInput = int, typename TOutput = float> |
using | Mila::Dnn::CudaEncoder = Encoder< DeviceType::Cuda, TInput, TOutput > |
| Type alias for CUDA-based encoder module with customizable tensor types.
|
|
using | ModuleBase = Module< TDeviceType, TInput, TOutput > |
| Alias for base module type.
|
|
using | MR = std::conditional_t< TDeviceType==DeviceType::Cuda, CudaMemoryResource, CpuMemoryResource > |
| Memory resource type determined based on device type.
|
|
|
| Encoder (const std::string &device_name, const EncoderConfig &config) |
| Constructs a new Encoder module with a device name.
|
|
| Encoder (std::shared_ptr< DeviceContext > device_context, const EncoderConfig &config) |
| Constructs a new Encoder module with a provided device context.
|
|
void | createOperation () |
| Creates the computational operation based on current device context.
|
|
void | forward (const Tensor< TInput, MR > &input, Tensor< TOutput, MR > &output) |
| Performs the forward pass of the encoder.
|
|
size_t | getChannels () const |
| Gets the number of channels (embedding dimension).
|
|
size_t | getMaxSequenceLength () const |
| Gets the maximum sequence length.
|
|
size_t | getVocabularyLength () const |
| Gets the vocabulary length.
|
|
void | initializeTensors () |
| Initializes the token and positional embedding tensors.
|
|
void | load (ModelArchive &archive) override |
| Loads the encoder parameters from a zip archive.
|
|
size_t | parameterCount () const override |
| Gets the number of parameters in the module.
|
|
void | save (ModelArchive &archive) const override |
| Saves the encoder parameters to a zip archive.
|
|
std::string | toString () const override |
| Gets the module information as a string.
|
|
|
OperationAttributes | attributes_ |
| Operation-specific attributes and configuration.
|
|
EncoderConfig | config_ |
| Configuration for the Encoder module.
|
|
std::shared_ptr< UnaryOperation< TDeviceType, TInput, TOutput > > | operation_ { nullptr } |
| The computational operation that implements the encoder logic.
|
|
std::vector< std::shared_ptr< Tensor< TOutput, MR > > > | output_state_ |
| Output state tensors used for intermediate values.
|
|
std::vector< std::shared_ptr< Tensor< TOutput, MR > > > | parameters_ |
| Vector of parameter tensors that will be used during forward/backward passes.
|
|
std::shared_ptr< Tensor< TOutput, MR > > | wpe_ { nullptr } |
| Position embedding table with shape (maxT,C), encodes token position information.
|
|
std::shared_ptr< Tensor< TOutput, MR > > | wte_ { nullptr } |
| Token embedding table with shape (V,C), maps token IDs to vector representations.
|
|