torch.zeros(2,4,4,6).diagonal(0,1,2).shape
torch.Size([2, 6, 4])
torch.zeros(2,4,4,6).diagonal(0,1,2).stride()
(96, 1, 30)

Note the peculiar stride 30, diagonal() is returning a specially constructed view onto input’s memory. Hence, contiguous() is needed regardless of dimensions’ ordering, if you want to copy & compact the output.