Skip to main content

ClikaRT::ops::rotary_embedding_varlen

function

rotary_embedding_varlen()

Tensor rotary_embedding_varlen(
    Tensor x0,
    Tensor cu_seqlens,
    OptionalTensor seqlens = {},
    OptionalTensor position_ids = {},
    OptionalTensor cos = {},
    OptionalTensor sin = {},
    std::optional<RotaryMode> mode = std::nullopt,
    std::optional<int64_t> rotary_dim = std::nullopt,
    std::optional<double> theta = std::nullopt,
    std::optional<RopeScaling> scaling = std::nullopt,
    std::optional<double> scale = std::nullopt,
    std::optional<double> low_freq_factor = std::nullopt,
    std::optional<double> high_freq_factor = std::nullopt,
    std::optional<int64_t> original_max_pos = std::nullopt,
    std::optional<double> beta_fast = std::nullopt,
    std::optional<double> beta_slow = std::nullopt,
    OptionalTensor freq_factors = {}
)

Rotary position embedding over token-packed (variable-length) layouts.

Packed [Sum(S), .., D] input with cu_seqlens [B+1] Int32 prefix sums (per-sequence positions restart at 0 unless position_ids is given); seqlens optionally carries explicit per-sequence lengths. angles (RoPE). cos / sin are the precomputed angle planes [max_pos, rotary_dim/2] Float32; position_ids (Int32/Int64) selects each token's row; absent, positions run 0, 1, 2, … per sequence. mode picks the pair layout (interleaved vs half-split); rotary_dim absent rotates the whole head dim.

Throws

  • ClikaRT::Error: when the input's dtype/shape is not served for this operation (the machine-readable reason rides code_name()).

Returns: x0 rotated; same shape and dtype.

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