23 lines
501 B
Python
23 lines
501 B
Python
import torch
|
|
import torch.nn as nn
|
|
import torch.nn.functional as F
|
|
|
|
class Model(nn.Module):
|
|
def __init__(self, bias: torch.Tensor):
|
|
super(Model, self).__init__()
|
|
self.register_buffer("bias", bias)
|
|
|
|
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
return F.gelu(x + self.bias, approximate='tanh')
|
|
|
|
batch_size = 16
|
|
dim = 16384
|
|
|
|
def get_inputs():
|
|
x = torch.randn(batch_size, dim)
|
|
return [x]
|
|
|
|
def get_init_inputs():
|
|
bias = torch.randn(dim)
|
|
return [bias]
|