提交 ff594fac 编写于 作者: Q qijun

make gpu_context inside macro

上级 aa5ca8a9
...@@ -136,18 +136,14 @@ All parameter, weight, gradient are variables in Paddle. ...@@ -136,18 +136,14 @@ All parameter, weight, gradient are variables in Paddle.
[]() -> paddle::platform::DeviceContext* { []() -> paddle::platform::DeviceContext* {
return new paddle::platform::CPUDeviceContext(); return new paddle::platform::CPUDeviceContext();
}) })
#ifndef PADDLE_ONLY_CPU
.def_static("gpu_context", .def_static("gpu_context",
[](paddle::platform::Place& place) [](paddle::platform::Place& place)
-> paddle::platform::DeviceContext* { -> 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); return new paddle::platform::CUDADeviceContext(place);
})
#endif #endif
}); ;
py::class_<paddle::platform::Place>(m, "GPUPlace").def(py::init<int>()); py::class_<paddle::platform::Place>(m, "GPUPlace").def(py::init<int>());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册