From a07deac9efb1dc2ff7cea2a9534847512533a8b1 Mon Sep 17 00:00:00 2001 From: qijun Date: Wed, 12 Jul 2017 09:09:12 +0000 Subject: [PATCH] follow comments --- paddle/platform/device_context.cc | 20 +++++++++++++------- paddle/platform/device_context.h | 11 +---------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/paddle/platform/device_context.cc b/paddle/platform/device_context.cc index 8d800ec4998..25ff352e8cf 100644 --- a/paddle/platform/device_context.cc +++ b/paddle/platform/device_context.cc @@ -13,12 +13,18 @@ limitations under the License. */ namespace paddle { namespace platform { -namespace dynload { -namespace dummy { -// Make DeviceContext A library. -int DUMMY_VAR_FOR_DEV_CTX = 0; -} // namespace dummy -} // namespace dynload +template <> +Eigen::DefaultDevice DeviceContext::get_eigen_device() { + return reinterpret_cast(this)->eigen_device(); +} + +#ifndef PADDLE_ONLY_CPU +template <> +Eigen::GpuDevice DeviceContext::get_eigen_device() { + return reinterpret_cast(this)->eigen_device(); +} +#endif + } // namespace platform -} // namespace paddle \ No newline at end of file +} // namespace paddle diff --git a/paddle/platform/device_context.h b/paddle/platform/device_context.h index 5b4b5e29994..d6cf114216d 100644 --- a/paddle/platform/device_context.h +++ b/paddle/platform/device_context.h @@ -31,7 +31,7 @@ class DeviceContext { virtual Place GetPlace() const = 0; template - inline DeviceType get_eigen_device(); + DeviceType get_eigen_device(); }; class CPUDeviceContext : public DeviceContext { @@ -52,11 +52,6 @@ class CPUDeviceContext : public DeviceContext { Eigen::DefaultDevice* eigen_device_{nullptr}; }; -template <> -Eigen::DefaultDevice DeviceContext::get_eigen_device() { - return dynamic_cast(this)->eigen_device(); -} - #ifndef PADDLE_ONLY_CPU class GPUPlaceGuard { @@ -183,10 +178,6 @@ class CUDADeviceContext : public DeviceContext { curandGenerator_t rand_generator_{nullptr}; }; -template <> -Eigen::GpuDevice DeviceContext::get_eigen_device() { - return dynamic_cast(this)->eigen_device(); -} #endif } // namespace platform -- GitLab