aboutsummaryrefslogtreecommitdiff
path: root/src/backends/backendsCommon/test/MockBackend.hpp
diff options
context:
space:
mode:
authorDavid Monahan <david.monahan@arm.com>2020-02-12 15:52:35 +0000
committerDavid Monahan <david.monahan@arm.com>2020-02-13 14:58:57 +0000
commitc1536d69c1468514425e143b0578656f51598b94 (patch)
tree36f2add33c611be04f2c9840ea43bc302fdf6cfe /src/backends/backendsCommon/test/MockBackend.hpp
parentabfa902188c3fcd72cf435a8a457807f3c7b6508 (diff)
downloadarmnn-c1536d69c1468514425e143b0578656f51598b94.tar.gz
IVGCVSW-4400 Backend Counter Registry Functionality
* Adding BackendProfilingContext to the MockBackend * Made IBackendProfilingContext pure Virtual * Added UnitTest using MockBackend for testing Backend Counter Registration * Moved Registry of backend counters from Initialize() to AddBackendProfilingContext() * Added m_MaxGlobalCounterId to ProfilingService * Removed automatic registration of MockBack in BackendRegistry() Signed-off-by: David Monahan <david.monahan@arm.com> Change-Id: Ie1c6c31e56d1ac7079d6116ecad041961014aedc
Diffstat (limited to 'src/backends/backendsCommon/test/MockBackend.hpp')
-rw-r--r--src/backends/backendsCommon/test/MockBackend.hpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/src/backends/backendsCommon/test/MockBackend.hpp b/src/backends/backendsCommon/test/MockBackend.hpp
index d1a0082e2e..21ce7ab85d 100644
--- a/src/backends/backendsCommon/test/MockBackend.hpp
+++ b/src/backends/backendsCommon/test/MockBackend.hpp
@@ -5,6 +5,10 @@
#pragma once
+#include "armnn/backends/profiling/IBackendProfiling.hpp"
+#include "armnn/backends/profiling/IBackendProfilingContext.hpp"
+#include "MockBackendId.hpp"
+
#include <LayerSupportCommon.hpp>
#include <armnn/backends/IBackendInternal.hpp>
#include <armnn/backends/OptimizationViews.hpp>
@@ -13,6 +17,84 @@
namespace armnn
{
+class MockBackendInitialiser
+{
+public:
+ MockBackendInitialiser();
+ ~MockBackendInitialiser();
+};
+
+class MockBackendProfilingService
+{
+public:
+ // Getter for the singleton instance
+ static MockBackendProfilingService& Instance()
+ {
+ static MockBackendProfilingService instance;
+ return instance;
+ }
+
+ armnn::profiling::IBackendProfilingContext* GetContext()
+ {
+ return m_sharedContext.get();
+ }
+
+ void SetProfilingContextPtr(IBackendInternal::IBackendProfilingContextPtr& shared)
+ {
+ m_sharedContext = shared;
+ }
+
+private:
+ IBackendInternal::IBackendProfilingContextPtr m_sharedContext;
+};
+
+class MockBackendProfilingContext : public profiling::IBackendProfilingContext
+{
+public:
+ MockBackendProfilingContext(IBackendInternal::IBackendProfilingPtr& backendProfiling)
+ : m_BackendProfiling(backendProfiling)
+ {}
+
+ ~MockBackendProfilingContext() = default;
+
+ IBackendInternal::IBackendProfilingPtr& GetBackendProfiling()
+ {
+ return m_BackendProfiling;
+ }
+
+ uint16_t RegisterCounters(uint16_t currentMaxGlobalCounterId)
+ {
+ std::unique_ptr<profiling::IRegisterBackendCounters> counterRegistrar =
+ m_BackendProfiling->GetCounterRegistrationInterface(currentMaxGlobalCounterId);
+
+ std::string categoryName("MockCounters");
+ counterRegistrar->RegisterCategory(categoryName);
+ uint16_t nextMaxGlobalCounterId = counterRegistrar->RegisterCounter(
+ 0, categoryName, 0, 0, 1.f, "Mock Counter One", "Some notional counter");
+
+ nextMaxGlobalCounterId = counterRegistrar->RegisterCounter(
+ 1, categoryName, 0, 0, 1.f, "Mock Counter Two", "Another notional counter");
+
+ std::string units("microseconds");
+ nextMaxGlobalCounterId = counterRegistrar->RegisterCounter(
+ 2, categoryName, 0, 0, 1.f, "Mock MultiCore Counter", "A dummy four core counter", units, 4);
+ return nextMaxGlobalCounterId;
+ }
+
+ void ActivateCounters(uint32_t, const std::vector<uint16_t>&)
+ {}
+
+ std::vector<profiling::Timestamp> ReportCounterValues()
+ {
+ return std::vector<profiling::Timestamp>();
+ }
+
+ void EnableProfiling(bool)
+ {}
+
+private:
+ IBackendInternal::IBackendProfilingPtr& m_BackendProfiling;
+};
class MockBackend : public IBackendInternal
{