(x)
| 258 | |
| 259 | |
| 260 | def rotate_half(x): |
| 261 | x = rearrange(x, "... (d r) -> ... d r", r=2) |
| 262 | x1, x2 = x.unbind(dim=-1) |
| 263 | x = torch.stack((-x2, x1), dim=-1) |
| 264 | return rearrange(x, "... d r -> ... (d r)") |
| 265 | |
| 266 | |
| 267 | class Rotary3DPositionEmbeddingMixin(BaseMixin): |