ArmNN
 21.02
ProfilingStateMachine.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include <atomic>
9 
11 
12 namespace armnn
13 {
14 
15 namespace profiling
16 {
17 
18 enum class ProfilingState
19 {
23  Active
24 };
25 
27 {
28 public:
30  ProfilingStateMachine(ProfilingState state) : m_State(state) {}
31 
32  ProfilingState GetCurrentState() const;
33  void TransitionToState(ProfilingState newState);
34  void Reset();
35 
37  {
38  IgnoreUnused(state1);
39  return false;
40  }
41 
42  template<typename T, typename... Args >
43  bool IsOneOfStates(T state1, T state2, Args... args)
44  {
45  if (state1 == state2)
46  {
47  return true;
48  }
49  else
50  {
51  return IsOneOfStates(state1, args...);
52  }
53  }
54 
55 private:
56  std::atomic<ProfilingState> m_State;
57 };
58 
59 constexpr char const* GetProfilingStateName(ProfilingState state)
60 {
61  switch (state)
62  {
63  case ProfilingState::Uninitialised: return "Uninitialised";
64  case ProfilingState::NotConnected: return "NotConnected";
65  case ProfilingState::WaitingForAck: return "WaitingForAck";
66  case ProfilingState::Active: return "Active";
67  default: return "Unknown";
68  }
69 }
70 
71 } // namespace profiling
72 
73 } // namespace armnn
74 
Copyright (c) 2021 ARM Limited and Contributors.
void IgnoreUnused(Ts &&...)
bool IsOneOfStates(T state1, T state2, Args... args)
constexpr char const * GetProfilingStateName(ProfilingState state)