My understanding of Tensor View operations is that they require a contiguous tensor input to work (which intuitively makes sense). To test this behavior I performed the following test, the results of which I find confusing:
import torch

test = torch.rand([10,10])
test.is_contiguous() # True

test = test[:8,1:9] # now of size [8,8]
test.is_contiguous() # False, as expected

test.view(-1) # returns error, as expected
# RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

# confusingly, no errors from any of these operations
test.diagonal() 
test.permute(1,0)
test.unbind(1)
...


My question is, why do operations such as diagonal and permute not cause contiguous errors, despite the fact that they are Tensor View operations as listed here ?
My hypothesis is that these functions contain calls to torch.contiguous() on the inputs before performing the actual desired operation. This wouldn’t impact the performance of these calls much. I’m having trouble verifying this though because it is extremely difficult to find the source code for these operations.