2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
6 #include "NeonTimer.hpp"
7 #include "NeonInterceptorScheduler.hpp"
9 #include <armnn/utility/Assert.hpp>
13 #include <boost/format.hpp>
19 static thread_local auto g_Interceptor = std::make_shared<NeonInterceptorScheduler>(arm_compute::Scheduler::get());
22 void NeonTimer::Start()
25 ARMNN_ASSERT(g_Interceptor->GetKernels() == nullptr);
26 g_Interceptor->SetKernels(&m_Kernels);
28 m_RealSchedulerType = arm_compute::Scheduler::get_type();
29 //Note: We can't currently replace a custom scheduler
30 if(m_RealSchedulerType != arm_compute::Scheduler::Type::CUSTOM)
32 // Keep the real schedule and add NeonInterceptorScheduler as an interceptor
33 m_RealScheduler = &arm_compute::Scheduler::get();
34 arm_compute::Scheduler::set(std::static_pointer_cast<arm_compute::IScheduler>(g_Interceptor));
38 void NeonTimer::Stop()
40 // Restore real scheduler
41 g_Interceptor->SetKernels(nullptr);
42 arm_compute::Scheduler::set(m_RealSchedulerType);
43 m_RealScheduler = nullptr;
46 std::vector<Measurement> NeonTimer::GetMeasurements() const
48 std::vector<Measurement> measurements = m_Kernels;
49 unsigned int kernel_number = 0;
50 for (auto & kernel : measurements)
52 std::string kernelName = std::string(this->GetName()) + "/" + std::to_string(kernel_number++) + ": " + kernel
54 kernel.m_Name = kernelName;
59 const char* NeonTimer::GetName() const
61 return "NeonKernelTimer";