Iterate over all tensor permuation in speceific dim

hello,
Given a tensor of shape Original = [A , B , C]
I want to build a list of tensors (target) in the following way:
the first element (a) = Original.
the second element (b), b = same as Original but the tensors are shifted by 1, meaning b[0 , : , :] = a[1 , : , : ]
the third element ©, c = same data as Origial but the tensors are shifted by 2 (c[0 , : , :] = a[2 , : , :]
this will results a list of size A since we are shifting the tensors each time by 1 until we get to the original tensor (original).

Hi Ameen!

Does torch.roll() do part of what you want?

Best.

K. Frank

1 Like