Skip to main content

Embedding

Gathers rows of its [num_embeddings, embedding_dim] table by token index.

__init__

__init__(self, num_embeddings: 'int', embedding_dim: 'int', *, dtype: 'DataType | None' = None, device: 'Device | None' = None) -> 'None'

Declare the table slot. dtype=None adopts the bound payload's dtype (on a quantized table a set dtype pins the gather's OUTPUT dtype instead).

extra_repr

extra_repr(self) -> 'str'

One line of per-class detail for :meth:__repr__ (a layer prints its geometry here).

forward

forward(self, ids: 'Tensor') -> 'Tensor'

Subclasses define the computation here; call the module itself (m(x)), not forward directly.

from_weights

from_weightsConstruct FROM a table (dense or quantized): geometry, dtype,

Construct FROM a table (dense or quantized): geometry, dtype, and device read off weight, bound in the same call.

set_weights

set_weights(self, weight: 'Tensor') -> 'None'

Bind the table directly; raises on a shape mismatch.