Forward pass through the RMSNorm layer. Args: x (torch.Tensor): The input tensor. Returns: torch.Tensor: The output tensor after applying RMSNorm.
(self, x)
| 227 | return x * torch.rsqrt(x.pow(2).mean(-1, keepdim=True) + self.eps) |
| 228 | |
| 229 | def forward(self, x): |
| 230 | """ |
| 231 | Forward pass through the RMSNorm layer. |
| 232 | |
| 233 | Args: |
| 234 | x (torch.Tensor): The input tensor. |
| 235 | |
| 236 | Returns: |
| 237 | torch.Tensor: The output tensor after applying RMSNorm. |
| 238 | |
| 239 | """ |
| 240 | output = self._norm(x.float()).type_as(x) |
| 241 | if hasattr(self, "weight"): |
| 242 | output = output * self.weight |
| 243 | return output |
| 244 | |
| 245 | |
| 246 | def get_norm_layer(norm_layer): |