array-api-compat icon indicating copy to clipboard operation
array-api-compat copied to clipboard

torch `take_along_axis` does not support negative indices

Open mdhaber opened this issue 1 month ago • 1 comments

The standard states that take_along_axis must support negative indices as usual, but:

from array_api_compat import torch as xp
xp.take_along_axis(xp.asarray([1]), xp.asarray([-1]))
# RuntimeError: index -1 is out of bounds for dimension 0 with size 1

mdhaber avatar Nov 03 '25 22:11 mdhaber

cf https://github.com/data-apis/array-api-compat/pull/361 for a fix and https://github.com/data-apis/array-api-tests/pull/397 for a test.

Would be helpful if you could test-drive gh-361 @mdhaber

ev-br avatar Nov 22 '25 15:11 ev-br