braindecode.functional.apply_rotary#
- braindecode.functional.apply_rotary(x, cos, sin, interleaved=True)[source]#
Rotate
xby the angles whose cosine and sine are given.x * cos + rotate(x) * sin, whererotateisrotate_pairs()(interleaved=True) orrotate_half().cosandsinmust broadcast tox; casting is left to the caller.- Parameters:
x (
Tensor) – Shape(..., head_dim).cos (
Tensor) – Fromrotary_angles().sin (
Tensor) – Fromrotary_angles().interleaved (
bool) – Feature layout, as inrotary_angles().
- Returns:
Same shape as
x.- Return type: