Method
__init__
(
self,
head_dim: int,
base=10000,
)
Source from the content-addressed store, hash-verified
| 31 | """ |
| 32 | |
| 33 | def __init__( |
| 34 | self, |
| 35 | head_dim: int, |
| 36 | base=10000, |
| 37 | ): |
| 38 | super().__init__() |
| 39 | inv_freq = 1.0 / (base ** (torch.arange(0, head_dim, 2).float() / head_dim)) |
| 40 | self.register_buffer("inv_freq", inv_freq, persistent=False) |
| 41 | self.head_dim = head_dim |
| 42 | self.seq_len_cached = None |
| 43 | self.batch_size_cached = None |
| 44 | self.cos_cached: torch.Tensor | None = None |
| 45 | self.sin_cached: torch.Tensor | None = None |
| 46 | |
| 47 | def cos_sin( |
| 48 | self, |
Callers
nothing calls this directly
Tested by
no test coverage detected