8f08bf22c330162ffa747b23c7d1f4e0352db334
[platform/upstream/armnn.git] / CMakeLists.txt
1 #
2 # Copyright © 2017 Arm Ltd. All rights reserved.
3 # SPDX-License-Identifier: MIT
4 #
5 cmake_minimum_required (VERSION 3.0.2) # 3.0.2 required for return() statement used in AddDllCopyCommands.cmake
6 project(armnn)
7
8 set(additional_cmake_files)
9 list(APPEND additional_cmake_files
10     cmake/Utils.cmake
11     cmake/GlobalConfig.cmake
12     cmake/AddDllCopyCommands.cmake)
13
14 foreach(cmake_file ${additional_cmake_files})
15     include(${cmake_file})
16 endforeach()
17
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}"')
21 endif()
22
23 include(GNUInstallDirs)
24
25 add_subdirectory(samples)
26 add_subdirectory(src/armnnTfLiteParser)
27 add_subdirectory(src/armnnSerializer)
28
29 if (BUILD_TESTS)
30     add_subdirectory(tests)
31 endif()
32
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})
35
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
68     )
69
70 add_library_ex(armnnUtils STATIC ${armnnUtils_sources})
71 target_include_directories(armnnUtils PRIVATE src/backends)
72
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
83         )
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")
87     endif()
88
89     add_library_ex(armnnCaffeParser SHARED ${armnn_caffe_parser_sources})
90     set_target_properties(armnnCaffeParser PROPERTIES COMPILE_FLAGS "${CAFFE_PARSER_ADDITIONAL_COMPILE_FLAGS}")
91
92     target_include_directories(armnnCaffeParser PRIVATE src/armnnUtils)
93
94     target_link_libraries(armnnCaffeParser ${Boost_LOG_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY})
95
96     target_link_libraries(armnnCaffeParser armnn)
97     target_link_libraries(armnnCaffeParser ${PROTOBUF_LIBRARIES})
98
99 endif()
100
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
108         )
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")
112     endif()
113
114     add_library_ex(armnnOnnxParser SHARED ${armnn_onnx_parser_sources})
115
116     target_include_directories(armnnOnnxParser PRIVATE src/armnnUtils)
117
118     target_link_libraries(armnnOnnxParser armnn)
119
120     # Protobuf
121     target_link_libraries(armnnOnnxParser ${PROTOBUF_LIBRARIES})
122 endif()
123
124 if(BUILD_TF_PARSER)
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
130         ${TF_PROTOBUFS}
131         )
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")
135     endif()
136
137     add_library_ex(armnnTfParser SHARED ${armnn_tf_parser_sources})
138
139     target_include_directories(armnnTfParser PRIVATE src/armnnUtils)
140
141     target_link_libraries(armnnTfParser armnn)
142
143     # Protobuf (use the specific version tensorflow wants)
144     target_link_libraries(armnnTfParser ${PROTOBUF_LIBRARIES})
145 endif()
146
147 if(BUILD_ARMNN_QUANTIZER AND ARMCOMPUTEREF)
148     if(NOT BUILD_ARMNN_SERIALIZER)
149         message(ERROR, "In order to build the ArmNN Quantization Tool you must set BUILD_ARMNN_SERIALIZER = YES")
150     endif()
151
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
160         )
161
162     add_library_ex(armnnQuantizer SHARED ${armnn_quantizer_sources})
163
164     target_include_directories(armnnQuantizer PRIVATE include/armnnDeserializer)
165     target_include_directories(armnnQuantizer PRIVATE src/armnnUtils)
166     target_include_directories(armnnQuantizer PRIVATE src/armnn)
167
168     include_directories(SYSTEM "${FLATBUFFERS_INCLUDE_PATH}")
169     set_target_properties(armnnQuantizer PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
170
171     target_link_libraries(armnnQuantizer
172             armnn
173             ${Boost_SYSTEM_LIBRARY}
174             ${Boost_PROGRAM_OPTIONS_LIBRARY}
175             ${Boost_FILESYSTEM_LIBRARY}
176             ${Boost_LOG_LIBRARY}
177             ${Boost_THREAD_LIBRARY} )
178
179     add_executable_ex(ArmnnQuantizer
180         src/armnnQuantizer/ArmNNQuantizerMain.cpp)
181
182     target_include_directories(ArmnnQuantizer PRIVATE include/armnnDeserializer)
183     target_include_directories(ArmnnQuantizer PRIVATE src/armnn)
184
185     target_link_libraries(ArmnnQuantizer
186             ${Boost_SYSTEM_LIBRARY}
187             ${Boost_PROGRAM_OPTIONS_LIBRARY}
188             ${Boost_FILESYSTEM_LIBRARY}
189             ${Boost_LOG_LIBRARY}
190             ${Boost_THREAD_LIBRARY} )
191
192     target_link_libraries(ArmnnQuantizer
193             armnnQuantizer
194             armnnSerializer
195             armnn
196             armnnUtils
197             ${FLATBUFFERS_LIBRARY})
198
199     if(Threads_FOUND AND (NOT ("${CMAKE_SYSTEM_NAME}" STREQUAL Android)))
200         target_link_libraries(ArmnnQuantizer pthread)
201     endif()
202
203 endif()
204
205
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/ActivationLayer.hpp
233     src/armnn/layers/ActivationLayer.cpp
234     src/armnn/layers/AdditionLayer.hpp
235     src/armnn/layers/AdditionLayer.cpp
236     src/armnn/layers/BatchNormalizationLayer.hpp
237     src/armnn/layers/BatchNormalizationLayer.cpp
238     src/armnn/layers/BatchToSpaceNdLayer.hpp
239     src/armnn/layers/BatchToSpaceNdLayer.cpp
240     src/armnn/layers/ConcatLayer.hpp
241     src/armnn/layers/ConcatLayer.cpp
242     src/armnn/layers/ConstantLayer.hpp
243     src/armnn/layers/ConstantLayer.cpp
244     src/armnn/layers/Convolution2dLayer.hpp
245     src/armnn/layers/Convolution2dLayer.cpp
246     src/armnn/layers/ConvertFp16ToFp32Layer.hpp
247     src/armnn/layers/ConvertFp16ToFp32Layer.cpp
248     src/armnn/layers/ConvertFp32ToFp16Layer.hpp
249     src/armnn/layers/ConvertFp32ToFp16Layer.cpp
250     src/armnn/layers/DebugLayer.hpp
251     src/armnn/layers/DebugLayer.cpp
252     src/armnn/layers/DepthwiseConvolution2dLayer.hpp
253     src/armnn/layers/DepthwiseConvolution2dLayer.cpp
254     src/armnn/layers/DequantizeLayer.hpp
255     src/armnn/layers/DequantizeLayer.cpp
256     src/armnn/layers/DetectionPostProcessLayer.hpp
257     src/armnn/layers/DetectionPostProcessLayer.cpp
258     src/armnn/layers/ElementwiseBaseLayer.hpp
259     src/armnn/layers/ElementwiseBaseLayer.cpp
260     src/armnn/layers/EqualLayer.hpp
261     src/armnn/layers/EqualLayer.cpp
262     src/armnn/layers/FakeQuantizationLayer.hpp
263     src/armnn/layers/FakeQuantizationLayer.cpp
264     src/armnn/layers/FloorLayer.hpp
265     src/armnn/layers/FloorLayer.cpp
266     src/armnn/layers/FullyConnectedLayer.hpp
267     src/armnn/layers/FullyConnectedLayer.cpp
268     src/armnn/layers/GatherLayer.cpp
269     src/armnn/layers/GatherLayer.hpp
270     src/armnn/layers/GreaterLayer.cpp
271     src/armnn/layers/GreaterLayer.hpp
272     src/armnn/layers/InputLayer.hpp
273     src/armnn/layers/InputLayer.cpp
274     src/armnn/layers/L2NormalizationLayer.hpp
275     src/armnn/layers/L2NormalizationLayer.cpp
276     src/armnn/layers/LstmLayer.cpp
277     src/armnn/layers/LstmLayer.hpp
278     src/armnn/layers/MaximumLayer.cpp
279     src/armnn/layers/MaximumLayer.hpp
280     src/armnn/layers/MeanLayer.hpp
281     src/armnn/layers/MeanLayer.cpp
282     src/armnn/layers/MemCopyLayer.hpp
283     src/armnn/layers/MemCopyLayer.cpp
284     src/armnn/layers/MemImportLayer.hpp
285     src/armnn/layers/MemImportLayer.cpp
286     src/armnn/layers/MergeLayer.hpp
287     src/armnn/layers/MergeLayer.cpp
288     src/armnn/layers/MinimumLayer.cpp
289     src/armnn/layers/MinimumLayer.hpp
290     src/armnn/layers/MultiplicationLayer.hpp
291     src/armnn/layers/MultiplicationLayer.cpp
292     src/armnn/layers/NormalizationLayer.hpp
293     src/armnn/layers/NormalizationLayer.cpp
294     src/armnn/layers/OutputLayer.hpp
295     src/armnn/layers/OutputLayer.cpp
296     src/armnn/layers/PadLayer.hpp
297     src/armnn/layers/PadLayer.cpp
298     src/armnn/layers/PermuteLayer.hpp
299     src/armnn/layers/PermuteLayer.cpp
300     src/armnn/layers/Pooling2dLayer.hpp
301     src/armnn/layers/Pooling2dLayer.cpp
302     src/armnn/layers/QuantizeLayer.cpp
303     src/armnn/layers/QuantizeLayer.hpp
304     src/armnn/layers/QuantizedLstmLayer.hpp
305     src/armnn/layers/QuantizedLstmLayer.cpp
306     src/armnn/layers/DivisionLayer.cpp
307     src/armnn/layers/DivisionLayer.hpp
308     src/armnn/layers/PreCompiledLayer.hpp
309     src/armnn/layers/PreCompiledLayer.cpp
310     src/armnn/layers/PreluLayer.hpp
311     src/armnn/layers/PreluLayer.cpp
312     src/armnn/layers/ReshapeLayer.hpp
313     src/armnn/layers/ReshapeLayer.cpp
314     src/armnn/layers/ResizeLayer.hpp
315     src/armnn/layers/ResizeLayer.cpp
316     src/armnn/layers/RsqrtLayer.cpp
317     src/armnn/layers/RsqrtLayer.hpp
318     src/armnn/layers/SoftmaxLayer.hpp
319     src/armnn/layers/SoftmaxLayer.cpp
320     src/armnn/layers/SpaceToBatchNdLayer.hpp
321     src/armnn/layers/SpaceToBatchNdLayer.cpp
322     src/armnn/layers/SpaceToDepthLayer.hpp
323     src/armnn/layers/SpaceToDepthLayer.cpp
324     src/armnn/layers/SplitterLayer.hpp
325     src/armnn/layers/SplitterLayer.cpp
326     src/armnn/layers/StackLayer.hpp
327     src/armnn/layers/StackLayer.cpp
328     src/armnn/layers/StridedSliceLayer.cpp
329     src/armnn/layers/StridedSliceLayer.hpp
330     src/armnn/layers/SubtractionLayer.cpp
331     src/armnn/layers/SubtractionLayer.hpp
332     src/armnn/layers/SwitchLayer.cpp
333     src/armnn/layers/SwitchLayer.hpp
334     src/armnn/layers/TransposeConvolution2dLayer.cpp
335     src/armnn/layers/TransposeConvolution2dLayer.hpp
336     src/armnn/BackendSettings.hpp
337     src/armnn/BackendHelper.cpp
338     src/armnn/CompatibleTypes.hpp
339     src/armnn/Descriptors.cpp
340     src/armnn/DeviceSpec.hpp
341     src/armnn/DynamicQuantizationVisitor.cpp
342     src/armnn/DynamicQuantizationVisitor.hpp
343     src/armnn/Exceptions.cpp
344     src/armnn/ExecutionFrame.cpp
345     src/armnn/ExecutionFrame.hpp
346     src/armnn/Graph.cpp
347     src/armnn/Graph.hpp
348     src/armnn/IGraphObservable.hpp
349     src/armnn/Instrument.hpp
350     src/armnn/InternalTypes.cpp
351     src/armnn/InternalTypes.hpp
352     src/armnn/ISubgraphViewConverter.hpp
353     src/armnn/JsonPrinter.cpp
354     src/armnn/JsonPrinter.hpp
355     src/armnn/Layer.cpp
356     src/armnn/LayerFwd.hpp
357     src/armnn/Layer.hpp
358     src/armnn/LayersFwd.hpp
359     src/armnn/LayerSupportCommon.hpp
360     src/armnn/LayerSupport.cpp
361     src/armnn/LoadedNetwork.cpp
362     src/armnn/LoadedNetwork.hpp
363     src/armnn/Network.cpp
364     src/armnn/Network.hpp
365     src/armnn/NetworkQuantizationScheme.hpp
366     src/armnn/NetworkQuantizer.cpp
367     src/armnn/NetworkQuantizer.hpp
368     src/armnn/NetworkQuantizerUtils.cpp
369     src/armnn/NetworkQuantizerUtils.hpp
370     src/armnn/NetworkUtils.cpp
371     src/armnn/NetworkUtils.hpp
372     src/armnn/Observable.cpp
373     src/armnn/Observable.hpp
374     src/armnn/Optimizer.cpp
375     src/armnn/Optimizer.hpp
376     src/armnn/OverrideInputRangeVisitor.cpp
377     src/armnn/OverrideInputRangeVisitor.hpp
378     src/armnn/Profiling.cpp
379     src/armnn/ProfilingEvent.cpp
380     src/armnn/ProfilingEvent.hpp
381     src/armnn/Profiling.hpp
382     src/armnn/QuantizerVisitor.cpp
383     src/armnn/QuantizerVisitor.hpp
384     src/armnn/Runtime.cpp
385     src/armnn/Runtime.hpp
386     src/armnn/RangeTracker.cpp
387     src/armnn/RangeTracker.hpp
388     src/armnn/ResolveType.hpp
389     src/armnn/SerializeLayerParameters.cpp
390     src/armnn/SerializeLayerParameters.hpp
391     src/armnn/StaticRangeVisitor.cpp
392     src/armnn/StaticRangeVisitor.hpp
393     src/armnn/SubgraphView.cpp
394     src/armnn/SubgraphView.hpp
395     src/armnn/SubgraphViewSelector.cpp
396     src/armnn/SubgraphViewSelector.hpp
397     src/armnn/Tensor.cpp
398     src/armnn/TypesUtils.cpp
399     src/armnn/Utils.cpp
400     src/armnn/WallClockTimer.cpp
401     src/armnn/WallClockTimer.hpp
402     src/armnn/optimizations/AddDebug.hpp
403     src/armnn/optimizations/All.hpp
404     src/armnn/optimizations/ConvertConstants.hpp
405     src/armnn/optimizations/ConvertFp32NetworkToFp16.hpp
406     src/armnn/optimizations/FoldPadIntoConvolution2d.hpp
407     src/armnn/optimizations/MovePermuteUp.hpp
408     src/armnn/optimizations/Optimization.hpp
409     src/armnn/optimizations/OptimizeConsecutiveReshapes.hpp
410     src/armnn/optimizations/OptimizeInverseConversions.hpp
411     src/armnn/optimizations/OptimizeInversePermutes.hpp
412     src/armnn/optimizations/PermuteAsReshape.hpp
413     src/armnn/optimizations/SquashEqualSiblings.hpp
414     src/profiling/CommandHandlerFunctor.cpp
415     src/profiling/CommandHandlerFunctor.hpp
416     src/profiling/CommandHandlerKey.cpp
417     src/profiling/CommandHandlerKey.hpp
418     src/profiling/CommandHandlerRegistry.cpp
419     src/profiling/CommandHandlerRegistry.hpp
420     src/profiling/CounterDirectory.cpp
421     src/profiling/CounterDirectory.hpp
422     src/profiling/EncodeVersion.hpp
423     src/profiling/IProfilingConnection.hpp
424     src/profiling/Packet.cpp
425     src/profiling/Packet.hpp
426     src/profiling/PacketVersionResolver.cpp
427     src/profiling/PacketVersionResolver.hpp
428     src/profiling/ProfilingConnectionFactory.cpp
429     src/profiling/ProfilingConnectionFactory.hpp
430     third-party/half/half.hpp
431     )
432
433 # Files used for Streamline-based profiling backend
434 if(PROFILING_BACKEND_STREAMLINE)
435     list(APPEND armnn_sources
436         ${GATOR_ROOT}/annotate/streamline_annotate.h
437         ${GATOR_ROOT}/annotate/streamline_annotate.c)
438 endif()
439
440 # the backends under src/backends extend the list of
441 # object libs armnn to include in the build
442 include(src/backends/backends.cmake)
443 foreach(lib ${armnnLibraries})
444     message("Adding object library dependency to armnn: ${lib}")
445     list(APPEND armnn_sources $<TARGET_OBJECTS:${lib}>)
446 endforeach()
447
448 add_library_ex(armnn SHARED ${armnn_sources})
449
450 target_include_directories(armnn PRIVATE src/armnn)
451 target_include_directories(armnn PRIVATE src/armnnUtils)
452 target_include_directories(armnn PRIVATE src/backends)
453
454 target_link_libraries(armnn armnnUtils)
455
456 target_link_libraries(armnn ${CMAKE_DL_LIBS})
457
458 install(TARGETS armnn
459         LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
460         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
461 if(BUILD_CAFFE_PARSER)
462     install(TARGETS armnnCaffeParser
463             LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
464             RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
465 endif()
466 if(BUILD_ONNX_PARSER)
467     install(TARGETS armnnOnnxParser
468             LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
469             RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
470 endif()
471 if(BUILD_TF_PARSER)
472     install(TARGETS armnnTfParser
473             LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
474             RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
475 endif()
476
477 install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
478
479 target_link_libraries(armnn ${Boost_LOG_LIBRARY} ${Boost_THREAD_LIBRARY}
480                             ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY})
481
482 if(ARMCOMPUTENEON OR ARMCOMPUTECL)
483     target_link_libraries(armnn ${ARMCOMPUTE_LIBRARIES})
484 endif()
485 if(ARMCOMPUTECL)
486     target_link_libraries(armnn ${OPENCL_LIBRARIES})
487 endif()
488
489 if(PROFILING_BACKEND_STREAMLINE)
490     target_link_libraries(armnn pthread)
491 endif()
492
493 if(BUILD_UNIT_TESTS)
494     set(unittest_sources)
495     list(APPEND unittest_sources
496         src/armnn/test/ConstTensorLayerVisitor.hpp
497         src/armnn/test/ConstTensorLayerVisitor.cpp
498         src/armnn/test/CreateWorkload.hpp
499         src/armnn/test/CsvReaderTest.cpp
500         src/armnn/test/EndToEndTest.cpp
501         src/armnn/test/ExecutionFrameTest.cpp
502         src/armnn/test/FloatingPointConverterTest.cpp
503         src/armnn/test/FlowControl.cpp
504         src/armnn/test/GraphTests.cpp
505         src/armnn/test/GraphUtils.cpp
506         src/armnn/test/GraphUtils.hpp
507         src/armnn/test/InstrumentTests.cpp
508         src/armnn/test/InferOutputTests.cpp
509         src/armnn/test/InferOutputTests.hpp
510         src/armnn/test/ModelAccuracyCheckerTest.cpp
511         src/armnn/test/NetworkTests.cpp
512         src/armnn/test/ObservableTest.cpp
513         src/armnn/test/OptimizerTests.cpp
514         src/armnn/test/OptionalTest.cpp
515         src/armnn/test/ProfilerTests.cpp
516         src/armnn/test/ProfilingEventTest.cpp
517         src/armnn/test/SubgraphViewTests.cpp
518         src/armnn/test/TensorHandleStrategyTest.cpp
519         src/armnn/test/TensorHelpers.hpp
520         src/armnn/test/TensorTest.cpp
521         src/armnn/test/TestInputOutputLayerVisitor.cpp
522         src/armnn/test/TestInputOutputLayerVisitor.hpp
523         src/armnn/test/TestLayerVisitor.cpp
524         src/armnn/test/TestLayerVisitor.hpp
525         src/armnn/test/TestNameOnlyLayerVisitor.cpp
526         src/armnn/test/TestNameOnlyLayerVisitor.hpp
527         src/armnn/test/TestNameAndDescriptorLayerVisitor.hpp
528         src/armnn/test/TestNameAndDescriptorLayerVisitor.cpp
529         src/armnn/test/TestUtils.cpp
530         src/armnn/test/TestUtils.hpp
531         src/armnn/test/UnitTests.cpp
532         src/armnn/test/UnitTests.hpp
533         src/armnn/test/UtilsTests.cpp
534         src/armnnUtils/test/PrototxtConversionsTest.cpp
535         src/armnnUtils/test/ParserHelperTest.cpp
536         src/profiling/test/ProfilingTests.cpp
537         )
538
539     if(ARMCOMPUTEREF)
540         list(APPEND unittest_sources
541             src/armnn/test/DebugCallbackTest.cpp
542             src/armnn/test/QuantizerTest.cpp
543             src/armnn/test/RuntimeTests.cpp
544             src/armnn/test/RuntimeTests.hpp
545             )
546     endif()
547
548     if(BUILD_TF_PARSER AND ARMCOMPUTEREF)
549         list(APPEND unittest_sources
550             src/armnnTfParser/test/Activations.cpp
551             src/armnnTfParser/test/Addition.cpp
552             src/armnnTfParser/test/AddN.cpp
553             src/armnnTfParser/test/Assert.cpp
554             src/armnnTfParser/test/BiasAdd.cpp
555             src/armnnTfParser/test/BroadcastForAdd.cpp
556             src/armnnTfParser/test/Convolution2d.cpp
557             src/armnnTfParser/test/Concat.cpp
558             src/armnnTfParser/test/ConcatOfConcats.cpp
559             src/armnnTfParser/test/DepthwiseConvolution2d.cpp
560             src/armnnTfParser/test/Equal.cpp
561             src/armnnTfParser/test/ExpandDims.cpp
562             src/armnnTfParser/test/FusedBatchNorm.cpp
563             src/armnnTfParser/test/Gather.cpp
564             src/armnnTfParser/test/Greater.cpp
565             src/armnnTfParser/test/Identity.cpp
566             src/armnnTfParser/test/LocalResponseNormalization.cpp
567             src/armnnTfParser/test/Maximum.cpp
568             src/armnnTfParser/test/MaximumForLeakyRelu.cpp
569             src/armnnTfParser/test/Mean.cpp
570             src/armnnTfParser/test/Minimum.cpp
571             src/armnnTfParser/test/Multiplication.cpp
572             src/armnnTfParser/test/Pad.cpp
573             src/armnnTfParser/test/MultiOutput.cpp
574             src/armnnTfParser/test/PassThru.cpp
575             src/armnnTfParser/test/Pooling.cpp
576             src/armnnTfParser/test/RealDiv.cpp
577             src/armnnTfParser/test/Reshape.cpp
578             src/armnnTfParser/test/ResizeBilinear.cpp
579             src/armnnTfParser/test/Rsqrt.cpp
580             src/armnnTfParser/test/Shape.cpp
581             src/armnnTfParser/test/Softmax.cpp
582             src/armnnTfParser/test/TestDependencies.cpp
583             src/armnnTfParser/test/FullyConnected.cpp
584             src/armnnTfParser/test/Constant.cpp
585             src/armnnTfParser/test/TestMultiInputsOutputs.cpp
586             src/armnnTfParser/test/Split.cpp
587             src/armnnTfParser/test/Squeeze.cpp
588             src/armnnTfParser/test/Sub.cpp
589             )
590
591     endif()
592
593     if(BUILD_TF_LITE_PARSER AND ARMCOMPUTEREF)
594         enable_language(ASM)
595         list(APPEND unittest_sources
596              src/armnnTfLiteParser/test/Activations.cpp
597              src/armnnTfLiteParser/test/Addition.cpp
598              src/armnnTfLiteParser/test/AvgPool2D.cpp
599              src/armnnTfLiteParser/test/BatchToSpaceND.cpp
600              src/armnnTfLiteParser/test/Concatenation.cpp
601              src/armnnTfLiteParser/test/Constant.cpp
602              src/armnnTfLiteParser/test/Conv2D.cpp
603              src/armnnTfLiteParser/test/DepthwiseConvolution2D.cpp
604              src/armnnTfLiteParser/test/DetectionPostProcess.cpp
605              src/armnnTfLiteParser/test/FullyConnected.cpp
606              src/armnnTfLiteParser/test/L2Normalization.cpp
607              src/armnnTfLiteParser/test/Maximum.cpp
608              src/armnnTfLiteParser/test/MaxPool2D.cpp
609              src/armnnTfLiteParser/test/Mean.cpp
610              src/armnnTfLiteParser/test/Minimum.cpp
611              src/armnnTfLiteParser/test/Multiplication.cpp
612              src/armnnTfLiteParser/test/Pack.cpp
613              src/armnnTfLiteParser/test/Pad.cpp
614              src/armnnTfLiteParser/test/Reshape.cpp
615              src/armnnTfLiteParser/test/ResizeBilinear.cpp
616              src/armnnTfLiteParser/test/Softmax.cpp
617              src/armnnTfLiteParser/test/SpaceToBatchND.cpp
618              src/armnnTfLiteParser/test/Split.cpp
619              src/armnnTfLiteParser/test/Squeeze.cpp
620              src/armnnTfLiteParser/test/StridedSlice.cpp
621              src/armnnTfLiteParser/test/Sub.cpp
622              src/armnnTfLiteParser/test/TransposeConv.cpp
623              src/armnnTfLiteParser/test/Unpack.cpp
624              src/armnnTfLiteParser/test/LoadModel.cpp
625              src/armnnTfLiteParser/test/GetBuffer.cpp
626              src/armnnTfLiteParser/test/OutputShapeOfSqueeze.cpp
627              src/armnnTfLiteParser/test/InputOutputTensorNames.cpp
628              src/armnnTfLiteParser/test/GetTensorIds.cpp
629              src/armnnTfLiteParser/test/GetSubgraphInputsOutputs.cpp
630              src/armnnTfLiteParser/test/GetInputsOutputs.cpp
631              src/armnnTfLiteParser/test/Schema.s
632              )
633         set_source_files_properties(src/armnnTfLiteParser/test/Schema.s PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp")
634
635     endif()
636
637     if(BUILD_CAFFE_PARSER AND ARMCOMPUTEREF)
638         list(APPEND unittest_sources
639             src/armnnCaffeParser/test/TestAdd.cpp
640             src/armnnCaffeParser/test/TestConcat.cpp
641             src/armnnCaffeParser/test/TestConvolution.cpp
642             src/armnnCaffeParser/test/TestDropout.cpp
643             src/armnnCaffeParser/test/TestInputs.cpp
644             src/armnnCaffeParser/test/TestMul.cpp
645             src/armnnCaffeParser/test/TestPooling2d.cpp
646             src/armnnCaffeParser/test/TestInPlace.cpp
647             src/armnnCaffeParser/test/TestMultiInputsOutputs.cpp
648             src/armnnCaffeParser/test/TestSplit.cpp
649             )
650     endif()
651
652     if(BUILD_ONNX_PARSER AND ARMCOMPUTEREF)
653         list(APPEND unittest_sources
654             src/armnnOnnxParser/test/Constructor.cpp
655             src/armnnOnnxParser/test/CreateNetwork.cpp
656             src/armnnOnnxParser/test/ProtoxtFixture.cpp
657             src/armnnOnnxParser/test/Const.cpp
658             src/armnnOnnxParser/test/Pooling.cpp
659             src/armnnOnnxParser/test/Reshape.cpp
660             src/armnnOnnxParser/test/Relu.cpp
661             src/armnnOnnxParser/test/Conv2D.cpp
662             src/armnnOnnxParser/test/Addition.cpp
663             src/armnnOnnxParser/test/FullyConnected.cpp
664             src/armnnOnnxParser/test/GetInputsOutputs.cpp
665             src/armnnOnnxParser/test/BatchNorm.cpp
666             src/armnnOnnxParser/test/DepthConv.cpp
667             )
668     endif()
669
670     if(BUILD_ARMNN_QUANTIZER AND ARMCOMPUTEREF)
671         list(APPEND unittest_sources
672              src/armnnQuantizer/test/QuantizationDataSetTests.cpp
673              )
674     endif()
675
676     if(BUILD_ARMNN_SERIALIZER AND ARMCOMPUTEREF)
677         enable_language(ASM)
678         list(APPEND unittest_sources
679             src/armnnSerializer/test/ActivationSerializationTests.cpp
680             src/armnnSerializer/test/SerializerTests.cpp
681             src/armnnDeserializer/test/DeserializeActivation.cpp
682             src/armnnDeserializer/test/DeserializeAdd.cpp
683             src/armnnDeserializer/test/DeserializeBatchToSpaceNd.cpp
684             src/armnnDeserializer/test/DeserializeBatchNormalization.cpp
685             src/armnnDeserializer/test/DeserializeConstant.cpp
686             src/armnnDeserializer/test/DeserializeConvolution2d.cpp
687             src/armnnDeserializer/test/DeserializeDivision.cpp
688             src/armnnDeserializer/test/DeserializeEqual.cpp
689             src/armnnDeserializer/test/DeserializeFloor.cpp
690             src/armnnDeserializer/test/DeserializeFullyConnected.cpp
691             src/armnnDeserializer/test/DeserializeGather.cpp
692             src/armnnDeserializer/test/DeserializeGreater.cpp
693             src/armnnDeserializer/test/DeserializeL2Normalization.cpp
694             src/armnnDeserializer/test/DeserializeMean.cpp
695             src/armnnDeserializer/test/DeserializeMultiplication.cpp
696             src/armnnDeserializer/test/DeserializeNormalization.cpp
697             src/armnnDeserializer/test/DeserializePad.cpp
698             src/armnnDeserializer/test/DeserializePermute.cpp
699             src/armnnDeserializer/test/DeserializePooling2d.cpp
700             src/armnnDeserializer/test/DeserializeReshape.cpp
701             src/armnnDeserializer/test/DeserializeResizeBilinear.cpp
702             src/armnnDeserializer/test/DeserializeRsqrt.cpp
703             src/armnnDeserializer/test/DeserializeSpaceToBatchNd.cpp
704             src/armnnDeserializer/test/DeserializeStridedSlice.cpp
705             src/armnnDeserializer/test/DeserializeSubtraction.cpp
706             src/armnnDeserializer/test/ParserFlatbuffersSerializeFixture.hpp
707             src/armnnDeserializer/test/SchemaSerialize.s
708             )
709         set_source_files_properties(src/armnnDeserializer/test/SchemaSerialize.s PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp")
710     endif()
711
712     foreach(lib ${armnnUnitTestLibraries})
713         message("Adding object library dependency to UnitTests: ${lib}")
714         list(APPEND unittest_sources $<TARGET_OBJECTS:${lib}>)
715     endforeach()
716
717     add_executable(UnitTests ${unittest_sources})
718     target_include_directories(UnitTests PRIVATE src/armnn)
719     target_include_directories(UnitTests PRIVATE src/armnnUtils)
720     target_include_directories(UnitTests PRIVATE src/backends)
721
722     if(VALGRIND_FOUND)
723         if(HEAP_PROFILING OR LEAK_CHECKING)
724             message("Valgrind is disabled for heap profiling and leak checking builds.")
725         else()
726             # Valgrind works with gperftools version number <= 2.4
727             target_compile_definitions(UnitTests PRIVATE "WITH_VALGRIND=1")
728         endif()
729     endif()
730
731     target_link_libraries(UnitTests ${CMAKE_THREAD_LIBS_INIT})
732     target_link_libraries(UnitTests ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY})
733
734     target_link_libraries(UnitTests armnn)
735     target_link_libraries(UnitTests armnnUtils)
736
737     if(BUILD_TF_PARSER)
738         target_link_libraries(UnitTests armnnTfParser)
739     endif()
740
741     if(BUILD_TF_LITE_PARSER)
742         target_include_directories(UnitTests SYSTEM PRIVATE "${TF_LITE_SCHEMA_INCLUDE_PATH}")
743         target_include_directories(UnitTests SYSTEM PRIVATE "${FLATBUFFERS_INCLUDE_PATH}")
744         target_link_libraries(UnitTests armnnTfLiteParser)
745     endif()
746
747     if(BUILD_CAFFE_PARSER)
748         target_link_libraries(UnitTests armnnCaffeParser)
749     endif()
750
751     if(BUILD_ARMNN_SERIALIZER AND ARMCOMPUTEREF)
752         target_include_directories(UnitTests SYSTEM PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src/armnnSerializer)
753         target_include_directories(UnitTests SYSTEM PRIVATE "${FLATBUFFERS_INCLUDE_PATH}")
754         target_link_libraries(UnitTests armnnSerializer)
755     endif()
756
757     if(BUILD_ARMNN_QUANTIZER AND ARMCOMPUTEREF)
758         target_include_directories(UnitTests SYSTEM PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src/armnnQuantizer)
759         target_include_directories(UnitTests SYSTEM PRIVATE "${FLATBUFFERS_INCLUDE_PATH}")
760         target_link_libraries(UnitTests armnnQuantizer armnnSerializer)
761     endif()
762
763     if(BUILD_ONNX_PARSER)
764         target_link_libraries(UnitTests armnnOnnxParser)
765     endif()
766
767     addDllCopyCommands(UnitTests)
768 endif()
769
770 if (BUILD_ARMNN_SERIALIZER AND (BUILD_TF_PARSER OR BUILD_TF_LITE_PARSER OR BUILD_ONNX_PARSER OR BUILD_CAFFE_PARSER) AND ARMCOMPUTEREF)
771     set(ArmnnConverter_sources
772         src/armnnConverter/ArmnnConverter.cpp)
773
774     add_executable_ex(ArmnnConverter ${ArmnnConverter_sources})
775     target_include_directories(ArmnnConverter PRIVATE src/armnn)
776     target_include_directories(ArmnnConverter PRIVATE src/armnnUtils)
777
778     if(BUILD_CAFFE_PARSER)
779         target_link_libraries(ArmnnConverter armnnCaffeParser)
780     endif()
781
782     if(BUILD_ONNX_PARSER)
783         target_link_libraries(ArmnnConverter armnnOnnxParser)
784     endif()
785
786     if(BUILD_TF_PARSER)
787         target_link_libraries(ArmnnConverter armnnTfParser)
788     endif()
789
790     if(BUILD_TF_LITE_PARSER)
791         target_link_libraries(ArmnnConverter armnnTfLiteParser)
792     endif()
793
794     target_link_libraries(ArmnnConverter armnnSerializer)
795
796     target_link_libraries(ArmnnConverter armnn)
797     target_link_libraries(ArmnnConverter ${CMAKE_THREAD_LIBS_INIT})
798     target_link_libraries(ArmnnConverter
799         ${Boost_SYSTEM_LIBRARY}
800         ${Boost_FILESYSTEM_LIBRARY}
801         ${Boost_PROGRAM_OPTIONS_LIBRARY})
802     addDllCopyCommands(ArmnnConverter)
803 endif()