From 4c11a488d7f20c219ea6265480bc02f4b2cea1e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonny=20Sv=C3=A4rd?= Date: Fri, 17 Dec 2021 17:04:08 +0100 Subject: Use lbl-profiler to setup PMU and PMU events Adapt layer-by-layer profiler to handle PMU event configuration, PMU setup and retrieving PMU counter values. Adapt the inference process application to support the lbl-profiler PMU setup and retrieve/save PMU counter values in the InferenceJob struct. Change-Id: I1667a5b11c43c54e7d28232b594dd118bf3f79a8 --- .../include/layer_by_layer_profiler.hpp | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'lib/layer_by_layer_profiler/include') diff --git a/lib/layer_by_layer_profiler/include/layer_by_layer_profiler.hpp b/lib/layer_by_layer_profiler/include/layer_by_layer_profiler.hpp index 8e8dc0f..37bd868 100644 --- a/lib/layer_by_layer_profiler/include/layer_by_layer_profiler.hpp +++ b/lib/layer_by_layer_profiler/include/layer_by_layer_profiler.hpp @@ -23,6 +23,7 @@ #include "tensorflow/lite/kernels/internal/compatibility.h" #include #include +#include // NOTE: This profiler only works on systems with 1 NPU due to the use of // ethosu_reserve_driver(). @@ -30,22 +31,32 @@ namespace tflite { class LayerByLayerProfiler : public MicroProfiler { public: enum Backend { PRINTF, EVENT_RECORDER }; - LayerByLayerProfiler(size_t max_events = 200, - Backend backend = PRINTF, - int32_t event_id = EventID(EventLevelError, EvtStatistics_No, EventRecordNone)); + LayerByLayerProfiler(const std::vector &event_config = {}, + bool pmu_cycle_counter_enable = true, + size_t max_events = 200, + Backend backend = PRINTF, + int32_t event_id = EventID(EventLevelError, EvtStatistics_No, EventRecordNone)); uint32_t BeginEvent(const char *tag); void EndEvent(uint32_t event_handle); uint64_t GetTotalTicks() const; void Log() const; + uint64_t GetPmuCycleCounterCount() const; + const std::vector &GetPmuEventCount() const; + private: - size_t max_events_; std::unique_ptr tags_; std::unique_ptr start_ticks_; std::unique_ptr end_ticks_; - Backend backend_; - int32_t event_id_; + std::vector pmu_event_config; + std::vector pmu_event_count; + bool pmu_cycle_counter_enable; + uint64_t pmu_cycle_counter_count; + + size_t max_events_; + Backend backend; + int32_t event_id; size_t num_events_; TF_LITE_REMOVE_VIRTUAL_DELETE; -- cgit v1.2.1