UniK3D-demo / unik3d /layers /activation.py
Luigi Piccinelli
init demo
1ea89dd
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)