Skip to main content

embedding

Function embedding 

Source
pub fn embedding(weight: &Tensor, indices: &[i64]) -> Result<Tensor, String>
Expand description

Embedding lookup: maps integer indices to dense vectors.

Performs a table lookup in the weight matrix, selecting rows corresponding to the given indices.

§Arguments

  • weight - Embedding matrix of shape [vocab_size, embed_dim]
  • indices - 1-D tensor of integer indices

§Returns

Tensor of shape [len(indices), embed_dim]

§Errors

Returns an error if any index is out of bounds for the vocabulary size.