From 9b964b535bb060b584d1336c956f34c03fa9e3fe Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Tue, 18 Jul 2017 16:16:59 +0800 Subject: [PATCH] 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. --- paddle/framework/tensor.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/paddle/framework/tensor.h b/paddle/framework/tensor.h index b405e3877c9..802471b341e 100644 --- a/paddle/framework/tensor.h +++ b/paddle/framework/tensor.h @@ -55,14 +55,14 @@ class Tensor { holder_.reset(new PlaceholderImpl( boost::get(place), product(dims_) * sizeof(T))); } 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( boost::get(place), product(dims_) * sizeof(T))); -#else - PADDLE_ENFORCE(true, "'GPUPlace' is not supported in CPU only device."); #endif } else { - PADDLE_ENFORCE(true, "Unknown 'place'."); + PADDLE_THROW("Unknown 'place'."); } offset_ = 0; } -- GitLab