forked from ccf-ai-infra/GPUCodeForces
24 lines
568 B
Python
24 lines
568 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.register_buffer("scale", scale)
|
|
self.register_buffer("bias", bias)
|
|
|
|
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
return torch.relu(x * self.scale + self.bias)
|
|
|
|
batch_size = 16
|
|
dim = 16384
|
|
|
|
def get_inputs():
|
|
x = torch.randn(batch_size, dim)
|
|
return [x]
|
|
|
|
def get_init_inputs():
|
|
scale = torch.randn(dim)
|
|
bias = torch.randn(dim)
|
|
return [scale, bias]
|