Demo:
a = torch.randn(10, 10)
b = a[1:, :]
a.shape
Out[45]: torch.Size([10, 10])
b.shape
Out[46]: torch.Size([9, 10])
id(a)
Out[47]: 139889952764416
id(a)
Out[48]: 139889952764416
id(b)
Out[49]: 139889948003072
id(b)
Out[50]: 139889948003072
id(a.storage())
Out[51]: 139889948211136
id(a.storage())
Out[52]: 139889948120832
id(b.storage())
Out[53]: 139889952743616
id(b.storage())
Out[54]: 139892027430848
Why is id(a.storage())
or id(b.storage())
different every time?
AND How can I tell if a
and b
here take up the same memory space?