PyTorch eager
PyTorch · python · MIT
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 46 lines, MIT.
85_Conv2d_GroupNorm_Scale_MaxPool_Clamp.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l2-85-conv2d-groupnorm-scale-maxpool-clamp-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
Conv2d GroupNorm Scale MaxPool Clampfp32 · [128, 8, 128, 128]
NVIDIA H100
2.51ms±0.00
#2 of 2
2026-03-05
Conv2d GroupNorm Scale MaxPool Clampfp32 · [128, 8, 128, 128]
NVIDIA H100
3.61ms±0.01
#2 of 2
2026-03-05
Reported · How evidence levels are derived →
Source and license
sourceavailable
revision digestsha256:8831b3261e6fff2e7d91c6dc9b2b3d41ea501038765bcf02802dce6a0ae18c65
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
85_Conv2d_GroupNorm_Scale_MaxPool_Clamp.py46 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Model that performs convolution, group normalization, scaling, max pooling, and clamping.
"""
def __init__(self, in_channels, out_channels, kernel_size, num_groups, scale_shape, maxpool_kernel_size, clamp_min, clamp_max):
super(Model, self).__init__()
self.conv = nn.Conv2d(in_channels, out_channels, kernel_size)
self.group_norm = nn.GroupNorm(num_groups, out_channels)
self.scale = nn.Parameter(torch.ones(scale_shape))
self.maxpool = nn.MaxPool2d(kernel_size=maxpool_kernel_size)
self.clamp_min = clamp_min
self.clamp_max = clamp_max
def forward(self, x):
"""
Args:
x: Input tensor of shape (batch_size, in_channels, height, width).
Returns:
Output tensor of shape (batch_size, out_channels, height', width').
"""
x = self.conv(x)
x = self.group_norm(x)
x = x * self.scale
x = self.maxpool(x)
x = torch.clamp(x, self.clamp_min, self.clamp_max)
return x
batch_size = 128
in_channels = 8
out_channels = 64
height, width = 128, 128
kernel_size = 3
num_groups = 16
scale_shape = (out_channels, 1, 1)
maxpool_kernel_size = 4
clamp_min = 0.0
clamp_max = 1.0
def get_inputs():
return [torch.rand(batch_size, in_channels, height, width)]
def get_init_inputs():
return [in_channels, out_channels, kernel_size, num_groups, scale_shape, maxpool_kernel_size, clamp_min, clamp_max]scrolls · 46 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