// The main caffe test code. Your test cpp code should include this hpp // to allow a main function to be compiled into the binary. #ifndef CAFFE_TEST_TEST_CAFFE_MAIN_HPP_ #define CAFFE_TEST_TEST_CAFFE_MAIN_HPP_ #include #include #include #include #include "caffe/common.hpp" using std::cout; using std::endl; #ifdef CMAKE_BUILD #include "caffe_config.h" #else #define CUDA_TEST_DEVICE -1 #define EXAMPLES_SOURCE_DIR "examples/" #define ABS_TEST_DATA_DIR "src/caffe/test/test_data" #endif int main(int argc, char** argv); namespace caffe { template class MultiDeviceTest : public ::testing::Test { public: typedef typename TypeParam::Dtype Dtype; protected: MultiDeviceTest() { Caffe::set_mode(TypeParam::device); } virtual ~MultiDeviceTest() {} }; typedef ::testing::Types TestDtypes; template struct CPUDevice { typedef TypeParam Dtype; static const Caffe::Brew device = Caffe::CPU; }; template class CPUDeviceTest : public MultiDeviceTest > { }; #ifdef CPU_ONLY typedef ::testing::Types, CPUDevice > TestDtypesAndDevices; #else template struct GPUDevice { typedef TypeParam Dtype; static const Caffe::Brew device = Caffe::GPU; }; template class GPUDeviceTest : public MultiDeviceTest > { }; typedef ::testing::Types, CPUDevice, GPUDevice, GPUDevice > TestDtypesAndDevices; #endif } // namespace caffe #endif // CAFFE_TEST_TEST_CAFFE_MAIN_HPP_