(self, x)
| 28 | self.variance_epsilon = eps |
| 29 | |
| 30 | def forward(self, x): |
| 31 | pdtype = x.dtype |
| 32 | x = x.float() |
| 33 | u = x.mean(-1, keepdim=True) |
| 34 | s = (x - u).pow(2).mean(-1, keepdim=True) |
| 35 | x = (x - u) / torch.sqrt(s + self.variance_epsilon) |
| 36 | return self.weight * x.to(pdtype) + self.bias |
| 37 | |
| 38 | |
| 39 | class QuickGELU(nn.Module): |