forked from ccf-ai-infra/GPUCodeForces
23 lines
519 B
Python
23 lines
519 B
Python
import torch
|
|
import torch.nn as nn
|
|
import torch.nn.functional as F
|
|
|
|
class Model(nn.Module):
|
|
def __init__(self):
|
|
super(Model, self).__init__()
|
|
|
|
def forward(self, a, b, gate):
|
|
blended = gate * a + (1 - gate) * b
|
|
return F.normalize(blended, p=2.0, dim=-1, eps=1e-12)
|
|
|
|
batch_size = 1024
|
|
dim = 1024
|
|
|
|
def get_inputs():
|
|
a = torch.randn(batch_size, dim)
|
|
b = torch.randn(batch_size, dim)
|
|
gate = torch.rand(batch_size, dim)
|
|
return [a, b, gate]
|
|
|
|
def get_init_inputs():
|
|
return [] |