PyTorch eager
PyTorch · python · MIT
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 37 lines, MIT.
37_FrobeniusNorm_.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l1-37-frobeniusnorm-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:a2500091d1c22c0b4f74a85271f15a195069d94b76af502082b08c3a5d00bfb4
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
37_FrobeniusNorm_.py37 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
Simple model that performs Frobenius norm normalization.
"""
def __init__(self):
"""
Initializes the Frobenius norm normalization layer.
"""
super(Model, self).__init__()
def forward(self, x: torch.Tensor) -> torch.Tensor:
"""
Applies Frobenius norm normalization to the input tensor.
Args:
x (torch.Tensor): Input tensor of arbitrary shape.
Returns:
torch.Tensor: Output tensor with Frobenius norm normalization applied, same shape as input.
"""
norm = torch.norm(x, p='fro')
return x / norm
batch_size = 112
features = 64
dim1 = 512
dim2 = 512
def get_inputs():
x = torch.rand(batch_size, features, dim1, dim2)
return [x]
def get_init_inputs():
return []scrolls · 37 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