TileOPs-Metax/workloads/layer_norm.py

19 lines
579 B
Python

import torch
from workloads.base import WorkloadBase
class LayerNormTest(WorkloadBase):
def __init__(self, m: int, n: int, dtype: torch.dtype, eps: float = 1e-5):
self.m = m
self.n = n
self.dtype = dtype
self.eps = eps
def gen_inputs(self) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
x = torch.randn(self.m, self.n, dtype=self.dtype, device="cuda")
weight = torch.randn(self.n, dtype=self.dtype, device="cuda")
bias = torch.randn(self.n, dtype=self.dtype, device="cuda")
return x, weight, bias