Skip to content
KernelIndex
Search⌘K

torch.compile (inductor)

PyTorch · python · MIT

Use it

Vendorable · source mirrored · MITView source →

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

92_cumsum_exclusive.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l1-92-cumsum-exclusive-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.

Operation / workload
Hardware
Latency
Rank
Observed
cumsum exclusivefp32 · [32768, 32768]
NVIDIA H100
3.15ms±0.03
#1 of 2
2026-03-05
cumsum exclusivefp32 · [32768, 32768]
NVIDIA H100
7.37ms±0.02
#1 of 2
2026-03-05

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:d600945c5d8c1654b24481649689072795b1a48666e7bc4a8b216a4bf305d8d8
license declaredMIT
license concludedMIT
imported2026-08-26

Kernel source

92_cumsum_exclusive.py29 lines
import torch
import torch.nn as nn

class Model(nn.Module):
    """
    A model that performs an exclusive cumulative sum (does not include the current element).

    Parameters:
        dim (int): The dimension along which to perform the exclusive cumulative sum.
    """

    def __init__(self, dim):
        super(Model, self).__init__()
        self.dim = dim

    def forward(self, x):
        cumsum = torch.cumsum(x.narrow(dim=self.dim, start=0, length=x.size(self.dim)-1), dim=self.dim)
        return torch.cat((torch.zeros_like(x.select(self.dim, 0).unsqueeze(self.dim)), cumsum), dim=self.dim)

batch_size = 32768
input_shape = (32768,)
dim = 1

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

def get_init_inputs():
    return [dim]
scrolls · 29 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