Files
pytorch/torch/csrc/Storage.cpp
Gregory Chanan 2113ea6fbf 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
2019-04-03 07:59:02 -07:00

38 lines
886 B
C++

#define __STDC_FORMAT_MACROS
#include <torch/csrc/python_headers.h>
#ifdef _MSC_VER
#include <Windows.h>
#endif
#include <structmember.h>
#define THP_HOST_HALF
#include <TH/TH.h>
// See Note [TH abstraction violation]
// - Used to get at the allocator associated with a storage
#include <TH/THStorageFunctions.hpp>
#include <libshm.h>
#include <torch/csrc/THP.h>
#include <torch/csrc/copy_utils.h>
#include <torch/csrc/DynamicTypes.h>
#include <torch/csrc/CudaIPCTypes.h>
#include <torch/csrc/Device.h>
#include <torch/csrc/autograd/utils/wrap_outputs.h>
#include <torch/csrc/generic/Storage.cpp>
#include <TH/THGenerateAllTypes.h>
#include <torch/csrc/generic/Storage.cpp>
#include <TH/THGenerateHalfType.h>
#include <torch/csrc/generic/Storage.cpp>
#include <TH/THGenerateBoolType.h>
template<>
void THPPointer<THStorage>::free() {
if (ptr) {
THStorage_free(ptr);
}
}