How is the pytorch Tensor data structure implemented?

Recently I found out that after creating a pytorch tensor like following,
w = torch.randn(5,10)
I can initialize any number of arbitrary number of variables inside the tensor w such as,
w.a = 1
w.b = 1.5 etc.

Can anyone point me to the use of such feature? Also if anyone can point me to the code snippet where the data structure of pytorch Tensor is defined, that will be really great! I wish to know more about it.

Thanks!
Varun

Hi,

There is no good use case for this :slight_smile:
This is a historical thing that probably shouldn’t be allowed.
Unfortunately, we cannot change this now because that would break existing code quite badly.