RMS normalization.
(x: torch.Tensor, weight: torch.Tensor, eps: float = 1e-6)
| 24 | |
| 25 | # RMS Normalization |
| 26 | def rmsnorm_ref(x: torch.Tensor, weight: torch.Tensor, eps: float = 1e-6) -> torch.Tensor: |
| 27 | """RMS normalization.""" |
| 28 | rms = torch.sqrt(torch.mean(x ** 2, dim=-1, keepdim=True) + eps) |
| 29 | return (x / rms) * weight |
| 30 | |
| 31 | # Flash Attention |
| 32 | def flash_attention_ref(Q: torch.Tensor, K: torch.Tensor, V: torch.Tensor, causal: bool = True, sm_scale: float = None) -> torch.Tensor: |
nothing calls this directly
no outgoing calls
no test coverage detected