MCPcopy Create free account
hub / github.com/RightNow-AI/autokernel / RMSNorm

Class RMSNorm

models/llama_7b.py:22–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20
21
22class RMSNorm(nn.Module):
23 def __init__(self, dim: int, eps: float = 1e-6):
24 super().__init__()
25 self.eps = eps
26 self.weight = nn.Parameter(torch.ones(dim))
27
28 def forward(self, x: torch.Tensor) -> torch.Tensor:
29 norm = torch.rsqrt(x.pow(2).mean(-1, keepdim=True) + self.eps)
30 return x * norm * self.weight
31
32
33def precompute_freqs_cis(dim: int, end: int, theta: float = 10000.0) -> torch.Tensor:

Callers 3

__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected