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 | Bind key | Logical dtype | Rank | Shape | Description | Presence |
|---|---|---|---|---|---|---|
x |
x |
T |
— | — | Input tensor to accumulate. | required |
Outputs
| Name | Bind key | Logical dtype | Rank | Shape | Description | Presence |
|---|---|---|---|---|---|---|
y |
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 | Semantic | Description | Presence |
|---|---|---|---|---|
axis |
i32 |
axis |
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
metadata.json— kernel metadata (id, digests, provenance)manifest.json— the op contract (source of truth)test.json— correctness casesbench.json— benchmark + tuning casescumsum-splitk-carry.wgsl.jinjacumsum-splitk-scan-vec4.wgsl.jinjacumsum-splitk-scan.wgsl.jinjacumsum-splitk-totals-vec4.wgsl.jinjacumsum-splitk-totals.wgsl.jinjacumsum-strided-row.wgsl.jinjascan-row-chunked-vec4.wgsl.jinjascan-row-chunked.wgsl.jinjascan-thread-row.wgsl.jinja
Use with @huggingface/kernels
The loader derives every required output's shape and logical dtype from the manifest contract and this call. It then allocates the result tensors automatically.
The version: 1 option selects the published kernel contract; it is independent of any operator opset, contrib since_version, or model 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
- -
Requires WebGPU support. See the compatibility table.