PyTorch eager
PyTorch · python · MIT
Kernel source · 43 lines ↓holds 1 record
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 43 lines, MIT.
2_ShallowWideMLP.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l3-2-shallowwidemlp-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:df4ca02a5a0c44465f3ce151104d68582544f05c181d6e55d91c6979c0188296
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
2_ShallowWideMLP.py43 lines
import torch
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self, input_size, hidden_layer_sizes, output_size):
"""
:param input_size: The number of input features
:param hidden_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 hidden_size in hidden_layer_sizes:
layers.append(nn.Linear(current_input_size, hidden_size))
layers.append(nn.ReLU())
current_input_size = hidden_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
hidden_layer_sizes = [32768, 32768]
output_size = 16384
def get_inputs():
return [torch.rand(batch_size, input_size)]
def get_init_inputs():
return [input_size, hidden_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