From: Jonathan L Long Date: Thu, 21 Aug 2014 03:06:11 +0000 (-0700) Subject: clean up cpu signbit definition X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0ac0f20413ea44847af7c8c7bcca655f499b0b60;p=platform%2Fupstream%2Fcaffe.git clean up cpu signbit definition The redundant "caffe_signbit" function was used as a circumlocution around CUDA's signbit macro; we can just add extra parens to prevent macro expansion. --- diff --git a/include/caffe/util/math_functions.hpp b/include/caffe/util/math_functions.hpp index f4310bf..62467fb 100644 --- a/include/caffe/util/math_functions.hpp +++ b/include/caffe/util/math_functions.hpp @@ -137,11 +137,10 @@ inline char caffe_sign(Dtype val) { DEFINE_CAFFE_CPU_UNARY_FUNC(sign, y[i] = caffe_sign(x[i])); // This returns a nonzero value if the input has its sign bit set. -// The name sngbit is meant to avoid conflicts with std::signbit in the macro -bool caffe_signbit(float arg); -bool caffe_signbit(double arg); -bool caffe_signbit(long double arg); -DEFINE_CAFFE_CPU_UNARY_FUNC(sgnbit, y[i] = caffe_signbit(x[i])); +// The name sngbit is meant to avoid conflicts with std::signbit in the macro. +// The extra parens are needed because CUDA < 6.5 defines signbit as a macro, +// and we don't want that to expand here when CUDA headers are also included. +DEFINE_CAFFE_CPU_UNARY_FUNC(sgnbit, y[i] = (std::signbit)(x[i])); DEFINE_CAFFE_CPU_UNARY_FUNC(fabs, y[i] = std::fabs(x[i])); diff --git a/src/caffe/util/math_functions.cpp b/src/caffe/util/math_functions.cpp index 7016e63..0338155 100644 --- a/src/caffe/util/math_functions.cpp +++ b/src/caffe/util/math_functions.cpp @@ -387,16 +387,4 @@ void caffe_cpu_scale(const int n, const double alpha, const double *x, cblas_dscal(n, alpha, y, 1); } - -using std::signbit; -bool caffe_signbit(float arg) { - return signbit(arg); -} -bool caffe_signbit(double arg) { - return signbit(arg); -} -bool caffe_signbit(long double arg) { - return signbit(arg); -} - } // namespace caffe