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
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 <memory>
 #include <pmu_ethosu.h>
+#include <vector>
 
 // NOTE: This profiler only works on systems with 1 NPU due to the use of
 // ethosu_reserve_driver().
@@ -30,22 +31,32 @@
 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<uint8_t> &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<uint32_t> &GetPmuEventCount() const;
+
 private:
-    size_t max_events_;
     std::unique_ptr<const char *[]> tags_;
     std::unique_ptr<uint64_t[]> start_ticks_;
     std::unique_ptr<uint64_t[]> end_ticks_;
 
-    Backend backend_;
-    int32_t event_id_;
+    std::vector<uint8_t> pmu_event_config;
+    std::vector<uint32_t> 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;