aboutsummaryrefslogtreecommitdiff
path: root/delegate/CMakeLists.txt
diff options
context:
space:
mode:
authorTeresa Charlin <teresa.charlinreyes@arm.com>2023-03-14 12:10:28 +0000
committerTeresa Charlin <teresa.charlinreyes@arm.com>2023-03-28 11:41:55 +0100
commitad1b3d7518429e2d16a2695d9b0bbf81b6565ac9 (patch)
treea5b8e1ad68a2437f007338f0b6195ca5ed2bddc3 /delegate/CMakeLists.txt
parent9cb3466b677a1048b8abb24661e92c4c83fdda04 (diff)
downloadarmnn-ad1b3d7518429e2d16a2695d9b0bbf81b6565ac9.tar.gz
IVGCVSW-7555 Restructure Delegate
* New folders created: * common is for common code where TfLite API is not used * classic is for existing delegate implementations * opaque is for new opaque delegate implementation, * tests is for shared between existing Delegate and Opaque Delegate which have test utils to work which delegate to use. * Existing delegate is built to libarmnnDelegate.so and opaque delegate is built as libarmnnOpaqueDelegate.so * Opaque structure is introduced but no API is added yet. * CmakeList.txt and delegate/CMakeList.txt have been modified and 2 new CmakeList.txt added * Rename BUILD_ARMNN_TFLITE_DELEGATE as BUILD_CLASSIC_DELEGATE * Rename BUILD_ARMNN_TFLITE_OPAQUE_DELEGATE as BUILD_OPAQUE_DELEGATE Signed-off-by: Teresa Charlin <teresa.charlinreyes@arm.com> Change-Id: Ib682b9ad0ac8d8acdc4ec6d9099bb0008a9fe8ed
Diffstat (limited to 'delegate/CMakeLists.txt')
-rw-r--r--delegate/CMakeLists.txt356
1 files changed, 171 insertions, 185 deletions
diff --git a/delegate/CMakeLists.txt b/delegate/CMakeLists.txt
index 55bdb7ca53..f6a5e512fa 100644
--- a/delegate/CMakeLists.txt
+++ b/delegate/CMakeLists.txt
@@ -7,112 +7,86 @@ cmake_minimum_required (VERSION 3.7.0)
project(armnnDelegate)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall -Wextra -Werror -Wold-style-cast -Wno-missing-braces -Wconversion -Wsign-conversion -Wno-comment")
-
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules/")
+option(BUILD_UNIT_TESTS "Build unit tests" ON)
+option(BUILD_CLASSIC_DELEGATE "Build classic delegate" ON)
+option(BUILD_OPAQUE_DELEGATE "Build opaque delegate" OFF)
+option(BUILD_SHARED_LIBS "Build share libs" ON)
+option(BUILD_DELEGATE_JNI_INTERFACE "Builds a library to allow accessing the Arm NN delegate from Java code.
+ This is an experimental feature." ON)
+
set(armnnDelegate_sources)
list(APPEND armnnDelegate_sources
- include/armnn_delegate.hpp
- include/DelegateOptions.hpp
- include/Version.hpp
- src/armnn_delegate.cpp
- src/armnn_external_delegate.cpp
- src/DelegateOptions.cpp
- src/Activation.hpp
- src/ArgMinMax.hpp
- src/BatchMatMul.hpp
- src/BatchSpace.hpp
- src/Comparison.hpp
- src/Convolution.hpp
- src/Control.hpp
- src/DelegateUtils.hpp
- src/ElementwiseBinary.hpp
- src/ElementwiseUnary.hpp
- src/Fill.hpp
- src/FullyConnected.hpp
- src/Gather.hpp
- src/GatherNd.hpp
- src/LogicalBinary.hpp
- src/Lstm.hpp
- src/MultiLayerFacade.hpp
- src/Normalization.hpp
- src/Pack.hpp
- src/Pad.hpp
- src/Pooling.hpp
- src/Prelu.hpp
- src/Quantization.hpp
- src/Redefine.hpp
- src/Reduce.hpp
- src/Resize.hpp
- src/Round.hpp
- src/Shape.hpp
- src/SharedFunctions.hpp
- src/SharedFunctions.cpp
- src/Slice.hpp
- src/Softmax.hpp
- src/SpaceDepth.hpp
- src/Split.hpp
- src/Unpack.hpp
- src/Transpose.hpp)
-
-add_library(armnnDelegate ${armnnDelegate_sources})
-
-target_include_directories(armnnDelegate
- PUBLIC
- $<INSTALL_INTERFACE:include>
- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
- PRIVATE
- ${CMAKE_CURRENT_SOURCE_DIR}/src)
-
-include(GNUInstallDirs)
+ common/include/DelegateOptions.hpp
+ common/src/DelegateOptions.cpp
+ common/src/DelegateUtils.hpp)
## Add Armnn as a Dependency
if(NOT ARMNN_SUB_PROJECT)
find_package(Armnn REQUIRED CONFIG HINTS ${Armnn_DIR})
endif()
-target_link_libraries(armnnDelegate PUBLIC Armnn::Armnn)
-## Add TfLite dependency
-find_package(TfLiteSrc REQUIRED MODULE)
-find_package(TfLite REQUIRED MODULE)
-
-target_link_libraries(armnnDelegate PUBLIC ${TfLite_LIB})
+if (BUILD_CLASSIC_DELEGATE)
+ add_subdirectory(classic)
+ add_library(armnnDelegate ${armnnDelegate_sources})
-# lpthread and ldl are not required for Android
-if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL Android)
- target_link_libraries(armnnDelegate PUBLIC -lpthread)
- target_link_libraries(armnnDelegate PUBLIC -ldl)
+ target_include_directories(armnnDelegate
+ PUBLIC
+ $<INSTALL_INTERFACE:include>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/common/include>
+ PRIVATE
+ ${CMAKE_CURRENT_SOURCE_DIR}/common/src)
+endif()
+if (BUILD_OPAQUE_DELEGATE)
+ add_subdirectory(opaque)
+ add_library(armnnOpaqueDelegate ${armnnDelegate_sources})
+
+ target_include_directories(armnnOpaqueDelegate
+ PUBLIC
+ $<INSTALL_INTERFACE:include>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/common/include>
+ PRIVATE
+ ${CMAKE_CURRENT_SOURCE_DIR}/common/src)
endif()
-# Various tflite header files are not warning clean
-# We can't change compilation flags on header files directly, so we need to add them to an interface library first
-add_library(tflite_headers INTERFACE)
-target_include_directories(tflite_headers INTERFACE $<BUILD_INTERFACE:${TfLite_INCLUDE_DIR}>
- $<INSTALL_INTERFACE:include/tflite_headers>)
-
-target_compile_options(tflite_headers INTERFACE -Wno-conversion
- -Wno-sign-conversion
- -Wno-unused-parameter
- -Wno-unused-function)
-
-target_link_libraries(armnnDelegate PUBLIC tflite_headers)
+include(GNUInstallDirs)
-## Add Flatbuffers dependency
-find_package(Flatbuffers REQUIRED MODULE)
+if (BUILD_CLASSIC_DELEGATE)
+ target_link_libraries(armnnDelegate PUBLIC Armnn::Armnn)
-target_link_libraries(armnnDelegate PRIVATE
- ${Flatbuffers_LIB})
+ ## Add armnnClassicDelegateObject as a Dependency
+ target_link_libraries(armnnDelegate PUBLIC armnnClassicDelegateObject)
+endif()
+if (BUILD_OPAQUE_DELEGATE)
+ target_link_libraries(armnnOpaqueDelegate PUBLIC Armnn::Armnn)
-# include/flatbuffers/flatbuffers.h is not warning clean
-# We can't change compilation flags on header files directly, so we need to add them to an interface library first
-add_library(flatbuffer_headers INTERFACE)
-target_include_directories(flatbuffer_headers INTERFACE $<BUILD_INTERFACE:${Flatbuffers_INCLUDE_DIR}>
- $<INSTALL_INTERFACE:include/flatbuffer_headers>)
-target_compile_options(flatbuffer_headers INTERFACE -Wno-sign-conversion)
+ ## Add armnnOpaqueDelegateObject as a Dependency
+ target_link_libraries(armnnOpaqueDelegate PUBLIC armnnOpaqueDelegateObject)
+endif()
-target_link_libraries(armnnDelegate PUBLIC flatbuffer_headers)
+## Add TfLite dependency
+find_package(TfLiteSrc REQUIRED MODULE)
+find_package(TfLite REQUIRED MODULE)
+if (BUILD_CLASSIC_DELEGATE)
+ target_link_libraries(armnnDelegate PUBLIC ${TfLite_LIB})
+
+ # lpthread and ldl are not required for Android
+ if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL Android)
+ target_link_libraries(armnnDelegate PUBLIC -lpthread)
+ target_link_libraries(armnnDelegate PUBLIC -ldl)
+ endif()
+endif()
+if (BUILD_OPAQUE_DELEGATE)
+ target_link_libraries(armnnOpaqueDelegate PUBLIC ${TfLite_LIB})
+
+ # lpthread and ldl are not required for Android
+ if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL Android)
+ target_link_libraries(armnnOpaqueDelegate PUBLIC -lpthread)
+ target_link_libraries(armnnOpaqueDelegate PUBLIC -ldl)
+ endif()
+endif()
# Add libraries from armnn third-party libraries
# Third-party header files are not warning clean
@@ -122,100 +96,113 @@ target_include_directories(thirdparty_headers INTERFACE $<BUILD_INTERFACE:${ARMN
$<INSTALL_INTERFACE:include/thirdparty_headers>)
target_compile_options(thirdparty_headers INTERFACE -Wno-old-style-cast)
-target_link_libraries(armnnDelegate PUBLIC thirdparty_headers)
+if (BUILD_CLASSIC_DELEGATE)
+ target_link_libraries(armnnDelegate PUBLIC thirdparty_headers)
+endif()
+if (BUILD_OPAQUE_DELEGATE)
+ target_link_libraries(armnnOpaqueDelegate PUBLIC thirdparty_headers)
+endif()
add_library(profiling_library_headers INTERFACE)
target_include_directories(profiling_library_headers INTERFACE $<BUILD_INTERFACE:${ARMNN_SOURCE_DIR}/profiling>
$<INSTALL_INTERFACE:include/profiling_library_headers>)
-target_link_libraries(armnnDelegate PUBLIC profiling_library_headers)
-target_link_libraries(armnnDelegate PUBLIC Armnn::armnnUtils)
-set_target_properties(armnnDelegate PROPERTIES VERSION ${DELEGATE_LIB_VERSION} SOVERSION ${DELEGATE_LIB_SOVERSION})
+if (BUILD_CLASSIC_DELEGATE)
+ target_link_libraries(armnnDelegate PUBLIC profiling_library_headers)
+ target_link_libraries(armnnDelegate PUBLIC Armnn::armnnUtils)
+
+ set_target_properties(armnnDelegate PROPERTIES VERSION ${DELEGATE_LIB_VERSION} SOVERSION ${DELEGATE_LIB_SOVERSION})
+endif()
+if (BUILD_OPAQUE_DELEGATE)
+ target_link_libraries(armnnOpaqueDelegate PUBLIC profiling_library_headers)
+ target_link_libraries(armnnOpaqueDelegate PUBLIC Armnn::armnnUtils)
+
+ set_target_properties(armnnOpaqueDelegate PROPERTIES VERSION ${OPAQUE_DELEGATE_LIB_VERSION} SOVERSION ${OPAQUE_DELEGATE_LIB_SOVERSION})
+endif()
-option(BUILD_UNIT_TESTS "Build unit tests" ON)
if(BUILD_UNIT_TESTS)
set(armnnDelegate_unittest_sources)
list(APPEND armnnDelegate_unittest_sources
- src/test/ActivationTest.cpp
- src/test/ActivationTestHelper.hpp
- src/test/ArgMinMaxTest.cpp
- src/test/ArgMinMaxTestHelper.hpp
- src/test/ArmnnDelegateTest.cpp
- src/test/BatchMatMulTest.cpp
- src/test/BatchMatMulTestHelper.hpp
- src/test/BatchSpaceTest.cpp
- src/test/BatchSpaceTestHelper.hpp
- src/test/CastTest.cpp
- src/test/CastTestHelper.hpp
- src/test/ComparisonTest.cpp
- src/test/ComparisonTestHelper.hpp
- src/test/ControlTest.cpp
- src/test/ControlTestHelper.hpp
- src/test/Convolution2dTest.cpp
- src/test/Convolution3dTest.cpp
- src/test/ConvolutionTestHelper.hpp
- src/test/DelegateOptionsTest.cpp
- src/test/DelegateOptionsTestHelper.hpp
- src/test/DepthwiseConvolution2dTest.cpp
- src/test/ElementwiseBinaryTest.cpp
- src/test/ElementwiseBinaryTestHelper.hpp
- src/test/ElementwiseUnaryTest.cpp
- src/test/ElementwiseUnaryTestHelper.hpp
- src/test/FillTest.cpp
- src/test/FillTestHelper.hpp
- src/test/FullyConnectedTest.cpp
- src/test/FullyConnectedTestHelper.hpp
- src/test/GatherTest.cpp
- src/test/GatherTestHelper.hpp
- src/test/GatherNdTest.cpp
- src/test/GatherNdTestHelper.hpp
- src/test/LogicalTest.cpp
- src/test/LogicalTestHelper.hpp
- src/test/LstmTest.cpp
- src/test/LstmTestHelper.hpp
- src/test/MirrorPadTest.cpp
- src/test/NormalizationTest.cpp
- src/test/NormalizationTestHelper.hpp
- src/test/PackTest.cpp
- src/test/PackTestHelper.hpp
- src/test/PadTest.cpp
- src/test/PadTestHelper.hpp
- src/test/Pooling2dTest.cpp
- src/test/Pooling2dTestHelper.hpp
- src/test/Pooling3dTest.cpp
- src/test/Pooling3dTestHelper.hpp
- src/test/PreluTest.cpp
- src/test/PreluTestHelper.hpp
- src/test/QuantizationTest.cpp
- src/test/QuantizationTestHelper.hpp
- src/test/RedefineTestHelper.hpp
- src/test/ReduceTest.cpp
- src/test/ReduceTestHelper.hpp
- src/test/ReshapeTest.cpp
- src/test/ResizeTest.cpp
- src/test/ResizeTestHelper.hpp
- src/test/RoundTest.cpp
- src/test/RoundTestHelper.hpp
- src/test/SoftmaxTest.cpp
- src/test/SoftmaxTestHelper.hpp
- src/test/SpaceDepthTest.cpp
- src/test/SpaceDepthTestHelper.hpp
- src/test/ShapeTest.cpp
- src/test/ShapeTestHelper.hpp
- src/test/SliceTest.cpp
- src/test/SliceTestHelper.hpp
- src/test/StridedSliceTest.cpp
- src/test/StridedSliceTestHelper.hpp
- src/test/SplitTest.cpp
- src/test/SplitTestHelper.hpp
- src/test/TestUtils.hpp
- src/test/TestUtils.cpp
- src/test/TransposeTest.cpp
- src/test/TransposeTestHelper.hpp
- src/test/UnidirectionalSequenceLstmTest.cpp
- src/test/UnidirectionalSequenceLstmTestHelper.hpp
- src/test/UnpackTest.cpp
- src/test/UnpackTestHelper.hpp)
+ test/ActivationTest.cpp
+ test/ActivationTestHelper.hpp
+ test/ArgMinMaxTest.cpp
+ test/ArgMinMaxTestHelper.hpp
+ test/ArmnnDelegateTest.cpp
+ test/BatchMatMulTest.cpp
+ test/BatchMatMulTestHelper.hpp
+ test/BatchSpaceTest.cpp
+ test/BatchSpaceTestHelper.hpp
+ test/CastTest.cpp
+ test/CastTestHelper.hpp
+ test/ComparisonTest.cpp
+ test/ComparisonTestHelper.hpp
+ test/ControlTest.cpp
+ test/ControlTestHelper.hpp
+ test/Convolution2dTest.cpp
+ test/Convolution3dTest.cpp
+ test/ConvolutionTestHelper.hpp
+ test/DelegateOptionsTest.cpp
+ test/DelegateOptionsTestHelper.hpp
+ test/DepthwiseConvolution2dTest.cpp
+ test/ElementwiseBinaryTest.cpp
+ test/ElementwiseBinaryTestHelper.hpp
+ test/ElementwiseUnaryTest.cpp
+ test/ElementwiseUnaryTestHelper.hpp
+ test/FillTest.cpp
+ test/FillTestHelper.hpp
+ test/FullyConnectedTest.cpp
+ test/FullyConnectedTestHelper.hpp
+ test/GatherTest.cpp
+ test/GatherTestHelper.hpp
+ test/GatherNdTest.cpp
+ test/GatherNdTestHelper.hpp
+ test/LogicalTest.cpp
+ test/LogicalTestHelper.hpp
+ test/LstmTest.cpp
+ test/LstmTestHelper.hpp
+ test/MirrorPadTest.cpp
+ test/NormalizationTest.cpp
+ test/NormalizationTestHelper.hpp
+ test/PackTest.cpp
+ test/PackTestHelper.hpp
+ test/PadTest.cpp
+ test/PadTestHelper.hpp
+ test/Pooling2dTest.cpp
+ test/Pooling2dTestHelper.hpp
+ test/Pooling3dTest.cpp
+ test/Pooling3dTestHelper.hpp
+ test/PreluTest.cpp
+ test/PreluTestHelper.hpp
+ test/QuantizationTest.cpp
+ test/QuantizationTestHelper.hpp
+ test/RedefineTestHelper.hpp
+ test/ReduceTest.cpp
+ test/ReduceTestHelper.hpp
+ test/ReshapeTest.cpp
+ test/ResizeTest.cpp
+ test/ResizeTestHelper.hpp
+ test/RoundTest.cpp
+ test/RoundTestHelper.hpp
+ test/SoftmaxTest.cpp
+ test/SoftmaxTestHelper.hpp
+ test/SpaceDepthTest.cpp
+ test/SpaceDepthTestHelper.hpp
+ test/ShapeTest.cpp
+ test/ShapeTestHelper.hpp
+ test/SliceTest.cpp
+ test/SliceTestHelper.hpp
+ test/StridedSliceTest.cpp
+ test/StridedSliceTestHelper.hpp
+ test/SplitTest.cpp
+ test/SplitTestHelper.hpp
+ test/TestUtils.hpp
+ test/TestUtils.cpp
+ test/TransposeTest.cpp
+ test/TransposeTestHelper.hpp
+ test/UnidirectionalSequenceLstmTest.cpp
+ test/UnidirectionalSequenceLstmTestHelper.hpp
+ test/UnpackTest.cpp
+ test/UnpackTestHelper.hpp)
# There's a known Android NDK bug which causes a subset of NeonLayerTests to
# fail. We'll exclude these tests in NeonLayerTests_NDK_Bug.cpp if we're doing
@@ -241,28 +228,26 @@ if(BUILD_UNIT_TESTS)
if ( INCLUDE_NDK_BUG_TESTS STREQUAL "ON" )
list(APPEND armnnDelegate_unittest_sources
- src/test/NeonDelegateTests_NDK_Issue.cpp
+ test/NeonDelegateTests_NDK_Issue.cpp
)
else()
endif()
+ if (BUILD_CLASSIC_DELEGATE) # For Opaque Delegate Unit Tests add OR BUILD_ARMNN_TFLITE_OPAQUE_DELEGATE here
+ add_executable(DelegateUnitTests ${armnnDelegate_unittest_sources})
- add_executable(DelegateUnitTests ${armnnDelegate_unittest_sources})
+ target_include_directories(DelegateUnitTests SYSTEM PRIVATE "${TF_LITE_SCHEMA_INCLUDE_PATH}")
- # Add half library from armnn third-party libraries
- target_link_libraries(DelegateUnitTests PRIVATE thirdparty_headers)
+ # Add half library from armnn third-party libraries
+ target_link_libraries(DelegateUnitTests PRIVATE thirdparty_headers)
- target_link_libraries(DelegateUnitTests PRIVATE armnnDelegate)
- target_link_libraries(DelegateUnitTests PRIVATE Armnn::armnnUtils)
-
- target_link_libraries(DelegateUnitTests PRIVATE tflite_headers)
- target_link_libraries(DelegateUnitTests PRIVATE flatbuffer_headers)
- target_link_libraries(DelegateUnitTests PRIVATE profiling_library_headers)
+ target_link_libraries(DelegateUnitTests PRIVATE armnnDelegate)
+ target_link_libraries(DelegateUnitTests PRIVATE Armnn::armnnUtils)
+ target_link_libraries(DelegateUnitTests PRIVATE profiling_library_headers)
+ endif()
endif()
-option(BUILD_DELEGATE_JNI_INTERFACE "Builds a library to allow accessing the Arm NN delegate from Java code.
- This is an experimental feature." Off)
if(BUILD_DELEGATE_JNI_INTERFACE)
add_subdirectory(armnnDelegateJNI)
endif()
@@ -271,6 +256,7 @@ endif()
## Export targets
set(armnn_delegate_export_targets)
list(APPEND armnn_delegate_export_targets
+ armnnClassicDelegateObject
armnnDelegate
tflite_headers
flatbuffer_headers