torch.compile (inductor)
PyTorch · python · MIT
Kernel source · 35 lines ↓holds 2 records
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 35 lines, MIT.
38_L1Norm_.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l1-38-l1norm-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.
Reported · How evidence levels are derived →
Source and license
sourceavailable
revision digestsha256:ef23d6f9ef94ca1a5a982f34af9675ca149d9701f4984801eda03c83c099d6a8
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
38_L1Norm_.py35 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Simple model that performs L1 normalization.
"""
def __init__(self):
"""
Initializes the L1 normalization layer.
"""
super(Model, self).__init__()
def forward(self, x: torch.Tensor) -> torch.Tensor:
"""
Applies L1 normalization to the input tensor.
Args:
x (torch.Tensor): Input tensor of shape (..., dim, ...).
Returns:
torch.Tensor: Output tensor with L1 normalization applied, same shape as input.
"""
return x / torch.mean(torch.abs(x), dim=1, keepdim=True)
batch_size = 32768
# choose dim so total <2^31
dim = 65535
def get_inputs():
x = torch.rand(batch_size, dim)
return [x]
def get_init_inputs():
return []scrolls · 35 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