ArmNN
 21.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 namespace armnn
14 {
15 namespace
16 {
17 static thread_local auto g_Interceptor = std::make_shared<NeonInterceptorScheduler>(arm_compute::Scheduler::get());
18 }
19 
21 {
22  m_Kernels.clear();
23  ARMNN_ASSERT(g_Interceptor->GetKernels() == nullptr);
24  g_Interceptor->SetKernels(&m_Kernels);
25 
26  m_RealSchedulerType = arm_compute::Scheduler::get_type();
27  //Note: We can't currently replace a custom scheduler
28  if(m_RealSchedulerType != arm_compute::Scheduler::Type::CUSTOM)
29  {
30  // Keep the real schedule and add NeonInterceptorScheduler as an interceptor
31  m_RealScheduler = &arm_compute::Scheduler::get();
32  arm_compute::Scheduler::set(std::static_pointer_cast<arm_compute::IScheduler>(g_Interceptor));
33  }
34 }
35 
37 {
38  // Restore real scheduler
39  g_Interceptor->SetKernels(nullptr);
40  arm_compute::Scheduler::set(m_RealSchedulerType);
41  m_RealScheduler = nullptr;
42 }
43 
44 std::vector<Measurement> NeonTimer::GetMeasurements() const
45 {
46  std::vector<Measurement> measurements = m_Kernels;
47  unsigned int kernel_number = 0;
48  for (auto & kernel : measurements)
49  {
50  std::string kernelName = std::string(this->GetName()) + "/" + std::to_string(kernel_number++) + ": " + kernel
51  .m_Name;
52  kernel.m_Name = kernelName;
53  }
54  return measurements;
55 }
56 
57 const char* NeonTimer::GetName() const
58 {
59  return "NeonKernelTimer";
60 }
61 
62 }
std::vector< Measurement > GetMeasurements() const override
Definition: NeonTimer.cpp:44
void Start() override
Definition: NeonTimer.cpp:20
Copyright (c) 2021 ARM Limited and Contributors.
void Stop() override
Definition: NeonTimer.cpp:36
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
const char * GetName() const override
Definition: NeonTimer.cpp:57