Skip to content
KernelIndex
Search⌘K

PyTorch eager

PyTorch · python · MIT

Use it

Vendorable · source mirrored · MITView source →

No package. Vendor the mirrored source: 29 lines, MIT.

25_Conv2d_Min_Tanh_Tanh.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l2-25-conv2d-min-tanh-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
Conv2d Min Tanh Tanhfp32 · [128, 16, 256, 256]
NVIDIA H100
6.48ms±0.00
#2 of 2
2026-03-05
Conv2d Min Tanh Tanhfp32 · [128, 16, 256, 256]
NVIDIA H100
9.82ms±0.05
#2 of 2
2026-03-05

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:9b87cfc32ec2b327066dd1fbea9283ff037c0b3adfb908924315c36a91b67432
license declaredMIT
license concludedMIT
imported2026-08-26

Kernel source

25_Conv2d_Min_Tanh_Tanh.py29 lines
import torch
import torch.nn as nn

class Model(nn.Module):
    """
    Model that performs a convolution, applies minimum operation, Tanh, and another Tanh.
    """
    def __init__(self, in_channels, out_channels, kernel_size):
        super(Model, self).__init__()
        self.conv = nn.Conv2d(in_channels, out_channels, kernel_size)

    def forward(self, x):
        x = self.conv(x)
        x = torch.min(x, dim=1, keepdim=True)[0] # Apply minimum operation along the channel dimension
        x = torch.tanh(x)
        x = torch.tanh(x)
        return x

batch_size = 128
in_channels = 16
out_channels = 64
height = width = 256
kernel_size = 3

def get_inputs():
    return [torch.rand(batch_size, in_channels, height, width)]

def get_init_inputs():
    return [in_channels, out_channels, kernel_size]
scrolls · 29 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