From 63db95dd11775b062bb1263c4f8a02e61631c59f Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Tue, 11 Dec 2018 20:40:33 -0800 Subject: [PATCH] Move UndefinedTensorImpl to c10 (meh) (#14817) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/14817 unfortunately, we still need this. Reviewed By: ezyang Differential Revision: D13348041 fbshipit-source-id: e8dcc89f5c71bd1ea2c9813990dac6e58e63b1fd --- aten/src/ATen/core/UndefinedTensorImpl.h | 35 +------------------ .../ATen => c10}/core/UndefinedTensorImpl.cpp | 4 +-- c10/core/UndefinedTensorImpl.h | 34 ++++++++++++++++++ 3 files changed, 37 insertions(+), 36 deletions(-) rename {aten/src/ATen => c10}/core/UndefinedTensorImpl.cpp (94%) create mode 100644 c10/core/UndefinedTensorImpl.h diff --git a/aten/src/ATen/core/UndefinedTensorImpl.h b/aten/src/ATen/core/UndefinedTensorImpl.h index fcfdffa75dd..885f6e195f0 100644 --- a/aten/src/ATen/core/UndefinedTensorImpl.h +++ b/aten/src/ATen/core/UndefinedTensorImpl.h @@ -1,34 +1 @@ -#pragma once - -#include - -namespace at { - -struct CAFFE2_API UndefinedTensorImpl final : public TensorImpl { - public: - // Without this, we get: - // error: identifier "at::UndefinedTensorImpl::_singleton" is undefined in device code - // (ostensibly because the constexpr tricks MSVC into trying to compile this - // function for device as well). -#ifdef _WIN32 - static inline TensorImpl * singleton() { -#else - static constexpr inline TensorImpl * singleton() { -#endif - return &_singleton; - } - IntList sizes() const override; - IntList strides() const override; - int64_t size(int64_t d) const override; - int64_t stride(int64_t d) const override; - int64_t dim() const override; - const Storage& storage() const override; - int64_t storage_offset() const override; -private: - UndefinedTensorImpl(); - static UndefinedTensorImpl _singleton; -public: - friend struct UndefinedType; -}; - -} // namespace at +#include diff --git a/aten/src/ATen/core/UndefinedTensorImpl.cpp b/c10/core/UndefinedTensorImpl.cpp similarity index 94% rename from aten/src/ATen/core/UndefinedTensorImpl.cpp rename to c10/core/UndefinedTensorImpl.cpp index 704f975bd95..2e2265397ea 100644 --- a/aten/src/ATen/core/UndefinedTensorImpl.cpp +++ b/c10/core/UndefinedTensorImpl.cpp @@ -1,7 +1,7 @@ -#include +#include #include -namespace at { +namespace c10 { // should this use the globalContext? Can it get a context passed in somehow? UndefinedTensorImpl::UndefinedTensorImpl() diff --git a/c10/core/UndefinedTensorImpl.h b/c10/core/UndefinedTensorImpl.h new file mode 100644 index 00000000000..5d268b7b821 --- /dev/null +++ b/c10/core/UndefinedTensorImpl.h @@ -0,0 +1,34 @@ +#pragma once + +#include + +namespace c10 { + +struct C10_API UndefinedTensorImpl final : public TensorImpl { + public: + // Without this, we get: + // error: identifier "at::UndefinedTensorImpl::_singleton" is undefined in device code + // (ostensibly because the constexpr tricks MSVC into trying to compile this + // function for device as well). +#ifdef _WIN32 + static inline TensorImpl * singleton() { +#else + static constexpr inline TensorImpl * singleton() { +#endif + return &_singleton; + } + IntList sizes() const override; + IntList strides() const override; + int64_t size(int64_t d) const override; + int64_t stride(int64_t d) const override; + int64_t dim() const override; + const Storage& storage() const override; + int64_t storage_offset() const override; +private: + UndefinedTensorImpl(); + static UndefinedTensorImpl _singleton; +public: + friend struct UndefinedType; +}; + +} // namespace c10