RotaryEmbedding#
- class sdm.nn.RotaryEmbedding(channels: int, layout: Literal['split_half', 'interleaved'], theta: float = 100000, requires_grad: bool = True, partial_rotary_factor: float = 1.0, device: device | str | None = None, dtype: dtype | None = None)#
Bases:
ModuleRotary Positional Embedding (RoPE) from the “RoFormer: Enhanced Transformer with Rotary Position Embedding” paper.
- Parameters:
channels (int) – The number of channels per attention head.
layout (Literal['split_half', 'interleaved']) – The channel pairing layout.
"split_half"pairs the first half of the channels with the second half."interleaved"pairs adjacent even and odd channels.theta (float) – The base frequency used to initialize inverse frequencies.
requires_grad (bool) – Whether inverse frequencies are learnable.
partial_rotary_factor (float) – The fraction of leading channels to which RoPE is applied.
dtype (dtype | None) – The dtype.