From 33e7977154a6ca961ce927e15625763f9cc13f8c Mon Sep 17 00:00:00 2001 From: Jerry Zhang Date: Tue, 16 Apr 2019 19:55:48 -0700 Subject: [PATCH] move const defs of DeviceType to DeviceType.h (#19185) Summary: Stack:     :black_circle:  **#19185 [c10][core][ez] move const defs of DeviceType to DeviceType.h**  [:yellow_heart:](https://our.intern.facebook.com/intern/diff/D14909415/) att Pull Request resolved: https://github.com/pytorch/pytorch/pull/19185 Differential Revision: D14909415 Pulled By: jerryzh168 fbshipit-source-id: 876cf999424d8394f5ff20e6750133a4e43466d4 --- c10/core/Backend.h | 6 ------ c10/core/DeviceType.h | 8 +++++++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/c10/core/Backend.h b/c10/core/Backend.h index 2fa5c47..1f8e585 100644 --- a/c10/core/Backend.h +++ b/c10/core/Backend.h @@ -223,12 +223,6 @@ static inline Backend backendToHIP(Backend b) { } } -constexpr DeviceType kCPU = DeviceType::CPU; -constexpr DeviceType kCUDA = DeviceType::CUDA; -constexpr DeviceType kHIP = DeviceType::HIP; -constexpr DeviceType kMSNPU = DeviceType::MSNPU; -constexpr DeviceType kXLA = DeviceType::XLA; - static inline const char* toString(Backend b) { switch (b) { case Backend::CPU: diff --git a/c10/core/DeviceType.h b/c10/core/DeviceType.h index f23d170..9f75966 100644 --- a/c10/core/DeviceType.h +++ b/c10/core/DeviceType.h @@ -31,6 +31,12 @@ enum class DeviceType : int16_t { ONLY_FOR_TEST = 20901, // This device type is only for test. }; +constexpr DeviceType kCPU = DeviceType::CPU; +constexpr DeviceType kCUDA = DeviceType::CUDA; +constexpr DeviceType kHIP = DeviceType::HIP; +constexpr DeviceType kMSNPU = DeviceType::MSNPU; +constexpr DeviceType kXLA = DeviceType::XLA; + // define explicit int constant constexpr int COMPILE_TIME_MAX_DEVICE_TYPES = static_cast(DeviceType::COMPILE_TIME_MAX_DEVICE_TYPES); @@ -53,7 +59,7 @@ C10_API bool isValidDeviceType(DeviceType d); C10_API std::ostream& operator<<(std::ostream& stream, DeviceType type); -} // namespace at +} // namespace c10 namespace std { template <> struct hash { -- 2.7.4