blob: 102d744aa7e3f3b4e419ec2be81be02538c07a88 [file] [log] [blame]
Jim Flynn6217c3d2022-06-14 10:58:23 +01001#
Ryan OSheab5540542022-07-06 09:52:52 +01002# Copyright © 2018-2023 Arm Ltd and Contributors. All rights reserved.
Jim Flynn6217c3d2022-06-14 10:58:23 +01003# SPDX-License-Identifier: MIT
4#
5
telsoa014fcda012018-03-09 14:13:49 +00006# UnitTests
7include(CheckIncludeFiles)
8
telsoa014fcda012018-03-09 14:13:49 +00009# Setup the inference test framework
10set(inference_test_sources
11 ClassifierTestCaseData.hpp
12 InferenceModel.hpp
13 InferenceTest.hpp
14 InferenceTest.inl
15 InferenceTest.cpp
16 InferenceTestImage.hpp
17 InferenceTestImage.cpp)
Sadik Armagan93e2e402019-05-02 09:31:38 +010018
telsoa014fcda012018-03-09 14:13:49 +000019add_library_ex(inferenceTest STATIC ${inference_test_sources})
20target_include_directories(inferenceTest PRIVATE ../src/armnnUtils)
David Beck1b61be52018-11-08 09:19:14 +000021target_include_directories(inferenceTest PRIVATE ../src/backends)
Sadik Armagan93e2e402019-05-02 09:31:38 +010022target_include_directories(inferenceTest PRIVATE ../third-party/stb)
telsoa014fcda012018-03-09 14:13:49 +000023
Ryan OSheab5540542022-07-06 09:52:52 +010024if (BUILD_TF_LITE_PARSER AND NOT EXECUTE_NETWORK_STATIC)
telsoa01c577f2c2018-08-31 09:22:23 +010025 macro(TfLiteParserTest testName sources)
26 add_executable_ex(${testName} ${sources})
27 target_include_directories(${testName} PRIVATE ../src/armnnUtils)
David Beck1b61be52018-11-08 09:19:14 +000028 target_include_directories(${testName} PRIVATE ../src/backends)
telsoa01c577f2c2018-08-31 09:22:23 +010029
30 target_link_libraries(${testName} inferenceTest)
31 target_link_libraries(${testName} armnnTfLiteParser)
32 target_link_libraries(${testName} armnn)
33 target_link_libraries(${testName} ${CMAKE_THREAD_LIBS_INIT})
telsoa01c577f2c2018-08-31 09:22:23 +010034 addDllCopyCommands(${testName})
35 endmacro()
36
Jim Flynn27a9bd92020-11-12 15:48:34 +000037 set(TfLiteBenchmark-Armnn_sources
38 TfLiteBenchmark-Armnn/TfLiteBenchmark-Armnn.cpp)
39 TfLiteParserTest(TfLiteBenchmark-Armnn "${TfLiteBenchmark-Armnn_sources}")
40
telsoa01c577f2c2018-08-31 09:22:23 +010041 set(TfLiteMobilenetQuantized-Armnn_sources
42 TfLiteMobilenetQuantized-Armnn/TfLiteMobilenetQuantized-Armnn.cpp
43 ImagePreprocessor.hpp
44 ImagePreprocessor.cpp)
45 TfLiteParserTest(TfLiteMobilenetQuantized-Armnn "${TfLiteMobilenetQuantized-Armnn_sources}")
Nattapat Chaimanowongd8eee592018-10-26 10:24:14 +010046
Aron Virginas-Tard089b742019-01-29 11:09:51 +000047 set(TfLiteMobileNetSsd-Armnn_sources
48 TfLiteMobileNetSsd-Armnn/TfLiteMobileNetSsd-Armnn.cpp
49 MobileNetSsdDatabase.hpp
50 MobileNetSsdInferenceTest.hpp
51 ObjectDetectionCommon.hpp)
52 TfLiteParserTest(TfLiteMobileNetSsd-Armnn "${TfLiteMobileNetSsd-Armnn_sources}")
53
Bruno Goncalves06304112018-12-27 16:13:58 -020054 set(TfLiteMobilenetV2Quantized-Armnn_sources
55 TfLiteMobilenetV2Quantized-Armnn/TfLiteMobilenetV2Quantized-Armnn.cpp
56 ImagePreprocessor.hpp
57 ImagePreprocessor.cpp)
58 TfLiteParserTest(TfLiteMobilenetV2Quantized-Armnn "${TfLiteMobilenetV2Quantized-Armnn_sources}")
59
Nattapat Chaimanowongd8eee592018-10-26 10:24:14 +010060 set(TfLiteVGG16Quantized-Armnn_sources
61 TfLiteVGG16Quantized-Armnn/TfLiteVGG16Quantized-Armnn.cpp
62 ImagePreprocessor.hpp
63 ImagePreprocessor.cpp)
64 TfLiteParserTest(TfLiteVGG16Quantized-Armnn "${TfLiteVGG16Quantized-Armnn_sources}")
Bruno Goncalvesc981df32018-12-27 16:15:01 -020065
David Monahana820e022019-04-23 11:03:38 +010066 set(TfLiteMobileNetQuantizedSoftmax-Armnn_sources
67 TfLiteMobileNetQuantizedSoftmax-Armnn/TfLiteMobileNetQuantizedSoftmax-Armnn.cpp
68 ImagePreprocessor.hpp
69 ImagePreprocessor.cpp)
70 TfLiteParserTest(TfLiteMobileNetQuantizedSoftmax-Armnn "${TfLiteMobileNetQuantizedSoftmax-Armnn_sources}")
71
Bruno Goncalvesc981df32018-12-27 16:15:01 -020072 set(TfLiteInceptionV3Quantized-Armnn_sources
73 TfLiteInceptionV3Quantized-Armnn/TfLiteInceptionV3Quantized-Armnn.cpp
74 ImagePreprocessor.hpp
75 ImagePreprocessor.cpp)
76 TfLiteParserTest(TfLiteInceptionV3Quantized-Armnn "${TfLiteInceptionV3Quantized-Armnn_sources}")
Bruno Goncalves8f293382018-12-27 16:15:38 -020077
Bruno Goncalvesccbde0e2018-12-28 10:09:53 -020078 set(TfLiteInceptionV4Quantized-Armnn_sources
79 TfLiteInceptionV4Quantized-Armnn/TfLiteInceptionV4Quantized-Armnn.cpp
80 ImagePreprocessor.hpp
81 ImagePreprocessor.cpp)
82 TfLiteParserTest(TfLiteInceptionV4Quantized-Armnn "${TfLiteInceptionV4Quantized-Armnn_sources}")
83
Bruno Goncalves8f293382018-12-27 16:15:38 -020084 set(TfLiteResNetV2-Armnn_sources
85 TfLiteResNetV2-Armnn/TfLiteResNetV2-Armnn.cpp
86 ImagePreprocessor.hpp
87 ImagePreprocessor.cpp)
88 TfLiteParserTest(TfLiteResNetV2-Armnn "${TfLiteResNetV2-Armnn_sources}")
Bruno Goncalves61980d42018-12-28 10:08:26 -020089
Nina Drozd472d4e02019-04-15 17:18:36 +010090 set(TfLiteResNetV2-50-Quantized-Armnn_sources
David Monahana820e022019-04-23 11:03:38 +010091 TfLiteResNetV2-50-Quantized-Armnn/TfLiteResNetV2-50-Quantized-Armnn.cpp
92 ImagePreprocessor.hpp
93 ImagePreprocessor.cpp)
Nina Drozd472d4e02019-04-15 17:18:36 +010094 TfLiteParserTest(TfLiteResNetV2-50-Quantized-Armnn "${TfLiteResNetV2-50-Quantized-Armnn_sources}")
95
Bruno Goncalves61980d42018-12-28 10:08:26 -020096 set(TfLiteMnasNet-Armnn_sources
97 TfLiteMnasNet-Armnn/TfLiteMnasNet-Armnn.cpp
98 ImagePreprocessor.hpp
99 ImagePreprocessor.cpp)
100 TfLiteParserTest(TfLiteMnasNet-Armnn "${TfLiteMnasNet-Armnn_sources}")
Derek Lambertid6cb30e2020-04-28 13:31:29 +0100101
102
103 set(TfLiteYoloV3Big-Armnn_sources
104 TfLiteYoloV3Big-Armnn/NMS.cpp
105 TfLiteYoloV3Big-Armnn/NMS.hpp
106 TfLiteYoloV3Big-Armnn/TfLiteYoloV3Big-Armnn.cpp
107 ImagePreprocessor.hpp
108 ImagePreprocessor.cpp)
109 TfLiteParserTest(TfLiteYoloV3Big-Armnn "${TfLiteYoloV3Big-Armnn_sources}")
Nikhil Raj5d955cf2021-04-19 16:59:48 +0100110
111
112
telsoa01c577f2c2018-08-31 09:22:23 +0100113endif()
114
Ryan OSheab5540542022-07-06 09:52:52 +0100115if (BUILD_ONNX_PARSER AND NOT EXECUTE_NETWORK_STATIC)
telsoa01c577f2c2018-08-31 09:22:23 +0100116 macro(OnnxParserTest testName sources)
117 add_executable_ex(${testName} ${sources})
118 target_include_directories(${testName} PRIVATE ../src/armnnUtils)
David Beck1b61be52018-11-08 09:19:14 +0000119 target_include_directories(${testName} PRIVATE ../src/backends)
telsoa01c577f2c2018-08-31 09:22:23 +0100120
121 target_link_libraries(${testName} inferenceTest)
122 target_link_libraries(${testName} armnnOnnxParser)
123 target_link_libraries(${testName} armnn)
124 target_link_libraries(${testName} ${CMAKE_THREAD_LIBS_INIT})
telsoa01c577f2c2018-08-31 09:22:23 +0100125 addDllCopyCommands(${testName})
126 endmacro()
127
128 set(OnnxMnist-Armnn_sources
129 OnnxMnist-Armnn/OnnxMnist-Armnn.cpp
130 MnistDatabase.hpp
131 MnistDatabase.cpp)
132 OnnxParserTest(OnnxMnist-Armnn "${OnnxMnist-Armnn_sources}")
133
134 set(OnnxMobileNet-Armnn_sources
135 OnnxMobileNet-Armnn/OnnxMobileNet-Armnn.cpp
136 ImagePreprocessor.hpp
137 ImagePreprocessor.cpp)
138 OnnxParserTest(OnnxMobileNet-Armnn "${OnnxMobileNet-Armnn_sources}")
139endif()
140
Jan Eilers17d34da2021-12-08 16:15:12 +0000141if (BUILD_ARMNN_SERIALIZER
Jan Eilers17d34da2021-12-08 16:15:12 +0000142 OR BUILD_TF_LITE_PARSER
143 OR BUILD_ONNX_PARSER
Teresa Charlinad1b3d72023-03-14 12:10:28 +0000144 OR BUILD_CLASSIC_DELEGATE)
telsoa014fcda012018-03-09 14:13:49 +0000145 set(ExecuteNetwork_sources
Teresa Charlin83b42912022-07-07 14:24:59 +0100146 ExecuteNetwork/IExecutor.hpp
147 ExecuteNetwork/ArmNNExecutor.cpp
148 ExecuteNetwork/ArmNNExecutor.hpp
Jan Eilers45274902020-10-15 18:34:43 +0100149 ExecuteNetwork/ExecuteNetwork.cpp
150 ExecuteNetwork/ExecuteNetworkProgramOptions.cpp
151 ExecuteNetwork/ExecuteNetworkProgramOptions.hpp
152 ExecuteNetwork/ExecuteNetworkParams.cpp
153 ExecuteNetwork/ExecuteNetworkParams.hpp
154 NetworkExecutionUtils/NetworkExecutionUtils.cpp
155 NetworkExecutionUtils/NetworkExecutionUtils.hpp)
telsoa014fcda012018-03-09 14:13:49 +0000156
Teresa Charlinad1b3d72023-03-14 12:10:28 +0000157 if(BUILD_CLASSIC_DELEGATE)
Colm Donelan88b90252022-10-23 14:02:57 +0100158 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-comment")
Teresa Charlin83b42912022-07-07 14:24:59 +0100159 set(ExecuteNetwork_sources
160 ${ExecuteNetwork_sources}
161 ExecuteNetwork/TfliteExecutor.cpp
162 ExecuteNetwork/TfliteExecutor.hpp)
163 endif()
164
telsoa014fcda012018-03-09 14:13:49 +0000165 add_executable_ex(ExecuteNetwork ${ExecuteNetwork_sources})
telsoa01c577f2c2018-08-31 09:22:23 +0100166 target_include_directories(ExecuteNetwork PRIVATE ../src/armnn)
Aron Virginas-Tar5cc8e562018-10-23 15:14:46 +0100167 target_include_directories(ExecuteNetwork PRIVATE ../src/armnnUtils)
David Beck1b61be52018-11-08 09:19:14 +0000168 target_include_directories(ExecuteNetwork PRIVATE ../src/backends)
Jan Eilers45274902020-10-15 18:34:43 +0100169 target_include_directories(ExecuteNetwork PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
Ryan OSheab5540542022-07-06 09:52:52 +0100170 if(EXECUTE_NETWORK_STATIC)
171 target_link_libraries(ExecuteNetwork
172 -Wl,--whole-archive
173 armnnSerializer
174 armnnTfLiteParser
175 armnn
176 pthread
177 -Wl,--no-whole-archive
178 )
179 else()
180 if (BUILD_ARMNN_SERIALIZER)
181 target_link_libraries(ExecuteNetwork armnnSerializer)
182 endif()
183 if (BUILD_TF_LITE_PARSER)
184 target_link_libraries(ExecuteNetwork armnnTfLiteParser)
185 endif()
186 if (BUILD_ONNX_PARSER)
187 target_link_libraries(ExecuteNetwork armnnOnnxParser)
188 endif()
Teresa Charlinad1b3d72023-03-14 12:10:28 +0000189 if (BUILD_CLASSIC_DELEGATE)
Ryan OSheab5540542022-07-06 09:52:52 +0100190 target_link_libraries(ExecuteNetwork ArmnnDelegate::ArmnnDelegate)
191 endif()
192 target_link_libraries(ExecuteNetwork armnn)
Aron Virginas-Tar64e4ccb2019-02-12 11:27:53 +0000193 endif()
telsoa01c577f2c2018-08-31 09:22:23 +0100194
Sadik Armagan5d03e312020-11-17 16:43:56 +0000195 target_link_libraries(ExecuteNetwork ${CMAKE_THREAD_LIBS_INIT})
196 addDllCopyCommands(ExecuteNetwork)
telsoa014fcda012018-03-09 14:13:49 +0000197endif()
Sadik Armagan8271f812019-04-19 09:55:06 +0100198
Éanna Ó Catháina4247d52019-05-08 14:00:45 +0100199if(BUILD_ACCURACY_TOOL)
200 macro(AccuracyTool executorName)
201 target_link_libraries(${executorName} ${CMAKE_THREAD_LIBS_INIT})
Francis Murtaghbee4bc92019-06-18 12:30:37 +0100202 if (BUILD_ARMNN_SERIALIZER)
203 target_link_libraries(${executorName} armnnSerializer)
204 endif()
Francis Murtaghbee4bc92019-06-18 12:30:37 +0100205 if (BUILD_TF_LITE_PARSER)
206 target_link_libraries(${executorName} armnnTfLiteParser)
207 endif()
208 if (BUILD_ONNX_PARSER)
209 target_link_libraries(${executorName} armnnOnnxParser)
210 endif()
Éanna Ó Catháina4247d52019-05-08 14:00:45 +0100211 addDllCopyCommands(${executorName})
212 endmacro()
213
214 set(ModelAccuracyTool-Armnn_sources
215 ModelAccuracyTool-Armnn/ModelAccuracyTool-Armnn.cpp)
216
217 add_executable_ex(ModelAccuracyTool ${ModelAccuracyTool-Armnn_sources})
218 target_include_directories(ModelAccuracyTool PRIVATE ../src/armnn)
219 target_include_directories(ModelAccuracyTool PRIVATE ../src/armnnUtils)
220 target_include_directories(ModelAccuracyTool PRIVATE ../src/backends)
221 target_link_libraries(ModelAccuracyTool inferenceTest)
222 target_link_libraries(ModelAccuracyTool armnn)
223 target_link_libraries(ModelAccuracyTool armnnSerializer)
224 AccuracyTool(ModelAccuracyTool)
225endif()
226
Kevin May4a621c432021-04-22 16:51:18 +0100227if(BUILD_ACCURACY_TOOL)
Sadik Armagan8271f812019-04-19 09:55:06 +0100228 macro(ImageTensorExecutor executorName)
229 target_link_libraries(${executorName} ${CMAKE_THREAD_LIBS_INIT})
Sadik Armagan8271f812019-04-19 09:55:06 +0100230 addDllCopyCommands(${executorName})
231 endmacro()
232
233 set(ImageTensorGenerator_sources
234 InferenceTestImage.hpp
235 InferenceTestImage.cpp
236 ImageTensorGenerator/ImageTensorGenerator.cpp)
237
238 add_executable_ex(ImageTensorGenerator ${ImageTensorGenerator_sources})
239 target_include_directories(ImageTensorGenerator PRIVATE ../src/armnn)
240 target_include_directories(ImageTensorGenerator PRIVATE ../src/armnnUtils)
241
242 target_link_libraries(ImageTensorGenerator armnn)
243 ImageTensorExecutor(ImageTensorGenerator)
244
245 set(ImageCSVFileGenerator_sources
246 ImageCSVFileGenerator/ImageCSVFileGenerator.cpp)
247
248 add_executable_ex(ImageCSVFileGenerator ${ImageCSVFileGenerator_sources})
Francis Murtagh532a29d2020-06-29 11:50:01 +0100249 target_include_directories(ImageCSVFileGenerator PRIVATE ../src/armnnUtils)
Sadik Armagan8271f812019-04-19 09:55:06 +0100250 ImageTensorExecutor(ImageCSVFileGenerator)
251endif()
Jim Flynne1fdd282021-10-26 21:26:10 +0100252
253if(BUILD_MEMORY_STRATEGY_BENCHMARK)
254 add_subdirectory(MemoryStrategyBenchmark)
255endif()