From ff594fac84920f710dbda44566bd880f7d32be4e Mon Sep 17 00:00:00 2001 From: qijun Date: Tue, 25 Jul 2017 16:35:36 +0800 Subject: [PATCH] make gpu_context inside macro --- paddle/pybind/pybind.cc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/paddle/pybind/pybind.cc b/paddle/pybind/pybind.cc index 24879ee78f1..e53340cc9fa 100644 --- a/paddle/pybind/pybind.cc +++ b/paddle/pybind/pybind.cc @@ -136,18 +136,14 @@ All parameter, weight, gradient are variables in Paddle. []() -> paddle::platform::DeviceContext* { return new paddle::platform::CPUDeviceContext(); }) +#ifndef PADDLE_ONLY_CPU .def_static("gpu_context", [](paddle::platform::Place& place) -> paddle::platform::DeviceContext* { -#ifdef PADDLE_ONLY_CPU - - // PADDLE_THROW("'GPUPlace' is not supported in CPU only - // device."); - return nullptr; -#else return new paddle::platform::CUDADeviceContext(place); + }) #endif - }); + ; py::class_(m, "GPUPlace").def(py::init()); -- GitLab