PyTorch eager
PyTorch · python · MIT
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 43 lines, MIT.
3_DeepNarrowMLP.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l3-3-deepnarrowmlp-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:71094c4ecf22cd77164331db2f273cb167ee7e41a743fc37dee7861d4dc568c7
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
3_DeepNarrowMLP.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 = 1024
input_size = 8192
hidden_layer_sizes = [1024] * 16 # deep network with wider layers
output_size = 8192
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