提交 a07deac9 编写于 作者: Q qijun

follow comments

上级 85806e75
...@@ -13,12 +13,18 @@ limitations under the License. */ ...@@ -13,12 +13,18 @@ limitations under the License. */
namespace paddle { namespace paddle {
namespace platform { namespace platform {
namespace dynload {
namespace dummy {
// Make DeviceContext A library.
int DUMMY_VAR_FOR_DEV_CTX = 0;
} // namespace dummy template <>
} // namespace dynload Eigen::DefaultDevice DeviceContext::get_eigen_device<Eigen::DefaultDevice>() {
return reinterpret_cast<CPUDeviceContext*>(this)->eigen_device();
}
#ifndef PADDLE_ONLY_CPU
template <>
Eigen::GpuDevice DeviceContext::get_eigen_device<Eigen::GpuDevice>() {
return reinterpret_cast<CUDADeviceContext*>(this)->eigen_device();
}
#endif
} // namespace platform } // namespace platform
} // namespace paddle } // namespace paddle
\ No newline at end of file
...@@ -31,7 +31,7 @@ class DeviceContext { ...@@ -31,7 +31,7 @@ class DeviceContext {
virtual Place GetPlace() const = 0; virtual Place GetPlace() const = 0;
template <typename DeviceType> template <typename DeviceType>
inline DeviceType get_eigen_device(); DeviceType get_eigen_device();
}; };
class CPUDeviceContext : public DeviceContext { class CPUDeviceContext : public DeviceContext {
...@@ -52,11 +52,6 @@ class CPUDeviceContext : public DeviceContext { ...@@ -52,11 +52,6 @@ class CPUDeviceContext : public DeviceContext {
Eigen::DefaultDevice* eigen_device_{nullptr}; Eigen::DefaultDevice* eigen_device_{nullptr};
}; };
template <>
Eigen::DefaultDevice DeviceContext::get_eigen_device<Eigen::DefaultDevice>() {
return dynamic_cast<CPUDeviceContext*>(this)->eigen_device();
}
#ifndef PADDLE_ONLY_CPU #ifndef PADDLE_ONLY_CPU
class GPUPlaceGuard { class GPUPlaceGuard {
...@@ -183,10 +178,6 @@ class CUDADeviceContext : public DeviceContext { ...@@ -183,10 +178,6 @@ class CUDADeviceContext : public DeviceContext {
curandGenerator_t rand_generator_{nullptr}; curandGenerator_t rand_generator_{nullptr};
}; };
template <>
Eigen::GpuDevice DeviceContext::get_eigen_device<Eigen::GpuDevice>() {
return dynamic_cast<CUDADeviceContext*>(this)->eigen_device();
}
#endif #endif
} // namespace platform } // namespace platform
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册