ArmNN
 20.05
NeonTimer.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "NeonTimer.hpp"
8 
10 
11 #include <memory>
12 
13 #include <boost/format.hpp>
14 
15 namespace armnn
16 {
17 namespace
18 {
19 static thread_local auto g_Interceptor = std::make_shared<NeonInterceptorScheduler>(arm_compute::Scheduler::get());
20 }
21 
23 {
24  m_Kernels.clear();
25  ARMNN_ASSERT(g_Interceptor->GetKernels() == nullptr);
26  g_Interceptor->SetKernels(&m_Kernels);
27 
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)
31  {
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));
35  }
36 }
37 
39 {
40  // Restore real scheduler
41  g_Interceptor->SetKernels(nullptr);
42  arm_compute::Scheduler::set(m_RealSchedulerType);
43  m_RealScheduler = nullptr;
44 }
45 
46 std::vector<Measurement> NeonTimer::GetMeasurements() const
47 {
48  std::vector<Measurement> measurements = m_Kernels;
49  unsigned int kernel_number = 0;
50  for (auto & kernel : measurements)
51  {
52  std::string kernelName = std::string(this->GetName()) + "/" + std::to_string(kernel_number++) + ": " + kernel
53  .m_Name;
54  kernel.m_Name = kernelName;
55  }
56  return measurements;
57 }
58 
59 const char* NeonTimer::GetName() const
60 {
61  return "NeonKernelTimer";
62 }
63 
64 }
std::vector< Measurement > GetMeasurements() const override
Definition: NeonTimer.cpp:46
void Start() override
Definition: NeonTimer.cpp:22
Copyright (c) 2020 ARM Limited.
void Stop() override
Definition: NeonTimer.cpp:38
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
const char * GetName() const override
Definition: NeonTimer.cpp:59