aboutsummaryrefslogtreecommitdiff
path: root/src/armnn
diff options
context:
space:
mode:
authorMatteo Martincigh <matteo.martincigh@arm.com>2019-08-05 14:12:11 +0100
committerMatteo Martincigh <matteo.martincigh@arm.com>2019-08-07 15:04:51 +0100
commite54aa06ec19813b737513ecb8224285d98e871ba (patch)
tree36bdb824d79abec37aa15e811010e5004854a063 /src/armnn
parent5488cfaaa1a411cb5a18c81a98b90c6e3011abdc (diff)
downloadarmnn-e54aa06ec19813b737513ecb8224285d98e871ba.tar.gz
IVGCVSW-3595 Implement the LoadDynamicBackends function in the Runtime class
* Changed the way the handle is acquired, loaded symbols are now kept local * Updated the makefiles to add more test files for the dynamic backends * Fixed the GetSharedObjects method so that the files are parsed in alphabetical order * Updated the unit tests to make them more strict wrt the order of the files * Created a new CreateDynamicBackends method in the utils class * Added new unit tests for the new function * Added LoadDynamicBackends in the Runtime class !android-nn-driver:1707 Change-Id: I1ef9ff3d5455ca6a7fd51cb7cfb3819686234f70 Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com>
Diffstat (limited to 'src/armnn')
-rw-r--r--src/armnn/Runtime.cpp19
-rw-r--r--src/armnn/Runtime.hpp3
2 files changed, 22 insertions, 0 deletions
diff --git a/src/armnn/Runtime.cpp b/src/armnn/Runtime.cpp
index f8b2462f96..3505030273 100644
--- a/src/armnn/Runtime.cpp
+++ b/src/armnn/Runtime.cpp
@@ -5,8 +5,11 @@
#include "Runtime.hpp"
#include <armnn/Version.hpp>
+
#include <backendsCommon/BackendRegistry.hpp>
#include <backendsCommon/IBackendContext.hpp>
+#include <backendsCommon/DynamicBackendUtils.hpp>
+#include <backendsCommon/DynamicBackend.hpp>
#include <iostream>
@@ -134,6 +137,10 @@ Runtime::Runtime(const CreationOptions& options)
{
BOOST_LOG_TRIVIAL(info) << "ArmNN v" << ARMNN_VERSION << "\n";
+ // Load any available/compatible dynamic backend before the runtime
+ // goes through the backend registry
+ LoadDynamicBackends(options.m_DynamicBackendsPath);
+
for (const auto& id : BackendRegistryInstance().GetBackendIds())
{
// Store backend contexts for the supported ones
@@ -237,4 +244,16 @@ void Runtime::RegisterDebugCallback(NetworkId networkId, const DebugCallbackFunc
loadedNetwork->RegisterDebugCallback(func);
}
+void Runtime::LoadDynamicBackends(const std::string& overrideBackendPath)
+{
+ // Get the paths where to load the dynamic backends from
+ std::vector<std::string> backendPaths = DynamicBackendUtils::GetBackendPaths(overrideBackendPath);
+
+ // Get the shared objects to try to load as dynamic backends
+ std::vector<std::string> sharedObjects = DynamicBackendUtils::GetSharedObjects(backendPaths);
+
+ // Create a list of dynamic backends
+ DynamicBackendUtils::CreateDynamicBackends(sharedObjects);
}
+
+} // namespace armnn
diff --git a/src/armnn/Runtime.hpp b/src/armnn/Runtime.hpp
index 10383bc970..624304ec0a 100644
--- a/src/armnn/Runtime.hpp
+++ b/src/armnn/Runtime.hpp
@@ -89,6 +89,9 @@ private:
}
}
+ /// Loads any available/compatible dynamic backend in the runtime.
+ void LoadDynamicBackends(const std::string& overrideBackendPath);
+
mutable std::mutex m_Mutex;
std::unordered_map<NetworkId, std::unique_ptr<LoadedNetwork>> m_LoadedNetworks;