torch.compile (inductor)
PyTorch · python · MIT
Kernel source · 43 lines ↓holds 1 record
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 43 lines, MIT.
45_Average_Pooling_2D.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l1-45-average-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:2b7892533b4993c8bb710014884d47ca2570542d577e83967a1b4cf6103d661a
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
45_Average_Pooling_2D.py43 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Simple model that performs 2D Average Pooling.
"""
def __init__(self, kernel_size: int, stride: int = None, padding: int = 0):
"""
Initializes the Average Pooling layer.
Args:
kernel_size (int): Size of the pooling window.
stride (int, optional): Stride of the pooling operation. Defaults to None (same as kernel_size).
padding (int, optional): Padding applied to the input tensor. Defaults to 0.
"""
super(Model, self).__init__()
self.avg_pool = nn.AvgPool2d(kernel_size=kernel_size, stride=stride, padding=padding)
def forward(self, x: torch.Tensor) -> torch.Tensor:
"""
Applies 2D Average Pooling to the input tensor.
Args:
x (torch.Tensor): Input tensor of shape (batch_size, channels, height, width).
Returns:
torch.Tensor: Output tensor with Average Pooling applied.
"""
return self.avg_pool(x)
batch_size = 16
channels = 64
height = 2048
width = 2048
kernel_size = 11
def get_inputs():
x = torch.rand(batch_size, channels, height, width)
return [x]
def get_init_inputs():
return [kernel_size]scrolls · 43 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