PyTorch eager
PyTorch · python · MIT
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 35 lines, MIT.
97_Matmul_BatchNorm_BiasAdd_Divide_Swish.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l2-97-matmul-batchnorm-biasadd-divide-swish-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:4cfdca16e94fe337e7e072231b95c80a7b351a0996274432fca47396e1fced48
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
97_Matmul_BatchNorm_BiasAdd_Divide_Swish.py35 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Model that performs a matrix multiplication, batch normalization, bias addition, division, and Swish activation.
"""
def __init__(self, in_features, out_features, bn_eps=1e-5, bn_momentum=0.1, bias_shape=(1,), divide_value=1.0):
super(Model, self).__init__()
self.matmul = nn.Linear(in_features, out_features)
self.bn = nn.BatchNorm1d(out_features, eps=bn_eps, momentum=bn_momentum)
self.bias = nn.Parameter(torch.randn(bias_shape))
self.divide_value = divide_value
def forward(self, x):
x = self.matmul(x)
x = self.bn(x)
x = x + self.bias
x = x / self.divide_value
x = x * torch.sigmoid(x)
return x
batch_size = 1024
in_features = 8192
out_features = 8192
bn_eps = 1e-5
bn_momentum = 0.1
bias_shape = (1,)
divide_value = 1.0
def get_inputs():
return [torch.rand(batch_size, in_features)]
def get_init_inputs():
return [in_features, out_features, bn_eps, bn_momentum, bias_shape, divide_value]scrolls · 35 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