PyTorch eager
PyTorch · python · MIT
Kernel source · 31 lines ↓holds 2 records
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 31 lines, MIT.
9_Matmul_Subtract_Multiply_ReLU.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l2-9-matmul-subtract-multiply-relu-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:1a60c4a96ac2d12fabef4090533982a8d48e439cbdfe84e81648377dc2c22332
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
9_Matmul_Subtract_Multiply_ReLU.py31 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Model that performs a matrix multiplication, subtraction, multiplication, and ReLU activation.
"""
def __init__(self, in_features, out_features, subtract_value, multiply_value):
super(Model, self).__init__()
self.linear = nn.Linear(in_features, out_features)
self.subtract_value = subtract_value
self.multiply_value = multiply_value
def forward(self, x):
x = self.linear(x)
x = x - self.subtract_value
x = x * self.multiply_value
x = torch.relu(x)
return x
batch_size = 1024
in_features = 8192
out_features = 8192
subtract_value = 2.0
multiply_value = 1.5
def get_inputs():
return [torch.rand(batch_size, in_features)]
def get_init_inputs():
return [in_features, out_features, subtract_value, multiply_value]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