diff options
author | Jonny Svärd <jonny.svaerd@arm.com> | 2022-05-10 17:29:30 +0200 |
---|---|---|
committer | Kristofer Jonsson <kristofer.jonsson@arm.com> | 2022-06-14 10:23:21 +0000 |
commit | 2ebaac7a007cbfae7fff818e4d6c4c33562eea0e (patch) | |
tree | 928435cf7c8312c8c03a921c33bc7e3b791980b3 /lib | |
parent | a3b7c692625205bbff3e078c378f146dd2578efd (diff) | |
download | ethos-u-core-software-2ebaac7a007cbfae7fff818e4d6c4c33562eea0e.tar.gz |
Refactor performance measurements
Change 'Inference runtime' to measure CPU cycles for the
Tensorflow Lite Micro interpreter.Invoke() call.
Add 'Operator(s) runtime' print that prints a summary for
cycles spent on all operators during an inference. (This is
equivalent to the old reported 'Inference runtime')
Move prints out of the EndEvent() function in ArmProfiler as
it otherwise interferes with the inference cycle measurement.
Change-Id: Ie11b5abb5b12a3bcf5a67841f04834d05dfd796d
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arm_profiler/include/arm_profiler.hpp | 1 | ||||
-rw-r--r-- | lib/arm_profiler/src/arm_profiler.cpp | 10 |
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/arm_profiler/include/arm_profiler.hpp b/lib/arm_profiler/include/arm_profiler.hpp index 0b97e2e..0e6784d 100644 --- a/lib/arm_profiler/include/arm_profiler.hpp +++ b/lib/arm_profiler/include/arm_profiler.hpp @@ -31,6 +31,7 @@ public: uint32_t BeginEvent(const char *tag); void EndEvent(uint32_t event_handle); uint64_t GetTotalTicks() const; + void ReportResults() const; private: size_t max_events_; diff --git a/lib/arm_profiler/src/arm_profiler.cpp b/lib/arm_profiler/src/arm_profiler.cpp index c90eec2..7648584 100644 --- a/lib/arm_profiler/src/arm_profiler.cpp +++ b/lib/arm_profiler/src/arm_profiler.cpp @@ -50,8 +50,6 @@ uint32_t ArmProfiler::BeginEvent(const char *tag) { void ArmProfiler::EndEvent(uint32_t event_handle) { TFLITE_DCHECK(event_handle < max_events_); end_ticks_[event_handle] = GetCurrentTimeTicks(); - tflite::GetMicroErrorReporter()->Report( - "%s : cycle_cnt : %u cycles", tags_[event_handle], end_ticks_[event_handle] - start_ticks_[event_handle]); } uint64_t ArmProfiler::GetTotalTicks() const { @@ -64,4 +62,12 @@ uint64_t ArmProfiler::GetTotalTicks() const { return ticks; } +void ArmProfiler::ReportResults() const { + tflite::GetMicroErrorReporter()->Report("Profiler report, CPU cycles per operator:"); + for (size_t i = 0; i < num_events_; ++i) { + tflite::GetMicroErrorReporter()->Report( + "%s : cycle_cnt : %u cycles", tags_[i], end_ticks_[i] - start_ticks_[i]); + } +} + } // namespace tflite |