torch.compile (inductor)
PyTorch · python · MIT
Kernel source · 50 lines ↓holds 1 record
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 50 lines, MIT.
41_Max_Pooling_1D.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l1-41-max-pooling-1d-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:a0b90a697298b57a337badc1eee6412a994c9868cf5e6a7e0e214b4aa74ce0ce
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
41_Max_Pooling_1D.py50 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Simple model that performs Max Pooling 1D.
"""
def __init__(self, kernel_size: int, stride: int = None, padding: int = 0, dilation: int = 1, return_indices: bool = False):
"""
Initializes the Max Pooling 1D layer.
Args:
kernel_size (int): Size of the window to take a max over.
stride (int, optional): Stride of the window. Defaults to None (same as kernel_size).
padding (int, optional): Implicit zero padding to be added on both sides. Defaults to 0.
dilation (int, optional): Spacing between kernel elements. Defaults to 1.
return_indices (bool, optional): Whether to return the indices of the maximum values. Defaults to False.
"""
super(Model, self).__init__()
self.maxpool = nn.MaxPool1d(kernel_size=kernel_size, stride=stride, padding=padding, dilation=dilation, return_indices=return_indices)
def forward(self, x: torch.Tensor) -> torch.Tensor:
"""
Applies Max Pooling 1D to the input tensor.
Args:
x (torch.Tensor): Input tensor of shape (batch_size, num_features, sequence_length).
Returns:
torch.Tensor: Output tensor with Max Pooling 1D applied, shape (batch_size, num_features, output_sequence_length).
"""
return self.maxpool(x)
batch_size = 64
features = 192
sequence_length = 65536
kernel_size = 8
stride = 1
padding = 4
dilation = 3
return_indices = False
def get_inputs():
x = torch.rand(batch_size, features, sequence_length)
return [x]
def get_init_inputs():
return [kernel_size, stride, padding, dilation, return_indices]scrolls · 50 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