torch.compile (inductor)
PyTorch · python · MIT
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 46 lines, MIT.
46_Average_Pooling_3D.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l1-46-average-pooling-3d-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:fec623a6f0e4958a83b0df873a7bbed62c4659ea64eca0edbc797f60434a103d
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
46_Average_Pooling_3D.py46 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Simple model that performs 3D 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 kernel to apply pooling.
stride (int, optional): Stride of the pooling operation. Defaults to None, which uses the kernel size.
padding (int, optional): Padding to apply before pooling. Defaults to 0.
"""
super(Model, self).__init__()
self.avg_pool = nn.AvgPool3d(kernel_size=kernel_size, stride=stride, padding=padding)
def forward(self, x: torch.Tensor) -> torch.Tensor:
"""
Applies Average Pooling to the input tensor.
Args:
x (torch.Tensor): Input tensor of shape (batch_size, channels, depth, height, width).
Returns:
torch.Tensor: Output tensor with Average Pooling applied, shape depends on kernel_size, stride and padding.
"""
return self.avg_pool(x)
batch_size = 16
channels = 32
depth = 128
height = 128
width = 256
kernel_size = 3
stride = 2
padding = 1
def get_inputs():
x = torch.rand(batch_size, channels, depth, height, width)
return [x]
def get_init_inputs():
return [kernel_size, stride, padding]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