MCPcopy Create free account
hub / github.com/OpenBitSys/BitDistiller / rotate_half

Function rotate_half

inference/models/falcon.py:20–24  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

18
19# rotary pos emb helpers (torch.jit.script does not seem to support staticmethod...)
20def rotate_half(x):
21 x1, x2 = x[..., : x.shape[-1] // 2], x[..., x.shape[-1] // 2 :]
22 return torch.cat(
23 (-x2, x1), dim=x1.ndim - 1
24 ) # dim=-1 triggers a bug in torch < 1.8.0
25
26
27class RotaryEmbedding(nn.Module):

Callers 1

forwardMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected