IVGCVSW-4317 Implement the Profiling Context Initialisation
* Call CreateBackendProfilingContext on each backend from Runtime passing
an instance of the BackendProfiling interface.
* Modify the signature of CreateBackendProfilingContext to remove const
and return a shared_ptr to BackendProfilingContext
* Add concrete BackendProfiling class.
* Store BackendProfilingContexts in Profiling service.
Signed-off-by: Colm Donelan <Colm.Donelan@arm.com>
Change-Id: I975eaa2093ae91fa623835f65f9e5b25eb65117a
diff --git a/src/armnn/Runtime.cpp b/src/armnn/Runtime.cpp
index 47c998a..c1416f9 100644
--- a/src/armnn/Runtime.cpp
+++ b/src/armnn/Runtime.cpp
@@ -16,6 +16,7 @@
#include <iostream>
#include <boost/polymorphic_cast.hpp>
+#include <backends/BackendProfiling.hpp>
using namespace armnn;
using namespace std;
@@ -181,6 +182,19 @@
m_BackendContexts.emplace(std::make_pair(id, std::move(context)));
}
supportedBackends.emplace(id);
+
+ unique_ptr<armnn::profiling::IBackendProfiling> profilingIface =
+ std::make_unique<armnn::profiling::BackendProfiling>(armnn::profiling::BackendProfiling(
+ options, armnn::profiling::ProfilingService::Instance(), id));
+
+ // Backends may also provide a profiling context. Ask for it now.
+ auto profilingContext = backend->CreateBackendProfilingContext(options, profilingIface);
+ // Backends that don't support profiling will return a null profiling context.
+ if (profilingContext)
+ {
+ // Pass the context onto the profiling service.
+ armnn::profiling::ProfilingService::Instance().AddBackendProfilingContext(id, profilingContext);
+ }
}
catch (const BackendUnavailableException&)
{
@@ -230,9 +244,11 @@
}
}
+
// Clear all dynamic backends.
DynamicBackendUtils::DeregisterDynamicBackends(m_DeviceSpec.GetDynamicBackends());
m_DeviceSpec.ClearDynamicBackends();
+ m_BackendContexts.clear();
}
LoadedNetwork* Runtime::GetLoadedNetworkPtr(NetworkId networkId) const