summaryrefslogtreecommitdiff
path: root/text_recognizer/network/transformer/swiglu.py
blob: e61662a55b8ae193e0df62f93206ae3ca7b36a26 (plain)
1
2
3
4
5
6
7
8
from torch import nn
import torch.nn.functional as F


class SwiGLU(nn.Module):
    def forward(self, x):
        x, gate = x.chunk(2, dim=-1)
        return F.silu(gate) * x