From 032bc74ca4bc6589a33f23db31accddc5b20baaa Mon Sep 17 00:00:00 2001 From: Finn Williams Date: Wed, 12 Feb 2020 11:02:34 +0000 Subject: IVGCVSW-4338 Implement the Activation of Counters in backends Signed-off-by: Finn Williams Change-Id: I4a2465f06e046f78242ff0a246c651638b205498 --- src/backends/backendsCommon/test/MockBackend.hpp | 32 +++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'src/backends/backendsCommon/test/MockBackend.hpp') diff --git a/src/backends/backendsCommon/test/MockBackend.hpp b/src/backends/backendsCommon/test/MockBackend.hpp index 21ce7ab85d..641d67ff24 100644 --- a/src/backends/backendsCommon/test/MockBackend.hpp +++ b/src/backends/backendsCommon/test/MockBackend.hpp @@ -13,6 +13,8 @@ #include #include #include +#include +#include namespace armnn { @@ -53,6 +55,7 @@ class MockBackendProfilingContext : public profiling::IBackendProfilingContext public: MockBackendProfilingContext(IBackendInternal::IBackendProfilingPtr& backendProfiling) : m_BackendProfiling(backendProfiling) + , m_CapturePeriod(0) {} ~MockBackendProfilingContext() = default; @@ -81,19 +84,42 @@ public: return nextMaxGlobalCounterId; } - void ActivateCounters(uint32_t, const std::vector&) - {} + Optional ActivateCounters(uint32_t capturePeriod, const std::vector& counterIds) + { + if ( capturePeriod == 0 || counterIds.size() == 0) + { + m_ActiveCounters.clear(); + } + else if (capturePeriod == 15939u) + { + return armnn::Optional("ActivateCounters example test error"); + } + m_CapturePeriod = capturePeriod; + m_ActiveCounters = counterIds; + return armnn::Optional(); + } std::vector ReportCounterValues() { - return std::vector(); + std::vector counterValues; + + for(auto counterId : m_ActiveCounters) + { + counterValues.emplace_back(profiling::CounterValue{counterId, counterId+1u}); + } + + uint64_t timestamp = m_CapturePeriod; + return {profiling::Timestamp{timestamp, counterValues}}; } void EnableProfiling(bool) {} private: + IBackendInternal::IBackendProfilingPtr& m_BackendProfiling; + uint32_t m_CapturePeriod; + std::vector m_ActiveCounters; }; class MockBackend : public IBackendInternal -- cgit v1.2.1