If you want to reshape the tensor using .view(), you definitely need to call .contiguous(). The call is necessary even if you don’t slice after permuting. Check the following example:
test = torch.range(0, 5).view(2, 3)
perm = test.permute(1, 0)
# the following line produces a RuntimeError
perm.view(2, 3)
# but this will work
perm.contiguous().view(2, 3)