ClikaRT::nn::QEmbedding
class
Header: ClikaRT/nn/qembedding.h
Inherits: ClikaRT::nn::Module
Quantized embedding-table module: gathers rows of a packed table by token index and decodes them to float.
The table is [V, E] (one row per vocabulary entry); forward(ids) returns ids.shape ++ [E]. The codes are never densely materialized: the gather decodes the rows it reads. A dense table is Embedding's.
auto emb = ClikaRT::nn::QEmbedding::make(weight); // a QTensor
auto h = emb->forward(token_ids); // [B, S] -> [B, S, E]
Static member functions
make(QTensor, QEmbeddingOptions)
static std::shared_ptr<QEmbedding> make(QTensor weight, QEmbeddingOptions options = {})
Defaults: every option at its default (QEmbeddingOptions).
Declared in ClikaRT/nn/qembedding.h, line 81
make(int64_t, int64_t, QEmbeddingOptions)
static std::shared_ptr<QEmbedding> make(
std::int64_t num_embeddings,
std::int64_t embedding_dim,
QEmbeddingOptions options = {}
)
Defaults: every option at its default (QEmbeddingOptions).
Declared in ClikaRT/nn/qembedding.h, line 95
Member functions
set_weights()
void set_weights(QTensor weight)
Bind the weight slot: a quantized payload whose logical shape is the declared [num_embeddings, embedding_dim]; the declared placement wins; the codes are never cast. Re-binding drops the built lookup; the next forward rebuilds. Raises ClikaRT::Error on a geometry mismatch or a weight without a scheme.
Declared in ClikaRT/nn/qembedding.h, line 107
~QEmbedding()
~QEmbedding() override
Declared in ClikaRT/nn/qembedding.h, line 111
to_impl(StreamOrDevice)
virtual Result<void> to_impl(StreamOrDevice where) override
Move to a placement (Device / Stream): the packed table moves with the module.
Declared in ClikaRT/nn/qembedding.h, line 115
to_impl(DataType)
The weight stays quantized at rest: a dtype move is Unsupported (decode explicitly, ops::dequantize, when a dense copy is wanted).
Declared in ClikaRT/nn/qembedding.h, line 118
forward()
forward_impl, unwrapped: raises ClikaRT::Error on failure.
Declared in ClikaRT/nn/qembedding.h, line 127
operator()()
Same as forward.
Declared in ClikaRT/nn/qembedding.h, line 131
num_embeddings()
std::int64_t num_embeddings() const noexcept
The declared row count.
Declared in ClikaRT/nn/qembedding.h, line 136
embedding_dim()
std::int64_t embedding_dim() const noexcept
The declared row length.
Declared in ClikaRT/nn/qembedding.h, line 138
options()
const QEmbeddingOptions& options() const noexcept
The settings this module was made with.
Declared in ClikaRT/nn/qembedding.h, line 140
Protected member functions
initialize_impl()
virtual Result<void> initialize_impl() override
The pack hook (Module::initialize_impl): builds the lookup now (idempotent, thread-safe). The weight slot must be bound; a still-declared slot is a clean error. After the build the registry slot reads back from the packed table.
Declared in ClikaRT/nn/qembedding.h, line 152