Apollo  6.0
Open source self driving car software
test_helper.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2018 The Apollo Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 #pragma once
17 
18 #define CUDA_TEST_DEVICE -1
19 #define EXAMPLES_SOURCE_DIR "examples/"
20 #define ABS_TEST_DATA_DIR "src/caffe/test/test_data"
21 
22 namespace apollo {
23 namespace perception {
24 namespace base {
25 
26 template <typename TypeParam>
27 class MultiDeviceTest : public ::testing::Test {
28  public:
29  typedef typename TypeParam::Dtype Dtype;
30 
31  protected:
33  // Caffe::set_mode(TypeParam::device);
34  }
35  virtual ~MultiDeviceTest() {}
36 };
37 
38 typedef ::testing::Types<float, double> TestDtypes;
39 
40 template <typename TypeParam>
41 struct CPUDevice {
42  typedef TypeParam Dtype;
43  // static const Caffe::Brew device = Caffe::CPU;
44 };
45 
46 template <typename Dtype>
47 class CPUDeviceTest : public MultiDeviceTest<CPUDevice<Dtype>> {};
48 
49 #if USE_GPU == 0
50 
51 typedef ::testing::Types<CPUDevice<float>, CPUDevice<double>>
53 
54 #else
55 
56 template <typename TypeParam>
57 struct GPUDevice {
58  typedef TypeParam Dtype;
59  // static const Caffe::Brew device = Caffe::GPU;
60 };
61 
62 template <typename Dtype>
63 class GPUDeviceTest : public MultiDeviceTest<GPUDevice<Dtype>> {};
64 
65 typedef ::testing::Types<CPUDevice<float>, CPUDevice<double>, GPUDevice<float>,
66  GPUDevice<double>>
68 
69 #endif
70 
71 } // namespace base
72 } // namespace perception
73 } // namespace apollo
Definition: test_helper.h:41
TypeParam Dtype
Definition: test_helper.h:42
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
::testing::Types< float, double > TestDtypes
Definition: test_helper.h:38
::testing::Types< CPUDevice< float >, CPUDevice< double > > TestDtypesAndDevices
Definition: test_helper.h:52
Definition: test_helper.h:27
TypeParam::Dtype Dtype
Definition: test_helper.h:29
virtual ~MultiDeviceTest()
Definition: test_helper.h:35
Definition: test_helper.h:47
MultiDeviceTest()
Definition: test_helper.h:32