Rename signbit in macros to sgnbit to avoid conflicts with std::signbit

This commit is contained in:
Kai Li 2014-03-11 17:05:27 +08:00
Родитель dc552e058f
Коммит a288d9538a
4 изменённых файлов: 11 добавлений и 9 удалений

Просмотреть файл

@ -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]));

Просмотреть файл

@ -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();

Просмотреть файл

@ -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 <>

Просмотреть файл

@ -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