зеркало из https://github.com/microsoft/caffe.git
Rename signbit in macros to sgnbit to avoid conflicts with std::signbit
This commit is contained in:
Родитель
dc552e058f
Коммит
a288d9538a
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче