// Copyright 2014 kloudkl@github
-#include <stdint.h> // for uint32_t & uint64_t
-#include <cmath> // for std::fabs
+#include <stdint.h> // for uint32_t & uint64_t
+#include <time.h>
+#include <climits>
+#include <cmath> // for std::fabs
+#include <cstdlib> // for rand_r
#include "gtest/gtest.h"
#include "caffe/blob.hpp"
virtual void SetUp() {
Caffe::set_random_seed(1701);
- this->blob_bottom_->Reshape(100, 70, 50, 30);
- this->blob_top_->Reshape(100, 70, 50, 30);
+ this->blob_bottom_->Reshape(11, 17, 19, 23);
+ this->blob_top_->Reshape(11, 17, 19, 23);
// fill the values
FillerParameter filler_param;
GaussianFiller<Dtype> filler(filler_param);
typedef ::testing::Types<float, double> Dtypes;
TYPED_TEST_CASE(MathFunctionsTest, Dtypes);
-TYPED_TEST(MathFunctionsTest, TestHammingDistance){
+TYPED_TEST(MathFunctionsTest, TestHammingDistance) {
int n = this->blob_bottom_->count();
const TypeParam* x = this->blob_bottom_->cpu_data();
const TypeParam* y = this->blob_top_->cpu_data();
caffe_hamming_distance<TypeParam>(n, x, y));
}
-TYPED_TEST(MathFunctionsTest, TestAsumCPU){
+TYPED_TEST(MathFunctionsTest, TestAsumCPU) {
int n = this->blob_bottom_->count();
const TypeParam* x = this->blob_bottom_->cpu_data();
TypeParam std_asum = 0;
CHECK_LT((cpu_asum - std_asum) / std_asum, 1e-2);
}
-TYPED_TEST(MathFunctionsTest, TestAsumGPU){
+TYPED_TEST(MathFunctionsTest, TestAsumGPU) {
int n = this->blob_bottom_->count();
const TypeParam* x = this->blob_bottom_->cpu_data();
TypeParam std_asum = 0;
CHECK_LT((gpu_asum - std_asum) / std_asum, 1e-2);
}
-TYPED_TEST(MathFunctionsTest, TestSignCPU){
+TYPED_TEST(MathFunctionsTest, TestSignCPU) {
int n = this->blob_bottom_->count();
const TypeParam* x = this->blob_bottom_->cpu_data();
caffe_cpu_sign<TypeParam>(n, x, this->blob_bottom_->mutable_cpu_diff());
}
}
-TYPED_TEST(MathFunctionsTest, TestSignGPU){
+TYPED_TEST(MathFunctionsTest, TestSignGPU) {
int n = this->blob_bottom_->count();
caffe_gpu_sign<TypeParam>(n, this->blob_bottom_->gpu_data(),
this->blob_bottom_->mutable_gpu_diff());
}
}
-TYPED_TEST(MathFunctionsTest, TestSgnbitCPU){
+TYPED_TEST(MathFunctionsTest, TestSgnbitCPU) {
int n = this->blob_bottom_->count();
const TypeParam* x = this->blob_bottom_->cpu_data();
caffe_cpu_sgnbit<TypeParam>(n, x, this->blob_bottom_->mutable_cpu_diff());
}
}
-TYPED_TEST(MathFunctionsTest, TestSgnbitGPU){
+TYPED_TEST(MathFunctionsTest, TestSgnbitGPU) {
int n = this->blob_bottom_->count();
caffe_gpu_sgnbit<TypeParam>(n, this->blob_bottom_->gpu_data(),
this->blob_bottom_->mutable_gpu_diff());
}
}
-TYPED_TEST(MathFunctionsTest, TestFabsCPU){
+TYPED_TEST(MathFunctionsTest, TestFabsCPU) {
int n = this->blob_bottom_->count();
const TypeParam* x = this->blob_bottom_->cpu_data();
caffe_cpu_fabs<TypeParam>(n, x, this->blob_bottom_->mutable_cpu_diff());
}
}
-TYPED_TEST(MathFunctionsTest, TestFabsGPU){
+TYPED_TEST(MathFunctionsTest, TestFabsGPU) {
int n = this->blob_bottom_->count();
caffe_gpu_fabs<TypeParam>(n, this->blob_bottom_->gpu_data(),
this->blob_bottom_->mutable_gpu_diff());
}
}
-TYPED_TEST(MathFunctionsTest, TestScaleCPU){
+TYPED_TEST(MathFunctionsTest, TestScaleCPU) {
int n = this->blob_bottom_->count();
+ // NOLINT_NEXT_LINE(runtime/threadsafe_fn)
TypeParam alpha = this->blob_bottom_->cpu_diff()[rand() %
this->blob_bottom_->count()];
caffe_cpu_scale<TypeParam>(n, alpha, this->blob_bottom_->cpu_data(),
}
}
-TYPED_TEST(MathFunctionsTest, TestScaleGPU){
+TYPED_TEST(MathFunctionsTest, TestScaleGPU) {
int n = this->blob_bottom_->count();
+ // NOLINT_NEXT_LINE(runtime/threadsafe_fn)
TypeParam alpha = this->blob_bottom_->cpu_diff()[rand() %
this->blob_bottom_->count()];
caffe_gpu_scale<TypeParam>(n, alpha, this->blob_bottom_->gpu_data(),
}
}
-}
+} // namespace caffe