20 #include <boost/core/ignore_unused.hpp> 56 void Print(std::ostream& outStream)
const override;
62 using EventPtr = std::unique_ptr<Event>;
68 struct ProfilingEventStats
76 template<
typename EventIterType>
77 void AnalyzeEventSequenceAndWriteResults(EventIterType first, EventIterType last, std::ostream& outStream)
const;
79 std::map<std::string, ProfilingEventStats> CalculateProfilingEventStats()
const;
80 void PopulateInferences(std::vector<const Event*>& outInferences,
int& outBaseLevel)
const;
81 void PopulateDescendants(std::map<
const Event*, std::vector<const Event*>>& outDescendantsMap)
const;
83 std::stack<Event*> m_Parents;
84 std::vector<EventPtr> m_EventSequence;
85 bool m_ProfilingEnabled;
98 void RegisterProfiler(
Profiler* profiler);
118 template<
typename... Args>
123 if (m_Profiler && m_Profiler->IsProfilingEnabled())
125 std::vector<InstrumentPtr> instruments(0);
126 instruments.reserve(
sizeof...(args));
127 ConstructNextInVector(instruments, args...);
128 m_Event = m_Profiler->BeginEvent(backendId, name, std::move(instruments));
134 if (m_Profiler && m_Event)
136 m_Profiler->EndEvent(m_Event);
142 void ConstructNextInVector(std::vector<InstrumentPtr>& instruments)
144 boost::ignore_unused(instruments);
147 template<
typename Arg,
typename... Args>
148 void ConstructNextInVector(std::vector<InstrumentPtr>& instruments, Arg arg, Args... args)
150 instruments.emplace_back(std::make_unique<Arg>(arg));
151 ConstructNextInVector(instruments, args...);
161 #include <boost/preprocessor.hpp> 163 #define ARMNN_SCOPED_PROFILING_EVENT_WITH_INSTRUMENTS_UNIQUE_LOC(backendId, ...) \ 164 armnn::ScopedProfilingEvent BOOST_PP_CAT(e_,__LINE__)(backendId, __VA_ARGS__); 167 #define ARMNN_SCOPED_PROFILING_EVENT_WITH_INSTRUMENTS(backendId, ...) \ 168 ARMNN_SCOPED_PROFILING_EVENT_WITH_INSTRUMENTS_UNIQUE_LOC(backendId, __VA_ARGS__); 170 #define ARMNN_SCOPED_PROFILING_EVENT(backendId, name) \ 171 ARMNN_SCOPED_PROFILING_EVENT_WITH_INSTRUMENTS(backendId, name, armnn::WallClockTimer())
Event * BeginEvent(const BackendId &backendId, const std::string &name, std::vector< InstrumentPtr > &&instruments)
void EndEvent(Event *event)
uint32_t GetEventColor(const BackendId &backendId) const
void EnableProfiling(bool enableProfiling) override
void Print(std::ostream &outStream) const override
void AnalyzeEventsAndWriteResults(std::ostream &outStream) const override
std::unique_ptr< Instrument > InstrumentPtr
std::unique_ptr< Instrument > InstrumentPtr
friend size_t GetProfilerEventSequenceSize(armnn::Profiler *profiler)
bool IsProfilingEnabled() override
ScopedProfilingEvent(const BackendId &backendId, const std::string &name, Args... args)