forked from ccf-ai-infra/GPUCodeForces
25 lines
607 B
Python
25 lines
607 B
Python
import torch
|
|
import torch.nn as nn
|
|
|
|
class Model(nn.Module):
|
|
def __init__(self, scale: torch.Tensor, bias: torch.Tensor):
|
|
super(Model, self).__init__()
|
|
self.scale = nn.Parameter(scale)
|
|
self.bias = nn.Parameter(bias)
|
|
|
|
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
z = x * self.scale.view(1,-1) + self.bias.view(1,-1)
|
|
g = torch.nn.functional.logsigmoid(z)
|
|
return x * g
|
|
|
|
B, D = 64, 8192
|
|
|
|
def get_inputs():
|
|
x = torch.randn(B, D)
|
|
return [x]
|
|
|
|
def get_init_inputs():
|
|
scale = torch.randn(D)
|
|
bias = torch.randn(D)
|
|
return [scale, bias]
|