What is the application scenario for torch.Storage? When should I use it?

What is the application scenario for torch.Storage? When should I use it? I began to learn pytorch

1 Like

Hi,

torch.Storage is the data structure that is underlying a torch.Tensor.
You can see the storage as a 1D array of data in memory, and a tensor as a fancy multidimensional way to see this memory and use it.
If you are using pytorch for neural networks, you should not need to use them directly.

1 Like

Thank you. It can only be a 1 D array?
for example:Torch.FloatStorage (3)

1 Like

Hi,

Yes, anything more complex than a 1D array needs to work with Tensors.

1 Like

Thank you.
How do you change a 1D array Tensor to Storage?

Tensors have a .storage() method that returns the underlying storage.

1 Like

Thank you.
I probably know. What’s the advanced usage of it?

There is not really a advance usage of it, it’s one of the layer on how to have very generic tensors.
It can allow to share the same storage for multiple tensors for example. Or handle some operations more efficiently.

I see. Thank you very much