AFAIK, torch.Tensor object is only a view over the corresponding torch.Storage object, which actually contains contiguous data. But why when we create a new tensor object from the existing one, by slicing it for example, another torch.Storage object is created? Does it mean that the memory, in this case, is allocated again?
In another word, why running the following snippet doesn’t result in AssertionError?
import torch

tensor_1 = torch.ones(5, 5)
id1 = id(tensor_1.storage())

tensor_2 = tensor[:3, :3]
id2 = id(tensor_2.storage())

assert id1 != id2