提交 b90780c3 编写于 作者: Y Yu Yang 提交者: GitHub

Merge pull request #2939 from reyoung/feature/refine_tensor_hpp

Tensor should use PADDLE_ONLY_CPU macro
...@@ -71,14 +71,14 @@ class Tensor { ...@@ -71,14 +71,14 @@ class Tensor {
holder_.reset(new PlaceholderImpl<T, platform::CPUPlace>( holder_.reset(new PlaceholderImpl<T, platform::CPUPlace>(
boost::get<platform::CPUPlace>(place), product(dims_) * sizeof(T))); boost::get<platform::CPUPlace>(place), product(dims_) * sizeof(T)));
} else if (platform::is_gpu_place(place)) { } else if (platform::is_gpu_place(place)) {
#ifdef __CUDACC__ #ifdef PADDLE_ONLY_CPU
PADDLE_THROW("'GPUPlace' is not supported in CPU only device.");
#else
holder_.reset(new PlaceholderImpl<T, platform::GPUPlace>( holder_.reset(new PlaceholderImpl<T, platform::GPUPlace>(
boost::get<platform::GPUPlace>(place), product(dims_) * sizeof(T))); boost::get<platform::GPUPlace>(place), product(dims_) * sizeof(T)));
#else
PADDLE_ENFORCE(true, "'GPUPlace' is not supported in CPU only device.");
#endif #endif
} else { } else {
PADDLE_ENFORCE(true, "Unknown 'place'."); PADDLE_THROW("Unknown 'place'.");
} }
offset_ = 0; offset_ = 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册