PyTorch eager
PyTorch · python · MIT
Kernel source · 43 lines ↓holds 2 records
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 43 lines, MIT.
1_MLP.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l3-1-mlp-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.
Reported · How evidence levels are derived →
Source and license
sourceavailable
revision digestsha256:ba9c7283b7d0cc7a5b60e369713b95b1b8c10a27c3acaae290cad1bb90d18842
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
1_MLP.py43 lines
import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, input_size, layer_sizes, output_size):
"""
:param input_size: The number of input features
:param layer_sizes: A list of ints containing the sizes of each hidden layer
:param output_size: The number of output features
"""
super(Model, self).__init__()
layers = []
current_input_size = input_size
for layer_size in layer_sizes:
layers.append(nn.Linear(current_input_size, layer_size))
layers.append(nn.ReLU())
current_input_size = layer_size
layers.append(nn.Linear(current_input_size, output_size))
self.network = nn.Sequential(*layers)
def forward(self, x):
"""
:param x: The input tensor, shape (batch_size, input_size)
:return: The output tensor, shape (batch_size, output_size)
"""
return self.network(x)
# Test code
batch_size = 128
input_size = 16384
layer_sizes = [16384, 16384]
output_size = 8192
def get_inputs():
return [torch.rand(batch_size, input_size)]
def get_init_inputs():
return [input_size, layer_sizes, output_size]scrolls · 43 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