burn icon indicating copy to clipboard operation
burn copied to clipboard

[Tensor] Add `cumsum` operation

Open laggui opened this issue 9 months ago • 1 comments

Implement cumulative sum across an input dimension.

Example:

let x = Tensor::arange(0..6 as i64, &device);
x.cumsum(0)
// [ 0,  1,  3,  6, 10, 15]

laggui avatar May 03 '24 14:05 laggui

cumprod has also been asked for twice on discord: https://discord.com/channels/1038839012602941528/1038839013735399547/1234609825619644477 https://discord.com/channels/1038839012602941528/1091796857996451942/1202670351322972302

let x = Tensor::arange(1..7 as i64, &device);
x.cumsum(0)
// [ 1,  2,  6,  24, 120, 720]

louisfd avatar May 03 '24 16:05 louisfd