From b5540547d615b7fb642018f426eaedfd70e85c6c Mon Sep 17 00:00:00 2001 From: Ryan OShea Date: Wed, 6 Jul 2022 09:52:52 +0100 Subject: IVGCVSW-7031 Generate static execute network * Build ExecNet lib dependencies as object libs except libarmnn * Disable PIPE when building static ExecNet * Remove multiple definition from AsyncExecutionCallback * Disable DynamicBackend for ExecNet Static build * Disable inference tests for TfLiteParser and ONNX during static ExecNet * Remove Tensorflow Parser if condition * Add Disable thread macro to InferenceModel * Don't compile dynamic backend symbols in Runtime.cpp for Baremetal and Exenet Static Signed-off-by: Ryan OShea Change-Id: If41c063eab5f05b3df0a6e064924a36a177f116a --- src/armnn/AsyncExecutionCallback.cpp | 4 +++- src/armnn/AsyncExecutionCallback.hpp | 3 +-- src/armnn/Runtime.cpp | 17 ++++++++++++----- src/armnnSerializer/CMakeLists.txt | 25 ++++++++++++++----------- src/armnnTestUtils/CMakeLists.txt | 6 ++++-- src/armnnTfLiteParser/CMakeLists.txt | 8 ++++++-- src/backends/backendsCommon/CMakeLists.txt | 4 ++-- src/backends/dynamic/reference/CMakeLists.txt | 6 +++--- 8 files changed, 45 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/armnn/AsyncExecutionCallback.cpp b/src/armnn/AsyncExecutionCallback.cpp index 5b87927af2..73ce66b7fb 100644 --- a/src/armnn/AsyncExecutionCallback.cpp +++ b/src/armnn/AsyncExecutionCallback.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2021 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2021-2023 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -11,6 +11,8 @@ namespace armnn namespace experimental { +InferenceId AsyncExecutionCallback::nextID = 0u; + void AsyncExecutionCallback::Notify(armnn::Status status, InferenceTimingPair timeTaken) { { diff --git a/src/armnn/AsyncExecutionCallback.hpp b/src/armnn/AsyncExecutionCallback.hpp index 9eab06b4fa..d48f80737d 100644 --- a/src/armnn/AsyncExecutionCallback.hpp +++ b/src/armnn/AsyncExecutionCallback.hpp @@ -1,5 +1,5 @@ // -// Copyright © 2021 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2021-2023 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -68,7 +68,6 @@ private: armnn::Status m_Status = Status::Failure; InferenceId m_InferenceId; }; -InferenceId AsyncExecutionCallback::nextID = 0u; // Manager to create and monitor AsyncExecutionCallbacks // GetNewCallback will create a callback for use in Threadpool::Schedule diff --git a/src/armnn/Runtime.cpp b/src/armnn/Runtime.cpp index cec54f4ec8..ff64e856f4 100644 --- a/src/armnn/Runtime.cpp +++ b/src/armnn/Runtime.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2017, 2023 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2017, 2022-2023 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -20,7 +20,10 @@ #include #include +#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) #include +#endif + #include #include @@ -334,11 +337,11 @@ 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) // Load any available/compatible dynamic backend before the runtime // goes through the backend registry LoadDynamicBackends(options.m_DynamicBackendsPath); - +#endif armnn::BackendIdSet supportedBackends; for (const auto& id : BackendRegistryInstance().GetBackendIds()) { @@ -354,9 +357,11 @@ 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) // We need to manually clean up the dynamic backends before throwing an exception. DynamicBackendUtils::DeregisterDynamicBackends(m_DeviceSpec.GetDynamicBackends()); m_DeviceSpec.ClearDynamicBackends(); +#endif throw armnn::Exception("Allocator associated with id " + id.Get() + " is null"); } @@ -579,10 +584,11 @@ RuntimeImpl::~RuntimeImpl() << std::endl; } } - +#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) // Clear all dynamic backends. DynamicBackendUtils::DeregisterDynamicBackends(m_DeviceSpec.GetDynamicBackends()); m_DeviceSpec.ClearDynamicBackends(); +#endif m_BackendContexts.clear(); BackendRegistryInstance().SetProfilingService(armnn::EmptyOptional()); @@ -763,6 +769,7 @@ void RuntimeImpl::RegisterDebugCallback(NetworkId networkId, const DebugCallback loadedNetwork->RegisterDebugCallback(func); } +#if !defined(ARMNN_BUILD_BARE_METAL) && !defined(ARMNN_EXECUTE_NETWORK_STATIC) void RuntimeImpl::LoadDynamicBackends(const std::string& overrideBackendPath) { // Get the paths where to load the dynamic backends from @@ -780,5 +787,5 @@ void RuntimeImpl::LoadDynamicBackends(const std::string& overrideBackendPath) // Add the registered dynamic backend ids to the list of supported backends m_DeviceSpec.AddSupportedBackends(registeredBackendIds, true); } - +#endif } // namespace armnn diff --git a/src/armnnSerializer/CMakeLists.txt b/src/armnnSerializer/CMakeLists.txt index 8acdafbc28..01c51e65d7 100755 --- a/src/armnnSerializer/CMakeLists.txt +++ b/src/armnnSerializer/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright © 2017, 2019-2020, 2022 Arm Ltd and Contributors. All rights reserved. +# Copyright © 2017, 2019-2020, 2022-2023 Arm Ltd and Contributors. All rights reserved. # SPDX-License-Identifier: MIT # if(BUILD_ARMNN_SERIALIZER) @@ -36,7 +36,7 @@ if(BUILD_ARMNN_SERIALIZER) ../armnnDeserializer/Deserializer.cpp ) - if(BUILD_BARE_METAL) + if(BUILD_BARE_METAL OR EXECUTE_NETWORK_STATIC) add_library_ex(armnnSerializer STATIC ${armnn_serializer_sources}) else() # We're going to export both a STATIC library and a SHARED library here. @@ -52,9 +52,11 @@ if(BUILD_ARMNN_SERIALIZER) target_include_directories(armnnSerializer PRIVATE ../armnn) target_include_directories(armnnSerializer PRIVATE ../armnnUtils) target_include_directories(armnnSerializer PRIVATE ../../generated) - target_include_directories(armnnSerializer-static PRIVATE ../armnn) - target_include_directories(armnnSerializer-static PRIVATE ../armnnUtils) - target_include_directories(armnnSerializer-static 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) + endif() list(APPEND armnn_serializer_sources ArmnnSchema_generated.h @@ -64,12 +66,13 @@ if(BUILD_ARMNN_SERIALIZER) target_include_directories(armnnSerializer SYSTEM PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(armnnSerializer armnn ${FLATBUFFERS_LIBRARY}) - - install(TARGETS armnnSerializer-static - EXPORT armnn-targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - ) + if (NOT BARE_METAL AND NOT EXECUTE_NETWORK_STATIC) + install(TARGETS armnnSerializer-static + EXPORT armnn-targets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + ) + endif() install(TARGETS armnnSerializer EXPORT armnn-targets diff --git a/src/armnnTestUtils/CMakeLists.txt b/src/armnnTestUtils/CMakeLists.txt index 3f6fb415a2..a4333cf306 100755 --- a/src/armnnTestUtils/CMakeLists.txt +++ b/src/armnnTestUtils/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright © 2021 Arm Ltd and Contributors. All rights reserved. +# Copyright © 2021, 2023 Arm Ltd and Contributors. All rights reserved. # SPDX-License-Identifier: MIT # @@ -31,7 +31,7 @@ list(APPEND armnnTestUtils_sources TestUtils.hpp ) -if(NOT BUILD_BARE_METAL) +if(NOT BUILD_BARE_METAL AND NOT EXECUTE_NETWORK_STATIC) list(APPEND armnnTestUtils_sources UnitTests.cpp UnitTests.hpp @@ -41,6 +41,8 @@ endif() if(BUILD_BARE_METAL) add_library_ex(armnnTestUtils STATIC ${armnnTestUtils_sources}) +elseif(EXECUTE_NETWORK_STATIC) + add_library_ex(armnnTestUtils OBJECT ${armnnTestUtils_sources}) else() add_library_ex(armnnTestUtils SHARED ${armnnTestUtils_sources}) endif() diff --git a/src/armnnTfLiteParser/CMakeLists.txt b/src/armnnTfLiteParser/CMakeLists.txt index f9653b6752..6096d1bf8c 100755 --- a/src/armnnTfLiteParser/CMakeLists.txt +++ b/src/armnnTfLiteParser/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright © 2017 Arm Ltd. All rights reserved. +# Copyright © 2017, 2023 Arm Ltd. All rights reserved. # SPDX-License-Identifier: MIT # if(BUILD_TF_LITE_PARSER) @@ -11,7 +11,11 @@ if(BUILD_TF_LITE_PARSER) TfLiteParser.cpp ) - add_library_ex(armnnTfLiteParser SHARED ${armnn_tf_lite_parser_sources}) + if(EXECUTE_NETWORK_STATIC) + add_library_ex(armnnTfLiteParser OBJECT ${armnn_tf_lite_parser_sources}) + else() + add_library_ex(armnnTfLiteParser SHARED ${armnn_tf_lite_parser_sources}) + endif() include_directories(SYSTEM "${FLATBUFFERS_INCLUDE_PATH}") set_target_properties(armnnTfLiteParser PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) diff --git a/src/backends/backendsCommon/CMakeLists.txt b/src/backends/backendsCommon/CMakeLists.txt index b2ab932384..8d7e114fa5 100644 --- a/src/backends/backendsCommon/CMakeLists.txt +++ b/src/backends/backendsCommon/CMakeLists.txt @@ -1,9 +1,9 @@ # -# Copyright © 2017 Arm Ltd and Contributors. All rights reserved. +# Copyright © 2017, 2023 Arm Ltd and Contributors. All rights reserved. # SPDX-License-Identifier: MIT # -if(NOT BUILD_BARE_METAL) +if(NOT BUILD_BARE_METAL AND NOT EXECUTE_NETWORK_STATIC) 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 de46f7a5cb..fe875282f5 100644 --- a/src/backends/dynamic/reference/CMakeLists.txt +++ b/src/backends/dynamic/reference/CMakeLists.txt @@ -1,9 +1,9 @@ # -# Copyright © 2017 Arm Ltd. All rights reserved. +# Copyright © 2017, 2023 Arm Ltd. All rights reserved. # SPDX-License-Identifier: MIT # -if(NOT BUILD_BARE_METAL) +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 @@ -33,5 +33,5 @@ target_include_directories(Arm_CpuRef_backend PRIVATE ${PROJECT_SOURCE_DIR}/prof set_target_properties(Arm_CpuRef_backend PROPERTIES PREFIX "") target_link_libraries(Arm_CpuRef_backend armnn) -# BUILD_BARE_METAL +# BUILD_BARE_METAL && EXECUTE_NETWORK_STATIC endif() -- cgit v1.2.1