| 47 | |
| 48 | # feedforward |
| 49 | class GEGLU(nn.Module): |
| 50 | def __init__(self, dim_in, dim_out): |
| 51 | super().__init__() |
| 52 | self.proj = nn.Linear(dim_in, dim_out * 2) |
| 53 | |
| 54 | def forward(self, x): |
| 55 | x, gate = self.proj(x).chunk(2, dim=-1) |
| 56 | return x * F.gelu(gate) |
| 57 | |
| 58 | |
| 59 | class FeedForward(nn.Module): |