Rename signbit in macros to sgnbit to avoid conflicts with std::signbit
authorKai Li <kaili_kloud@163.com>
Tue, 11 Mar 2014 09:05:27 +0000 (17:05 +0800)
committerKai Li <kaili_kloud@163.com>
Sun, 23 Mar 2014 13:26:00 +0000 (21:26 +0800)
include/caffe/util/math_functions.hpp
src/caffe/test/test_math_functions.cpp
src/caffe/util/math_functions.cpp
src/caffe/util/math_functions.cu

index 268cb2b..b18a058 100644 (file)
@@ -174,11 +174,13 @@ DEFINE_CAFFE_CPU_UNARY_FUNC(sign, y[i] = caffe_sign<Dtype>(x[i]));
 template<typename Dtype>
 void caffe_gpu_sign(const int n, const Dtype* x, Dtype* y);
 
-// returns a nonzero value is the input has its sign bit set.
-DEFINE_CAFFE_CPU_UNARY_FUNC(signbit, y[i] = std::signbit(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
+using std::signbit;
+DEFINE_CAFFE_CPU_UNARY_FUNC(sgnbit, y[i] = signbit(x[i]));
 
 template<typename Dtype>
-void caffe_gpu_signbit(const int n, const Dtype* x, Dtype* y);
+void caffe_gpu_sgnbit(const int n, const Dtype* x, Dtype* y);
 
 DEFINE_CAFFE_CPU_UNARY_FUNC(fabs, y[i] = std::fabs(x[i]));
 
index d314d73..9a68d87 100644 (file)
@@ -119,19 +119,19 @@ TYPED_TEST(MathFunctionsTest, TestSignGPU){
   }
 }
 
-TYPED_TEST(MathFunctionsTest, TestSignbitCPU){
+TYPED_TEST(MathFunctionsTest, TestSgnbitCPU){
   int n = this->blob_bottom_->count();
   const TypeParam* x = this->blob_bottom_->cpu_data();
-  caffe_cpu_signbit<TypeParam>(n, x, this->blob_bottom_->mutable_cpu_diff());
+  caffe_cpu_sgnbit<TypeParam>(n, x, this->blob_bottom_->mutable_cpu_diff());
   const TypeParam* signbits = this->blob_bottom_->cpu_diff();
   for (int i = 0; i < n; ++i) {
     CHECK_EQ(signbits[i], x[i] < 0 ? 1 : 0);
   }
 }
 
-TYPED_TEST(MathFunctionsTest, TestSignbitGPU){
+TYPED_TEST(MathFunctionsTest, TestSgnbitGPU){
   int n = this->blob_bottom_->count();
-  caffe_gpu_signbit<TypeParam>(n, this->blob_bottom_->gpu_data(),
+  caffe_gpu_sgnbit<TypeParam>(n, this->blob_bottom_->gpu_data(),
                             this->blob_bottom_->mutable_gpu_diff());
   const TypeParam* signbits = this->blob_bottom_->cpu_diff();
   const TypeParam* x = this->blob_bottom_->cpu_data();
index ad83a99..80e420f 100644 (file)
@@ -411,7 +411,7 @@ void caffe_gpu_asum<double>(const int n, const double* x, double* y) {
 }
 
 INSTANTIATE_CAFFE_CPU_UNARY_FUNC(sign);
-INSTANTIATE_CAFFE_CPU_UNARY_FUNC(signbit);
+INSTANTIATE_CAFFE_CPU_UNARY_FUNC(sgnbit);
 INSTANTIATE_CAFFE_CPU_UNARY_FUNC(fabs);
 
 template <>
index e3eaacc..2cf1cfc 100644 (file)
@@ -36,7 +36,7 @@ void caffe_gpu_mul<double>(const int N, const double* a,
 }
 
 DEFINE_AND_INSTANTIATE_GPU_UNARY_FUNC(sign, y[index] = (Dtype(0) < x[index]) - (x[index] < Dtype(0)));
-DEFINE_AND_INSTANTIATE_GPU_UNARY_FUNC(signbit, y[index] = signbit(x[index]));
+DEFINE_AND_INSTANTIATE_GPU_UNARY_FUNC(sgnbit, y[index] = signbit(x[index]));
 DEFINE_AND_INSTANTIATE_GPU_UNARY_FUNC(fabs, y[index] = fabs(x[index]));
 
 }  // namespace caffe