It is important at the time of pickling to know what we are really saving to disks. Saving Pytorch tensors is most likely saving its underlying storage. This could be confused with views because many views could share the same underlying storage. The view could be very narrow, but its underlying storage could still be very large. Saving this view to disks would result in a large file as well.
import torch x = torch.randn(100) torch.save(x, 'saved.pt')
saved.pt would have the size of 100 floats instead of one. To really save just the view portion of the storage, we need to create a distinct storage containing only the viewed portion of the old one. This could be done using