PyTorch eager
PyTorch · python · MIT
Use it
Vendorable · source mirrored · MITView source →
No package. Vendor the mirrored source: 44 lines, MIT.
90_cumprod.py
curl "https://kernelindex.com/api/v1/implementations/kernelbench-l1-90-cumprod-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.
Reported · How evidence levels are derived →
Source and license
sourceavailable
revision digestsha256:7284a599600fa5b59f3450c6ae2ea1e9d1ff44b5a37b9ec1b6fa5714705a16fa
license declaredMIT
license concludedMIT
imported2026-08-26
Kernel source
90_cumprod.py44 lines
import torch
import torch.nn as nn
class Model(nn.Module):
"""
A model that performs a cumulative product operation along a specified dimension.
Parameters:
dim (int): The dimension along which to perform the cumulative product operation.
"""
def __init__(self, dim):
"""
Initialize the CumulativeProductModel.
Args:
dim (int): The dimension along which to perform the cumulative product.
"""
super(Model, self).__init__()
self.dim = dim
def forward(self, x):
"""
Forward pass, computing the cumulative product along the specified dimension.
Args:
x (torch.Tensor): Input tensor of shape (batch_size, *input_shape).
Returns:
torch.Tensor: Tensor of the same shape as `x` after applying cumulative product along `dim`.
"""
return torch.cumprod(x, dim=self.dim)
# Define input dimensions and parameters
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 · 44 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