Open
Description
The array API specification stipulates that the slicing syntax needs to be equivalent to Pythons slice()
syntax. That includes negative step sizes that PyTorch does not support:
import torch
t = torch.rand((3,))
t[::-1]
ValueError: step must be greater than zero
Additional context
This was already proposed in #229, but finally dismissed in #229 (comment) in favor of torch.flip()
. Note that this is only a substitution for a negative step size of 1 (::-1
) rather than negative step sizes in general.