PyTorch eager
PyTorch · python · MIT
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 44 lines, MIT.
44_Average_Pooling_1D.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l1-44-average-pooling-1d-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
Reported · How evidence levels are derived →
Source and license
sourceavailable
revision digestsha256:8fbc614615042d2b612dda2e0d27968e9fef9f0779439785e5dc72e30d04aa74
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
44_Average_Pooling_1D.py44 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Simple model that performs 1D Average Pooling.
"""
def __init__(self, kernel_size: int, stride: int = 1, padding: int = 0):
"""
Initializes the 1D Average Pooling layer.
Args:
kernel_size (int): Size of the pooling window.
stride (int, optional): Stride of the pooling operation. Defaults to 1.
padding (int, optional): Padding applied to the input tensor. Defaults to 0.
"""
super(Model, self).__init__()
self.avg_pool = nn.AvgPool1d(kernel_size=kernel_size, stride=stride, padding=padding)
def forward(self, x: torch.Tensor) -> torch.Tensor:
"""
Applies 1D Average Pooling to the input tensor.
Args:
x (torch.Tensor): Input tensor of shape (batch_size, in_channels, input_length).
Returns:
torch.Tensor: Output tensor with 1D Average Pooling applied, shape (batch_size, in_channels, output_length).
"""
return self.avg_pool(x)
batch_size = 64
in_channels = 128
input_length = 65536
kernel_size = 8
stride = 1
padding = 4
def get_inputs():
x = torch.rand(batch_size, in_channels, input_length)
return [x]
def get_init_inputs():
return [kernel_size, stride, padding]scrolls · 44 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