Skip to content

Commit

Permalink
Refactor types FloatCPU and DoubleCPU into a new type CPUDevice<T>
Browse files Browse the repository at this point in the history
Similarly, FloatGPU and DoubleGPU are replaced by a new type GPUDevice<T>.
  • Loading branch information
flx42 committed May 26, 2015
1 parent 8df472a commit 25538ce
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions include/caffe/test/test_caffe_main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,28 @@ class MultiDeviceTest : public ::testing::Test {

typedef ::testing::Types<float, double> TestDtypes;

struct FloatCPU {
typedef float Dtype;
static const Caffe::Brew device = Caffe::CPU;
};

struct DoubleCPU {
typedef double Dtype;
template <typename TypeParam>
struct CPUDevice {
typedef TypeParam Dtype;
static const Caffe::Brew device = Caffe::CPU;
};

#ifdef CPU_ONLY

typedef ::testing::Types<FloatCPU, DoubleCPU> TestDtypesAndDevices;
typedef ::testing::Types<CPUDevice<float>,
CPUDevice<double> > TestDtypesAndDevices;

#else

struct FloatGPU {
typedef float Dtype;
static const Caffe::Brew device = Caffe::GPU;
};

struct DoubleGPU {
typedef double Dtype;
template <typename TypeParam>
struct GPUDevice {
typedef TypeParam Dtype;
static const Caffe::Brew device = Caffe::GPU;
};

typedef ::testing::Types<FloatCPU, DoubleCPU, FloatGPU, DoubleGPU>
TestDtypesAndDevices;
typedef ::testing::Types<CPUDevice<float>, CPUDevice<double>,
GPUDevice<float>, GPUDevice<double> >
TestDtypesAndDevices;

#endif

Expand Down

0 comments on commit 25538ce

Please sign in to comment.