Forward pass through the RMSNorm layer. Args: x (torch.Tensor): The input tensor. Returns: torch.Tensor: The output tensor after applying RMSNorm.
(self, x)
| 58 | return x * torch.rsqrt(x.pow(2).mean(-1, keepdim=True) + self.eps) |
| 59 | |
| 60 | def forward(self, x): |
| 61 | """ |
| 62 | Forward pass through the RMSNorm layer. |
| 63 | |
| 64 | Args: |
| 65 | x (torch.Tensor): The input tensor. |
| 66 | |
| 67 | Returns: |
| 68 | torch.Tensor: The output tensor after applying RMSNorm. |
| 69 | |
| 70 | """ |
| 71 | output = self._norm(x.float()).type_as(x) |
| 72 | if hasattr(self, "weight"): |
| 73 | output = output * self.weight |
| 74 | return output |
| 75 | |
| 76 | |
| 77 | ACTIVATION_FUNCTIONS = { |