smhh24's picture
Upload 90 files
560b597 verified
raw
history blame contribute delete
374 Bytes
import torch
import torch.nn as nn
import torch.nn.functional as F
class SwiGLU(nn.Module):
def forward(self, x: torch.Tensor) -> torch.Tensor:
x, gates = x.chunk(2, dim=-1)
return x * F.silu(gates)
class GEGLU(nn.Module):
def forward(self, x: torch.Tensor) -> torch.Tensor:
x, gates = x.chunk(2, dim=-1)
return x * F.gelu(gates)