Skip to content
KernelIndex
Search⌘K

PyTorch eager

PyTorch · python · MIT

Use it

Vendorable · source mirrored · MITView source →

No package. Vendor the mirrored source: 34 lines, MIT.

41_Gemm_BatchNorm_GELU_ReLU.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l2-41-gemm-batchnorm-gelu-relu-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
Gemm BatchNorm GELU ReLUfp32 · [16384, 4096]
NVIDIA H100
11.5ms±0.03
#2 of 2
2026-03-05
Gemm BatchNorm GELU ReLUfp32 · [16384, 4096]
NVIDIA H100
17.2ms±0.12
#2 of 2
2026-03-05

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:575602d4e230f7a5a4663bb2cda6b6ad29f4c40d9e88d42ca6842b4070d1a62d
license declaredMIT
license concludedMIT
imported2026-08-26

Kernel source

41_Gemm_BatchNorm_GELU_ReLU.py34 lines
import torch
import torch.nn as nn

class Model(nn.Module):
    """
    Model that performs a GEMM, BatchNorm, GELU, and ReLU in sequence.
    """
    def __init__(self, in_features, out_features):
        super(Model, self).__init__()
        self.gemm = nn.Linear(in_features, out_features)
        self.batch_norm = nn.BatchNorm1d(out_features)

    def forward(self, x):
        """
        Args:
            x (torch.Tensor): Input tensor of shape (batch_size, in_features).
        Returns:
            torch.Tensor: Output tensor of shape (batch_size, out_features).
        """
        x = self.gemm(x)
        x = self.batch_norm(x)
        x = torch.nn.functional.gelu(x)
        x = torch.relu(x)
        return x

batch_size = 16384
in_features = 4096
out_features = 4096

def get_inputs():
    return [torch.rand(batch_size, in_features)]

def get_init_inputs():
    return [in_features, out_features]
scrolls · 34 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