How are pytorch tensors stored internally?

I was trying to find out more about how the pytorch tensors are encoded in the source code, but I can’t seem to find a concrete answer.
Could someone please point me to the relevant source code in C++ or Python? i.e. what happens when we run torch.tensor([1,2,3]), at a low level? Which classes are used to represent the object(s)?

Additionally, is there a way to get the bit level representation of the tensor as it is stored in memory?

1 Like

This blog post explains the internals as well as the tensor representation and might be helpful.