PyTorch eager
PyTorch · python · MIT
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 28 lines, MIT.
57_Conv2d_ReLU_HardSwish.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l2-57-conv2d-relu-hardswish-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:3beae59107fa7c05c12e518d3ade7ef55482e8e557f06c4e59759abf9b4f548b
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
57_Conv2d_ReLU_HardSwish.py28 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Simple model that performs a convolution, applies ReLU, and applies HardSwish activation.
"""
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.relu(x)
x = x * torch.clamp((x + 3) / 6, 0, 1)
return x
batch_size = 128
in_channels = 8
out_channels = 64
height, width = 128, 128
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]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