This is mainly out of curiosity (since one can always use the transform ToTensor() in the dataloader).
But when storing data (e.g. pre-processed data, synthetic data etc.), is there any advantage to saving the data already as a torch.tensor  rather than as an image, PIL image thing, numpy array, etc?
fully functionable example e.g.
#%%

import torch

from pathlib import Path

path = Path('~/data/tmp/').expanduser()

tensor_a = torch.rand(2,3)
tensor_b = torch.rand(1,3)

db = {'a': tensor_a, 'b': tensor_b}

torch.save(db, path/'torch_db')
loaded = torch.load(path/'torch_db')
print( loaded['a'] == tensor_a )
print( loaded['b'] == tensor_b )


Q:

if it’s already in tensor format, does that cause issues with ToTensor() Op?


Note: that we probably can’t preload things to speed things in gpu since the dataloader loading of data is subtle due to cuda multithtreading subtlities.

related: Save a tensor to file 28