diff options
Diffstat (limited to 'src/armnn')
-rw-r--r-- | src/armnn/NeonInterceptorScheduler.cpp | 2 | ||||
-rw-r--r-- | src/armnn/WallClockTimer.cpp | 26 | ||||
-rw-r--r-- | src/armnn/WallClockTimer.hpp | 4 | ||||
-rw-r--r-- | src/armnn/test/JsonPrinterTests.cpp | 6 |
4 files changed, 32 insertions, 6 deletions
diff --git a/src/armnn/NeonInterceptorScheduler.cpp b/src/armnn/NeonInterceptorScheduler.cpp index 8363def68e..7e2737e89e 100644 --- a/src/armnn/NeonInterceptorScheduler.cpp +++ b/src/armnn/NeonInterceptorScheduler.cpp @@ -31,6 +31,7 @@ void NeonInterceptorScheduler::schedule(arm_compute::ICPPKernel* kernel, const H m_RealScheduler.schedule(kernel, hints.split_dimension()); m_Timer.Stop(); + m_Timer.SetScaleFactor(Measurement::Unit::TIME_US); std::vector<Measurement> measurements = m_Timer.GetMeasurements(); BOOST_ASSERT(!measurements.empty()); @@ -46,6 +47,7 @@ void NeonInterceptorScheduler::run_workloads(std::vector <Workload>& workloads) m_RealScheduler.run_tagged_workloads(workloads, nullptr); m_Timer.Stop(); + m_Timer.SetScaleFactor(Measurement::Unit::TIME_US); std::vector<Measurement> measurements = m_Timer.GetMeasurements(); BOOST_ASSERT_MSG(measurements.size() == 3, "WallClockTimer does not have correct amount of measurements."); diff --git a/src/armnn/WallClockTimer.cpp b/src/armnn/WallClockTimer.cpp index 882b7eb6ef..911b0147e0 100644 --- a/src/armnn/WallClockTimer.cpp +++ b/src/armnn/WallClockTimer.cpp @@ -4,6 +4,7 @@ // #include "WallClockTimer.hpp" +#include "armnn/Exceptions.hpp" namespace armnn { @@ -27,15 +28,34 @@ void WallClockTimer::Stop() m_Stop = clock::now(); } +void WallClockTimer::SetScaleFactor(Measurement::Unit measurementUnit) +{ + switch(measurementUnit) + { + case Measurement::TIME_MS: + m_ScaleFactor = 1.f; + break; + case Measurement::TIME_US: + m_ScaleFactor = 1000.f; + break; + case Measurement::TIME_NS: + m_ScaleFactor = 1000000.f; + break; + default: + throw InvalidArgumentException("Invalid scale used"); + } + m_Unit = measurementUnit; +} + std::vector<Measurement> WallClockTimer::GetMeasurements() const { const auto delta = std::chrono::duration<double, std::milli>(m_Stop - m_Start); const auto startTimeMs = std::chrono::duration<double, std::milli>(m_Start.time_since_epoch()); const auto stopTimeMs = std::chrono::duration<double, std::milli>(m_Stop.time_since_epoch()); - return { { WALL_CLOCK_TIME, delta.count(), Measurement::Unit::TIME_MS }, - { WALL_CLOCK_TIME_START, startTimeMs.count(), Measurement::Unit::TIME_MS }, - { WALL_CLOCK_TIME_STOP, stopTimeMs.count(), Measurement::Unit::TIME_MS } }; + return { { WALL_CLOCK_TIME, delta.count() * m_ScaleFactor, m_Unit }, + { WALL_CLOCK_TIME_START, startTimeMs.count() * m_ScaleFactor, m_Unit }, + { WALL_CLOCK_TIME_STOP, stopTimeMs.count() * m_ScaleFactor, m_Unit } }; } } //namespace armnn diff --git a/src/armnn/WallClockTimer.hpp b/src/armnn/WallClockTimer.hpp index 5e88382015..09cc514eae 100644 --- a/src/armnn/WallClockTimer.hpp +++ b/src/armnn/WallClockTimer.hpp @@ -42,6 +42,8 @@ public: // Get the name of the timer const char* GetName() const override; + void SetScaleFactor(Measurement::Unit measurementUnit); + // Get the recorded measurements std::vector<Measurement> GetMeasurements() const override; @@ -58,6 +60,8 @@ public: private: clock::time_point m_Start; clock::time_point m_Stop; + float m_ScaleFactor = 1.f; + Measurement::Unit m_Unit = Measurement::Unit::TIME_MS; }; } //namespace armnn diff --git a/src/armnn/test/JsonPrinterTests.cpp b/src/armnn/test/JsonPrinterTests.cpp index 18adfc258d..01078e3666 100644 --- a/src/armnn/test/JsonPrinterTests.cpp +++ b/src/armnn/test/JsonPrinterTests.cpp @@ -276,7 +276,7 @@ void SetupSoftmaxProfilerWithSpecifiedBackendsAndValidateJSONPrinterResult( break; case armnn::Compute::CpuAcc: backend = "Neon"; changeLine31 = ",\n\"NeonKernelTimer/: NEFillBorderKernel\": {"; - changeLine39 = R"(ms" + changeLine39 = R"(us" }, "NeonKernelTimer/: NELogitsDMaxKernel": { "raw": [ @@ -284,7 +284,7 @@ void SetupSoftmaxProfilerWithSpecifiedBackendsAndValidateJSONPrinterResult( , ], -"unit": "ms" +"unit": "us" }, "NeonKernelTimer/: NELogitsDSoftmaxKernel": { "raw": [ @@ -292,7 +292,7 @@ void SetupSoftmaxProfilerWithSpecifiedBackendsAndValidateJSONPrinterResult( , ], -"unit": "ms")"; +"unit": "us")"; changeLine40 = R"( }, "CopyMemGeneric_Execute": { |