Skip to content

torch.arange type #2812

@glample

Description

@glample

torch.arange has a different behavior than np.arange
torch.arange(0, 10) returns a FloatTensor, but shouldn't it be a LongTensor?
Also, torch.arange(10), which I would expect to behave like torch.arange(0, 10), fails, and returns:

TypeError: torch.arange received an invalid combination of arguments - got (float), but expected one of:
 * (float start, float end)
 * (float start, float end, float step)

np.arange can also take float as input, and in that case will return a float array instead of a int64 array. Could we have something similar in pytorch? If inputs are int, return a LongTensor, if they are float, return a FloatTensor?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions