MLCE-347 'REDUCE_MIN, REDUCE_MAX, REDUCE_SUM Support'
[platform/upstream/armnn.git] / tests / CMakeLists.txt
1 # UnitTests
2 include(CheckIncludeFiles)
3
4 # Setup the inference test framework
5 set(inference_test_sources
6     ClassifierTestCaseData.hpp
7     InferenceModel.hpp
8     InferenceTest.hpp
9     InferenceTest.inl
10     InferenceTest.cpp
11     InferenceTestImage.hpp
12     InferenceTestImage.cpp)
13
14 add_library_ex(inferenceTest STATIC ${inference_test_sources})
15 target_include_directories(inferenceTest PRIVATE ../src/armnnUtils)
16 target_include_directories(inferenceTest PRIVATE ../src/backends)
17 target_include_directories(inferenceTest PRIVATE ../third-party/stb)
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         addDllCopyCommands(${testName})
31     endmacro()
32
33     set(CaffeCifar10AcrossChannels-Armnn_sources
34         CaffeCifar10AcrossChannels-Armnn/CaffeCifar10AcrossChannels-Armnn.cpp
35         Cifar10Database.hpp
36         Cifar10Database.cpp)
37     CaffeParserTest(CaffeCifar10AcrossChannels-Armnn "${CaffeCifar10AcrossChannels-Armnn_sources}")
38
39     set(CaffeMnist-Armnn_sources
40         CaffeMnist-Armnn/CaffeMnist-Armnn.cpp
41         MnistDatabase.hpp
42         MnistDatabase.cpp)
43     CaffeParserTest(CaffeMnist-Armnn "${CaffeMnist-Armnn_sources}")
44
45     set(CaffeAlexNet-Armnn_sources
46         CaffeAlexNet-Armnn/CaffeAlexNet-Armnn.cpp
47         CaffePreprocessor.hpp
48         CaffePreprocessor.cpp)
49     CaffeParserTest(CaffeAlexNet-Armnn "${CaffeAlexNet-Armnn_sources}")
50
51     set(MultipleNetworksCifar10_SRC
52         MultipleNetworksCifar10/MultipleNetworksCifar10.cpp
53         Cifar10Database.hpp
54         Cifar10Database.cpp)
55     CaffeParserTest(MultipleNetworksCifar10 "${MultipleNetworksCifar10_SRC}")
56
57     set(CaffeResNet-Armnn_sources
58         CaffeResNet-Armnn/CaffeResNet-Armnn.cpp
59         CaffePreprocessor.hpp
60         CaffePreprocessor.cpp)
61     CaffeParserTest(CaffeResNet-Armnn "${CaffeResNet-Armnn_sources}")
62
63     set(CaffeVGG-Armnn_sources
64         CaffeVGG-Armnn/CaffeVGG-Armnn.cpp
65         CaffePreprocessor.hpp
66         CaffePreprocessor.cpp)
67     CaffeParserTest(CaffeVGG-Armnn "${CaffeVGG-Armnn_sources}")
68
69     set(CaffeInception_BN-Armnn_sources
70         CaffeInception_BN-Armnn/CaffeInception_BN-Armnn.cpp
71         CaffePreprocessor.hpp
72         CaffePreprocessor.cpp)
73     CaffeParserTest(CaffeInception_BN-Armnn "${CaffeInception_BN-Armnn_sources}")
74
75     set(CaffeYolo-Armnn_sources
76         CaffeYolo-Armnn/CaffeYolo-Armnn.cpp
77         YoloDatabase.hpp
78         YoloDatabase.cpp
79         YoloInferenceTest.hpp)
80     CaffeParserTest(CaffeYolo-Armnn "${CaffeYolo-Armnn_sources}")
81 endif()
82
83 if(BUILD_TF_PARSER)
84     macro(TfParserTest testName sources)
85         add_executable_ex(${testName} ${sources})
86         target_include_directories(${testName} PRIVATE ../src/armnnUtils)
87         target_include_directories(${testName} PRIVATE ../src/backends)
88
89         target_link_libraries(${testName} inferenceTest)
90         target_link_libraries(${testName} armnnTfParser)
91         target_link_libraries(${testName} armnn)
92         target_link_libraries(${testName} ${CMAKE_THREAD_LIBS_INIT})
93         addDllCopyCommands(${testName})
94     endmacro()
95
96     set(TfMnist-Armnn_sources
97         TfMnist-Armnn/TfMnist-Armnn.cpp
98         MnistDatabase.hpp
99         MnistDatabase.cpp)
100     TfParserTest(TfMnist-Armnn "${TfMnist-Armnn_sources}")
101
102     set(TfCifar10-Armnn_sources
103         TfCifar10-Armnn/TfCifar10-Armnn.cpp
104         Cifar10Database.hpp
105         Cifar10Database.cpp)
106     TfParserTest(TfCifar10-Armnn "${TfCifar10-Armnn_sources}")
107
108     set(TfMobileNet-Armnn_sources
109         TfMobileNet-Armnn/TfMobileNet-Armnn.cpp
110         ImagePreprocessor.hpp
111         ImagePreprocessor.cpp)
112     TfParserTest(TfMobileNet-Armnn "${TfMobileNet-Armnn_sources}")
113
114     set(TfInceptionV3-Armnn_sources
115         TfInceptionV3-Armnn/TfInceptionV3-Armnn.cpp
116         ImagePreprocessor.hpp
117         ImagePreprocessor.cpp)
118     TfParserTest(TfInceptionV3-Armnn "${TfInceptionV3-Armnn_sources}")
119
120     set(TfResNext-Armnn_sources
121         TfResNext_Quantized-Armnn/TfResNext_Quantized-Armnn.cpp
122         CaffePreprocessor.hpp
123         CaffePreprocessor.cpp)
124     TfParserTest(TfResNext-Armnn "${TfResNext-Armnn_sources}")
125 endif()
126
127 if (BUILD_TF_LITE_PARSER)
128     macro(TfLiteParserTest testName sources)
129         add_executable_ex(${testName} ${sources})
130         target_include_directories(${testName} PRIVATE ../src/armnnUtils)
131         target_include_directories(${testName} PRIVATE ../src/backends)
132
133         target_link_libraries(${testName} inferenceTest)
134         target_link_libraries(${testName} armnnTfLiteParser)
135         target_link_libraries(${testName} armnn)
136         target_link_libraries(${testName} ${CMAKE_THREAD_LIBS_INIT})
137         addDllCopyCommands(${testName})
138     endmacro()
139
140     set(TfLiteMobilenetQuantized-Armnn_sources
141         TfLiteMobilenetQuantized-Armnn/TfLiteMobilenetQuantized-Armnn.cpp
142         ImagePreprocessor.hpp
143         ImagePreprocessor.cpp)
144     TfLiteParserTest(TfLiteMobilenetQuantized-Armnn "${TfLiteMobilenetQuantized-Armnn_sources}")
145
146     set(TfLiteMobileNetSsd-Armnn_sources
147         TfLiteMobileNetSsd-Armnn/TfLiteMobileNetSsd-Armnn.cpp
148         MobileNetSsdDatabase.hpp
149         MobileNetSsdInferenceTest.hpp
150         ObjectDetectionCommon.hpp)
151     TfLiteParserTest(TfLiteMobileNetSsd-Armnn "${TfLiteMobileNetSsd-Armnn_sources}")
152
153     set(TfLiteMobilenetV2Quantized-Armnn_sources
154         TfLiteMobilenetV2Quantized-Armnn/TfLiteMobilenetV2Quantized-Armnn.cpp
155         ImagePreprocessor.hpp
156         ImagePreprocessor.cpp)
157     TfLiteParserTest(TfLiteMobilenetV2Quantized-Armnn "${TfLiteMobilenetV2Quantized-Armnn_sources}")
158
159     set(TfLiteVGG16Quantized-Armnn_sources
160         TfLiteVGG16Quantized-Armnn/TfLiteVGG16Quantized-Armnn.cpp
161         ImagePreprocessor.hpp
162         ImagePreprocessor.cpp)
163     TfLiteParserTest(TfLiteVGG16Quantized-Armnn "${TfLiteVGG16Quantized-Armnn_sources}")
164
165     set(TfLiteMobileNetQuantizedSoftmax-Armnn_sources
166         TfLiteMobileNetQuantizedSoftmax-Armnn/TfLiteMobileNetQuantizedSoftmax-Armnn.cpp
167         ImagePreprocessor.hpp
168         ImagePreprocessor.cpp)
169     TfLiteParserTest(TfLiteMobileNetQuantizedSoftmax-Armnn "${TfLiteMobileNetQuantizedSoftmax-Armnn_sources}")
170
171     set(TfLiteInceptionV3Quantized-Armnn_sources
172         TfLiteInceptionV3Quantized-Armnn/TfLiteInceptionV3Quantized-Armnn.cpp
173         ImagePreprocessor.hpp
174         ImagePreprocessor.cpp)
175     TfLiteParserTest(TfLiteInceptionV3Quantized-Armnn "${TfLiteInceptionV3Quantized-Armnn_sources}")
176
177     set(TfLiteInceptionV4Quantized-Armnn_sources
178         TfLiteInceptionV4Quantized-Armnn/TfLiteInceptionV4Quantized-Armnn.cpp
179         ImagePreprocessor.hpp
180         ImagePreprocessor.cpp)
181     TfLiteParserTest(TfLiteInceptionV4Quantized-Armnn "${TfLiteInceptionV4Quantized-Armnn_sources}")
182
183     set(TfLiteResNetV2-Armnn_sources
184         TfLiteResNetV2-Armnn/TfLiteResNetV2-Armnn.cpp
185         ImagePreprocessor.hpp
186         ImagePreprocessor.cpp)
187     TfLiteParserTest(TfLiteResNetV2-Armnn "${TfLiteResNetV2-Armnn_sources}")
188
189     set(TfLiteResNetV2-50-Quantized-Armnn_sources
190         TfLiteResNetV2-50-Quantized-Armnn/TfLiteResNetV2-50-Quantized-Armnn.cpp
191         ImagePreprocessor.hpp
192         ImagePreprocessor.cpp)
193     TfLiteParserTest(TfLiteResNetV2-50-Quantized-Armnn "${TfLiteResNetV2-50-Quantized-Armnn_sources}")
194
195     set(TfLiteMnasNet-Armnn_sources
196         TfLiteMnasNet-Armnn/TfLiteMnasNet-Armnn.cpp
197         ImagePreprocessor.hpp
198         ImagePreprocessor.cpp)
199     TfLiteParserTest(TfLiteMnasNet-Armnn "${TfLiteMnasNet-Armnn_sources}")
200
201
202     set(TfLiteYoloV3Big-Armnn_sources
203         TfLiteYoloV3Big-Armnn/NMS.cpp
204         TfLiteYoloV3Big-Armnn/NMS.hpp
205         TfLiteYoloV3Big-Armnn/TfLiteYoloV3Big-Armnn.cpp
206         ImagePreprocessor.hpp
207         ImagePreprocessor.cpp)
208     TfLiteParserTest(TfLiteYoloV3Big-Armnn "${TfLiteYoloV3Big-Armnn_sources}")
209 endif()
210
211 if (BUILD_ONNX_PARSER)
212     macro(OnnxParserTest testName sources)
213         add_executable_ex(${testName} ${sources})
214         target_include_directories(${testName} PRIVATE ../src/armnnUtils)
215         target_include_directories(${testName} PRIVATE ../src/backends)
216
217         target_link_libraries(${testName} inferenceTest)
218         target_link_libraries(${testName} armnnOnnxParser)
219         target_link_libraries(${testName} armnn)
220         target_link_libraries(${testName} ${CMAKE_THREAD_LIBS_INIT})
221         addDllCopyCommands(${testName})
222     endmacro()
223
224     set(OnnxMnist-Armnn_sources
225         OnnxMnist-Armnn/OnnxMnist-Armnn.cpp
226         MnistDatabase.hpp
227         MnistDatabase.cpp)
228     OnnxParserTest(OnnxMnist-Armnn "${OnnxMnist-Armnn_sources}")
229
230     set(OnnxMobileNet-Armnn_sources
231         OnnxMobileNet-Armnn/OnnxMobileNet-Armnn.cpp
232         ImagePreprocessor.hpp
233         ImagePreprocessor.cpp)
234     OnnxParserTest(OnnxMobileNet-Armnn "${OnnxMobileNet-Armnn_sources}")
235 endif()
236
237 if (BUILD_ARMNN_SERIALIZER OR BUILD_CAFFE_PARSER OR BUILD_TF_PARSER OR BUILD_TF_LITE_PARSER OR BUILD_ONNX_PARSER)
238     set(ExecuteNetwork_sources
239         ExecuteNetwork/ExecuteNetwork.cpp
240         ExecuteNetwork/ExecuteNetworkProgramOptions.cpp
241         ExecuteNetwork/ExecuteNetworkProgramOptions.hpp
242         ExecuteNetwork/ExecuteNetworkParams.cpp
243         ExecuteNetwork/ExecuteNetworkParams.hpp
244         NetworkExecutionUtils/NetworkExecutionUtils.cpp
245         NetworkExecutionUtils/NetworkExecutionUtils.hpp)
246
247     add_executable_ex(ExecuteNetwork ${ExecuteNetwork_sources})
248     target_include_directories(ExecuteNetwork PRIVATE ../src/armnn)
249     target_include_directories(ExecuteNetwork PRIVATE ../src/armnnUtils)
250     target_include_directories(ExecuteNetwork PRIVATE ../src/backends)
251     target_include_directories(ExecuteNetwork PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
252
253     if (BUILD_ARMNN_SERIALIZER)
254         target_link_libraries(ExecuteNetwork armnnSerializer)
255     endif()
256     if (BUILD_CAFFE_PARSER)
257         target_link_libraries(ExecuteNetwork armnnCaffeParser)
258     endif()
259     if (BUILD_TF_PARSER)
260         target_link_libraries(ExecuteNetwork armnnTfParser)
261     endif()
262
263     if (BUILD_TF_LITE_PARSER)
264         target_link_libraries(ExecuteNetwork armnnTfLiteParser)
265     endif()
266     if (BUILD_ONNX_PARSER)
267         target_link_libraries(ExecuteNetwork armnnOnnxParser)
268     endif()
269     if (BUILD_ARMNN_TFLITE_DELEGATE)
270         target_link_libraries(ExecuteNetwork ArmnnDelegate::ArmnnDelegate)
271     endif()
272     target_link_libraries(ExecuteNetwork armnn)
273
274    target_link_libraries(ExecuteNetwork ${CMAKE_THREAD_LIBS_INIT})
275    addDllCopyCommands(ExecuteNetwork)
276 endif()
277
278 if(BUILD_ACCURACY_TOOL)
279     macro(AccuracyTool executorName)
280         target_link_libraries(${executorName} ${CMAKE_THREAD_LIBS_INIT})
281         if (BUILD_ARMNN_SERIALIZER)
282             target_link_libraries(${executorName} armnnSerializer)
283         endif()
284         if (BUILD_CAFFE_PARSER)
285             target_link_libraries(${executorName} armnnCaffeParser)
286         endif()
287         if (BUILD_TF_PARSER)
288             target_link_libraries(${executorName} armnnTfParser)
289         endif()
290         if (BUILD_TF_LITE_PARSER)
291             target_link_libraries(${executorName} armnnTfLiteParser)
292         endif()
293         if (BUILD_ONNX_PARSER)
294             target_link_libraries(${executorName} armnnOnnxParser)
295         endif()
296         addDllCopyCommands(${executorName})
297     endmacro()
298
299     set(ModelAccuracyTool-Armnn_sources
300             ModelAccuracyTool-Armnn/ModelAccuracyTool-Armnn.cpp)
301
302     add_executable_ex(ModelAccuracyTool ${ModelAccuracyTool-Armnn_sources})
303     target_include_directories(ModelAccuracyTool PRIVATE ../src/armnn)
304     target_include_directories(ModelAccuracyTool PRIVATE ../src/armnnUtils)
305     target_include_directories(ModelAccuracyTool PRIVATE ../src/backends)
306     target_link_libraries(ModelAccuracyTool inferenceTest)
307     target_link_libraries(ModelAccuracyTool armnn)
308     target_link_libraries(ModelAccuracyTool armnnSerializer)
309     AccuracyTool(ModelAccuracyTool)
310 endif()
311
312 if(BUILD_ARMNN_QUANTIZER)
313     macro(ImageTensorExecutor executorName)
314         target_link_libraries(${executorName} ${CMAKE_THREAD_LIBS_INIT})
315         addDllCopyCommands(${executorName})
316     endmacro()
317
318     set(ImageTensorGenerator_sources
319             InferenceTestImage.hpp
320             InferenceTestImage.cpp
321             ImageTensorGenerator/ImageTensorGenerator.cpp)
322
323     add_executable_ex(ImageTensorGenerator ${ImageTensorGenerator_sources})
324     target_include_directories(ImageTensorGenerator PRIVATE ../src/armnn)
325     target_include_directories(ImageTensorGenerator PRIVATE ../src/armnnUtils)
326
327     target_link_libraries(ImageTensorGenerator armnn)
328     ImageTensorExecutor(ImageTensorGenerator)
329
330     set(ImageCSVFileGenerator_sources
331             ImageCSVFileGenerator/ImageCSVFileGenerator.cpp)
332
333     add_executable_ex(ImageCSVFileGenerator ${ImageCSVFileGenerator_sources})
334     target_include_directories(ImageCSVFileGenerator PRIVATE ../src/armnnUtils)
335     ImageTensorExecutor(ImageCSVFileGenerator)
336 endif()