forked from ccf-ai-infra/GPUCodeForces
31 lines
545 B
Python
31 lines
545 B
Python
import torch
|
|
import torch.nn as nn
|
|
import torch.nn.functional as F
|
|
|
|
|
|
class Model(nn.Module):
|
|
|
|
def __init__(self):
|
|
super().__init__()
|
|
|
|
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
"""
|
|
GeGLU(x) = GELU(gate) * act
|
|
"""
|
|
gate, act = x.chunk(2, dim=-1)
|
|
|
|
return F.gelu(gate) * act
|
|
|
|
|
|
batch_size = 4096
|
|
feature_dim = 4096
|
|
|
|
|
|
def get_inputs():
|
|
x = torch.randn(batch_size, feature_dim, dtype=torch.float32)
|
|
return [x]
|
|
|
|
|
|
def get_init_inputs():
|
|
return []
|