torch.compile (inductor)
PyTorch · python · MIT
Kernel source · 48 lines ↓holds 2 records
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 48 lines, MIT.
42_Max_Pooling_2D.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l1-42-max-pooling-2d-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:214b39aa63276aaeb6f4391dc77bbdddd458b987ab912637a8ad5e83a37f5561
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
42_Max_Pooling_2D.py48 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Simple model that performs Max Pooling 2D.
"""
def __init__(self, kernel_size: int, stride: int, padding: int, dilation: int):
"""
Initializes the Max Pooling 2D layer.
Args:
kernel_size (int): Size of the pooling window.
stride (int): Stride of the pooling window.
padding (int): Padding to be applied before pooling.
dilation (int): Spacing between kernel elements.
"""
super(Model, self).__init__()
self.maxpool = nn.MaxPool2d(kernel_size=kernel_size, stride=stride, padding=padding, dilation=dilation)
def forward(self, x: torch.Tensor) -> torch.Tensor:
"""
Applies Max Pooling 2D to the input tensor.
Args:
x (torch.Tensor): Input tensor of shape (batch_size, channels, height, width).
Returns:
torch.Tensor: Output tensor after Max Pooling 2D, shape (batch_size, channels, pooled_height, pooled_width).
"""
return self.maxpool(x)
batch_size = 32
channels = 64
height = 512
width = 512
kernel_size = 4
stride = 1
padding = 1
dilation = 1
def get_inputs():
x = torch.rand(batch_size, channels, height, width)
return [x]
def get_init_inputs():
return [kernel_size, stride, padding, dilation]
scrolls · 48 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