From a3dc95ec2b0ac9e7f87dd32d03679a4b2a9b5d2a Mon Sep 17 00:00:00 2001 From: Ryan OShea Date: Mon, 20 Mar 2023 11:10:40 +0000 Subject: Improve reusability of code that is defined out by cmake build paths * Added new ARMNN_STUB_PROFILING and ARMNN_DISABLE_DYNAMIC_BACKEND defines to replace BUILD_BARE_METAL and BUILD_EXECUTE_NETWORK_STATIC * Add new CMake variables to disable sample apps and dynamic backends * Improve BUILD_SHARED_LIBS CMake variable * Add new archive output location to various libraries so that the static libraries appear in the same location as the shared libraries * Fixes for bare metal build * Add ARMNN_DISABLE_FILE_SYSTEM defines to missing locations Signed-off-by: Ryan OShea Change-Id: I1db9a8f483e7134bd261294b35240cf21b150d45 --- CMakeLists.txt | 19 ++++--- cmake/GlobalConfig.cmake | 31 +++++++---- profiling/client/src/ProfilingService.cpp | 62 +++++++++++----------- profiling/server/src/basePipeServer/CMakeLists.txt | 2 + .../server/src/timelineDecoder/CMakeLists.txt | 2 + samples/CMakeLists.txt | 2 +- src/armnn/Network.cpp | 2 + src/armnn/Runtime.cpp | 10 ++-- src/armnnDeserializer/CMakeLists.txt | 7 ++- src/armnnSerializer/CMakeLists.txt | 26 ++++----- src/armnnTestUtils/CMakeLists.txt | 13 ++--- src/armnnTfLiteParser/CMakeLists.txt | 8 +-- src/backends/backends.cmake | 17 +++--- src/backends/backendsCommon/CMakeLists.txt | 2 +- src/backends/dynamic/reference/CMakeLists.txt | 4 -- src/backends/reference/workloads/Debug.cpp | 2 + src/timelineDecoder/CMakeLists.txt | 1 + 17 files changed, 115 insertions(+), 95 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index edb1485126..a20543b9ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,12 +56,15 @@ include(GNUInstallDirs) add_subdirectory(profiling/common/src) add_subdirectory(profiling/client/src) - -add_subdirectory(samples) +if(ARMNN_SAMPLE_APPS_ENABLED) + add_subdirectory(samples) +endif() add_subdirectory(src/armnnTfLiteParser) add_subdirectory(src/armnnSerializer) add_subdirectory(src/armnnDeserializer) -add_subdirectory(src/armnnTestUtils) +if(BUILD_UNIT_TESTS) + add_subdirectory(src/armnnTestUtils) +endif() if (BUILD_TESTS) add_subdirectory(tests) @@ -456,14 +459,10 @@ if (BUILD_OPAQUE_DELEGATE) add_definitions(-DARMNN_TFLITE_OPAQUE_DELEGATE) endif() -if(BUILD_BARE_METAL OR EXECUTE_NETWORK_STATIC) - add_library_ex(armnn STATIC ${armnn_sources}) +if (BUILD_SHARED_LIBS) + add_library_ex(armnn SHARED ${armnn_sources}) else() - if (BUILD_SHARED_LIBS) - add_library_ex(armnn SHARED ${armnn_sources}) - else() - add_library(armnn ${armnn_sources}) - endif() + add_library(armnn STATIC ${armnn_sources}) endif() target_compile_definitions(armnn PRIVATE "ARMNN_COMPILING_DLL") diff --git a/cmake/GlobalConfig.cmake b/cmake/GlobalConfig.cmake index 3337f41cbf..2d97899ce8 100644 --- a/cmake/GlobalConfig.cmake +++ b/cmake/GlobalConfig.cmake @@ -7,6 +7,7 @@ option(BUILD_ONNX_PARSER "Build Onnx parser" OFF) option(BUILD_UNIT_TESTS "Build unit tests" ON) option(BUILD_TESTS "Build test applications" OFF) +option(ARMNN_SAMPLE_APPS_ENABLED "Build Sample ArmNN Applications" ON) option(BUILD_FOR_COVERAGE "Use no optimization and output .gcno and .gcda files" OFF) option(ARMCOMPUTENEON "Build with ARM Compute NEON support" OFF) option(ARMCOMPUTECL "Build with ARM Compute OpenCL support" OFF) @@ -56,7 +57,11 @@ option(EXECUTE_NETWORK_STATIC " This is a limited experimental build that is ent BUILD_TIMELINE_DECODER=0 BUILD_BASE_PIPE_SERVER=0 BUILD_UNIT_TESTS=0 - BUILD_GATORD_MOCK=0" OFF) + ARMNN_SAMPLE_APPS_ENABLED=0 + BUILD_SHARED_LIBS=0 + BUILD_GATORD_MOCK=0 + HEAP_PROFILING=0 + LEAK_CHECKING=0" OFF) if(BUILD_ARMNN_TFLITE_DELEGATE) message(BUILD_ARMNN_TFLITE_DELEGATE option is deprecated, it will be removed in 24.02, please use BUILD_CLASSIC_DELEGATE instead) @@ -160,16 +165,23 @@ include(CMakeFindDependencyMacro) if(EXECUTE_NETWORK_STATIC) add_definitions(-DARMNN_DISABLE_SOCKETS - -DBUILD_SHARED_LIBS=0 - -DARMNN_EXECUTE_NETWORK_STATIC) + -DARMNN_STUB_PROFILING + -DARMNN_DISABLE_DYNAMIC_BACKENDS) + set(ARMNN_SAMPLE_APPS_ENABLED 0) + set(DISABLE_DYNAMIC_BACKENDS 1) + set(BUILD_SHARED_LIBS 0) endif() if(BUILD_BARE_METAL) add_definitions(-DARMNN_BUILD_BARE_METAL - -DARMNN_DISABLE_FILESYSTEM - -DARMNN_DISABLE_PROCESSES - -DARMNN_DISABLE_THREADS - -DARMNN_DISABLE_SOCKETS) + -DARMNN_DISABLE_FILESYSTEM + -DARMNN_DISABLE_PROCESSES + -DARMNN_DISABLE_THREADS + -DARMNN_DISABLE_SOCKETS + -DARMNN_STUB_PROFILING + -DARMNN_DISABLE_DYNAMIC_BACKENDS) + set(DISABLE_DYNAMIC_BACKENDS 1) + set(BUILD_SHARED_LIBS 0) endif() if (NOT BUILD_PIPE_ONLY) @@ -452,7 +464,6 @@ if(PROFILING_BACKEND_STREAMLINE) add_definitions(-DARMNN_STREAMLINE_ENABLED) endif() -if(NOT BUILD_BARE_METAL AND NOT EXECUTE_NETWORK_STATIC) if(HEAP_PROFILING OR LEAK_CHECKING) find_path(HEAP_PROFILER_INCLUDE gperftools/heap-profiler.h PATHS ${GPERFTOOLS_ROOT}/include @@ -472,8 +483,8 @@ if(HEAP_PROFILING OR LEAK_CHECKING) endif() else() # Valgrind only works with gperftools version number <= 2.4 - CHECK_INCLUDE_FILE(valgrind/memcheck.h VALGRIND_FOUND) -endif() + include(CheckIncludeFiles) + CHECK_INCLUDE_FILES("valgrind/memcheck.h" VALGRIND_FOUND) endif() if(NOT BUILD_TF_LITE_PARSER) diff --git a/profiling/client/src/ProfilingService.cpp b/profiling/client/src/ProfilingService.cpp index 37f0de9f6f..8dbe12ce69 100644 --- a/profiling/client/src/ProfilingService.cpp +++ b/profiling/client/src/ProfilingService.cpp @@ -10,7 +10,7 @@ #include #include -#if defined(ARMNN_BUILD_BARE_METAL) || defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if defined(ARMNN_STUB_PROFILING) #include #endif @@ -26,7 +26,7 @@ namespace pipe void ProfilingService::ResetExternalProfilingOptions(const arm::pipe::ProfilingOptions& options, bool resetProfilingService) { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) // Update the profiling options m_Options = options; m_TimelineReporting = options.m_TimelineEnabled; @@ -41,23 +41,23 @@ void ProfilingService::ResetExternalProfilingOptions(const arm::pipe::ProfilingO #else IgnoreUnused(options); IgnoreUnused(resetProfilingService); -#endif // ARMNN_BUILD_BARE_METAL || ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } bool ProfilingService::IsProfilingEnabled() const { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) return m_Options.m_EnableProfiling; #else return false; -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } ProfilingState ProfilingService::ConfigureProfilingService( const ProfilingOptions& options, bool resetProfilingService) { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) ResetExternalProfilingOptions(options, resetProfilingService); ProfilingState currentState = m_StateMachine.GetCurrentState(); if (options.m_EnableProfiling) @@ -106,12 +106,12 @@ ProfilingState ProfilingService::ConfigureProfilingService( IgnoreUnused(options); IgnoreUnused(resetProfilingService); return ProfilingState::Uninitialised; -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } void ProfilingService::Update() { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) if (!m_Options.m_EnableProfiling) { // Don't run if profiling is disabled @@ -189,12 +189,12 @@ void ProfilingService::Update() throw arm::pipe::ProfilingException(fmt::format("Unknown profiling service state: {}", static_cast(currentState))); } -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } void ProfilingService::Disconnect() { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) ProfilingState currentState = m_StateMachine.GetCurrentState(); switch (currentState) { @@ -211,7 +211,7 @@ void ProfilingService::Disconnect() throw arm::pipe::ProfilingException(fmt::format("Unknown profiling service state: {}", static_cast(currentState))); } -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } // Store a profiling context returned from a backend that support profiling, and register its counters @@ -219,7 +219,7 @@ void ProfilingService::AddBackendProfilingContext( const std::string& backendId, std::shared_ptr profilingContext) { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) ARM_PIPE_ASSERT(profilingContext != nullptr); // Register the backend counters m_MaxGlobalCounterId = profilingContext->RegisterCounters(m_MaxGlobalCounterId); @@ -227,7 +227,7 @@ void ProfilingService::AddBackendProfilingContext( #else IgnoreUnused(backendId); IgnoreUnused(profilingContext); -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } const ICounterDirectory& ProfilingService::GetCounterDirectory() const { @@ -343,14 +343,14 @@ std::unique_ptr ProfilingService::GetSendTimelinePacket() c void ProfilingService::Initialize() { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) m_Initialiser.InitialiseProfilingService(*this); -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } void ProfilingService::InitializeCounterValue(uint16_t counterUid) { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) // Increase the size of the counter index if necessary if (counterUid >= m_CounterIndex.size()) { @@ -365,12 +365,12 @@ void ProfilingService::InitializeCounterValue(uint16_t counterUid) m_CounterIndex.at(counterUid) = counterValuePtr; #else IgnoreUnused(counterUid); -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } void ProfilingService::Reset() { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) // Stop the profiling service... Stop(); @@ -384,12 +384,12 @@ void ProfilingService::Reset() // ...finally reset the profiling state machine m_StateMachine.Reset(); m_BackendProfilingContexts.clear(); -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } void ProfilingService::Stop() { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) { // only lock when we are updating the inference completed variable std::unique_lock lck(m_ServiceActiveMutex); m_ServiceActive = false; @@ -411,24 +411,24 @@ void ProfilingService::Stop() // ...then move to the "NotConnected" state m_StateMachine.TransitionToState(ProfilingState::NotConnected); -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } inline void ProfilingService::CheckCounterUid(uint16_t counterUid) const { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) if (!IsCounterRegistered(counterUid)) { throw arm::pipe::InvalidArgumentException(fmt::format("Counter UID {} is not registered", counterUid)); } #else IgnoreUnused(counterUid); -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } void ProfilingService::NotifyBackendsForTimelineReporting() { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) BackendProfilingContext::iterator it = m_BackendProfilingContexts.begin(); while (it != m_BackendProfilingContexts.end()) { @@ -437,23 +437,23 @@ void ProfilingService::NotifyBackendsForTimelineReporting() // Increment the Iterator to point to next entry it++; } -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } void ProfilingService::NotifyProfilingServiceActive() { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) { // only lock when we are updating the inference completed variable std::unique_lock lck(m_ServiceActiveMutex); m_ServiceActive = true; } m_ServiceActiveConditionVariable.notify_one(); -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } void ProfilingService::WaitForProfilingServiceActivation(unsigned int timeout) { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) std::unique_lock lck(m_ServiceActiveMutex); auto start = std::chrono::high_resolution_clock::now(); @@ -475,14 +475,14 @@ void ProfilingService::WaitForProfilingServiceActivation(unsigned int timeout) } #else IgnoreUnused(timeout); -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } ProfilingService::~ProfilingService() { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_STUB_PROFILING) Stop(); -#endif // ARMNN_BUILD_BARE_METAL && ARMNN_EXECUTE_NETWORK_STATIC +#endif // ARMNN_STUB_PROFILING } } // namespace pipe diff --git a/profiling/server/src/basePipeServer/CMakeLists.txt b/profiling/server/src/basePipeServer/CMakeLists.txt index b5dc68c2c4..ce957f6a5f 100644 --- a/profiling/server/src/basePipeServer/CMakeLists.txt +++ b/profiling/server/src/basePipeServer/CMakeLists.txt @@ -37,6 +37,8 @@ if(BUILD_BASE_PIPE_SERVER) endif() set_target_properties(armnnBasePipeServer PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) + set_target_properties(armnnBasePipeServer PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) + set_target_properties(armnnBasePipeServer PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION}) diff --git a/profiling/server/src/timelineDecoder/CMakeLists.txt b/profiling/server/src/timelineDecoder/CMakeLists.txt index 4ac68a52af..93513deef2 100644 --- a/profiling/server/src/timelineDecoder/CMakeLists.txt +++ b/profiling/server/src/timelineDecoder/CMakeLists.txt @@ -36,6 +36,8 @@ if(BUILD_TIMELINE_DECODER) endif() set_target_properties(timelineDecoder PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) + set_target_properties(timelineDecoder PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) + set_target_properties(timelineDecoder PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) install(TARGETS timelineDecoder diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index e5ee711627..e1b1a70057 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -2,7 +2,7 @@ # Copyright © 2018-2023 Arm Ltd and Contributors. All rights reserved. # SPDX-License-Identifier: MIT # -if (NOT BUILD_BARE_METAL AND NOT EXECUTE_NETWORK_STATIC) +if (NOT BUILD_BARE_METAL) if(BUILD_SAMPLE_APP AND ARMNNREF) add_executable(SimpleSample SimpleSample.cpp) target_link_libraries(SimpleSample armnn ${CMAKE_THREAD_LIBS_INIT}) diff --git a/src/armnn/Network.cpp b/src/armnn/Network.cpp index a069585216..b768ea888f 100644 --- a/src/armnn/Network.cpp +++ b/src/armnn/Network.cpp @@ -1950,8 +1950,10 @@ IOptimizedNetworkPtr Optimize(const Graph& inGraph, // Setup the output file path try { +#if !defined(ARMNN_DISABLE_FILESYSTEM) auto result = armnnUtils::Filesystem::CreateDirectory("/ArmNNIntermediateLayerOutputs"); ARMNN_LOG(info) << "Intermediate tensors will be written to: " << result; +#endif Optimizer::Pass(optGraph, MakeOptimizations(InsertDebugToFileLayer())); } catch (const armnn::RuntimeException& e) diff --git a/src/armnn/Runtime.cpp b/src/armnn/Runtime.cpp index ff64e856f4..f71fad1f35 100644 --- a/src/armnn/Runtime.cpp +++ b/src/armnn/Runtime.cpp @@ -20,7 +20,7 @@ #include #include -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_DISABLE_DYNAMIC_BACKENDS) #include #endif @@ -337,7 +337,7 @@ RuntimeImpl::RuntimeImpl(const IRuntime::CreationOptions& options) throw RuntimeException( "It is not possible to enable timeline reporting without profiling being enabled"); } -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_DISABLE_DYNAMIC_BACKENDS) // Load any available/compatible dynamic backend before the runtime // goes through the backend registry LoadDynamicBackends(options.m_DynamicBackendsPath); @@ -357,7 +357,7 @@ RuntimeImpl::RuntimeImpl(const IRuntime::CreationOptions& options) if (customAllocatorMapIterator != options.m_CustomAllocatorMap.end() && customAllocatorMapIterator->second == nullptr) { -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_DISABLE_DYNAMIC_BACKENDS) // We need to manually clean up the dynamic backends before throwing an exception. DynamicBackendUtils::DeregisterDynamicBackends(m_DeviceSpec.GetDynamicBackends()); m_DeviceSpec.ClearDynamicBackends(); @@ -584,7 +584,7 @@ RuntimeImpl::~RuntimeImpl() << std::endl; } } -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_DISABLE_DYNAMIC_BACKENDS) // Clear all dynamic backends. DynamicBackendUtils::DeregisterDynamicBackends(m_DeviceSpec.GetDynamicBackends()); m_DeviceSpec.ClearDynamicBackends(); @@ -769,7 +769,7 @@ void RuntimeImpl::RegisterDebugCallback(NetworkId networkId, const DebugCallback loadedNetwork->RegisterDebugCallback(func); } -#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) +#if !defined(ARMNN_DISABLE_DYNAMIC_BACKENDS) void RuntimeImpl::LoadDynamicBackends(const std::string& overrideBackendPath) { // Get the paths where to load the dynamic backends from diff --git a/src/armnnDeserializer/CMakeLists.txt b/src/armnnDeserializer/CMakeLists.txt index 630eb370df..e77235881f 100755 --- a/src/armnnDeserializer/CMakeLists.txt +++ b/src/armnnDeserializer/CMakeLists.txt @@ -29,12 +29,17 @@ if(BUILD_ARMNN_DESERIALIZER) Deserializer.hpp Deserializer.cpp ) - +if(BUILD_SHARED_LIBS) add_library_ex(armnnDeserializer SHARED ${armnn_deserializer_sources}) +else() + add_library_ex(armnnDeserializer STATIC ${armnn_deserializer_sources}) +endif() include_directories(SYSTEM "${FLATBUFFERS_INCLUDE_PATH}") set_target_properties(armnnDeserializer PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) + set_target_properties(armnnDeserializer PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) + target_include_directories(armnnDeserializer PRIVATE ../armnn) target_include_directories(armnnDeserializer PRIVATE ../armnnUtils) target_include_directories(armnnDeserializer PRIVATE ../../generated) diff --git a/src/armnnSerializer/CMakeLists.txt b/src/armnnSerializer/CMakeLists.txt index 01c51e65d7..20faae955e 100755 --- a/src/armnnSerializer/CMakeLists.txt +++ b/src/armnnSerializer/CMakeLists.txt @@ -36,28 +36,30 @@ if(BUILD_ARMNN_SERIALIZER) ../armnnDeserializer/Deserializer.cpp ) - if(BUILD_BARE_METAL OR EXECUTE_NETWORK_STATIC) - add_library_ex(armnnSerializer STATIC ${armnn_serializer_sources}) - else() + include_directories(SYSTEM "${FLATBUFFERS_INCLUDE_PATH}") + + if(BUILD_SHARED_LIBS) # We're going to export both a STATIC library and a SHARED library here. # In some instances it's easier to include the serializer directly into # the target executable or library rather than have yet another .so. add_library(armnnSerializer-static STATIC ${armnn_serializer_sources}) add_library_ex(armnnSerializer SHARED ${armnn_serializer_sources}) - endif() - include_directories(SYSTEM "${FLATBUFFERS_INCLUDE_PATH}") - - set_target_properties(armnnSerializer PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) - target_include_directories(armnnSerializer PRIVATE ../armnn) - target_include_directories(armnnSerializer PRIVATE ../armnnUtils) - target_include_directories(armnnSerializer PRIVATE ../../generated) - if (NOT BARE_METAL AND NOT EXECUTE_NETWORK_STATIC) target_include_directories(armnnSerializer-static PRIVATE ../armnn) target_include_directories(armnnSerializer-static PRIVATE ../armnnUtils) target_include_directories(armnnSerializer-static PRIVATE ../../generated) + + set_target_properties(armnnSerializer PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) + set_target_properties(armnnSerializer-static PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) + else() + add_library_ex(armnnSerializer STATIC ${armnn_serializer_sources}) + set_target_properties(armnnSerializer PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) endif() + target_include_directories(armnnSerializer PRIVATE ../armnn) + target_include_directories(armnnSerializer PRIVATE ../armnnUtils) + target_include_directories(armnnSerializer PRIVATE ../../generated) + list(APPEND armnn_serializer_sources ArmnnSchema_generated.h ) @@ -66,7 +68,7 @@ if(BUILD_ARMNN_SERIALIZER) target_include_directories(armnnSerializer SYSTEM PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(armnnSerializer armnn ${FLATBUFFERS_LIBRARY}) - if (NOT BARE_METAL AND NOT EXECUTE_NETWORK_STATIC) + if (BUILD_SHARED_LIBS) install(TARGETS armnnSerializer-static EXPORT armnn-targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/src/armnnTestUtils/CMakeLists.txt b/src/armnnTestUtils/CMakeLists.txt index a4333cf306..b2f31245b7 100755 --- a/src/armnnTestUtils/CMakeLists.txt +++ b/src/armnnTestUtils/CMakeLists.txt @@ -31,23 +31,20 @@ list(APPEND armnnTestUtils_sources TestUtils.hpp ) -if(NOT BUILD_BARE_METAL AND NOT EXECUTE_NETWORK_STATIC) list(APPEND armnnTestUtils_sources UnitTests.cpp UnitTests.hpp ) -endif() - -if(BUILD_BARE_METAL) - add_library_ex(armnnTestUtils STATIC ${armnnTestUtils_sources}) -elseif(EXECUTE_NETWORK_STATIC) - add_library_ex(armnnTestUtils OBJECT ${armnnTestUtils_sources}) -else() +if(BUILD_SHARED_LIBS) add_library_ex(armnnTestUtils SHARED ${armnnTestUtils_sources}) +else() + add_library_ex(armnnTestUtils STATIC ${armnnTestUtils_sources}) endif() set_target_properties(armnnTestUtils PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) +set_target_properties(armnnTestUtils PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) + target_include_directories(armnnTestUtils PUBLIC diff --git a/src/armnnTfLiteParser/CMakeLists.txt b/src/armnnTfLiteParser/CMakeLists.txt index 6096d1bf8c..782aa1ccee 100755 --- a/src/armnnTfLiteParser/CMakeLists.txt +++ b/src/armnnTfLiteParser/CMakeLists.txt @@ -11,14 +11,15 @@ if(BUILD_TF_LITE_PARSER) TfLiteParser.cpp ) - if(EXECUTE_NETWORK_STATIC) - add_library_ex(armnnTfLiteParser OBJECT ${armnn_tf_lite_parser_sources}) - else() + if(BUILD_SHARED_LIBS) add_library_ex(armnnTfLiteParser SHARED ${armnn_tf_lite_parser_sources}) + else() + add_library_ex(armnnTfLiteParser STATIC ${armnn_tf_lite_parser_sources}) endif() include_directories(SYSTEM "${FLATBUFFERS_INCLUDE_PATH}") set_target_properties(armnnTfLiteParser PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) + set_target_properties(armnnTfLiteParser PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) target_include_directories(armnnTfLiteParser PRIVATE ../armnn) target_include_directories(armnnTfLiteParser PRIVATE ../armnnUtils) target_include_directories(armnnTfLiteParser SYSTEM PRIVATE "${TF_LITE_SCHEMA_INCLUDE_PATH}") @@ -66,7 +67,6 @@ if(BUILD_TF_LITE_PARSER) endif() set_target_properties(armnnTfLiteParser PROPERTIES VERSION ${TFLITE_PARSER_LIB_VERSION} SOVERSION ${TFLITE_PARSER_LIB_SOVERSION} ) - install(TARGETS armnnTfLiteParser LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/backends/backends.cmake b/src/backends/backends.cmake index aca3b63ca9..98af2716e3 100644 --- a/src/backends/backends.cmake +++ b/src/backends/backends.cmake @@ -19,11 +19,12 @@ foreach(includeFile ${backendIncludes}) message(STATUS "Including backend into the build: ${includeFile}") include(${includeFile}) endforeach() - -# parse dynamic backend sub-directories -file(GLOB dynamicBackendDirs ${PROJECT_SOURCE_DIR}/src/backends/dynamic/*) -foreach(dynamicBackendDir ${dynamicBackendDirs}) - if (EXISTS ${dynamicBackendDir} AND IS_DIRECTORY ${dynamicBackendDir}) - add_subdirectory(${dynamicBackendDir}) - endif() -endforeach() +if(NOT DISABLE_DYNAMIC_BACKENDS) + # parse dynamic backend sub-directories + file(GLOB dynamicBackendDirs ${PROJECT_SOURCE_DIR}/src/backends/dynamic/*) + foreach(dynamicBackendDir ${dynamicBackendDirs}) + if (EXISTS ${dynamicBackendDir} AND IS_DIRECTORY ${dynamicBackendDir}) + add_subdirectory(${dynamicBackendDir}) + endif() + endforeach() +endif() diff --git a/src/backends/backendsCommon/CMakeLists.txt b/src/backends/backendsCommon/CMakeLists.txt index 28ff205d6e..977067b48f 100644 --- a/src/backends/backendsCommon/CMakeLists.txt +++ b/src/backends/backendsCommon/CMakeLists.txt @@ -3,7 +3,7 @@ # SPDX-License-Identifier: MIT # -if(NOT BUILD_BARE_METAL AND NOT EXECUTE_NETWORK_STATIC) +if(NOT DISABLE_DYNAMIC_BACKENDS) list(APPEND armnnBackendsCommon_sources DynamicBackend.cpp DynamicBackend.hpp diff --git a/src/backends/dynamic/reference/CMakeLists.txt b/src/backends/dynamic/reference/CMakeLists.txt index fe875282f5..acf53383a1 100644 --- a/src/backends/dynamic/reference/CMakeLists.txt +++ b/src/backends/dynamic/reference/CMakeLists.txt @@ -3,7 +3,6 @@ # SPDX-License-Identifier: MIT # -if((NOT BUILD_BARE_METAL) AND (NOT EXECUTE_NETWORK_STATIC)) # File needed to wrap the existing backend into a dynamic one list(APPEND armnnRefDynamicBackend_sources @@ -32,6 +31,3 @@ target_include_directories(Arm_CpuRef_backend PRIVATE ${PROJECT_SOURCE_DIR}/prof target_include_directories(Arm_CpuRef_backend PRIVATE ${PROJECT_SOURCE_DIR}/profiling/client/include) set_target_properties(Arm_CpuRef_backend PROPERTIES PREFIX "") target_link_libraries(Arm_CpuRef_backend armnn) - -# BUILD_BARE_METAL && EXECUTE_NETWORK_STATIC -endif() diff --git a/src/backends/reference/workloads/Debug.cpp b/src/backends/reference/workloads/Debug.cpp index f4f9792fc1..50aecc8b66 100644 --- a/src/backends/reference/workloads/Debug.cpp +++ b/src/backends/reference/workloads/Debug.cpp @@ -103,10 +103,12 @@ void Debug(const TensorInfo& inputInfo, { if (outputsToFile) { +#if !defined(ARMNN_DISABLE_FILESYSTEM) fs::path tmpDir = fs::temp_directory_path(); std::ofstream out(tmpDir.generic_string() + "/ArmNNIntermediateLayerOutputs/" + layerName + ".numpy"); PrintOutput(inputInfo, inputData, guid, layerName, slotIndex, out); out.close(); +#endif } else { diff --git a/src/timelineDecoder/CMakeLists.txt b/src/timelineDecoder/CMakeLists.txt index 3aabf5be76..0f15771a3e 100644 --- a/src/timelineDecoder/CMakeLists.txt +++ b/src/timelineDecoder/CMakeLists.txt @@ -22,6 +22,7 @@ if(BUILD_TIMELINE_DECODER) add_library_ex(timelineDecoderJson SHARED ${timelineDecoderJson_sources}) set_target_properties(timelineDecoderJson PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) + set_target_properties(timelineDecoderJson PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) set_target_properties(timelineDecoderJson PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) target_link_libraries(timelineDecoderJson armnn) -- cgit v1.2.1