For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Mojo function
rope_value
def rope_value[dtype: DType, freq_dtype: DType, width: SIMDLength](val: SIMD[dtype, width], freq: SIMD[freq_dtype, width]) -> SIMD[dtype, width]
Applies a rotary position embedding transformation to a SIMD vector.
Deinterleaves the input into real and imaginary parts, multiplies them as complex numbers against the frequency coefficients, and reinterleaves the result back into the original dtype.
Parameters:
- βdtype (
DType): Element type of the input and output SIMD vector (inferred). - βfreq_dtype (
DType): Element type of the frequency coefficients (inferred). - βwidth (
SIMDLength): Number of elements in the SIMD vector (inferred).
Args:
- βval (
SIMD[dtype, width]): The input SIMD vector with interleaved real and imaginary parts. - βfreq (
SIMD[freq_dtype, width]): The frequency coefficients with interleaved real and imaginary parts.
Returns:
SIMD[dtype, width]: The RoPE-transformed SIMD vector in the original dtype.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!