torch.compile (inductor)
PyTorch · python · MIT
Kernel source · 45 lines ↓holds 1 record
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 45 lines, MIT.
82_conv_depthwise_2D_square_input_square_kernel.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l1-82-conv-depthwise-2d-square-input-square-kernel-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
conv depthwise 2D square input square kernelfp32 · [16, 64, 512, 512]
NVIDIA H100
2.48ms±0.02
#1 of 2
2026-03-05
conv depthwise 2D square input square kernelfp32 · [16, 64, 512, 512]
NVIDIA H100
3.95ms±0.00
#2 of 2
2026-03-05
Reported · How evidence levels are derived →
Source and license
sourceavailable
revision digestsha256:4f167840b7e08c788c6c8f700d7a745a172bf52c1aaf74fa950d886c4141a8d2
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
82_conv_depthwise_2D_square_input_square_kernel.py45 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Performs a depthwise 2D convolution operation with square input and square kernel.
Args:
in_channels (int): Number of channels in the input tensor.
kernel_size (int): Size of the convolution kernel.
stride (int, optional): Stride of the convolution. Defaults to 1.
padding (int, optional): Padding applied to the input. Defaults to 0.
bias (bool, optional): If `True`, adds a learnable bias to the output. Defaults to `False`.
"""
def __init__(self, in_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, bias: bool = False):
super(Model, self).__init__()
self.conv2d = nn.Conv2d(in_channels, in_channels, kernel_size, stride=stride, padding=padding, groups=in_channels, bias=bias)
def forward(self, x: torch.Tensor) -> torch.Tensor:
"""
Performs the depthwise 2D convolution.
Args:
x (torch.Tensor): Input tensor of shape (batch_size, in_channels, height, width).
Returns:
torch.Tensor: Output tensor of shape (batch_size, in_channels, height_out, width_out).
"""
return self.conv2d(x)
# Test code
batch_size = 16
in_channels = 64
kernel_size = 3
width = 512
height = 512
stride = 1
padding = 0
def get_inputs():
x = torch.rand(batch_size, in_channels, height, width)
return [x]
def get_init_inputs():
return [in_channels, kernel_size, stride, padding]scrolls · 45 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