forked from ccf-ai-infra/GPUCodeForces
28 lines
585 B
Python
28 lines
585 B
Python
# upsample_torch.py
|
|
import torch
|
|
import torch.nn as nn
|
|
import torch.nn.functional as F
|
|
|
|
BATCH_SIZE = 16
|
|
CHANNELS = 64
|
|
H_IN, W_IN = 128, 128
|
|
SCALE_FACTOR = 2
|
|
|
|
class Model(nn.Module):
|
|
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.upsample = nn.UpsamplingNearest2d(scale_factor=SCALE_FACTOR)
|
|
|
|
def forward(self, input: torch.Tensor) -> torch.Tensor:
|
|
|
|
return self.upsample(input)
|
|
|
|
def get_inputs():
|
|
|
|
input_tensor = torch.randn(BATCH_SIZE, CHANNELS, H_IN, W_IN, dtype=torch.float32)
|
|
return [input_tensor]
|
|
|
|
def get_init_inputs():
|
|
|
|
return [] |