#include <armnn/Types.hpp>
#include <armnn/BackendId.hpp>
+#include <armnn/Optional.hpp>
#include <memory>
#include <unordered_map>
namespace armnn
{
+namespace profiling
+{
+ class ProfilingService;
+}
class IBackendInternal;
using IBackendInternalUniquePtr = std::unique_ptr<IBackendInternal>;
size_t Size() const;
BackendIdSet GetBackendIds() const;
std::string GetBackendIdsAsString() const;
+ void SetProfilingService(armnn::Optional<profiling::ProfilingService&> profilingService);
BackendRegistry() {}
virtual ~BackendRegistry() {}
BackendRegistry& operator=(const BackendRegistry&) = delete;
FactoryStorage m_Factories;
+ armnn::Optional<profiling::ProfilingService&> m_ProfilingService;
};
BackendRegistry& BackendRegistryInstance();
#include <armnn/BackendRegistry.hpp>
#include <armnn/Exceptions.hpp>
+#include <ProfilingService.hpp>
namespace armnn
{
CHECK_LOCATION());
}
m_Factories[id] = factory;
+
+ if (m_ProfilingService.has_value())
+ {
+ if (m_ProfilingService.has_value() && m_ProfilingService.value().IsProfilingEnabled())
+ {
+ m_ProfilingService.value().IncrementCounterValue(armnn::profiling::REGISTERED_BACKENDS);
+ }
+ }
+
}
void BackendRegistry::Deregister(const BackendId& id)
{
m_Factories.erase(id);
+
+ if (m_ProfilingService.has_value() && m_ProfilingService.value().IsProfilingEnabled())
+ {
+ m_ProfilingService.value().IncrementCounterValue(armnn::profiling::UNREGISTERED_BACKENDS);
+ }
}
bool BackendRegistry::IsBackendRegistered(const BackendId& id) const
std::swap(instance.m_Factories, other);
}
+void BackendRegistry::SetProfilingService(armnn::Optional<profiling::ProfilingService&> profilingService)
+{
+ m_ProfilingService = profilingService;
+}
+
} // namespace armnn
}
}
+ BackendRegistryInstance().SetProfilingService(m_ProfilingService);
// pass configuration info to the profiling service
m_ProfilingService.ConfigureProfilingService(options.m_ProfilingOptions);
DynamicBackendUtils::DeregisterDynamicBackends(m_DeviceSpec.GetDynamicBackends());
m_DeviceSpec.ClearDynamicBackends();
m_BackendContexts.clear();
+
+ BackendRegistryInstance().SetProfilingService(armnn::EmptyOptional());
}
LoadedNetwork* Runtime::GetLoadedNetworkPtr(NetworkId networkId) const
{
// Reset the profiling service to the uninitialized state
armnn::IRuntime::CreationOptions options;
- options.m_ProfilingOptions.m_EnableProfiling = true;;
+ options.m_ProfilingOptions.m_EnableProfiling = true;
armnn::MockBackendInitialiser initialiser;
// Create a runtime
std::string("backends"));
ARMNN_ASSERT(registeredBackendsCounter);
InitializeCounterValue(registeredBackendsCounter->m_Uid);
+
+ // Due to backends being registered before the profiling service becomes active,
+ // we need to set the counter to the correct value here
+ SetCounterValue(armnn::profiling::REGISTERED_BACKENDS, static_cast<uint32_t>(BackendRegistryInstance().Size()));
}
// Register a counter for the number of registered backends
if (!m_CounterDirectory.IsCounterRegistered("Backends unregistered"))