Advanced Indexing with ranges

Using the advanced indexing currently merged in master, is it possible to do something like this to crop tensors in a batch:

    x = torch.rand(2,3,4,4)   #BSxCxHxW
    y = x[[0,1],[0,1,2],[0:2, 2:4],[0:2, 2:4]]
    # OR
    y = x[[0,1],[0,1,2],[0, 2]:[2, 4],[0, 2]:[2, 4]] 

which should give the top left patch of first image and bottom right patch of second image. The statements above give errors, but is there some other way to achieve this?

Thanks :slight_smile:

At the moment, Trevor finished implemented cases like:

y = x[[0,1],[0,1,2],:, :]

Non : slicing on the non-advanced-index dimensions is not yet done.

2 Likes