PyTorch eager
PyTorch · python · MIT
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 37 lines, MIT.
30_Gemm_GroupNorm_Hardtanh.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l2-30-gemm-groupnorm-hardtanh-torch?include=source"interfacepython · torch_eager
symbolModel.forward
Compatibility
measured onNVIDIA H100
declared hardwaredeclared only
architectures—
dtypes
Benchmark evidence
2 measurements across 1 GPU, fastest first.
Operation / workload
Hardware
Latency
Rank
Observed
Reported · How evidence levels are derived →
Source and license
sourceavailable
revision digestsha256:19a23e79912772f33938b0ba76ab52b0145b079441bf92a2c7462f05bc8354f8
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
30_Gemm_GroupNorm_Hardtanh.py37 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Simple model that performs a GEMM, applies Group Normalization, and then HardTanh.
"""
def __init__(self, in_features, out_features, num_groups, hardtanh_min, hardtanh_max):
super(Model, self).__init__()
self.gemm = nn.Linear(in_features, out_features)
self.group_norm = nn.GroupNorm(num_groups, out_features)
self.hardtanh = nn.Hardtanh(min_val=hardtanh_min, max_val=hardtanh_max)
def forward(self, x):
"""
Args:
x (torch.Tensor): Input tensor of shape (batch_size, in_features).
Returns:
torch.Tensor: Output tensor of shape (batch_size, out_features).
"""
x = self.gemm(x)
x = self.group_norm(x)
x = self.hardtanh(x)
return x
batch_size = 1024
in_features = 8192
out_features = 8192
num_groups = 16
hardtanh_min = -2.0
hardtanh_max = 2.0
def get_inputs():
return [torch.rand(batch_size, in_features)]
def get_init_inputs():
return [in_features, out_features, num_groups, hardtanh_min, hardtanh_max]scrolls · 37 lines total
Source code from KernelBench, © 2023 Anne Ouyang, Simon Guo, Azalia Mirhoseini (Scaling Intelligence Lab, Stanford University), MIT License · MIT
Best evidence level for this revision: reported
JSON