PyTorch eager
PyTorch · python · MIT
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 38 lines, MIT.
10_ConvTranspose2d_MaxPool_Hardtanh_Mean_Tanh.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l2-10-convtranspose2d-maxpool-hardtanh-mean-tanh-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
ConvTranspose2d MaxPool Hardtanh Mean Tanhfp32 · [128, 64, 256, 256]
NVIDIA H100
9.68ms±0.01
#2 of 2
2026-03-05
ConvTranspose2d MaxPool Hardtanh Mean Tanhfp32 · [128, 64, 256, 256]
NVIDIA H100
14.5ms±0.06
#2 of 2
2026-03-05
Reported · How evidence levels are derived →
Source and license
sourceavailable
revision digestsha256:6e1dc57aa74849131b3ee1f1a9fd494d6a408d1a793c6c9d69448f71de509e82
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
10_ConvTranspose2d_MaxPool_Hardtanh_Mean_Tanh.py38 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Model that performs a transposed convolution, followed by max pooling, hardtanh activation, mean operation, and tanh activation.
"""
def __init__(self, in_channels, out_channels, kernel_size, stride, padding, maxpool_kernel_size, maxpool_stride, hardtanh_min, hardtanh_max):
super(Model, self).__init__()
self.conv_transpose = nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=stride, padding=padding)
self.maxpool = nn.MaxPool2d(kernel_size=maxpool_kernel_size, stride=maxpool_stride)
self.hardtanh = nn.Hardtanh(min_val=hardtanh_min, max_val=hardtanh_max)
def forward(self, x):
x = self.conv_transpose(x)
x = self.maxpool(x)
x = self.hardtanh(x)
x = torch.mean(x, dim=(2, 3), keepdim=True)
x = torch.tanh(x)
return x
batch_size = 128
in_channels = 64
out_channels = 64
height = width = 256
kernel_size = 3
stride = 1
padding = 1
maxpool_kernel_size = 2
maxpool_stride = 2
hardtanh_min = -1
hardtanh_max = 1
def get_inputs():
return [torch.rand(batch_size, in_channels, height, width)]
def get_init_inputs():
return [in_channels, out_channels, kernel_size, stride, padding, maxpool_kernel_size, maxpool_stride, hardtanh_min, hardtanh_max]scrolls · 38 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