Add device and dtype to storage. (#18749)
authorGregory Chanan <gchanan@fb.com>
Wed, 3 Apr 2019 14:52:54 +0000 (07:52 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 3 Apr 2019 14:59:02 +0000 (07:59 -0700)
commit2113ea6fbf20cb820ea6a504b1dfe30297ce4d7c
tree1836229c8e8429a01157390001a0a3967d8e1f43
parenta3da3653ebb80d274bcec29c81c0538b410e527a
Add device and dtype to storage. (#18749)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18749
ghimport-source-id: 9026a037f5e11cdb9ccd386f4b6b5768b9c3259b

Stack from [ghstack](https://github.com/ezyang/ghstack):
* #18751 Disallow changing the device of a tensor via set_.
* #18750 Use non-legacy constructors for tensor deserialization.
* **#18749 Add device and dtype to storage.**

The goal here is to fix our serialization, which currently depends on the legacy constructors.  Having dtype and device on Storage allows us to use the non-legacy constructors.

This fits somewhat along our goal of removing Storage, my having Storage act like a Tensor.

Differential Revision: D14729516

fbshipit-source-id: bf4a3e8669ad4859931f4a3fa56df605cbc08dcb
test/test_torch.py
torch/csrc/Storage.cpp
torch/csrc/cuda/Storage.cpp
torch/csrc/generic/Storage.cpp