PyTorch eager
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?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:5a3c24b4d8b553789cf74a5c70275df6431824b2835348cf8092a4f656ebc2cd
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