IVGCVSW-2053: Validate BackendId parameters for the InferenceTest (EndToEnd tests...
[platform/upstream/armnn.git] / tests / CMakeLists.txt
1 # UnitTests
2 include(CheckIncludeFiles)
3
4 include_directories(SYSTEM "${THIRD_PARTY_INCLUDE_DIRS}")
5
6 # Setup the inference test framework
7 set(inference_test_sources
8     ClassifierTestCaseData.hpp
9     InferenceModel.hpp
10     InferenceTest.hpp
11     InferenceTest.inl
12     InferenceTest.cpp
13     InferenceTestImage.hpp
14     InferenceTestImage.cpp)
15 add_library_ex(inferenceTest STATIC ${inference_test_sources})
16 target_include_directories(inferenceTest PRIVATE ../src/armnnUtils)
17 target_include_directories(inferenceTest PRIVATE ../src/backends)
18
19 if(BUILD_CAFFE_PARSER)
20     macro(CaffeParserTest testName sources)
21         add_executable_ex(${testName} ${sources})
22         target_include_directories(${testName} PRIVATE ../src/armnnUtils)
23         target_include_directories(${testName} PRIVATE ../src/backends)
24         set_target_properties(${testName} PROPERTIES COMPILE_FLAGS "${CAFFE_PARSER_TEST_ADDITIONAL_COMPILE_FLAGS}")
25
26         target_link_libraries(${testName} inferenceTest)
27         target_link_libraries(${testName} armnnCaffeParser)
28         target_link_libraries(${testName} armnn)
29         target_link_libraries(${testName} ${CMAKE_THREAD_LIBS_INIT})
30         if(OPENCL_LIBRARIES)
31             target_link_libraries(${testName} ${OPENCL_LIBRARIES})
32         endif()
33         target_link_libraries(${testName}
34             ${Boost_SYSTEM_LIBRARY}
35             ${Boost_FILESYSTEM_LIBRARY}
36             ${Boost_PROGRAM_OPTIONS_LIBRARY})
37         addDllCopyCommands(${testName})
38     endmacro()
39
40     set(CaffeCifar10AcrossChannels-Armnn_sources
41         CaffeCifar10AcrossChannels-Armnn/CaffeCifar10AcrossChannels-Armnn.cpp
42         Cifar10Database.hpp
43         Cifar10Database.cpp)
44     CaffeParserTest(CaffeCifar10AcrossChannels-Armnn "${CaffeCifar10AcrossChannels-Armnn_sources}")
45
46     set(CaffeMnist-Armnn_sources
47         CaffeMnist-Armnn/CaffeMnist-Armnn.cpp
48         MnistDatabase.hpp
49         MnistDatabase.cpp)
50     CaffeParserTest(CaffeMnist-Armnn "${CaffeMnist-Armnn_sources}")
51
52     set(CaffeAlexNet-Armnn_sources
53         CaffeAlexNet-Armnn/CaffeAlexNet-Armnn.cpp
54         CaffePreprocessor.hpp
55         CaffePreprocessor.cpp)
56     CaffeParserTest(CaffeAlexNet-Armnn "${CaffeAlexNet-Armnn_sources}")
57
58     set(MultipleNetworksCifar10_SRC
59         MultipleNetworksCifar10/MultipleNetworksCifar10.cpp
60         Cifar10Database.hpp
61         Cifar10Database.cpp)
62     CaffeParserTest(MultipleNetworksCifar10 "${MultipleNetworksCifar10_SRC}")
63
64     set(CaffeResNet-Armnn_sources
65         CaffeResNet-Armnn/CaffeResNet-Armnn.cpp
66         CaffePreprocessor.hpp
67         CaffePreprocessor.cpp)
68     CaffeParserTest(CaffeResNet-Armnn "${CaffeResNet-Armnn_sources}")
69
70     set(CaffeVGG-Armnn_sources
71         CaffeVGG-Armnn/CaffeVGG-Armnn.cpp
72         CaffePreprocessor.hpp
73         CaffePreprocessor.cpp)
74     CaffeParserTest(CaffeVGG-Armnn "${CaffeVGG-Armnn_sources}")
75
76     set(CaffeInception_BN-Armnn_sources
77         CaffeInception_BN-Armnn/CaffeInception_BN-Armnn.cpp
78         CaffePreprocessor.hpp
79         CaffePreprocessor.cpp)
80     CaffeParserTest(CaffeInception_BN-Armnn "${CaffeInception_BN-Armnn_sources}")
81
82     set(CaffeYolo-Armnn_sources
83         CaffeYolo-Armnn/CaffeYolo-Armnn.cpp
84         YoloDatabase.hpp
85         YoloDatabase.cpp
86         YoloInferenceTest.hpp)
87     CaffeParserTest(CaffeYolo-Armnn "${CaffeYolo-Armnn_sources}")
88 endif()
89
90 if(BUILD_TF_PARSER)
91     macro(TfParserTest testName sources)
92         add_executable_ex(${testName} ${sources})
93         target_include_directories(${testName} PRIVATE ../src/armnnUtils)
94         target_include_directories(${testName} PRIVATE ../src/backends)
95
96         target_link_libraries(${testName} inferenceTest)
97         target_link_libraries(${testName} armnnTfParser)
98         target_link_libraries(${testName} armnn)
99         target_link_libraries(${testName} ${CMAKE_THREAD_LIBS_INIT})
100         if(OPENCL_LIBRARIES)
101             target_link_libraries(${testName} ${OPENCL_LIBRARIES})
102         endif()
103         target_link_libraries(${testName}
104             ${Boost_SYSTEM_LIBRARY}
105             ${Boost_FILESYSTEM_LIBRARY}
106             ${Boost_PROGRAM_OPTIONS_LIBRARY})
107         addDllCopyCommands(${testName})
108     endmacro()
109
110     set(TfMnist-Armnn_sources
111         TfMnist-Armnn/TfMnist-Armnn.cpp
112         MnistDatabase.hpp
113         MnistDatabase.cpp)
114     TfParserTest(TfMnist-Armnn "${TfMnist-Armnn_sources}")
115
116     set(TfCifar10-Armnn_sources
117         TfCifar10-Armnn/TfCifar10-Armnn.cpp
118         Cifar10Database.hpp
119         Cifar10Database.cpp)
120     TfParserTest(TfCifar10-Armnn "${TfCifar10-Armnn_sources}")
121
122     set(TfMobileNet-Armnn_sources
123         TfMobileNet-Armnn/TfMobileNet-Armnn.cpp
124         ImagePreprocessor.hpp
125         ImagePreprocessor.cpp)
126     TfParserTest(TfMobileNet-Armnn "${TfMobileNet-Armnn_sources}")
127
128     set(TfInceptionV3-Armnn_sources
129         TfInceptionV3-Armnn/TfInceptionV3-Armnn.cpp
130         ImagePreprocessor.hpp
131         ImagePreprocessor.cpp)
132     TfParserTest(TfInceptionV3-Armnn "${TfInceptionV3-Armnn_sources}")
133
134     set(TfResNext-Armnn_sources
135         TfResNext_Quantized-Armnn/TfResNext_Quantized-Armnn.cpp
136         CaffePreprocessor.hpp
137         CaffePreprocessor.cpp)
138     TfParserTest(TfResNext-Armnn "${TfResNext-Armnn_sources}")
139 endif()
140
141 if (BUILD_TF_LITE_PARSER)
142     macro(TfLiteParserTest testName sources)
143         add_executable_ex(${testName} ${sources})
144         target_include_directories(${testName} PRIVATE ../src/armnnUtils)
145         target_include_directories(${testName} PRIVATE ../src/backends)
146
147         target_link_libraries(${testName} inferenceTest)
148         target_link_libraries(${testName} armnnTfLiteParser)
149         target_link_libraries(${testName} armnn)
150         target_link_libraries(${testName} ${CMAKE_THREAD_LIBS_INIT})
151         if(OPENCL_LIBRARIES)
152             target_link_libraries(${testName} ${OPENCL_LIBRARIES})
153         endif()
154         target_link_libraries(${testName}
155             ${Boost_SYSTEM_LIBRARY}
156             ${Boost_FILESYSTEM_LIBRARY}
157             ${Boost_PROGRAM_OPTIONS_LIBRARY})
158         addDllCopyCommands(${testName})
159     endmacro()
160
161     set(TfLiteMobilenetQuantized-Armnn_sources
162         TfLiteMobilenetQuantized-Armnn/TfLiteMobilenetQuantized-Armnn.cpp
163         ImagePreprocessor.hpp
164         ImagePreprocessor.cpp)
165     TfLiteParserTest(TfLiteMobilenetQuantized-Armnn "${TfLiteMobilenetQuantized-Armnn_sources}")
166 endif()
167
168 if (BUILD_ONNX_PARSER)
169     macro(OnnxParserTest testName sources)
170         add_executable_ex(${testName} ${sources})
171         target_include_directories(${testName} PRIVATE ../src/armnnUtils)
172         target_include_directories(${testName} PRIVATE ../src/backends)
173
174         target_link_libraries(${testName} inferenceTest)
175         target_link_libraries(${testName} armnnOnnxParser)
176         target_link_libraries(${testName} armnn)
177         target_link_libraries(${testName} ${CMAKE_THREAD_LIBS_INIT})
178         if(OPENCL_LIBRARIES)
179             target_link_libraries(${testName} ${OPENCL_LIBRARIES})
180         endif()
181         target_link_libraries(${testName}
182             ${Boost_SYSTEM_LIBRARY}
183             ${Boost_FILESYSTEM_LIBRARY}
184             ${Boost_PROGRAM_OPTIONS_LIBRARY})
185         addDllCopyCommands(${testName})
186     endmacro()
187
188     set(OnnxMnist-Armnn_sources
189         OnnxMnist-Armnn/OnnxMnist-Armnn.cpp
190         MnistDatabase.hpp
191         MnistDatabase.cpp)
192     OnnxParserTest(OnnxMnist-Armnn "${OnnxMnist-Armnn_sources}")
193
194     set(OnnxMobileNet-Armnn_sources
195         OnnxMobileNet-Armnn/OnnxMobileNet-Armnn.cpp
196         ImagePreprocessor.hpp
197         ImagePreprocessor.cpp)
198     OnnxParserTest(OnnxMobileNet-Armnn "${OnnxMobileNet-Armnn_sources}")
199 endif()
200
201 if (BUILD_CAFFE_PARSER OR BUILD_TF_PARSER OR BUILD_TF_LITE_PARSER OR BUILD_ONNX_PARSER)
202     set(ExecuteNetwork_sources
203         ExecuteNetwork/ExecuteNetwork.cpp)
204
205     add_executable_ex(ExecuteNetwork ${ExecuteNetwork_sources})
206     target_include_directories(ExecuteNetwork PRIVATE ../src/armnn)
207     target_include_directories(ExecuteNetwork PRIVATE ../src/armnnUtils)
208     target_include_directories(ExecuteNetwork PRIVATE ../src/backends)
209
210     if (BUILD_CAFFE_PARSER)
211         target_link_libraries(ExecuteNetwork armnnCaffeParser)
212     endif()
213     if (BUILD_TF_PARSER)
214         target_link_libraries(ExecuteNetwork armnnTfParser)
215     endif()
216
217     if (BUILD_TF_LITE_PARSER)
218         target_link_libraries(ExecuteNetwork armnnTfLiteParser)
219     endif()
220     if (BUILD_ONNX_PARSER)
221             target_link_libraries(ExecuteNetwork armnnOnnxParser)
222     endif()
223
224     target_link_libraries(ExecuteNetwork armnn)
225     target_link_libraries(ExecuteNetwork ${CMAKE_THREAD_LIBS_INIT})
226     if(OPENCL_LIBRARIES)
227         target_link_libraries(ExecuteNetwork ${OPENCL_LIBRARIES})
228     endif()
229     target_link_libraries(ExecuteNetwork
230         ${Boost_SYSTEM_LIBRARY}
231         ${Boost_FILESYSTEM_LIBRARY}
232         ${Boost_PROGRAM_OPTIONS_LIBRARY})
233     addDllCopyCommands(ExecuteNetwork)
234 endif()