title: PyTorch tensor slice and memory usage
body: <pre class="lang-py prettyprint-override"><code>import torch
  T = torch.FloatTensor(range(0,10 ** 6)) # 1M
  
  #case 1:
  torch.save(T, 'junk.pt')
  # results in a 4 MB file size
  
  #case 2:
  torch.save(T[-20:], 'junk2.pt')
  # results in a 4 MB file size
  
  #case 3:
  torch.save(torch.FloatTensor(T[-20:]), 'junk3.pt')
  # results in a 4 MB file size
  
  #case 4:
  torch.save(torch.FloatTensor(T[-20:].tolist()), 'junk4.pt')
  # results in a 405 Bytes file size
  
  </code></pre>
  <p>My questions are:</p>
  <ol>
  <li><p>In case 3 the resulting file size seems surprising as we are creating a new tensor. Why is this new tensor not just the slice?</p>
  </li>
  <li><p>Is case 4, the optimal method for saving just part (slice) of a tensor?</p>
  </li>
  <li><p>More generally, if I want to 'trim' a very large 1-dimensional tensor by removing the first half of its values in order to save memory, do I have to proceed as in case 4, or is there a more direct and less computationally costly way that does not involve creating a python list.</p>
  </li>
  </ol>