Shuffle elements of tensor

Is there a native way in pytorch to shuffle the elements of a tensor?

I tried generating a random permutation of indeces with torch.randperm() and apply it using torch.index_select() , but I was only able to to shuffle rows/columns using this technique.

you can do tensor.view(-1) to view it as a flat tensor, apply the shuffling and then view it in the original shape again

Thanks, that works! Although it feels a little bit like a workaround.