Skip to content

arange should return empty array if bounds are inconsistent with step sign #70915

@pmeier

Description

@pmeier

The array API specification stipulates that the following should hold for the return value of torch.arange:

The length of the output array must be ceil((stop-start)/step) if stop - start and step have the same sign, and length 0 otherwise. We currently bail out:

>>> torch.arange(1, 0)
RuntimeError: upper bound and larger bound inconsistent with step sign

cc @gchanan @mruberry @rgommers @pmeier @asmeurer @leofang @AnirudhDagar @asi1024 @emcastillo @kmaehashi

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: python array apiIssues related to the Python Array APImodule: tensor creationtriagedThis 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