ClikaRT::ops::rotary_embedding
function
rotary_embedding()
Tensor rotary_embedding(
Tensor x0,
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 padded [.., S, D] layouts.
Rotates the leading rotary_dim of each head vector by per-position 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 ridescode_name()).
Returns: x0 rotated; same shape and dtype.
auto q_rot = ClikaRT::ops::rotary_embedding(q, pos_ids, cos, sin);
Declared in ClikaRT/compute/ops.h, line 2109