torch.compile (inductor)
PyTorch · python · MIT
Kernel source · 38 lines ↓holds 1 record
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 38 lines, MIT.
55_Matmul_MaxPool_Sum_Scale.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l2-55-matmul-maxpool-sum-scale-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:df478a906e1f9daf2775b82dea97510a03e6e824fe74c4845a11e2fd6b20a32f
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
55_Matmul_MaxPool_Sum_Scale.py38 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Model that performs matrix multiplication, max pooling, sum, and scaling.
"""
def __init__(self, in_features, out_features, kernel_size, scale_factor):
super(Model, self).__init__()
self.matmul = nn.Linear(in_features, out_features)
self.max_pool = nn.MaxPool1d(kernel_size)
self.scale_factor = scale_factor
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.matmul(x)
x = self.max_pool(x.unsqueeze(1)).squeeze(1)
x = torch.sum(x, dim=1)
x = x * self.scale_factor
return x
batch_size = 128
in_features = 32768
out_features = 32768
kernel_size = 2
scale_factor = 0.5
def get_inputs():
return [torch.rand(batch_size, in_features)]
def get_init_inputs():
return [in_features, out_features, kernel_size, scale_factor]scrolls · 38 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