ArmNN
 20.05
ActivateTimelineReportingCommandHandler.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2020 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
8 
9 #include <armnn/Exceptions.hpp>
10 #include <boost/format.hpp>
11 
12 namespace armnn
13 {
14 
15 namespace profiling
16 {
17 
19 {
20  ProfilingState currentState = m_StateMachine.GetCurrentState();
21 
22  if (!m_ReportStructure.has_value())
23  {
24  throw armnn::Exception(std::string("Profiling Service constructor must be initialised with an "
25  "IReportStructure argument in order to run timeline reporting"));
26  }
27 
28  switch ( currentState )
29  {
33  throw RuntimeException(boost::str(
34  boost::format("Activate Timeline Reporting Command Handler invoked while in a wrong state: %1%")
35  % GetProfilingStateName(currentState)));
37  if ( !( packet.GetPacketFamily() == 0u && packet.GetPacketId() == 6u ))
38  {
39  throw armnn::Exception(std::string("Expected Packet family = 0, id = 6 but received family =")
40  + std::to_string(packet.GetPacketFamily())
41  + " id = " + std::to_string(packet.GetPacketId()));
42  }
43 
44  m_SendTimelinePacket.SendTimelineMessageDirectoryPackage();
45 
47 
48  m_TimelineReporting = true;
49 
50  m_ReportStructure.value().ReportStructure();
51 
52  m_BackendNotifier.NotifyBackendsForTimelineReporting();
53 
54  break;
55  default:
56  throw RuntimeException(boost::str(boost::format("Unknown profiling service state: %1%")
57  % static_cast<int>(currentState)));
58  }
59 }
60 
61 } // namespace profiling
62 
63 } // namespace armnn
virtual void NotifyBackendsForTimelineReporting()=0
void SendTimelineMessageDirectoryPackage() override
Create and write a TimelineMessageDirectoryPackage in the buffer.
Copyright (c) 2020 ARM Limited.
Base class for all ArmNN exceptions so that users can filter to just those.
Definition: Exceptions.hpp:46
static void SendWellKnownLabelsAndEventClasses(ISendTimelinePacket &timelinePacket)
constexpr char const * GetProfilingStateName(ProfilingState state)