torch.compile (inductor)
PyTorch · python · MIT
Kernel source · 31 lines ↓holds 1 record
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 31 lines, MIT.
95_Matmul_Add_Swish_Tanh_GELU_Hardtanh.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l2-95-matmul-add-swish-tanh-gelu-hardtanh-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
Reported · How evidence levels are derived →
Source and license
sourceavailable
revision digestsha256:df4c59e6ef5c5f16bdbcf30b3ee80de5c9e5f10d1fc6ec1612cf9a8fee13b9fe
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
95_Matmul_Add_Swish_Tanh_GELU_Hardtanh.py31 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Simple model that performs a matrix multiplication, adds a value, applies Swish, Tanh, GELU, and Hardtanh activation functions.
"""
def __init__(self, in_features, out_features, add_value_shape):
super(Model, self).__init__()
self.matmul = nn.Linear(in_features, out_features)
self.add_value = nn.Parameter(torch.randn(add_value_shape))
def forward(self, x):
x = self.matmul(x)
x = x + self.add_value
x = torch.sigmoid(x) * x # Swish
x = torch.tanh(x)
x = torch.nn.functional.gelu(x) # GELU
x = torch.nn.functional.hardtanh(x, min_val=-1, max_val=1) # Hardtanh
return x
batch_size = 1024
in_features = 8192
out_features = 8192
add_value_shape = (out_features,)
def get_inputs():
return [torch.rand(batch_size, in_features)]
def get_init_inputs():
return [in_features, out_features, add_value_shape]scrolls · 31 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