RotaryEmbedding#
- class RotaryEmbedding(dim, base=10000.0, device=None, dtype=None)[source]#
Bases:
ModulePrecompute the cosine and sine tables used by rotary embeddings.
Shape#
positions:(P,)or(B, P).Returns:
(cos, sin)with shape(P, dim / 2)or(B, P, dim / 2).
Attributes:#
- dim:
Number of channels rotated by RoPE.
- base:
Frequency base used to build the inverse frequency spectrum.
- inv_freq:
Buffer containing the inverse frequencies used to generate the tables.
Initialize the RoPE table builder.
- type dim:
- param dim:
Number of channels rotated by RoPE.
- type dim:
- type base:
- param base:
Frequency base used to build the inverse frequency spectrum.
- type base:
- type device:
torch.device, optional- param device:
Buffer factory options.
- type device:
torch.device, optional- type dtype:
torch.dtype, optional- param dtype:
Buffer factory options.
- type dtype:
torch.dtype, optional