For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo function
gptj_rotate
def gptj_rotate[pairs: Int, *, odd_fuses_sine: Bool = False](values: SIMD[.float32, (Int(2) * pairs)], cosine: SIMD[.float32, pairs], sine: SIMD[.float32, pairs]) -> SIMD[.float32, (Int(2) * pairs)]
Rotates interleaved (even, odd) channel pairs.
Each output fuses one product into an FMA, as the reference stores'
compilers contract even * cos - odd * sin and the odd output. Triton
contracts odd * cos + even * sin around odd * cos, CUDA contracts
even * sin + odd * cos around even * sin.
Parameters:
- pairs (
Int): The number of pairs. - odd_fuses_sine (
Bool): Fuseeven * sinrather thanodd * cosinto the odd output.
Args:
- values (
SIMD[.float32, (Int(2) * pairs)]): The pairs, even channels at even lanes. - cosine (
SIMD[.float32, pairs]): The cosine of each pair's angle. - sine (
SIMD[.float32, pairs]): The sine of each pair's angle.
Returns:
SIMD[.float32, (Int(2) * pairs)]: The rotated pairs.