Skip to content

Reverse Cumulative Sum #33520

@lematt1991

Description

@lematt1991

🚀 Feature

Add reverse option to torch.cumsum, such as in tensorflow

Motivation

This would compute right to left cumulative sum more efficiently. Currently, as far as I know, the only way to do it is

x = torch.arange(9).view(3, 3)
r2lcumsum = th.flip(th.cumsum(th.flip(x, [1]), 1), [1])

Result should be:

tensor([[ 3,  3,  2],
        [12,  9,  5],
        [21, 15,  8]])

Pitch

Add reverse arg to native cumsum function

Alternatives

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    function requestA request for a new function or the addition of new arguments/modes to an existing function.triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions