From 7b4886faccb52af9afe7fdeffcbae87e7fbc1484 Mon Sep 17 00:00:00 2001 From: James Conroy Date: Thu, 11 Apr 2019 10:23:58 +0100 Subject: IVGCVSW-2543 Add timing for ExecuteNetwork inference * Adds a new command line option 'threshold-time' to ExecuteNetwork, the maximum allowed time for inference in EnqueueWorkload. * ExecuteNetwork now outputs inference time elapsed and (if supplied) threshold time. * If actual elapsed inference time is greater than supplied threshold time, fail the test. Change-Id: If441b49a29cf5450687c07500c9046a80ece56fc Signed-off-by: James Conroy --- tests/InferenceModel.hpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'tests/InferenceModel.hpp') diff --git a/tests/InferenceModel.hpp b/tests/InferenceModel.hpp index 25ccbee45a..e168923048 100644 --- a/tests/InferenceModel.hpp +++ b/tests/InferenceModel.hpp @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -506,7 +507,9 @@ public: return m_OutputBindings[outputIndex].second.GetNumElements(); } - void Run(const std::vector& inputContainers, std::vector& outputContainers) + std::chrono::duration Run( + const std::vector& inputContainers, + std::vector& outputContainers) { for (unsigned int i = 0; i < outputContainers.size(); ++i) { @@ -532,10 +535,15 @@ public: profiler->EnableProfiling(m_EnableProfiling); } + // Start timer to record inference time in EnqueueWorkload (in milliseconds) + const auto start_time = GetCurrentTime(); + armnn::Status ret = m_Runtime->EnqueueWorkload(m_NetworkIdentifier, MakeInputTensors(inputContainers), MakeOutputTensors(outputContainers)); + const auto end_time = GetCurrentTime(); + // if profiling is enabled print out the results if (profiler && profiler->IsProfilingEnabled()) { @@ -546,6 +554,10 @@ public: { throw armnn::Exception("IRuntime::EnqueueWorkload failed"); } + else + { + return std::chrono::duration(end_time - start_time); + } } const BindingPointInfo& GetInputBindingInfo(unsigned int inputIndex = 0u) const @@ -613,4 +625,17 @@ private: { return ::MakeOutputTensors(m_OutputBindings, outputDataContainers); } + + std::chrono::high_resolution_clock::time_point GetCurrentTime() + { + return std::chrono::high_resolution_clock::now(); + } + + std::chrono::duration GetTimeDuration( + std::chrono::high_resolution_clock::time_point& start_time, + std::chrono::high_resolution_clock::time_point& end_time) + { + return std::chrono::duration(end_time - start_time); + } + }; -- cgit v1.2.1