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/BackendId.hpp
209 include/armnn/Descriptors.hpp
210 include/armnn/DescriptorsFwd.hpp
211 include/armnn/Exceptions.hpp
212 include/armnn/ILayerSupport.hpp
213 include/armnn/ILayerVisitor.hpp
214 include/armnn/INetwork.hpp
215 include/armnn/IProfiler.hpp
216 include/armnn/IRuntime.hpp
217 include/armnn/LayerSupport.hpp
218 include/armnn/LayerVisitorBase.hpp
219 include/armnn/LstmParams.hpp
220 include/armnn/MemorySources.hpp
221 include/armnn/NetworkFwd.hpp
222 include/armnn/Optional.hpp
223 include/armnn/QuantizedLstmParams.hpp
224 include/armnn/Tensor.hpp
225 include/armnn/TensorFwd.hpp
226 include/armnn/Types.hpp
227 include/armnn/TypesUtils.hpp
228 include/armnn/Utils.hpp
229 include/armnn/Version.hpp
230 src/armnn/layers/LayerCloneBase.hpp
231 src/armnn/layers/LayerWithParameters.hpp
232 src/armnn/layers/AbsLayer.hpp
233 src/armnn/layers/AbsLayer.cpp
234 src/armnn/layers/ActivationLayer.hpp
235 src/armnn/layers/ActivationLayer.cpp
236 src/armnn/layers/AdditionLayer.hpp
237 src/armnn/layers/AdditionLayer.cpp
238 src/armnn/layers/ArgMinMaxLayer.hpp
239 src/armnn/layers/ArgMinMaxLayer.cpp
240 src/armnn/layers/BatchNormalizationLayer.hpp
241 src/armnn/layers/BatchNormalizationLayer.cpp
242 src/armnn/layers/BatchToSpaceNdLayer.hpp
243 src/armnn/layers/BatchToSpaceNdLayer.cpp
244 src/armnn/layers/ConcatLayer.hpp
245 src/armnn/layers/ConcatLayer.cpp
246 src/armnn/layers/ConstantLayer.hpp
247 src/armnn/layers/ConstantLayer.cpp
248 src/armnn/layers/Convolution2dLayer.hpp
249 src/armnn/layers/Convolution2dLayer.cpp
250 src/armnn/layers/ConvertFp16ToFp32Layer.hpp
251 src/armnn/layers/ConvertFp16ToFp32Layer.cpp
252 src/armnn/layers/ConvertFp32ToFp16Layer.hpp
253 src/armnn/layers/ConvertFp32ToFp16Layer.cpp
254 src/armnn/layers/DebugLayer.hpp
255 src/armnn/layers/DebugLayer.cpp
256 src/armnn/layers/DepthwiseConvolution2dLayer.hpp
257 src/armnn/layers/DepthwiseConvolution2dLayer.cpp
258 src/armnn/layers/DequantizeLayer.hpp
259 src/armnn/layers/DequantizeLayer.cpp
260 src/armnn/layers/DetectionPostProcessLayer.hpp
261 src/armnn/layers/DetectionPostProcessLayer.cpp
262 src/armnn/layers/ElementwiseBaseLayer.hpp
263 src/armnn/layers/ElementwiseBaseLayer.cpp
264 src/armnn/layers/EqualLayer.hpp
265 src/armnn/layers/EqualLayer.cpp
266 src/armnn/layers/FakeQuantizationLayer.hpp
267 src/armnn/layers/FakeQuantizationLayer.cpp
268 src/armnn/layers/FloorLayer.hpp
269 src/armnn/layers/FloorLayer.cpp
270 src/armnn/layers/FullyConnectedLayer.hpp
271 src/armnn/layers/FullyConnectedLayer.cpp
272 src/armnn/layers/GatherLayer.cpp
273 src/armnn/layers/GatherLayer.hpp
274 src/armnn/layers/GreaterLayer.cpp
275 src/armnn/layers/GreaterLayer.hpp
276 src/armnn/layers/InputLayer.hpp
277 src/armnn/layers/InputLayer.cpp
278 src/armnn/layers/L2NormalizationLayer.hpp
279 src/armnn/layers/L2NormalizationLayer.cpp
280 src/armnn/layers/LstmLayer.cpp
281 src/armnn/layers/LstmLayer.hpp
282 src/armnn/layers/MaximumLayer.cpp
283 src/armnn/layers/MaximumLayer.hpp
284 src/armnn/layers/MeanLayer.hpp
285 src/armnn/layers/MeanLayer.cpp
286 src/armnn/layers/MemCopyLayer.hpp
287 src/armnn/layers/MemCopyLayer.cpp
288 src/armnn/layers/MemImportLayer.hpp
289 src/armnn/layers/MemImportLayer.cpp
290 src/armnn/layers/MergeLayer.hpp
291 src/armnn/layers/MergeLayer.cpp
292 src/armnn/layers/MinimumLayer.cpp
293 src/armnn/layers/MinimumLayer.hpp
294 src/armnn/layers/MultiplicationLayer.hpp
295 src/armnn/layers/MultiplicationLayer.cpp
296 src/armnn/layers/NormalizationLayer.hpp
297 src/armnn/layers/NormalizationLayer.cpp
298 src/armnn/layers/OutputLayer.hpp
299 src/armnn/layers/OutputLayer.cpp
300 src/armnn/layers/PadLayer.hpp
301 src/armnn/layers/PadLayer.cpp
302 src/armnn/layers/PermuteLayer.hpp
303 src/armnn/layers/PermuteLayer.cpp
304 src/armnn/layers/Pooling2dLayer.hpp
305 src/armnn/layers/Pooling2dLayer.cpp
306 src/armnn/layers/QuantizeLayer.cpp
307 src/armnn/layers/QuantizeLayer.hpp
308 src/armnn/layers/QuantizedLstmLayer.hpp
309 src/armnn/layers/QuantizedLstmLayer.cpp
310 src/armnn/layers/DivisionLayer.cpp
311 src/armnn/layers/DivisionLayer.hpp
312 src/armnn/layers/PreCompiledLayer.hpp
313 src/armnn/layers/PreCompiledLayer.cpp
314 src/armnn/layers/PreluLayer.hpp
315 src/armnn/layers/PreluLayer.cpp
316 src/armnn/layers/ReshapeLayer.hpp
317 src/armnn/layers/ReshapeLayer.cpp
318 src/armnn/layers/ResizeLayer.hpp
319 src/armnn/layers/ResizeLayer.cpp
320 src/armnn/layers/RsqrtLayer.cpp
321 src/armnn/layers/RsqrtLayer.hpp
322 src/armnn/layers/SliceLayer.cpp
323 src/armnn/layers/SliceLayer.hpp
324 src/armnn/layers/SoftmaxLayer.hpp
325 src/armnn/layers/SoftmaxLayer.cpp
326 src/armnn/layers/SpaceToBatchNdLayer.hpp
327 src/armnn/layers/SpaceToBatchNdLayer.cpp
328 src/armnn/layers/SpaceToDepthLayer.hpp
329 src/armnn/layers/SpaceToDepthLayer.cpp
330 src/armnn/layers/SplitterLayer.hpp
331 src/armnn/layers/SplitterLayer.cpp
332 src/armnn/layers/StackLayer.hpp
333 src/armnn/layers/StackLayer.cpp
334 src/armnn/layers/StridedSliceLayer.cpp
335 src/armnn/layers/StridedSliceLayer.hpp
336 src/armnn/layers/SubtractionLayer.cpp
337 src/armnn/layers/SubtractionLayer.hpp
338 src/armnn/layers/SwitchLayer.cpp
339 src/armnn/layers/SwitchLayer.hpp
340 src/armnn/layers/TransposeConvolution2dLayer.cpp
341 src/armnn/layers/TransposeConvolution2dLayer.hpp
342 src/armnn/BackendSettings.hpp
343 src/armnn/BackendHelper.cpp
344 src/armnn/CompatibleTypes.hpp
345 src/armnn/Descriptors.cpp
346 src/armnn/DeviceSpec.hpp
347 src/armnn/DynamicQuantizationVisitor.cpp
348 src/armnn/DynamicQuantizationVisitor.hpp
349 src/armnn/Exceptions.cpp
350 src/armnn/ExecutionFrame.cpp
351 src/armnn/ExecutionFrame.hpp
354 src/armnn/IGraphObservable.hpp
355 src/armnn/Instrument.hpp
356 src/armnn/InternalTypes.cpp
357 src/armnn/InternalTypes.hpp
358 src/armnn/ISubgraphViewConverter.hpp
359 src/armnn/JsonPrinter.cpp
360 src/armnn/JsonPrinter.hpp
362 src/armnn/LayerFwd.hpp
364 src/armnn/LayersFwd.hpp
365 src/armnn/LayerSupportCommon.hpp
366 src/armnn/LayerSupport.cpp
367 src/armnn/LoadedNetwork.cpp
368 src/armnn/LoadedNetwork.hpp
369 src/armnn/Network.cpp
370 src/armnn/Network.hpp
371 src/armnn/NetworkQuantizationScheme.hpp
372 src/armnn/NetworkQuantizer.cpp
373 src/armnn/NetworkQuantizer.hpp
374 src/armnn/NetworkQuantizerUtils.cpp
375 src/armnn/NetworkQuantizerUtils.hpp
376 src/armnn/NetworkUtils.cpp
377 src/armnn/NetworkUtils.hpp
378 src/armnn/Observable.cpp
379 src/armnn/Observable.hpp
380 src/armnn/Optimizer.cpp
381 src/armnn/Optimizer.hpp
382 src/armnn/OverrideInputRangeVisitor.cpp
383 src/armnn/OverrideInputRangeVisitor.hpp
384 src/armnn/Profiling.cpp
385 src/armnn/ProfilingEvent.cpp
386 src/armnn/ProfilingEvent.hpp
387 src/armnn/Profiling.hpp
388 src/armnn/QuantizerVisitor.cpp
389 src/armnn/QuantizerVisitor.hpp
390 src/armnn/Runtime.cpp
391 src/armnn/Runtime.hpp
392 src/armnn/RangeTracker.cpp
393 src/armnn/RangeTracker.hpp
394 src/armnn/ResolveType.hpp
395 src/armnn/SerializeLayerParameters.cpp
396 src/armnn/SerializeLayerParameters.hpp
397 src/armnn/StaticRangeVisitor.cpp
398 src/armnn/StaticRangeVisitor.hpp
399 src/armnn/SubgraphView.cpp
400 src/armnn/SubgraphView.hpp
401 src/armnn/SubgraphViewSelector.cpp
402 src/armnn/SubgraphViewSelector.hpp
404 src/armnn/TypesUtils.cpp
406 src/armnn/WallClockTimer.cpp
407 src/armnn/WallClockTimer.hpp
408 src/armnn/optimizations/AddDebug.hpp
409 src/armnn/optimizations/All.hpp
410 src/armnn/optimizations/ConvertConstants.hpp
411 src/armnn/optimizations/ConvertFp32NetworkToFp16.hpp
412 src/armnn/optimizations/FoldPadIntoConvolution2d.hpp
413 src/armnn/optimizations/MovePermuteUp.hpp
414 src/armnn/optimizations/Optimization.hpp
415 src/armnn/optimizations/OptimizeConsecutiveReshapes.hpp
416 src/armnn/optimizations/OptimizeInverseConversions.hpp
417 src/armnn/optimizations/OptimizeInversePermutes.hpp
418 src/armnn/optimizations/PermuteAsReshape.hpp
419 src/armnn/optimizations/SquashEqualSiblings.hpp
420 src/profiling/CommandHandlerFunctor.cpp
421 src/profiling/CommandHandlerFunctor.hpp
422 src/profiling/CommandHandlerKey.cpp
423 src/profiling/CommandHandlerKey.hpp
424 src/profiling/CommandHandlerRegistry.cpp
425 src/profiling/CommandHandlerRegistry.hpp
426 src/profiling/CounterDirectory.cpp
427 src/profiling/CounterDirectory.hpp
428 src/profiling/EncodeVersion.hpp
429 src/profiling/Holder.cpp
430 src/profiling/Holder.hpp
431 src/profiling/IProfilingConnection.hpp
432 src/profiling/Packet.cpp
433 src/profiling/Packet.hpp
434 src/profiling/PacketVersionResolver.cpp
435 src/profiling/PacketVersionResolver.hpp
436 src/profiling/ProfilingConnectionFactory.cpp
437 src/profiling/ProfilingConnectionFactory.hpp
438 src/profiling/IBufferWrapper.hpp
439 src/profiling/IPeriodicCounterCapture.hpp
440 src/profiling/ISendCounterPacket.hpp
441 src/profiling/SendCounterPacket.hpp
442 src/profiling/SendCounterPacket.cpp
443 src/profiling/SocketProfilingConnection.cpp
444 src/profiling/SocketProfilingConnection.hpp
445 src/profiling/ProfilingUtils.hpp
446 src/profiling/ProfilingUtils.cpp
447 src/profiling/ProfilingStateMachine.cpp
448 src/profiling/ProfilingStateMachine.hpp
449 src/profiling/ProfilingService.cpp
450 src/profiling/ProfilingService.hpp
451 src/profiling/PeriodicCounterSelectionCommandHandler.cpp
452 src/profiling/PeriodicCounterSelectionCommandHandler.hpp
453 third-party/half/half.hpp
456 # Files used for Streamline-based profiling backend
457 if(PROFILING_BACKEND_STREAMLINE)
458 list(APPEND armnn_sources
459 ${GATOR_ROOT}/annotate/streamline_annotate.h
460 ${GATOR_ROOT}/annotate/streamline_annotate.c)
463 # the backends under src/backends extend the list of
464 # object libs armnn to include in the build
465 include(src/backends/backends.cmake)
466 foreach(lib ${armnnLibraries})
467 message("Adding object library dependency to armnn: ${lib}")
468 list(APPEND armnn_sources $<TARGET_OBJECTS:${lib}>)
471 add_library_ex(armnn SHARED ${armnn_sources})
473 target_include_directories(armnn PRIVATE src/armnn)
474 target_include_directories(armnn PRIVATE src/armnnUtils)
475 target_include_directories(armnn PRIVATE src/backends)
477 target_link_libraries(armnn armnnUtils)
479 target_link_libraries(armnn ${CMAKE_DL_LIBS})
481 install(TARGETS armnn
482 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
483 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
484 if(BUILD_CAFFE_PARSER)
485 install(TARGETS armnnCaffeParser
486 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
487 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
489 if(BUILD_ONNX_PARSER)
490 install(TARGETS armnnOnnxParser
491 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
492 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
495 install(TARGETS armnnTfParser
496 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
497 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
500 install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
502 target_link_libraries(armnn ${Boost_LOG_LIBRARY} ${Boost_THREAD_LIBRARY}
503 ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY})
505 if(ARMCOMPUTENEON OR ARMCOMPUTECL)
506 target_link_libraries(armnn ${ARMCOMPUTE_LIBRARIES})
509 target_link_libraries(armnn ${OPENCL_LIBRARIES})
512 if(PROFILING_BACKEND_STREAMLINE)
513 target_link_libraries(armnn pthread)
517 set(unittest_sources)
518 list(APPEND unittest_sources
519 src/armnn/test/ConstTensorLayerVisitor.hpp
520 src/armnn/test/ConstTensorLayerVisitor.cpp
521 src/armnn/test/CreateWorkload.hpp
522 src/armnn/test/CsvReaderTest.cpp
523 src/armnn/test/EndToEndTest.cpp
524 src/armnn/test/ExecutionFrameTest.cpp
525 src/armnn/test/FloatingPointConverterTest.cpp
526 src/armnn/test/FlowControl.cpp
527 src/armnn/test/GraphTests.cpp
528 src/armnn/test/GraphUtils.cpp
529 src/armnn/test/GraphUtils.hpp
530 src/armnn/test/InstrumentTests.cpp
531 src/armnn/test/InferOutputTests.cpp
532 src/armnn/test/InferOutputTests.hpp
533 src/armnn/test/ModelAccuracyCheckerTest.cpp
534 src/armnn/test/NetworkTests.cpp
535 src/armnn/test/ObservableTest.cpp
536 src/armnn/test/OptimizerTests.cpp
537 src/armnn/test/OptionalTest.cpp
538 src/armnn/test/ProfilerTests.cpp
539 src/armnn/test/ProfilingEventTest.cpp
540 src/armnn/test/SubgraphViewTests.cpp
541 src/armnn/test/TensorHandleStrategyTest.cpp
542 src/armnn/test/TensorHelpers.hpp
543 src/armnn/test/TensorTest.cpp
544 src/armnn/test/TestInputOutputLayerVisitor.cpp
545 src/armnn/test/TestInputOutputLayerVisitor.hpp
546 src/armnn/test/TestLayerVisitor.cpp
547 src/armnn/test/TestLayerVisitor.hpp
548 src/armnn/test/TestNameOnlyLayerVisitor.cpp
549 src/armnn/test/TestNameOnlyLayerVisitor.hpp
550 src/armnn/test/TestNameAndDescriptorLayerVisitor.hpp
551 src/armnn/test/TestNameAndDescriptorLayerVisitor.cpp
552 src/armnn/test/TestUtils.cpp
553 src/armnn/test/TestUtils.hpp
554 src/armnn/test/UnitTests.cpp
555 src/armnn/test/UnitTests.hpp
556 src/armnn/test/UtilsTests.cpp
557 src/armnnUtils/test/PrototxtConversionsTest.cpp
558 src/armnnUtils/test/ParserHelperTest.cpp
559 src/armnnUtils/test/TensorUtilsTest.cpp
560 src/profiling/test/ProfilingTests.cpp
561 src/profiling/test/SendCounterPacketTests.cpp
565 list(APPEND unittest_sources
566 src/armnn/test/DebugCallbackTest.cpp
567 src/armnn/test/QuantizerTest.cpp
568 src/armnn/test/RuntimeTests.cpp
569 src/armnn/test/RuntimeTests.hpp
573 if(BUILD_TF_PARSER AND ARMNNREF)
574 list(APPEND unittest_sources
575 src/armnnTfParser/test/Activations.cpp
576 src/armnnTfParser/test/Addition.cpp
577 src/armnnTfParser/test/AddN.cpp
578 src/armnnTfParser/test/Assert.cpp
579 src/armnnTfParser/test/BiasAdd.cpp
580 src/armnnTfParser/test/BroadcastForAdd.cpp
581 src/armnnTfParser/test/Convolution2d.cpp
582 src/armnnTfParser/test/Concat.cpp
583 src/armnnTfParser/test/ConcatOfConcats.cpp
584 src/armnnTfParser/test/DepthwiseConvolution2d.cpp
585 src/armnnTfParser/test/Equal.cpp
586 src/armnnTfParser/test/ExpandDims.cpp
587 src/armnnTfParser/test/FusedBatchNorm.cpp
588 src/armnnTfParser/test/Gather.cpp
589 src/armnnTfParser/test/Greater.cpp
590 src/armnnTfParser/test/Identity.cpp
591 src/armnnTfParser/test/LocalResponseNormalization.cpp
592 src/armnnTfParser/test/Maximum.cpp
593 src/armnnTfParser/test/MaximumForLeakyRelu.cpp
594 src/armnnTfParser/test/Mean.cpp
595 src/armnnTfParser/test/Minimum.cpp
596 src/armnnTfParser/test/Multiplication.cpp
597 src/armnnTfParser/test/Pad.cpp
598 src/armnnTfParser/test/MultiOutput.cpp
599 src/armnnTfParser/test/PassThru.cpp
600 src/armnnTfParser/test/Pooling.cpp
601 src/armnnTfParser/test/RealDiv.cpp
602 src/armnnTfParser/test/Reshape.cpp
603 src/armnnTfParser/test/ResizeBilinear.cpp
604 src/armnnTfParser/test/Rsqrt.cpp
605 src/armnnTfParser/test/Shape.cpp
606 src/armnnTfParser/test/Softmax.cpp
607 src/armnnTfParser/test/TestDependencies.cpp
608 src/armnnTfParser/test/FullyConnected.cpp
609 src/armnnTfParser/test/Constant.cpp
610 src/armnnTfParser/test/TestMultiInputsOutputs.cpp
611 src/armnnTfParser/test/Split.cpp
612 src/armnnTfParser/test/Squeeze.cpp
613 src/armnnTfParser/test/Sub.cpp
618 if(BUILD_TF_LITE_PARSER AND ARMNNREF)
620 list(APPEND unittest_sources
621 src/armnnTfLiteParser/test/Activations.cpp
622 src/armnnTfLiteParser/test/Addition.cpp
623 src/armnnTfLiteParser/test/AvgPool2D.cpp
624 src/armnnTfLiteParser/test/BatchToSpaceND.cpp
625 src/armnnTfLiteParser/test/Concatenation.cpp
626 src/armnnTfLiteParser/test/Constant.cpp
627 src/armnnTfLiteParser/test/Conv2D.cpp
628 src/armnnTfLiteParser/test/DepthwiseConvolution2D.cpp
629 src/armnnTfLiteParser/test/DetectionPostProcess.cpp
630 src/armnnTfLiteParser/test/FullyConnected.cpp
631 src/armnnTfLiteParser/test/L2Normalization.cpp
632 src/armnnTfLiteParser/test/Maximum.cpp
633 src/armnnTfLiteParser/test/MaxPool2D.cpp
634 src/armnnTfLiteParser/test/Mean.cpp
635 src/armnnTfLiteParser/test/Minimum.cpp
636 src/armnnTfLiteParser/test/Multiplication.cpp
637 src/armnnTfLiteParser/test/Pack.cpp
638 src/armnnTfLiteParser/test/Pad.cpp
639 src/armnnTfLiteParser/test/Reshape.cpp
640 src/armnnTfLiteParser/test/ResizeBilinear.cpp
641 src/armnnTfLiteParser/test/Softmax.cpp
642 src/armnnTfLiteParser/test/SpaceToBatchND.cpp
643 src/armnnTfLiteParser/test/Split.cpp
644 src/armnnTfLiteParser/test/Squeeze.cpp
645 src/armnnTfLiteParser/test/StridedSlice.cpp
646 src/armnnTfLiteParser/test/Sub.cpp
647 src/armnnTfLiteParser/test/TransposeConv.cpp
648 src/armnnTfLiteParser/test/Transpose.cpp
649 src/armnnTfLiteParser/test/Unpack.cpp
650 src/armnnTfLiteParser/test/LoadModel.cpp
651 src/armnnTfLiteParser/test/GetBuffer.cpp
652 src/armnnTfLiteParser/test/OutputShapeOfSqueeze.cpp
653 src/armnnTfLiteParser/test/InputOutputTensorNames.cpp
654 src/armnnTfLiteParser/test/GetTensorIds.cpp
655 src/armnnTfLiteParser/test/GetSubgraphInputsOutputs.cpp
656 src/armnnTfLiteParser/test/GetInputsOutputs.cpp
657 src/armnnTfLiteParser/test/Schema.s
659 set_source_files_properties(src/armnnTfLiteParser/test/Schema.s PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp")
663 if(BUILD_CAFFE_PARSER AND ARMNNREF)
664 list(APPEND unittest_sources
665 src/armnnCaffeParser/test/TestAdd.cpp
666 src/armnnCaffeParser/test/TestConcat.cpp
667 src/armnnCaffeParser/test/TestConvolution.cpp
668 src/armnnCaffeParser/test/TestDropout.cpp
669 src/armnnCaffeParser/test/TestInputs.cpp
670 src/armnnCaffeParser/test/TestMul.cpp
671 src/armnnCaffeParser/test/TestPooling2d.cpp
672 src/armnnCaffeParser/test/TestInPlace.cpp
673 src/armnnCaffeParser/test/TestMultiInputsOutputs.cpp
674 src/armnnCaffeParser/test/TestSplit.cpp
678 if(BUILD_ONNX_PARSER AND ARMNNREF)
679 list(APPEND unittest_sources
680 src/armnnOnnxParser/test/Constructor.cpp
681 src/armnnOnnxParser/test/CreateNetwork.cpp
682 src/armnnOnnxParser/test/ProtoxtFixture.cpp
683 src/armnnOnnxParser/test/Const.cpp
684 src/armnnOnnxParser/test/Pooling.cpp
685 src/armnnOnnxParser/test/Reshape.cpp
686 src/armnnOnnxParser/test/Relu.cpp
687 src/armnnOnnxParser/test/Conv2D.cpp
688 src/armnnOnnxParser/test/Addition.cpp
689 src/armnnOnnxParser/test/FullyConnected.cpp
690 src/armnnOnnxParser/test/GetInputsOutputs.cpp
691 src/armnnOnnxParser/test/BatchNorm.cpp
692 src/armnnOnnxParser/test/DepthConv.cpp
696 if(BUILD_ARMNN_QUANTIZER AND ARMNNREF)
697 list(APPEND unittest_sources
698 src/armnnQuantizer/test/QuantizationDataSetTests.cpp
702 if(BUILD_ARMNN_SERIALIZER AND ARMNNREF)
704 list(APPEND unittest_sources
705 src/armnnSerializer/test/ActivationSerializationTests.cpp
706 src/armnnSerializer/test/SerializerTests.cpp
707 src/armnnDeserializer/test/DeserializeAbs.cpp
708 src/armnnDeserializer/test/DeserializeActivation.cpp
709 src/armnnDeserializer/test/DeserializeAdd.cpp
710 src/armnnDeserializer/test/DeserializeBatchToSpaceNd.cpp
711 src/armnnDeserializer/test/DeserializeBatchNormalization.cpp
712 src/armnnDeserializer/test/DeserializeConstant.cpp
713 src/armnnDeserializer/test/DeserializeConvolution2d.cpp
714 src/armnnDeserializer/test/DeserializeDivision.cpp
715 src/armnnDeserializer/test/DeserializeEqual.cpp
716 src/armnnDeserializer/test/DeserializeFloor.cpp
717 src/armnnDeserializer/test/DeserializeFullyConnected.cpp
718 src/armnnDeserializer/test/DeserializeGather.cpp
719 src/armnnDeserializer/test/DeserializeGreater.cpp
720 src/armnnDeserializer/test/DeserializeL2Normalization.cpp
721 src/armnnDeserializer/test/DeserializeMean.cpp
722 src/armnnDeserializer/test/DeserializeMultiplication.cpp
723 src/armnnDeserializer/test/DeserializeNormalization.cpp
724 src/armnnDeserializer/test/DeserializePad.cpp
725 src/armnnDeserializer/test/DeserializePermute.cpp
726 src/armnnDeserializer/test/DeserializePooling2d.cpp
727 src/armnnDeserializer/test/DeserializeReshape.cpp
728 src/armnnDeserializer/test/DeserializeResizeBilinear.cpp
729 src/armnnDeserializer/test/DeserializeRsqrt.cpp
730 src/armnnDeserializer/test/DeserializeSpaceToBatchNd.cpp
731 src/armnnDeserializer/test/DeserializeStridedSlice.cpp
732 src/armnnDeserializer/test/DeserializeSubtraction.cpp
733 src/armnnDeserializer/test/ParserFlatbuffersSerializeFixture.hpp
734 src/armnnDeserializer/test/SchemaSerialize.s
736 set_source_files_properties(src/armnnDeserializer/test/SchemaSerialize.s PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp")
739 foreach(lib ${armnnUnitTestLibraries})
740 message("Adding object library dependency to UnitTests: ${lib}")
741 list(APPEND unittest_sources $<TARGET_OBJECTS:${lib}>)
744 add_executable(UnitTests ${unittest_sources})
745 target_include_directories(UnitTests PRIVATE src/armnn)
746 target_include_directories(UnitTests PRIVATE src/armnnUtils)
747 target_include_directories(UnitTests PRIVATE src/backends)
750 if(HEAP_PROFILING OR LEAK_CHECKING)
751 message("Valgrind is disabled for heap profiling and leak checking builds.")
753 # Valgrind works with gperftools version number <= 2.4
754 target_compile_definitions(UnitTests PRIVATE "WITH_VALGRIND=1")
758 target_link_libraries(UnitTests ${CMAKE_THREAD_LIBS_INIT})
759 target_link_libraries(UnitTests ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY})
761 target_link_libraries(UnitTests armnn)
762 target_link_libraries(UnitTests armnnUtils)
765 target_link_libraries(UnitTests armnnTfParser)
768 if(BUILD_TF_LITE_PARSER)
769 target_include_directories(UnitTests SYSTEM PRIVATE "${TF_LITE_SCHEMA_INCLUDE_PATH}")
770 target_include_directories(UnitTests SYSTEM PRIVATE "${FLATBUFFERS_INCLUDE_PATH}")
771 target_link_libraries(UnitTests armnnTfLiteParser)
774 if(BUILD_CAFFE_PARSER)
775 target_link_libraries(UnitTests armnnCaffeParser)
778 if(BUILD_ARMNN_SERIALIZER AND ARMNNREF)
779 target_include_directories(UnitTests SYSTEM PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src/armnnSerializer)
780 target_include_directories(UnitTests SYSTEM PRIVATE "${FLATBUFFERS_INCLUDE_PATH}")
781 target_link_libraries(UnitTests armnnSerializer)
784 if(BUILD_ARMNN_QUANTIZER AND ARMNNREF)
785 target_include_directories(UnitTests SYSTEM PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src/armnnQuantizer)
786 target_include_directories(UnitTests SYSTEM PRIVATE "${FLATBUFFERS_INCLUDE_PATH}")
787 target_link_libraries(UnitTests armnnQuantizer armnnSerializer)
790 if(BUILD_ONNX_PARSER)
791 target_link_libraries(UnitTests armnnOnnxParser)
794 addDllCopyCommands(UnitTests)
797 if (BUILD_ARMNN_SERIALIZER AND (BUILD_TF_PARSER OR BUILD_TF_LITE_PARSER OR BUILD_ONNX_PARSER OR BUILD_CAFFE_PARSER) AND ARMNNREF)
798 set(ArmnnConverter_sources
799 src/armnnConverter/ArmnnConverter.cpp)
801 add_executable_ex(ArmnnConverter ${ArmnnConverter_sources})
802 target_include_directories(ArmnnConverter PRIVATE src/armnn)
803 target_include_directories(ArmnnConverter PRIVATE src/armnnUtils)
805 if(BUILD_CAFFE_PARSER)
806 target_link_libraries(ArmnnConverter armnnCaffeParser)
809 if(BUILD_ONNX_PARSER)
810 target_link_libraries(ArmnnConverter armnnOnnxParser)
814 target_link_libraries(ArmnnConverter armnnTfParser)
817 if(BUILD_TF_LITE_PARSER)
818 target_link_libraries(ArmnnConverter armnnTfLiteParser)
821 target_link_libraries(ArmnnConverter armnnSerializer)
823 target_link_libraries(ArmnnConverter armnn)
824 target_link_libraries(ArmnnConverter ${CMAKE_THREAD_LIBS_INIT})
825 target_link_libraries(ArmnnConverter
826 ${Boost_SYSTEM_LIBRARY}
827 ${Boost_FILESYSTEM_LIBRARY}
828 ${Boost_PROGRAM_OPTIONS_LIBRARY})
829 addDllCopyCommands(ArmnnConverter)
832 if(BUILD_GATORD_MOCK)
833 set(gatord_mock_sources)
834 list(APPEND gatord_mock_sources
835 tests/profiling/GatordMockMain.cpp
836 tests/profiling/CommandLineProcessor.hpp
837 tests/profiling/CommandLineProcessor.cpp
838 tests/profiling/GatordMockService.hpp
839 tests/profiling/GatordMockService.cpp
842 include_directories( ${Boost_INCLUDE_DIRS} )
844 add_executable_ex(GartordMock ${gatord_mock_sources})
846 target_link_libraries(GartordMock
847 ${Boost_PROGRAM_OPTIONS_LIBRARY}