torch.compile (inductor)
PyTorch · python · MIT
Kernel source · 29 lines ↓holds 2 records
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 29 lines, MIT.
39_Gemm_Scale_BatchNorm.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l2-39-gemm-scale-batchnorm-torch-compile-inductor?include=source"interfacepython · torch_compile_inductor
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:41bc4f01ef6a884fe2e31b43a99ccf57ba075877558a91507145d593bda89757
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
39_Gemm_Scale_BatchNorm.py29 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Simple model that performs a matrix multiplication, scales the result, and applies batch normalization.
"""
def __init__(self, in_features, out_features, scale_shape, eps=1e-5, momentum=0.1):
super(Model, self).__init__()
self.gemm = nn.Linear(in_features, out_features)
self.scale = nn.Parameter(torch.randn(scale_shape))
self.bn = nn.BatchNorm1d(out_features, eps=eps, momentum=momentum)
def forward(self, x):
x = self.gemm(x)
x = x * self.scale
x = self.bn(x)
return x
batch_size = 16384
in_features = 4096
out_features = 4096
scale_shape = (out_features,)
def get_inputs():
return [torch.rand(batch_size, in_features)]
def get_init_inputs():
return [in_features, out_features, scale_shape]scrolls · 29 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