IVGCVSW-6817 Add IProfilingService& as an argument to the IReportStructure

Signed-off-by: Cathal Corbett <cathal.corbett@arm.com>
Change-Id: Ib8e75eea49debe3b1dd8fa72623a55b26cb6ded4
diff --git a/src/armnn/LoadedNetwork.cpp b/src/armnn/LoadedNetwork.cpp
index 1dbd1e3..46c1ce5 100644
--- a/src/armnn/LoadedNetwork.cpp
+++ b/src/armnn/LoadedNetwork.cpp
@@ -543,14 +543,14 @@
     }
 }
 
-void LoadedNetwork::SendNetworkStructure()
+void LoadedNetwork::SendNetworkStructure(arm::pipe::IProfilingService& profilingService)
 {
     ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "LoadNetwork_SendNetworkStructure");
     Graph& order = m_OptimizedNetwork->pOptimizedNetworkImpl->GetGraph().TopologicalSort();
     ProfilingGuid networkGuid = m_OptimizedNetwork->GetGuid();
 
     std::unique_ptr<TimelineUtilityMethods> timelineUtils =
-        TimelineUtilityMethods::GetTimelineUtils(*m_ProfilingService);
+        TimelineUtilityMethods::GetTimelineUtils(profilingService);
 
     timelineUtils->CreateTypedEntity(networkGuid, LabelsAndEventClasses::NETWORK_GUID);
 
@@ -560,19 +560,19 @@
         AddLayerStructure(timelineUtils, *layer, networkGuid);
         switch (layer->GetType())
         {
-        case LayerType::Input:
-        case LayerType::Output:
-        {
-            // Inputs and outputs are treated in a special way - see EnqueueInput() and EnqueueOutput().
-            break;
-        }
-        default:
+            case LayerType::Input:
+            case LayerType::Output:
             {
-            for (auto& workload : m_WorkloadQueue)
-            {
-                // Add workload to the post-optimisation network structure
-                AddWorkloadStructure(timelineUtils, workload, *layer);
+                // Inputs and outputs are treated in a special way - see EnqueueInput() and EnqueueOutput().
+                break;
             }
+            default:
+            {
+                for (auto& workload : m_WorkloadQueue)
+                {
+                    // Add workload to the post-optimisation network structure
+                    AddWorkloadStructure(timelineUtils, workload, *layer);
+                }
             break;
             }
         }
diff --git a/src/armnn/LoadedNetwork.hpp b/src/armnn/LoadedNetwork.hpp
index 19f2bcf..85f90c1 100644
--- a/src/armnn/LoadedNetwork.hpp
+++ b/src/armnn/LoadedNetwork.hpp
@@ -89,7 +89,7 @@
 
     void RegisterDebugCallback(const DebugCallbackFunction& func);
 
-    void SendNetworkStructure();
+    void SendNetworkStructure(arm::pipe::IProfilingService& profilingService);
 
     bool IsAsyncEnabled()
     {
diff --git a/src/armnn/Runtime.cpp b/src/armnn/Runtime.cpp
index af257e1..57bcedd 100644
--- a/src/armnn/Runtime.cpp
+++ b/src/armnn/Runtime.cpp
@@ -286,18 +286,18 @@
     return nullptr;
 }
 
-void RuntimeImpl::ReportStructure() // arm::pipe::IProfilingService& profilingService as param
+void RuntimeImpl::ReportStructure(arm::pipe::IProfilingService& profilingService)
 {
-    // No-op for the time being, but this may be useful in future to have the profilingService available
-    // if (profilingService.IsProfilingEnabled()){}
-
-    LoadedNetworks::iterator it = m_LoadedNetworks.begin();
-    while (it != m_LoadedNetworks.end())
+    if (profilingService.IsProfilingEnabled())
     {
-        auto& loadedNetwork = it->second;
-        loadedNetwork->SendNetworkStructure();
-        // Increment the Iterator to point to next entry
-        it++;
+        LoadedNetworks::iterator it = m_LoadedNetworks.begin();
+        while (it != m_LoadedNetworks.end())
+        {
+            auto& loadedNetwork = it->second;
+            loadedNetwork->SendNetworkStructure(profilingService);
+            // Increment the Iterator to point to next entry
+            it++;
+        }
     }
 }
 
diff --git a/src/armnn/Runtime.hpp b/src/armnn/Runtime.hpp
index f2462b1..9a20902 100644
--- a/src/armnn/Runtime.hpp
+++ b/src/armnn/Runtime.hpp
@@ -110,7 +110,7 @@
 
     //NOTE: we won't need the profiling service reference but it is good to pass the service
     // in this way to facilitate other implementations down the road
-    void ReportStructure() override;
+    void ReportStructure(arm::pipe::IProfilingService& profilingService) override;
 
     void InitialiseProfilingService(arm::pipe::IProfilingService& profilingService) override;
 
diff --git a/src/profiling/ActivateTimelineReportingCommandHandler.cpp b/src/profiling/ActivateTimelineReportingCommandHandler.cpp
index 7f949d3..940b823 100644
--- a/src/profiling/ActivateTimelineReportingCommandHandler.cpp
+++ b/src/profiling/ActivateTimelineReportingCommandHandler.cpp
@@ -5,6 +5,8 @@
 
 #include "ActivateTimelineReportingCommandHandler.hpp"
 #include "TimelineUtilityMethods.hpp"
+#include <ArmNNProfilingServiceInitialiser.hpp>
+#include <armnn/profiling/ArmNNProfiling.hpp>
 
 #include <armnn/Exceptions.hpp>
 #include <fmt/format.h>
@@ -49,7 +51,10 @@
 
                 m_TimelineReporting = true;
 
-                m_ReportStructure.value().ReportStructure();
+                armnn::ArmNNProfilingServiceInitialiser initialiser;
+                std::unique_ptr<IProfilingService> profilingService = IProfilingService::CreateProfilingService(
+                    arm::pipe::MAX_ARMNN_COUNTER, initialiser);
+                m_ReportStructure.value().ReportStructure(*profilingService);
 
                 m_BackendNotifier.NotifyBackendsForTimelineReporting();
             }
diff --git a/src/profiling/IReportStructure.hpp b/src/profiling/IReportStructure.hpp
index 82a84ff..8891cbd 100644
--- a/src/profiling/IReportStructure.hpp
+++ b/src/profiling/IReportStructure.hpp
@@ -11,11 +11,13 @@
 namespace pipe
 {
 
+class IProfilingService;
+
 class IReportStructure
 {
 public:
     virtual ~IReportStructure() {}
-    virtual void ReportStructure() = 0;
+    virtual void ReportStructure(arm::pipe::IProfilingService& profilingService) = 0;
 };
 
 } // namespace pipe
diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp
index fd26703..128e1f1 100644
--- a/src/profiling/test/ProfilingTests.cpp
+++ b/src/profiling/test/ProfilingTests.cpp
@@ -1910,7 +1910,7 @@
     class TestReportStructure : public IReportStructure
     {
         public:
-        virtual void ReportStructure() override
+        virtual void ReportStructure(arm::pipe::IProfilingService& profilingService) override
         {
             m_ReportStructureCalled = true;
         }