2 # Copyright © 2017 Arm Ltd. All rights reserved.
3 # SPDX-License-Identifier: MIT
5 cmake_minimum_required (VERSION 3.0.2) # 3.0.2 required for return() statement used in AddDllCopyCommands.cmake
8 set(additional_cmake_files)
9 list(APPEND additional_cmake_files
11 cmake/GlobalConfig.cmake
12 cmake/AddDllCopyCommands.cmake)
14 foreach(cmake_file ${additional_cmake_files})
15 include(${cmake_file})
18 if (DYNAMIC_BACKEND_PATHS)
19 # It's expected to have the format: DYNAMIC_BACKEND_PATHS="PATH_1:PATH_2...:PATH_N"
20 add_definitions('-DDYNAMIC_BACKEND_PATHS="${DYNAMIC_BACKEND_PATHS}"')
23 include(GNUInstallDirs)
25 add_subdirectory(samples)
26 add_subdirectory(src/armnnTfLiteParser)
27 add_subdirectory(src/armnnSerializer)
30 add_subdirectory(tests)
33 # Include the additional cmake files in their own target so that they will appear nicely in IDEs
34 add_custom_target(AdditionalCMakeFiles SOURCES ${additional_cmake_files})
36 set(armnnUtils_sources)
37 list(APPEND armnnUtils_sources
38 src/armnnUtils/GraphTopologicalSort.hpp
39 src/armnnUtils/Half.hpp
40 src/armnnUtils/Logging.hpp
41 src/armnnUtils/Logging.cpp
42 src/armnnUtils/Permute.hpp
43 src/armnnUtils/Permute.cpp
44 src/armnnUtils/DataLayoutIndexed.cpp
45 src/armnnUtils/DataLayoutIndexed.hpp
46 src/armnnUtils/DotSerializer.cpp
47 src/armnnUtils/DotSerializer.hpp
48 src/armnnUtils/HeapProfiling.cpp
49 src/armnnUtils/HeapProfiling.hpp
50 src/armnnUtils/LeakChecking.cpp
51 src/armnnUtils/LeakChecking.hpp
52 src/armnnUtils/ModelAccuracyChecker.cpp
53 src/armnnUtils/ModelAccuracyChecker.hpp
54 src/armnnUtils/CsvReader.cpp
55 src/armnnUtils/CsvReader.hpp
56 src/armnnUtils/FloatingPointConverter.cpp
57 src/armnnUtils/FloatingPointConverter.hpp
58 src/armnnUtils/VerificationHelpers.hpp
59 src/armnnUtils/VerificationHelpers.cpp
60 src/armnnUtils/ParserHelper.hpp
61 src/armnnUtils/ParserHelper.cpp
62 src/armnnUtils/ParserPrototxtFixture.hpp
63 src/armnnUtils/PrototxtConversions.hpp
64 src/armnnUtils/PrototxtConversions.cpp
65 src/armnnUtils/TensorIOUtils.hpp
66 src/armnnUtils/TensorUtils.hpp
67 src/armnnUtils/TensorUtils.cpp
70 add_library_ex(armnnUtils STATIC ${armnnUtils_sources})
71 target_include_directories(armnnUtils PRIVATE src/backends)
73 if(BUILD_CAFFE_PARSER)
74 # ArmNN Parser source files required for all build options
75 set(armnn_caffe_parser_sources)
76 list(APPEND armnn_caffe_parser_sources
77 include/armnnCaffeParser/ICaffeParser.hpp
78 src/armnnCaffeParser/RecordByRecordCaffeParser.hpp
79 src/armnnCaffeParser/RecordByRecordCaffeParser.cpp
80 src/armnnCaffeParser/CaffeParser.hpp
81 src/armnnCaffeParser/CaffeParser.cpp
82 ${CAFFE_GENERATED_SOURCES}/caffe/proto/caffe.pb.cc
84 # The generated Caffe protobuf .cc file is not warning clean and we can't fix them.
85 if(COMPILER_IS_GNU_LIKE)
86 set_source_files_properties(${CAFFE_GENERATED_SOURCES}/caffe/proto/caffe.pb.cc PROPERTIES COMPILE_FLAGS "-Wno-conversion -Wno-sign-conversion")
89 add_library_ex(armnnCaffeParser SHARED ${armnn_caffe_parser_sources})
90 set_target_properties(armnnCaffeParser PROPERTIES COMPILE_FLAGS "${CAFFE_PARSER_ADDITIONAL_COMPILE_FLAGS}")
92 target_include_directories(armnnCaffeParser PRIVATE src/armnnUtils)
94 target_link_libraries(armnnCaffeParser ${Boost_LOG_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY})
96 target_link_libraries(armnnCaffeParser armnn)
97 target_link_libraries(armnnCaffeParser ${PROTOBUF_LIBRARIES})
101 if(BUILD_ONNX_PARSER)
102 set(armnn_onnx_parser_sources)
103 list(APPEND armnn_onnx_parser_sources
104 include/armnnOnnxParser/IOnnxParser.hpp
105 src/armnnOnnxParser/OnnxParser.hpp
106 src/armnnOnnxParser/OnnxParser.cpp
107 ${ONNX_GENERATED_SOURCES}/onnx/onnx.pb.cc
109 # The generated onnx protobuf .cc files are not warning clean and we can't fix them.
110 if(COMPILER_IS_GNU_LIKE)
111 set_source_files_properties(${ONNX_GENERATED_SOURCES}/onnx/onnx.pb.cc PROPERTIES COMPILE_FLAGS "-Wno-conversion -Wno-sign-conversion")
114 add_library_ex(armnnOnnxParser SHARED ${armnn_onnx_parser_sources})
116 target_include_directories(armnnOnnxParser PRIVATE src/armnnUtils)
118 target_link_libraries(armnnOnnxParser armnn)
121 target_link_libraries(armnnOnnxParser ${PROTOBUF_LIBRARIES})
125 set(armnn_tf_parser_sources)
126 list(APPEND armnn_tf_parser_sources
127 include/armnnTfParser/ITfParser.hpp
128 src/armnnTfParser/TfParser.hpp
129 src/armnnTfParser/TfParser.cpp
132 # The generated tensorflow protobuf .cc files are not warning clean and we can't fix them.
133 if(COMPILER_IS_GNU_LIKE)
134 set_source_files_properties(${TF_PROTOBUFS} PROPERTIES COMPILE_FLAGS "-Wno-conversion -Wno-sign-conversion")
137 add_library_ex(armnnTfParser SHARED ${armnn_tf_parser_sources})
139 target_include_directories(armnnTfParser PRIVATE src/armnnUtils)
141 target_link_libraries(armnnTfParser armnn)
143 # Protobuf (use the specific version tensorflow wants)
144 target_link_libraries(armnnTfParser ${PROTOBUF_LIBRARIES})
147 if(BUILD_ARMNN_QUANTIZER AND ARMNNREF)
148 if(NOT BUILD_ARMNN_SERIALIZER)
149 message(ERROR, "In order to build the ArmNN Quantization Tool you must set BUILD_ARMNN_SERIALIZER = YES")
152 set(armnn_quantizer_sources)
153 list(APPEND armnn_quantizer_sources
154 src/armnnQuantizer/QuantizationDataSet.hpp
155 src/armnnQuantizer/QuantizationDataSet.cpp
156 src/armnnQuantizer/QuantizationInput.hpp
157 src/armnnQuantizer/QuantizationInput.cpp
158 src/armnnQuantizer/CommandLineProcessor.hpp
159 src/armnnQuantizer/CommandLineProcessor.cpp
162 add_library_ex(armnnQuantizer SHARED ${armnn_quantizer_sources})
164 target_include_directories(armnnQuantizer PRIVATE include/armnnDeserializer)
165 target_include_directories(armnnQuantizer PRIVATE src/armnnUtils)
166 target_include_directories(armnnQuantizer PRIVATE src/armnn)
168 include_directories(SYSTEM "${FLATBUFFERS_INCLUDE_PATH}")
169 set_target_properties(armnnQuantizer PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
171 target_link_libraries(armnnQuantizer
173 ${Boost_SYSTEM_LIBRARY}
174 ${Boost_PROGRAM_OPTIONS_LIBRARY}
175 ${Boost_FILESYSTEM_LIBRARY}
177 ${Boost_THREAD_LIBRARY} )
179 add_executable_ex(ArmnnQuantizer
180 src/armnnQuantizer/ArmNNQuantizerMain.cpp)
182 target_include_directories(ArmnnQuantizer PRIVATE include/armnnDeserializer)
183 target_include_directories(ArmnnQuantizer PRIVATE src/armnn)
185 target_link_libraries(ArmnnQuantizer
186 ${Boost_SYSTEM_LIBRARY}
187 ${Boost_PROGRAM_OPTIONS_LIBRARY}
188 ${Boost_FILESYSTEM_LIBRARY}
190 ${Boost_THREAD_LIBRARY} )
192 target_link_libraries(ArmnnQuantizer
197 ${FLATBUFFERS_LIBRARY})
199 if(Threads_FOUND AND (NOT ("${CMAKE_SYSTEM_NAME}" STREQUAL Android)))
200 target_link_libraries(ArmnnQuantizer pthread)
206 list(APPEND armnn_sources
207 include/armnn/ArmNN.hpp
208 include/armnn/BackendHelper.hpp
209 include/armnn/BackendId.hpp
210 include/armnn/Conversion.hpp
211 include/armnn/Deprecated.hpp
212 include/armnn/Descriptors.hpp
213 include/armnn/DescriptorsFwd.hpp
214 include/armnn/Exceptions.hpp
215 include/armnn/ILayerSupport.hpp
216 include/armnn/ILayerVisitor.hpp
217 include/armnn/INetwork.hpp
218 include/armnn/IProfiler.hpp
219 include/armnn/IRuntime.hpp
220 include/armnn/LayerSupport.hpp
221 include/armnn/LayerVisitorBase.hpp
222 include/armnn/LstmParams.hpp
223 include/armnn/MemorySources.hpp
224 include/armnn/NetworkFwd.hpp
225 include/armnn/Optional.hpp
226 include/armnn/QuantizedLstmParams.hpp
227 include/armnn/Tensor.hpp
228 include/armnn/TensorFwd.hpp
229 include/armnn/Types.hpp
230 include/armnn/TypesUtils.hpp
231 include/armnn/Utils.hpp
232 include/armnn/Version.hpp
233 src/armnn/layers/LayerCloneBase.hpp
234 src/armnn/layers/LayerWithParameters.hpp
235 src/armnn/layers/AbsLayer.hpp
236 src/armnn/layers/AbsLayer.cpp
237 src/armnn/layers/ActivationLayer.hpp
238 src/armnn/layers/ActivationLayer.cpp
239 src/armnn/layers/AdditionLayer.hpp
240 src/armnn/layers/AdditionLayer.cpp
241 src/armnn/layers/ArgMinMaxLayer.hpp
242 src/armnn/layers/ArgMinMaxLayer.cpp
243 src/armnn/layers/BatchNormalizationLayer.hpp
244 src/armnn/layers/BatchNormalizationLayer.cpp
245 src/armnn/layers/BatchToSpaceNdLayer.hpp
246 src/armnn/layers/BatchToSpaceNdLayer.cpp
247 src/armnn/layers/ConcatLayer.hpp
248 src/armnn/layers/ConcatLayer.cpp
249 src/armnn/layers/ConstantLayer.hpp
250 src/armnn/layers/ConstantLayer.cpp
251 src/armnn/layers/Convolution2dLayer.hpp
252 src/armnn/layers/Convolution2dLayer.cpp
253 src/armnn/layers/ConvertFp16ToFp32Layer.hpp
254 src/armnn/layers/ConvertFp16ToFp32Layer.cpp
255 src/armnn/layers/ConvertFp32ToFp16Layer.hpp
256 src/armnn/layers/ConvertFp32ToFp16Layer.cpp
257 src/armnn/layers/DebugLayer.hpp
258 src/armnn/layers/DebugLayer.cpp
259 src/armnn/layers/DepthwiseConvolution2dLayer.hpp
260 src/armnn/layers/DepthwiseConvolution2dLayer.cpp
261 src/armnn/layers/DequantizeLayer.hpp
262 src/armnn/layers/DequantizeLayer.cpp
263 src/armnn/layers/DetectionPostProcessLayer.hpp
264 src/armnn/layers/DetectionPostProcessLayer.cpp
265 src/armnn/layers/ElementwiseBaseLayer.hpp
266 src/armnn/layers/ElementwiseBaseLayer.cpp
267 src/armnn/layers/EqualLayer.hpp
268 src/armnn/layers/EqualLayer.cpp
269 src/armnn/layers/FakeQuantizationLayer.hpp
270 src/armnn/layers/FakeQuantizationLayer.cpp
271 src/armnn/layers/FloorLayer.hpp
272 src/armnn/layers/FloorLayer.cpp
273 src/armnn/layers/FullyConnectedLayer.hpp
274 src/armnn/layers/FullyConnectedLayer.cpp
275 src/armnn/layers/GatherLayer.cpp
276 src/armnn/layers/GatherLayer.hpp
277 src/armnn/layers/GreaterLayer.cpp
278 src/armnn/layers/GreaterLayer.hpp
279 src/armnn/layers/InputLayer.hpp
280 src/armnn/layers/InputLayer.cpp
281 src/armnn/layers/L2NormalizationLayer.hpp
282 src/armnn/layers/L2NormalizationLayer.cpp
283 src/armnn/layers/LstmLayer.cpp
284 src/armnn/layers/LstmLayer.hpp
285 src/armnn/layers/MaximumLayer.cpp
286 src/armnn/layers/MaximumLayer.hpp
287 src/armnn/layers/MeanLayer.hpp
288 src/armnn/layers/MeanLayer.cpp
289 src/armnn/layers/MemCopyLayer.hpp
290 src/armnn/layers/MemCopyLayer.cpp
291 src/armnn/layers/MemImportLayer.hpp
292 src/armnn/layers/MemImportLayer.cpp
293 src/armnn/layers/MergeLayer.hpp
294 src/armnn/layers/MergeLayer.cpp
295 src/armnn/layers/MinimumLayer.cpp
296 src/armnn/layers/MinimumLayer.hpp
297 src/armnn/layers/MultiplicationLayer.hpp
298 src/armnn/layers/MultiplicationLayer.cpp
299 src/armnn/layers/NormalizationLayer.hpp
300 src/armnn/layers/NormalizationLayer.cpp
301 src/armnn/layers/OutputLayer.hpp
302 src/armnn/layers/OutputLayer.cpp
303 src/armnn/layers/PadLayer.hpp
304 src/armnn/layers/PadLayer.cpp
305 src/armnn/layers/PermuteLayer.hpp
306 src/armnn/layers/PermuteLayer.cpp
307 src/armnn/layers/Pooling2dLayer.hpp
308 src/armnn/layers/Pooling2dLayer.cpp
309 src/armnn/layers/QuantizeLayer.cpp
310 src/armnn/layers/QuantizeLayer.hpp
311 src/armnn/layers/QuantizedLstmLayer.hpp
312 src/armnn/layers/QuantizedLstmLayer.cpp
313 src/armnn/layers/DivisionLayer.cpp
314 src/armnn/layers/DivisionLayer.hpp
315 src/armnn/layers/PreCompiledLayer.hpp
316 src/armnn/layers/PreCompiledLayer.cpp
317 src/armnn/layers/PreluLayer.hpp
318 src/armnn/layers/PreluLayer.cpp
319 src/armnn/layers/ReshapeLayer.hpp
320 src/armnn/layers/ReshapeLayer.cpp
321 src/armnn/layers/ResizeLayer.hpp
322 src/armnn/layers/ResizeLayer.cpp
323 src/armnn/layers/RsqrtLayer.cpp
324 src/armnn/layers/RsqrtLayer.hpp
325 src/armnn/layers/SliceLayer.cpp
326 src/armnn/layers/SliceLayer.hpp
327 src/armnn/layers/SoftmaxLayer.hpp
328 src/armnn/layers/SoftmaxLayer.cpp
329 src/armnn/layers/SpaceToBatchNdLayer.hpp
330 src/armnn/layers/SpaceToBatchNdLayer.cpp
331 src/armnn/layers/SpaceToDepthLayer.hpp
332 src/armnn/layers/SpaceToDepthLayer.cpp
333 src/armnn/layers/SplitterLayer.hpp
334 src/armnn/layers/SplitterLayer.cpp
335 src/armnn/layers/StackLayer.hpp
336 src/armnn/layers/StackLayer.cpp
337 src/armnn/layers/StridedSliceLayer.cpp
338 src/armnn/layers/StridedSliceLayer.hpp
339 src/armnn/layers/SubtractionLayer.cpp
340 src/armnn/layers/SubtractionLayer.hpp
341 src/armnn/layers/SwitchLayer.cpp
342 src/armnn/layers/SwitchLayer.hpp
343 src/armnn/layers/TransposeConvolution2dLayer.cpp
344 src/armnn/layers/TransposeConvolution2dLayer.hpp
345 src/armnn/BackendSettings.hpp
346 src/armnn/BackendHelper.cpp
347 src/armnn/CompatibleTypes.hpp
348 src/armnn/Descriptors.cpp
349 src/armnn/DeviceSpec.hpp
350 src/armnn/DynamicQuantizationVisitor.cpp
351 src/armnn/DynamicQuantizationVisitor.hpp
352 src/armnn/Exceptions.cpp
353 src/armnn/ExecutionFrame.cpp
354 src/armnn/ExecutionFrame.hpp
357 src/armnn/IGraphObservable.hpp
358 src/armnn/Instrument.hpp
359 src/armnn/InternalTypes.cpp
360 src/armnn/InternalTypes.hpp
361 src/armnn/ISubgraphViewConverter.hpp
362 src/armnn/JsonPrinter.cpp
363 src/armnn/JsonPrinter.hpp
365 src/armnn/LayerFwd.hpp
367 src/armnn/LayersFwd.hpp
368 src/armnn/LayerSupportCommon.hpp
369 src/armnn/LayerSupport.cpp
370 src/armnn/LoadedNetwork.cpp
371 src/armnn/LoadedNetwork.hpp
372 src/armnn/Network.cpp
373 src/armnn/Network.hpp
374 src/armnn/NetworkQuantizationScheme.hpp
375 src/armnn/NetworkQuantizer.cpp
376 src/armnn/NetworkQuantizer.hpp
377 src/armnn/NetworkQuantizerUtils.cpp
378 src/armnn/NetworkQuantizerUtils.hpp
379 src/armnn/NetworkUtils.cpp
380 src/armnn/NetworkUtils.hpp
381 src/armnn/Observable.cpp
382 src/armnn/Observable.hpp
383 src/armnn/Optimizer.cpp
384 src/armnn/Optimizer.hpp
385 src/armnn/OverrideInputRangeVisitor.cpp
386 src/armnn/OverrideInputRangeVisitor.hpp
387 src/armnn/Profiling.cpp
388 src/armnn/ProfilingEvent.cpp
389 src/armnn/ProfilingEvent.hpp
390 src/armnn/Profiling.hpp
391 src/armnn/QuantizerVisitor.cpp
392 src/armnn/QuantizerVisitor.hpp
393 src/armnn/Runtime.cpp
394 src/armnn/Runtime.hpp
395 src/armnn/RangeTracker.cpp
396 src/armnn/RangeTracker.hpp
397 src/armnn/ResolveType.hpp
398 src/armnn/SerializeLayerParameters.cpp
399 src/armnn/SerializeLayerParameters.hpp
400 src/armnn/StaticRangeVisitor.cpp
401 src/armnn/StaticRangeVisitor.hpp
402 src/armnn/SubgraphView.cpp
403 src/armnn/SubgraphView.hpp
404 src/armnn/SubgraphViewSelector.cpp
405 src/armnn/SubgraphViewSelector.hpp
407 src/armnn/TypesUtils.cpp
409 src/armnn/WallClockTimer.cpp
410 src/armnn/WallClockTimer.hpp
411 src/armnn/optimizations/AddDebug.hpp
412 src/armnn/optimizations/All.hpp
413 src/armnn/optimizations/ConvertConstants.hpp
414 src/armnn/optimizations/ConvertFp32NetworkToFp16.hpp
415 src/armnn/optimizations/FoldPadIntoConvolution2d.hpp
416 src/armnn/optimizations/MovePermuteUp.hpp
417 src/armnn/optimizations/Optimization.hpp
418 src/armnn/optimizations/OptimizeConsecutiveReshapes.hpp
419 src/armnn/optimizations/OptimizeInverseConversions.hpp
420 src/armnn/optimizations/OptimizeInversePermutes.hpp
421 src/armnn/optimizations/PermuteAsReshape.hpp
422 src/armnn/optimizations/SquashEqualSiblings.hpp
423 src/profiling/CommandHandlerFunctor.cpp
424 src/profiling/CommandHandlerFunctor.hpp
425 src/profiling/CommandHandlerKey.cpp
426 src/profiling/CommandHandlerKey.hpp
427 src/profiling/CommandHandlerRegistry.cpp
428 src/profiling/CommandHandlerRegistry.hpp
429 src/profiling/CounterDirectory.cpp
430 src/profiling/CounterDirectory.hpp
431 src/profiling/EncodeVersion.hpp
432 src/profiling/Holder.cpp
433 src/profiling/Holder.hpp
434 src/profiling/IBufferWrapper.hpp
435 src/profiling/ICounterDirectory.hpp
436 src/profiling/ISendCounterPacket.hpp
437 src/profiling/IPeriodicCounterCapture.hpp
438 src/profiling/IProfilingConnection.hpp
439 src/profiling/Packet.cpp
440 src/profiling/Packet.hpp
441 src/profiling/PacketVersionResolver.cpp
442 src/profiling/PacketVersionResolver.hpp
443 src/profiling/PeriodicCounterSelectionCommandHandler.cpp
444 src/profiling/PeriodicCounterSelectionCommandHandler.hpp
445 src/profiling/ProfilingConnectionFactory.cpp
446 src/profiling/ProfilingConnectionFactory.hpp
447 src/profiling/ProfilingService.cpp
448 src/profiling/ProfilingService.hpp
449 src/profiling/ProfilingStateMachine.cpp
450 src/profiling/ProfilingStateMachine.hpp
451 src/profiling/ProfilingUtils.cpp
452 src/profiling/ProfilingUtils.hpp
453 src/profiling/SendCounterPacket.cpp
454 src/profiling/SendCounterPacket.hpp
455 src/profiling/SocketProfilingConnection.cpp
456 src/profiling/SocketProfilingConnection.hpp
457 third-party/half/half.hpp
460 # Files used for Streamline-based profiling backend
461 if(PROFILING_BACKEND_STREAMLINE)
462 list(APPEND armnn_sources
463 ${GATOR_ROOT}/annotate/streamline_annotate.h
464 ${GATOR_ROOT}/annotate/streamline_annotate.c)
467 # the backends under src/backends extend the list of
468 # object libs armnn to include in the build
469 include(src/backends/backends.cmake)
470 foreach(lib ${armnnLibraries})
471 message("Adding object library dependency to armnn: ${lib}")
472 list(APPEND armnn_sources $<TARGET_OBJECTS:${lib}>)
475 add_library_ex(armnn SHARED ${armnn_sources})
477 target_include_directories(armnn PRIVATE src/armnn)
478 target_include_directories(armnn PRIVATE src/armnnUtils)
479 target_include_directories(armnn PRIVATE src/backends)
480 target_include_directories(armnn PRIVATE src/profiling)
482 target_link_libraries(armnn armnnUtils)
484 target_link_libraries(armnn ${CMAKE_DL_LIBS})
486 install(TARGETS armnn
487 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
488 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
489 if(BUILD_CAFFE_PARSER)
490 install(TARGETS armnnCaffeParser
491 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
492 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
494 if(BUILD_ONNX_PARSER)
495 install(TARGETS armnnOnnxParser
496 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
497 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
500 install(TARGETS armnnTfParser
501 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
502 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
505 install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
507 target_link_libraries(armnn ${Boost_LOG_LIBRARY} ${Boost_THREAD_LIBRARY}
508 ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY})
510 if(ARMCOMPUTENEON OR ARMCOMPUTECL)
511 target_link_libraries(armnn ${ARMCOMPUTE_LIBRARIES})
514 target_link_libraries(armnn ${OPENCL_LIBRARIES})
517 if(PROFILING_BACKEND_STREAMLINE)
518 target_link_libraries(armnn pthread)
522 set(unittest_sources)
523 list(APPEND unittest_sources
524 src/armnn/test/ConstTensorLayerVisitor.hpp
525 src/armnn/test/ConstTensorLayerVisitor.cpp
526 src/armnn/test/CreateWorkload.hpp
527 src/armnn/test/CsvReaderTest.cpp
528 src/armnn/test/EndToEndTest.cpp
529 src/armnn/test/ExecutionFrameTest.cpp
530 src/armnn/test/FloatingPointConverterTest.cpp
531 src/armnn/test/FlowControl.cpp
532 src/armnn/test/GraphTests.cpp
533 src/armnn/test/GraphUtils.cpp
534 src/armnn/test/GraphUtils.hpp
535 src/armnn/test/InstrumentTests.cpp
536 src/armnn/test/InferOutputTests.cpp
537 src/armnn/test/InferOutputTests.hpp
538 src/armnn/test/ModelAccuracyCheckerTest.cpp
539 src/armnn/test/NetworkTests.cpp
540 src/armnn/test/ObservableTest.cpp
541 src/armnn/test/OptimizerTests.cpp
542 src/armnn/test/OptionalTest.cpp
543 src/armnn/test/ProfilerTests.cpp
544 src/armnn/test/ProfilingEventTest.cpp
545 src/armnn/test/SubgraphViewTests.cpp
546 src/armnn/test/TensorHandleStrategyTest.cpp
547 src/armnn/test/TensorHelpers.hpp
548 src/armnn/test/TensorTest.cpp
549 src/armnn/test/TestInputOutputLayerVisitor.cpp
550 src/armnn/test/TestInputOutputLayerVisitor.hpp
551 src/armnn/test/TestLayerVisitor.cpp
552 src/armnn/test/TestLayerVisitor.hpp
553 src/armnn/test/TestNameOnlyLayerVisitor.cpp
554 src/armnn/test/TestNameOnlyLayerVisitor.hpp
555 src/armnn/test/TestNameAndDescriptorLayerVisitor.hpp
556 src/armnn/test/TestNameAndDescriptorLayerVisitor.cpp
557 src/armnn/test/TestUtils.cpp
558 src/armnn/test/TestUtils.hpp
559 src/armnn/test/UnitTests.cpp
560 src/armnn/test/UnitTests.hpp
561 src/armnn/test/UtilsTests.cpp
562 src/armnnUtils/test/PrototxtConversionsTest.cpp
563 src/armnnUtils/test/ParserHelperTest.cpp
564 src/armnnUtils/test/TensorUtilsTest.cpp
565 src/profiling/test/ProfilingTests.cpp
566 src/profiling/test/SendCounterPacketTests.cpp
570 list(APPEND unittest_sources
571 src/armnn/test/DebugCallbackTest.cpp
572 src/armnn/test/QuantizerTest.cpp
573 src/armnn/test/RuntimeTests.cpp
574 src/armnn/test/RuntimeTests.hpp
578 if(BUILD_TF_PARSER AND ARMNNREF)
579 list(APPEND unittest_sources
580 src/armnnTfParser/test/Activations.cpp
581 src/armnnTfParser/test/Addition.cpp
582 src/armnnTfParser/test/AddN.cpp
583 src/armnnTfParser/test/Assert.cpp
584 src/armnnTfParser/test/BiasAdd.cpp
585 src/armnnTfParser/test/BroadcastForAdd.cpp
586 src/armnnTfParser/test/Convolution2d.cpp
587 src/armnnTfParser/test/Concat.cpp
588 src/armnnTfParser/test/ConcatOfConcats.cpp
589 src/armnnTfParser/test/DepthwiseConvolution2d.cpp
590 src/armnnTfParser/test/Equal.cpp
591 src/armnnTfParser/test/ExpandDims.cpp
592 src/armnnTfParser/test/FusedBatchNorm.cpp
593 src/armnnTfParser/test/Gather.cpp
594 src/armnnTfParser/test/Greater.cpp
595 src/armnnTfParser/test/Identity.cpp
596 src/armnnTfParser/test/LocalResponseNormalization.cpp
597 src/armnnTfParser/test/Maximum.cpp
598 src/armnnTfParser/test/MaximumForLeakyRelu.cpp
599 src/armnnTfParser/test/Mean.cpp
600 src/armnnTfParser/test/Minimum.cpp
601 src/armnnTfParser/test/Multiplication.cpp
602 src/armnnTfParser/test/Pad.cpp
603 src/armnnTfParser/test/MultiOutput.cpp
604 src/armnnTfParser/test/PassThru.cpp
605 src/armnnTfParser/test/Pooling.cpp
606 src/armnnTfParser/test/RealDiv.cpp
607 src/armnnTfParser/test/Reshape.cpp
608 src/armnnTfParser/test/ResizeBilinear.cpp
609 src/armnnTfParser/test/Rsqrt.cpp
610 src/armnnTfParser/test/Shape.cpp
611 src/armnnTfParser/test/Softmax.cpp
612 src/armnnTfParser/test/TestDependencies.cpp
613 src/armnnTfParser/test/FullyConnected.cpp
614 src/armnnTfParser/test/Constant.cpp
615 src/armnnTfParser/test/TestMultiInputsOutputs.cpp
616 src/armnnTfParser/test/Split.cpp
617 src/armnnTfParser/test/Squeeze.cpp
618 src/armnnTfParser/test/Sub.cpp
623 if(BUILD_TF_LITE_PARSER AND ARMNNREF)
625 list(APPEND unittest_sources
626 src/armnnTfLiteParser/test/Activations.cpp
627 src/armnnTfLiteParser/test/Addition.cpp
628 src/armnnTfLiteParser/test/AvgPool2D.cpp
629 src/armnnTfLiteParser/test/BatchToSpaceND.cpp
630 src/armnnTfLiteParser/test/Concatenation.cpp
631 src/armnnTfLiteParser/test/Constant.cpp
632 src/armnnTfLiteParser/test/Conv2D.cpp
633 src/armnnTfLiteParser/test/DepthwiseConvolution2D.cpp
634 src/armnnTfLiteParser/test/DetectionPostProcess.cpp
635 src/armnnTfLiteParser/test/FullyConnected.cpp
636 src/armnnTfLiteParser/test/L2Normalization.cpp
637 src/armnnTfLiteParser/test/Maximum.cpp
638 src/armnnTfLiteParser/test/MaxPool2D.cpp
639 src/armnnTfLiteParser/test/Mean.cpp
640 src/armnnTfLiteParser/test/Minimum.cpp
641 src/armnnTfLiteParser/test/Multiplication.cpp
642 src/armnnTfLiteParser/test/Pack.cpp
643 src/armnnTfLiteParser/test/Pad.cpp
644 src/armnnTfLiteParser/test/Reshape.cpp
645 src/armnnTfLiteParser/test/ResizeBilinear.cpp
646 src/armnnTfLiteParser/test/Softmax.cpp
647 src/armnnTfLiteParser/test/SpaceToBatchND.cpp
648 src/armnnTfLiteParser/test/Split.cpp
649 src/armnnTfLiteParser/test/Squeeze.cpp
650 src/armnnTfLiteParser/test/StridedSlice.cpp
651 src/armnnTfLiteParser/test/Sub.cpp
652 src/armnnTfLiteParser/test/TransposeConv.cpp
653 src/armnnTfLiteParser/test/Transpose.cpp
654 src/armnnTfLiteParser/test/Unpack.cpp
655 src/armnnTfLiteParser/test/LoadModel.cpp
656 src/armnnTfLiteParser/test/GetBuffer.cpp
657 src/armnnTfLiteParser/test/OutputShapeOfSqueeze.cpp
658 src/armnnTfLiteParser/test/InputOutputTensorNames.cpp
659 src/armnnTfLiteParser/test/GetTensorIds.cpp
660 src/armnnTfLiteParser/test/GetSubgraphInputsOutputs.cpp
661 src/armnnTfLiteParser/test/GetInputsOutputs.cpp
662 src/armnnTfLiteParser/test/Schema.s
664 set_source_files_properties(src/armnnTfLiteParser/test/Schema.s PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp")
668 if(BUILD_CAFFE_PARSER AND ARMNNREF)
669 list(APPEND unittest_sources
670 src/armnnCaffeParser/test/TestAdd.cpp
671 src/armnnCaffeParser/test/TestConcat.cpp
672 src/armnnCaffeParser/test/TestConvolution.cpp
673 src/armnnCaffeParser/test/TestDropout.cpp
674 src/armnnCaffeParser/test/TestInputs.cpp
675 src/armnnCaffeParser/test/TestMul.cpp
676 src/armnnCaffeParser/test/TestPooling2d.cpp
677 src/armnnCaffeParser/test/TestInPlace.cpp
678 src/armnnCaffeParser/test/TestMultiInputsOutputs.cpp
679 src/armnnCaffeParser/test/TestSplit.cpp
683 if(BUILD_ONNX_PARSER AND ARMNNREF)
684 list(APPEND unittest_sources
685 src/armnnOnnxParser/test/Constructor.cpp
686 src/armnnOnnxParser/test/CreateNetwork.cpp
687 src/armnnOnnxParser/test/ProtoxtFixture.cpp
688 src/armnnOnnxParser/test/Const.cpp
689 src/armnnOnnxParser/test/Pooling.cpp
690 src/armnnOnnxParser/test/Reshape.cpp
691 src/armnnOnnxParser/test/Relu.cpp
692 src/armnnOnnxParser/test/Conv2D.cpp
693 src/armnnOnnxParser/test/Addition.cpp
694 src/armnnOnnxParser/test/FullyConnected.cpp
695 src/armnnOnnxParser/test/GetInputsOutputs.cpp
696 src/armnnOnnxParser/test/BatchNorm.cpp
697 src/armnnOnnxParser/test/DepthConv.cpp
701 if(BUILD_ARMNN_QUANTIZER AND ARMNNREF)
702 list(APPEND unittest_sources
703 src/armnnQuantizer/test/QuantizationDataSetTests.cpp
707 if(BUILD_ARMNN_SERIALIZER AND ARMNNREF)
709 list(APPEND unittest_sources
710 src/armnnSerializer/test/ActivationSerializationTests.cpp
711 src/armnnSerializer/test/SerializerTests.cpp
712 src/armnnDeserializer/test/DeserializeAbs.cpp
713 src/armnnDeserializer/test/DeserializeActivation.cpp
714 src/armnnDeserializer/test/DeserializeAdd.cpp
715 src/armnnDeserializer/test/DeserializeBatchToSpaceNd.cpp
716 src/armnnDeserializer/test/DeserializeBatchNormalization.cpp
717 src/armnnDeserializer/test/DeserializeConstant.cpp
718 src/armnnDeserializer/test/DeserializeConvolution2d.cpp
719 src/armnnDeserializer/test/DeserializeDivision.cpp
720 src/armnnDeserializer/test/DeserializeEqual.cpp
721 src/armnnDeserializer/test/DeserializeFloor.cpp
722 src/armnnDeserializer/test/DeserializeFullyConnected.cpp
723 src/armnnDeserializer/test/DeserializeGather.cpp
724 src/armnnDeserializer/test/DeserializeGreater.cpp
725 src/armnnDeserializer/test/DeserializeL2Normalization.cpp
726 src/armnnDeserializer/test/DeserializeMean.cpp
727 src/armnnDeserializer/test/DeserializeMultiplication.cpp
728 src/armnnDeserializer/test/DeserializeNormalization.cpp
729 src/armnnDeserializer/test/DeserializePad.cpp
730 src/armnnDeserializer/test/DeserializePermute.cpp
731 src/armnnDeserializer/test/DeserializePooling2d.cpp
732 src/armnnDeserializer/test/DeserializeReshape.cpp
733 src/armnnDeserializer/test/DeserializeResizeBilinear.cpp
734 src/armnnDeserializer/test/DeserializeRsqrt.cpp
735 src/armnnDeserializer/test/DeserializeSpaceToBatchNd.cpp
736 src/armnnDeserializer/test/DeserializeStridedSlice.cpp
737 src/armnnDeserializer/test/DeserializeSubtraction.cpp
738 src/armnnDeserializer/test/ParserFlatbuffersSerializeFixture.hpp
739 src/armnnDeserializer/test/SchemaSerialize.s
741 set_source_files_properties(src/armnnDeserializer/test/SchemaSerialize.s PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp")
744 foreach(lib ${armnnUnitTestLibraries})
745 message("Adding object library dependency to UnitTests: ${lib}")
746 list(APPEND unittest_sources $<TARGET_OBJECTS:${lib}>)
749 add_executable(UnitTests ${unittest_sources})
750 target_include_directories(UnitTests PRIVATE src/armnn)
751 target_include_directories(UnitTests PRIVATE src/armnnUtils)
752 target_include_directories(UnitTests PRIVATE src/backends)
753 target_include_directories(UnitTests PRIVATE src/profiling)
756 if(HEAP_PROFILING OR LEAK_CHECKING)
757 message("Valgrind is disabled for heap profiling and leak checking builds.")
759 # Valgrind works with gperftools version number <= 2.4
760 target_compile_definitions(UnitTests PRIVATE "WITH_VALGRIND=1")
764 target_link_libraries(UnitTests ${CMAKE_THREAD_LIBS_INIT})
765 target_link_libraries(UnitTests ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY})
767 target_link_libraries(UnitTests armnn)
768 target_link_libraries(UnitTests armnnUtils)
771 target_link_libraries(UnitTests armnnTfParser)
774 if(BUILD_TF_LITE_PARSER)
775 target_include_directories(UnitTests SYSTEM PRIVATE "${TF_LITE_SCHEMA_INCLUDE_PATH}")
776 target_include_directories(UnitTests SYSTEM PRIVATE "${FLATBUFFERS_INCLUDE_PATH}")
777 target_link_libraries(UnitTests armnnTfLiteParser)
780 if(BUILD_CAFFE_PARSER)
781 target_link_libraries(UnitTests armnnCaffeParser)
784 if(BUILD_ARMNN_SERIALIZER AND ARMNNREF)
785 target_include_directories(UnitTests SYSTEM PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src/armnnSerializer)
786 target_include_directories(UnitTests SYSTEM PRIVATE "${FLATBUFFERS_INCLUDE_PATH}")
787 target_link_libraries(UnitTests armnnSerializer)
790 if(BUILD_ARMNN_QUANTIZER AND ARMNNREF)
791 target_include_directories(UnitTests SYSTEM PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src/armnnQuantizer)
792 target_include_directories(UnitTests SYSTEM PRIVATE "${FLATBUFFERS_INCLUDE_PATH}")
793 target_link_libraries(UnitTests armnnQuantizer armnnSerializer)
796 if(BUILD_ONNX_PARSER)
797 target_link_libraries(UnitTests armnnOnnxParser)
800 addDllCopyCommands(UnitTests)
803 if (BUILD_ARMNN_SERIALIZER AND (BUILD_TF_PARSER OR BUILD_TF_LITE_PARSER OR BUILD_ONNX_PARSER OR BUILD_CAFFE_PARSER) AND ARMNNREF)
804 set(ArmnnConverter_sources
805 src/armnnConverter/ArmnnConverter.cpp)
807 add_executable_ex(ArmnnConverter ${ArmnnConverter_sources})
808 target_include_directories(ArmnnConverter PRIVATE src/armnn)
809 target_include_directories(ArmnnConverter PRIVATE src/armnnUtils)
811 if(BUILD_CAFFE_PARSER)
812 target_link_libraries(ArmnnConverter armnnCaffeParser)
815 if(BUILD_ONNX_PARSER)
816 target_link_libraries(ArmnnConverter armnnOnnxParser)
820 target_link_libraries(ArmnnConverter armnnTfParser)
823 if(BUILD_TF_LITE_PARSER)
824 target_link_libraries(ArmnnConverter armnnTfLiteParser)
827 target_link_libraries(ArmnnConverter armnnSerializer)
829 target_link_libraries(ArmnnConverter armnn)
830 target_link_libraries(ArmnnConverter ${CMAKE_THREAD_LIBS_INIT})
831 target_link_libraries(ArmnnConverter
832 ${Boost_SYSTEM_LIBRARY}
833 ${Boost_FILESYSTEM_LIBRARY}
834 ${Boost_PROGRAM_OPTIONS_LIBRARY})
835 addDllCopyCommands(ArmnnConverter)
838 if(BUILD_GATORD_MOCK)
839 set(gatord_mock_sources)
840 list(APPEND gatord_mock_sources
841 tests/profiling/GatordMockMain.cpp
842 tests/profiling/CommandLineProcessor.hpp
843 tests/profiling/CommandLineProcessor.cpp
844 tests/profiling/GatordMockService.hpp
845 tests/profiling/GatordMockService.cpp
848 include_directories( ${Boost_INCLUDE_DIRS} )
850 add_executable_ex(GartordMock ${gatord_mock_sources})
852 target_link_libraries(GartordMock
853 ${Boost_PROGRAM_OPTIONS_LIBRARY}