From f271210595953fee610dd049909d7e3a40f58285 Mon Sep 17 00:00:00 2001 From: tensor-tang Date: Fri, 15 Dec 2017 15:15:18 +0800 Subject: [PATCH] fix undefined issue when with_gpu --- paddle/operators/math/math_function.cc | 8 ++++++++ paddle/platform/place.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/paddle/operators/math/math_function.cc b/paddle/operators/math/math_function.cc index 2b35e4532..a05810d77 100644 --- a/paddle/operators/math/math_function.cc +++ b/paddle/operators/math/math_function.cc @@ -277,6 +277,14 @@ void set_constant_with_place( TensorSetConstantCPU(tensor, value)); } +template <> +void set_constant_with_place( + const platform::DeviceContext& context, framework::Tensor* tensor, + float value) { + framework::VisitDataType(framework::ToDataType(tensor->type()), + TensorSetConstantCPU(tensor, value)); +} + struct TensorSetConstantWithPlace : public boost::static_visitor { TensorSetConstantWithPlace(const platform::DeviceContext& context, framework::Tensor* tensor, float value) diff --git a/paddle/platform/place.h b/paddle/platform/place.h index e745b2e83..70acc5b2d 100644 --- a/paddle/platform/place.h +++ b/paddle/platform/place.h @@ -31,7 +31,7 @@ struct CPUPlace { inline bool operator!=(const CPUPlace &) const { return false; } }; -struct MKLDNNPlace : public CPUPlace { +struct MKLDNNPlace { MKLDNNPlace() {} // needed for variant equality comparison -- GitLab