55 void Print(std::ostream& outStream)
const override;
61 using EventPtr = std::unique_ptr<Event>;
67 struct ProfilingEventStats
75 template<
typename EventIterType>
76 void AnalyzeEventSequenceAndWriteResults(EventIterType first, EventIterType last, std::ostream& outStream)
const;
78 std::map<std::string, ProfilingEventStats> CalculateProfilingEventStats()
const;
79 void PopulateInferences(std::vector<const Event*>& outInferences,
int& outBaseLevel)
const;
80 void PopulateDescendants(std::map<
const Event*, std::vector<const Event*>>& outDescendantsMap)
const;
82 std::stack<Event*> m_Parents;
83 std::vector<EventPtr> m_EventSequence;
84 bool m_ProfilingEnabled;
97 void RegisterProfiler(
Profiler* profiler);
117 template<
typename... Args>
122 if (m_Profiler && m_Profiler->IsProfilingEnabled())
124 std::vector<InstrumentPtr> instruments(0);
125 instruments.reserve(
sizeof...(args));
126 ConstructNextInVector(instruments, args...);
127 m_Event = m_Profiler->BeginEvent(backendId, name, std::move(instruments));
133 if (m_Profiler && m_Event)
135 m_Profiler->EndEvent(m_Event);
141 void ConstructNextInVector(std::vector<InstrumentPtr>& instruments)
146 template<
typename Arg,
typename... Args>
147 void ConstructNextInVector(std::vector<InstrumentPtr>& instruments, Arg arg, Args... args)
149 instruments.emplace_back(std::make_unique<Arg>(arg));
150 ConstructNextInVector(instruments, args...);
160 #include <boost/preprocessor.hpp> 162 #define ARMNN_SCOPED_PROFILING_EVENT_WITH_INSTRUMENTS_UNIQUE_LOC(backendId, ...) \ 163 armnn::ScopedProfilingEvent BOOST_PP_CAT(e_,__LINE__)(backendId, __VA_ARGS__); 166 #define ARMNN_SCOPED_PROFILING_EVENT_WITH_INSTRUMENTS(backendId, ...) \ 167 ARMNN_SCOPED_PROFILING_EVENT_WITH_INSTRUMENTS_UNIQUE_LOC(backendId, __VA_ARGS__); 169 #define ARMNN_SCOPED_PROFILING_EVENT(backendId, name) \ 170 ARMNN_SCOPED_PROFILING_EVENT_WITH_INSTRUMENTS(backendId, name, armnn::WallClockTimer()) void EndEvent(Event *event)
Event class records measurements reported by BeginEvent()/EndEvent() and returns measurements when Ev...
ScopedProfilingEvent(const BackendId &backendId, const std::string &name, Args... args)
std::unique_ptr< Instrument > InstrumentPtr
void EnableProfiling(bool enableProfiling) override
Enables/disables profiling for this profiler.
Copyright (c) 2020 ARM Limited.
void IgnoreUnused(Ts &&...)
void AnalyzeEventsAndWriteResults(std::ostream &outStream) const override
Analyzes the tracked events and writes the results to the given output stream.
bool IsProfilingEnabled() override
Checks whether profiling is enabled.
Event * BeginEvent(const BackendId &backendId, const std::string &name, std::vector< InstrumentPtr > &&instruments)
friend size_t GetProfilerEventSequenceSize(armnn::Profiler *profiler)
uint32_t GetEventColor(const BackendId &backendId) const
void Print(std::ostream &outStream) const override
Print stats for events in JSON Format to the given output stream.
std::unique_ptr< Instrument > InstrumentPtr