提交 9b964b53 编写于 作者: Y Yu Yang

Tensor should use PADDLE_ONLY_CPU macro

* Not use __CUDACC__ macro, because malloc in GPU memory do not have to
  used in .cu file.
* Also, `PADDLE_ENFORCE` logic is wrong.
上级 875946ff
...@@ -55,14 +55,14 @@ class Tensor { ...@@ -55,14 +55,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.
先完成此消息的编辑!
想要评论请 注册