(self, dim=None, dtype=torch.float, eps=1e-5, weight=None)
| 2494 | class RMSNormalize(nn.Module): |
| 2495 | |
| 2496 | def __init__(self, dim=None, dtype=torch.float, eps=1e-5, weight=None): |
| 2497 | super(RMSNormalize, self).__init__() |
| 2498 | if weight is not None: |
| 2499 | self.weight = weight |
| 2500 | else: |
| 2501 | self.weight = nn.Parameter(torch.ones(dim, dtype=dtype, device=get_accelerator().current_device_name())) |
| 2502 | |
| 2503 | self.eps = eps |
| 2504 | |
| 2505 | def forward(self, hidden_states): |
| 2506 | variance = hidden_states.to(torch.float32).pow(2).mean(-1, keepdim=True) |
nothing calls this directly
no test coverage detected