torch.compile (inductor)
PyTorch · python · MIT
Kernel source · 39 lines ↓holds 2 records
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 39 lines, MIT.
84_Gemm_BatchNorm_Scaling_Softmax.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l2-84-gemm-batchnorm-scaling-softmax-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:d2be8e155017cf686612568376a5c63fd29305a4aa5b6af3536ef6027beadd36
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
84_Gemm_BatchNorm_Scaling_Softmax.py39 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Model that performs a matrix multiplication (Gemm), Batch Normalization, scaling, and Softmax.
"""
def __init__(self, in_features, out_features, bn_eps=1e-5, bn_momentum=0.1, scale_shape=(1,)):
super(Model, self).__init__()
self.gemm = nn.Linear(in_features, out_features)
self.bn = nn.BatchNorm1d(out_features, eps=bn_eps, momentum=bn_momentum)
self.scale = nn.Parameter(torch.ones(scale_shape))
self.softmax = nn.Softmax(dim=1)
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.bn(x)
x = self.scale * x
x = self.softmax(x)
return x
batch_size = 1024
in_features = 8192
out_features = 8192
bn_eps = 1e-5
bn_momentum = 0.1
scale_shape = (1,)
def get_inputs():
return [torch.rand(batch_size, in_features)]
def get_init_inputs():
return [in_features, out_features, bn_eps, bn_momentum, scale_shape]scrolls · 39 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