---
title: "cumulativeSum(alongAxis:)"
framework: coreml
role: symbol
role_heading: Instance Method
path: "coreml/mltensor/cumulativesum(alongaxis:)"
---

# cumulativeSum(alongAxis:)

Computes the cumulative sum along the specified axis.

## Declaration

```swift
func cumulativeSum(alongAxis axis: Int = 0) -> MLTensor
```

## Parameters

- `axis`: The axis along which to perform the cumulative sum. The default value is 0. Must be in the range [-rank, rank) and have a rank greater than zero.

## Return Value

Return Value The result of the cumulative sum operation.

## Discussion

Discussion The scalar type of the tensor must be numeric. For example: MLTensor([1, 2, 3]).cumulativeSum() = [1, 1 + 2, 1 + 2 + 3]

## See Also

### Computing the cumulative value

- [cumulativeProduct(alongAxis:)](coreml/mltensor/cumulativeproduct(alongaxis:).md)
