Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 1 | # |
| 2 | # Copyright © 2020 Arm Ltd and Contributors. All rights reserved. |
| 3 | # SPDX-License-Identifier: MIT |
| 4 | # |
| 5 | |
Jan Eilers | b968a4f | 2020-11-15 14:44:43 +0000 | [diff] [blame] | 6 | cmake_minimum_required (VERSION 3.7.0) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 7 | project(armnnDelegate) |
| 8 | |
Finn Williams | 6f9f990 | 2020-11-13 13:23:15 +0000 | [diff] [blame] | 9 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wextra -Werror -Wold-style-cast -Wno-missing-braces -Wconversion -Wsign-conversion") |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 10 | |
Finn Williams | bbbefec | 2020-11-25 14:32:42 +0000 | [diff] [blame] | 11 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules/") |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 12 | |
| 13 | set(armnnDelegate_sources) |
| 14 | list(APPEND armnnDelegate_sources |
| 15 | include/armnn_delegate.hpp |
| 16 | include/DelegateOptions.hpp |
| 17 | src/armnn_delegate.cpp |
Sadik Armagan | 62483be | 2020-10-23 17:14:43 +0100 | [diff] [blame] | 18 | src/DelegateOptions.cpp |
| 19 | src/Activation.hpp |
| 20 | src/ArgMinMax.hpp |
| 21 | src/BatchSpace.hpp |
| 22 | src/Comparison.hpp |
| 23 | src/Convolution.hpp |
| 24 | src/Control.hpp |
| 25 | src/DelegateUtils.hpp |
| 26 | src/ElementwiseBinary.hpp |
| 27 | src/ElementwiseUnary.hpp |
| 28 | src/Fill.hpp |
| 29 | src/FullyConnected.hpp |
| 30 | src/Gather.hpp |
Matthew Sloyan | c8eb955 | 2020-11-26 10:54:22 +0000 | [diff] [blame] | 31 | src/LogicalBinary.hpp |
Sadik Armagan | 62483be | 2020-10-23 17:14:43 +0100 | [diff] [blame] | 32 | src/Lstm.hpp |
| 33 | src/Normalization.hpp |
| 34 | src/Pad.hpp |
| 35 | src/Pooling.hpp |
| 36 | src/Quantization.hpp |
| 37 | src/Redefine.hpp |
| 38 | src/Resize.hpp |
| 39 | src/Round.hpp |
| 40 | src/Slice.hpp |
| 41 | src/Softmax.hpp |
| 42 | src/SpaceDepth.hpp |
Sadik Armagan | 34fa1bd | 2020-11-27 12:40:52 +0000 | [diff] [blame] | 43 | src/Split.hpp |
Sadik Armagan | 62483be | 2020-10-23 17:14:43 +0100 | [diff] [blame] | 44 | src/Transpose.hpp) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 45 | |
| 46 | add_library(armnnDelegate SHARED ${armnnDelegate_sources}) |
| 47 | |
| 48 | target_include_directories(armnnDelegate |
| 49 | PUBLIC |
| 50 | $<INSTALL_INTERFACE:include> |
| 51 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 52 | PRIVATE |
| 53 | ${CMAKE_CURRENT_SOURCE_DIR}/src) |
| 54 | |
| 55 | include(GNUInstallDirs) |
| 56 | |
| 57 | ## Add Armnn as a Dependency |
Finn Williams | bbbefec | 2020-11-25 14:32:42 +0000 | [diff] [blame] | 58 | if(NOT ARMNN_SUB_PROJECT) |
| 59 | find_package(Armnn REQUIRED CONFIG HINTS ${Armnn_DIR}) |
| 60 | endif() |
| 61 | target_link_libraries(armnnDelegate PUBLIC Armnn::Armnn) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 62 | |
| 63 | ## Add TfLite v2.3.1 dependency |
| 64 | find_package(TfLite REQUIRED MODULE) |
| 65 | |
Finn Williams | bbbefec | 2020-11-25 14:32:42 +0000 | [diff] [blame] | 66 | target_link_libraries(armnnDelegate PUBLIC ${TfLite_LIB}) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 67 | |
Finn Williams | 6f9f990 | 2020-11-13 13:23:15 +0000 | [diff] [blame] | 68 | # Various tflite header files are not warning clean |
| 69 | # We can't change compilation flags on header files directly, so we need to add them to an interface library first |
| 70 | add_library(tflite_headers INTERFACE) |
| 71 | target_include_directories(tflite_headers INTERFACE $<BUILD_INTERFACE:${TfLite_INCLUDE_DIR}> |
| 72 | $<INSTALL_INTERFACE:include/tflite_headers>) |
| 73 | |
| 74 | target_compile_options(tflite_headers INTERFACE $<$<CXX_COMPILER_ID:GNU>:-Wno-conversion |
| 75 | -Wno-sign-conversion |
| 76 | -Wno-unused-parameter |
| 77 | -Wno-unused-function>) |
| 78 | |
Finn Williams | bbbefec | 2020-11-25 14:32:42 +0000 | [diff] [blame] | 79 | target_link_libraries(armnnDelegate PUBLIC tflite_headers) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 80 | |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 81 | ## Add Flatbuffers dependency |
| 82 | find_package(Flatbuffers REQUIRED MODULE) |
| 83 | |
Finn Williams | bbbefec | 2020-11-25 14:32:42 +0000 | [diff] [blame] | 84 | target_link_libraries(armnnDelegate PRIVATE |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 85 | ${Flatbuffers_LIB}) |
| 86 | |
Finn Williams | 6f9f990 | 2020-11-13 13:23:15 +0000 | [diff] [blame] | 87 | # include/flatbuffers/flatbuffers.h is not warning clean |
| 88 | # We can't change compilation flags on header files directly, so we need to add them to an interface library first |
| 89 | add_library(flatbuffer_headers INTERFACE) |
| 90 | target_include_directories(flatbuffer_headers INTERFACE $<BUILD_INTERFACE:${Flatbuffers_INCLUDE_DIR}> |
| 91 | $<INSTALL_INTERFACE:include/flatbuffer_headers>) |
| 92 | target_compile_options(flatbuffer_headers INTERFACE $<$<CXX_COMPILER_ID:GNU>:-Wno-sign-conversion>) |
| 93 | |
Finn Williams | bbbefec | 2020-11-25 14:32:42 +0000 | [diff] [blame] | 94 | target_link_libraries(armnnDelegate PUBLIC flatbuffer_headers) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 95 | |
Sadik Armagan | 4189cc5 | 2020-11-11 18:01:48 +0000 | [diff] [blame] | 96 | option(BUILD_UNIT_TESTS "Build unit tests" ON) |
| 97 | if(BUILD_UNIT_TESTS) |
| 98 | set(armnnDelegate_unittest_sources) |
| 99 | list(APPEND armnnDelegate_unittest_sources |
David Monahan | 0cf8442 | 2020-11-16 15:53:03 +0000 | [diff] [blame] | 100 | src/test/ActivationTest.cpp |
| 101 | src/test/ActivationTestHelper.hpp |
Sadik Armagan | 62483be | 2020-10-23 17:14:43 +0100 | [diff] [blame] | 102 | src/test/ArmnnDelegateTest.cpp |
Sadik Armagan | 8b9858d | 2020-11-09 08:26:22 +0000 | [diff] [blame] | 103 | src/test/ComparisonTest.cpp |
| 104 | src/test/ComparisonTestHelper.hpp |
Matthew Sloyan | 91c4171 | 2020-11-13 09:47:35 +0000 | [diff] [blame] | 105 | src/test/ControlTest.cpp |
| 106 | src/test/ControlTestHelper.hpp |
Sadik Armagan | 32ca144 | 2020-11-13 17:51:56 +0000 | [diff] [blame] | 107 | src/test/Convolution2dTest.cpp |
| 108 | src/test/ConvolutionTestHelper.hpp |
| 109 | src/test/DepthwiseConvolution2dTest.cpp |
Sadik Armagan | 67e95f2 | 2020-10-29 16:14:54 +0000 | [diff] [blame] | 110 | src/test/ElementwiseBinaryTest.cpp |
| 111 | src/test/ElementwiseBinaryTestHelper.hpp |
Sadik Armagan | 0534e03 | 2020-10-27 17:30:18 +0000 | [diff] [blame] | 112 | src/test/ElementwiseUnaryTest.cpp |
Matthew Sloyan | 0d35a93 | 2020-11-09 12:25:05 +0000 | [diff] [blame] | 113 | src/test/ElementwiseUnaryTestHelper.hpp |
Sadik Armagan | 6e36a64 | 2020-11-10 21:18:41 +0000 | [diff] [blame] | 114 | src/test/FullyConnectedTest.cpp |
| 115 | src/test/FullyConnectedTestHelper.hpp |
Teresa Charlin | 98427a1 | 2020-11-25 18:22:57 +0000 | [diff] [blame] | 116 | src/test/GatherTest.cpp |
| 117 | src/test/GatherTestHelper.hpp |
Matthew Sloyan | c8eb955 | 2020-11-26 10:54:22 +0000 | [diff] [blame] | 118 | src/test/LogicalTest.cpp |
| 119 | src/test/LogicalTestHelper.hpp |
Narumol Prangnawarat | 50c87d3 | 2020-11-09 18:42:11 +0000 | [diff] [blame] | 120 | src/test/Pooling2dTest.cpp |
| 121 | src/test/Pooling2dTestHelper.hpp |
Matthew Sloyan | 0d35a93 | 2020-11-09 12:25:05 +0000 | [diff] [blame] | 122 | src/test/QuantizationTest.cpp |
Jan Eilers | e339bf6 | 2020-11-10 18:43:23 +0000 | [diff] [blame] | 123 | src/test/QuantizationTestHelper.hpp |
David Monahan | 1670b0c | 2020-11-18 14:40:27 +0000 | [diff] [blame] | 124 | src/test/RedefineTestHelper.hpp |
| 125 | src/test/ReshapeTest.cpp |
Jan Eilers | e339bf6 | 2020-11-10 18:43:23 +0000 | [diff] [blame] | 126 | src/test/ResizeTest.cpp |
| 127 | src/test/ResizeTestHelper.hpp |
James Ward | a857810 | 2020-11-13 18:05:04 +0000 | [diff] [blame] | 128 | src/test/SoftmaxTest.cpp |
| 129 | src/test/SoftmaxTestHelper.hpp |
Sadik Armagan | 34fa1bd | 2020-11-27 12:40:52 +0000 | [diff] [blame] | 130 | src/test/SplitTest.cpp |
| 131 | src/test/SplitTestHelper.hpp |
James Ward | a857810 | 2020-11-13 18:05:04 +0000 | [diff] [blame] | 132 | src/test/TestUtils.hpp |
Jan Eilers | 3812fbc | 2020-11-17 19:06:35 +0000 | [diff] [blame] | 133 | src/test/TestUtils.cpp |
James Ward | f89964e | 2020-11-09 11:57:47 +0000 | [diff] [blame] | 134 | src/test/TransposeTest.cpp |
James Ward | a857810 | 2020-11-13 18:05:04 +0000 | [diff] [blame] | 135 | src/test/TransposeTestHelper.hpp) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 136 | |
Sadik Armagan | 4189cc5 | 2020-11-11 18:01:48 +0000 | [diff] [blame] | 137 | add_executable(DelegateUnitTests ${armnnDelegate_unittest_sources}) |
| 138 | target_include_directories(DelegateUnitTests PRIVATE third-party) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 139 | |
Sadik Armagan | 4189cc5 | 2020-11-11 18:01:48 +0000 | [diff] [blame] | 140 | # Add half library from armnn third-party libraries |
| 141 | target_include_directories(DelegateUnitTests PRIVATE ${ARMNN_SOURCE_DIR}/third-party) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 142 | |
Finn Williams | bbbefec | 2020-11-25 14:32:42 +0000 | [diff] [blame] | 143 | target_link_libraries(DelegateUnitTests PRIVATE armnnDelegate) |
| 144 | target_link_libraries(DelegateUnitTests PRIVATE Armnn::armnnUtils) |
Sadik Armagan | 4189cc5 | 2020-11-11 18:01:48 +0000 | [diff] [blame] | 145 | |
Finn Williams | bbbefec | 2020-11-25 14:32:42 +0000 | [diff] [blame] | 146 | target_link_libraries(DelegateUnitTests PRIVATE tflite_headers) |
| 147 | target_link_libraries(DelegateUnitTests PRIVATE flatbuffer_headers) |
Finn Williams | 6f9f990 | 2020-11-13 13:23:15 +0000 | [diff] [blame] | 148 | |
Sadik Armagan | 4189cc5 | 2020-11-11 18:01:48 +0000 | [diff] [blame] | 149 | endif() |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 150 | |
| 151 | #################################################### |
| 152 | ## Export targets |
| 153 | set(armnn_delegate_export_targets) |
| 154 | list(APPEND armnn_delegate_export_targets |
Finn Williams | 6f9f990 | 2020-11-13 13:23:15 +0000 | [diff] [blame] | 155 | armnnDelegate |
| 156 | tflite_headers |
| 157 | flatbuffer_headers) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 158 | |
| 159 | install( |
| 160 | TARGETS ${armnn_delegate_export_targets} |
| 161 | EXPORT armnn-delegate-targets |
| 162 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 163 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 164 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 165 | |
| 166 | ## Set export alias |
| 167 | set_target_properties(armnnDelegate |
| 168 | PROPERTIES |
| 169 | EXPORT_NAME ArmnnDelegate) |
| 170 | |
| 171 | ## Export target scrips |
| 172 | install( |
| 173 | EXPORT armnn-delegate-targets |
| 174 | FILE ArmnnDelegateTargets.cmake |
| 175 | NAMESPACE ArmnnDelegate:: |
| 176 | DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
| 177 | |
| 178 | ## Create ArmnnDelegateConfig.cmake |
| 179 | include(CMakePackageConfigHelpers) |
| 180 | set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}) |
| 181 | message(STATUS "CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}" ) |
| 182 | message(STATUS "CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}" ) |
Finn Williams | bbbefec | 2020-11-25 14:32:42 +0000 | [diff] [blame] | 183 | SET(Armnn_DIR "${Armnn_DIR}") |
| 184 | |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 185 | configure_package_config_file( |
| 186 | ${CMAKE_CURRENT_LIST_DIR}/cmake/Modules/ArmnnDelegateConfig.cmake.in |
| 187 | ${CMAKE_CURRENT_BINARY_DIR}/ArmnnDelegateConfig.cmake |
Finn Williams | bbbefec | 2020-11-25 14:32:42 +0000 | [diff] [blame] | 188 | INSTALL_DESTINATION ${INSTALL_CONFIGDIR} |
| 189 | PATH_VARS Armnn_DIR) |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 190 | |
| 191 | ## Install ArmNN Delegate config file |
| 192 | install( |
| 193 | FILES |
| 194 | ${CMAKE_CURRENT_BINARY_DIR}/ArmnnDelegateConfig.cmake |
| 195 | DESTINATION ${INSTALL_CONFIGDIR}) |
| 196 | |
| 197 | ## Export from build tree |
| 198 | export( |
| 199 | EXPORT armnn-delegate-targets |
| 200 | FILE ${CMAKE_CURRENT_BINARY_DIR}/ArmnnDelegateTargets.cmake |
| 201 | NAMESPACE ArmnnDelegate::) |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 202 | add_library(ArmnnDelegate::ArmnnDelegate ALIAS armnnDelegate) |
| 203 | |
Sadik Armagan | 3c24f43 | 2020-10-19 17:35:30 +0100 | [diff] [blame] | 204 | |
Narumol Prangnawarat | 50c87d3 | 2020-11-09 18:42:11 +0000 | [diff] [blame] | 205 | #################################################### |