Skip to main content

ClikaRT::ops::embedding

function

embedding()

Tensor embedding(
    Tensor indices,
    Tensor weight,
    OptionalTensor bias = {},
    std::optional<Activation> activation = std::nullopt
)

Embedding lookup: gathers rows of weight by indices, with an optional bias + activation epilogue.

Parameters

  • indices: Int32 or Int64, any shape.
  • weight: the table [V, E] (row per vocabulary entry).
  • bias: optional [E], added to every gathered row.
  • activation: optional activation applied after the bias.

Throws

  • ClikaRT::Error: when indices is not an integer dtype or the shapes are inconsistent (code_name() carries the reason).

Returns: indices.shape ++ [E], dtype of weight.

auto h = ClikaRT::ops::embedding(token_ids, table); // [B, S] -> [B, S, E]

Declared in ClikaRT/compute/ops.h, line 2072