braindecode.functional.rotate_half#

braindecode.functional.rotate_half(x)[source]#

Rotate the two feature halves from (a, b) to (-b, a).

The half-split layout of GPT-NeoX / LLaMA rotary embeddings; see rotate_pairs() for the interleaved layout.

Parameters:

x (Tensor) – Tensor of shape (..., features) with an even final dimension.

Returns:

Same shape, device and dtype as x.

Return type:

Tensor