ai.onnx.CumSum

ai.onnx · standard ONNX operator · ONNX opset ≥ 14

Description

Computes the cumulative sum of elements along a specified axis. By default, the sum is inclusive (each output element includes itself); setting exclusive to 1 excludes the current element, and setting reverse to 1 scans in the opposite direction.

See the ONNX CumSum spec for the reference semantics.

Inputs

Name Logical dtype Rank Shape Description Presence
x T Input tensor to accumulate. required

Outputs

Name Logical dtype Rank Shape Description Presence
y T same as x same as x Output tensor of the same shape and type as x, containing cumulative sums along the specified axis. required

Runtime arguments

Name Kind Description Presence
axis i32 Axis along which to accumulate; negative values count from the back. required

Attributes

Default values (overridable per request):

Attribute Default Description
exclusive 0 If 1, the j-th output element is the sum of the first (j-1) input elements, excluding the j-th element itself; defaults to 0 (inclusive).
reverse 0 If 1, performs the cumulative sum scanning in the reverse direction along the axis; defaults to 0.

Type constraints

Variable Allowed dtypes
T float32, float16, int32, uint32

Files

Use with @huggingface/kernels

npm install --save-exact @huggingface/kernels@0.0.1-preview.2

Required output shapes and logical data types are inferred from the supplied inputs and attributes; result tensors are allocated automatically.

The version: 1 option selects the published kernel contract; it is independent of any operator opset, contrib since_version, or model version. It follows the v1 branch as fixes land. To pin exact artifact bytes, pass a 40-character commit revision instead of version.

Replace each *Data placeholder with a typed array containing the corresponding input data.

import { getKernel } from "@huggingface/kernels";

const kernel = await getKernel("webgpu-kernels/ai.onnx.CumSum", { version: 1 });
const { y } = await kernel({ x: { data: xData, shape: [5] }, axis: 0 });
Downloads last month
-
kernel
webgpu
wgsl
apache-2.0
WebGPU

Requires WebGPU support. See the compatibility table.