Map-Det3D / mapdet3d /op /layer /activation.py
RoyYang0714's picture
feat: Add the Gradio demo for Map-Det3D.
0122a25
Raw
History Blame Contribute Delete
506 Bytes
"""Activation functions."""
import torch.nn.functional as F
from torch import Tensor, nn
class SwiGLU(nn.Module):
"""SwiGLU activation function."""
def forward(self, x: Tensor) -> Tensor:
"""Forward pass."""
x, gates = x.chunk(2, dim=-1)
return x * F.silu(gates)
class GEGLU(nn.Module):
"""GEGLU activation function."""
def forward(self, x: Tensor) -> Tensor:
"""Forward pass."""
x, gates = x.chunk(2, dim=-1)
return x * F.gelu(gates)