PyTorch eager
PyTorch · python · MIT
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 35 lines, MIT.
31_Conv2d_Min_Add_Multiply.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l2-31-conv2d-min-add-multiply-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:745233fdf5b4103c2a44388fc837581288cb8d68d2c2ff868ea146fc51653c50
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
31_Conv2d_Min_Add_Multiply.py35 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Simple model that performs a convolution, takes the minimum with a constant, adds a bias term, and multiplies by a scaling factor.
"""
def __init__(self, in_channels, out_channels, kernel_size, constant_value, bias_shape, scaling_factor):
super(Model, self).__init__()
self.conv = nn.Conv2d(in_channels, out_channels, kernel_size)
self.constant_value = constant_value
self.bias = nn.Parameter(torch.randn(bias_shape))
self.scaling_factor = scaling_factor
def forward(self, x):
x = self.conv(x)
x = torch.min(x, torch.tensor(self.constant_value))
x = x + self.bias
x = x * self.scaling_factor
return x
batch_size = 128
in_channels = 64
out_channels = 128
height = width = 128
kernel_size = 3
constant_value = 0.5
bias_shape = (out_channels, 1, 1)
scaling_factor = 2.0
def get_inputs():
return [torch.rand(batch_size, in_channels, height, width)]
def get_init_inputs():
return [in_channels, out_channels, kernel_size, constant_value, bias_shape, scaling_factor]scrolls · 35 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