diff options
author | Keith Davis <keith.davis@arm.com> | 2021-07-20 11:25:22 +0100 |
---|---|---|
committer | Keith Davis <keith.davis@arm.com> | 2021-08-04 11:49:16 +0100 |
commit | 554fa09a0f3d6c9c572634c9d2de9bfb6c3218b0 (patch) | |
tree | 1820a2cadcc1f34667199acff2d044e5d2083ea2 /src/armnn/Profiling.hpp | |
parent | 96fd98c28441618fbdf9376fe46a368ef06b19e1 (diff) | |
download | armnn-554fa09a0f3d6c9c572634c9d2de9bfb6c3218b0.tar.gz |
IVGCVSW-5980 JSON profiling output
* Add new ProfilingDetails class to construct operator details string
* Add new macro which helps append layer details to ostream
* Add ProfilingEnabled to NetworkProperties so that profiling can be
realised when loading the network
* Add further optional info to WorkloadInfo specific to convolutions
* Generalise some JsonPrinter functions into JsonUtils for reusability
* Remove explicit enabling of profiling within InferenceModel as it is
done when loading network
* Add ProfilingDetails macros to ConvolutionWorkloads for validation
Signed-off-by: Keith Davis <keith.davis@arm.com>
Change-Id: Ie84bc7dc667e72e6bcb635544f9ead7af1765690
Diffstat (limited to 'src/armnn/Profiling.hpp')
-rw-r--r-- | src/armnn/Profiling.hpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/armnn/Profiling.hpp b/src/armnn/Profiling.hpp index d134425b6c..785f50521e 100644 --- a/src/armnn/Profiling.hpp +++ b/src/armnn/Profiling.hpp @@ -5,6 +5,7 @@ #pragma once #include "ProfilingEvent.hpp" +#include "ProfilingDetails.hpp" #include <armnn/utility/IgnoreUnused.hpp> #include "armnn/IProfiler.hpp" @@ -38,6 +39,14 @@ public: const std::string& name, std::vector<InstrumentPtr>&& instruments); + template<typename DescriptorType> + void AddLayerDetails(const std::string& label, + const DescriptorType& desc, + const WorkloadInfo& infos) + { + m_ProfilingDetails->AddDetailsToString(label, desc, infos); + } + // Marks the end of a user-defined event. void EndEvent(Event* event); @@ -61,6 +70,8 @@ public: uint32_t GetEventColor(const BackendId& backendId) const; using EventPtr = std::unique_ptr<Event>; + using DescPtr = std::unique_ptr<ProfilingDetails>; + struct Marker { std::size_t m_Id; @@ -83,6 +94,7 @@ public: std::stack<Event*> m_Parents; std::vector<EventPtr> m_EventSequence; + DescPtr m_ProfilingDetails = std::make_unique<ProfilingDetails>(); bool m_ProfilingEnabled; }; @@ -152,8 +164,39 @@ private: IProfiler* m_Profiler; ///< Profiler used }; +// Helper to easily add operator details during profiling. +class ScopedProfilingUpdateDescriptions +{ +public: + template<typename DescriptorType> + ScopedProfilingUpdateDescriptions(const std::string& name, const DescriptorType& desc, const WorkloadInfo& infos) + : m_Profiler(ProfilerManager::GetInstance().GetProfiler()) + { + if (m_Profiler && m_Profiler->IsProfilingEnabled()) + { + m_Profiler->AddLayerDetails(name, desc, infos); + } + } + + ~ScopedProfilingUpdateDescriptions() + {} + +private: + + IProfiler* m_Profiler; ///< Profiler used +}; + +template<typename DescriptorType> +void IProfiler::AddLayerDetails(const std::string& name, + const DescriptorType& desc, + const WorkloadInfo& infos) +{ + return pProfilerImpl->AddLayerDetails(name, desc, infos); +} + } // namespace armnn +// Event Definitions for profiling #define ARMNN_SCOPED_PROFILING_EVENT_WITH_INSTRUMENTS_UNIQUE_LOC_INNER(lineNumber, backendId, /*name,*/ ...) \ armnn::ScopedProfilingEvent e_ ## lineNumber(backendId, /*name,*/ __VA_ARGS__); @@ -172,3 +215,13 @@ private: #define ARMNN_SCOPED_PROFILING_EVENT(backendId, name) \ ARMNN_SCOPED_PROFILING_EVENT_WITH_INSTRUMENTS(backendId, name, armnn::WallClockTimer()) + +// Workload Description definitons for profiling +#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC_UNIQUE_LOC_INNER(lineNumber, name, desc, infos) \ + armnn::ScopedProfilingUpdateDescriptions e_ ## lineNumber(name, desc, infos); + +#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC_UNIQUE_LOC(lineNumber, name, desc, infos) \ + ARMNN_REPORT_PROFILING_WORKLOAD_DESC_UNIQUE_LOC_INNER(lineNumber, name, desc, infos) + +#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos) \ + ARMNN_REPORT_PROFILING_WORKLOAD_DESC_UNIQUE_LOC(__LINE__, name, desc, infos) |