ArmNN
 23.05
JSONTimelineDecoder.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include <server/include/timelineDecoder/ITimelineDecoder.hpp>
9 
11 
12 #include <map>
13 #include <vector>
14 
15 namespace armnn
16 {
17 namespace timelinedecoder
18 {
19 class JSONTimelineDecoder : public arm::pipe::ITimelineDecoder
20 {
21 public:
22  struct JSONEntity
23  {
24  public:
25  std::vector<uint64_t> connected_entities;
26  std::vector<uint64_t> childEntities;
27 
28  JSONEntity(uint64_t guid): m_Guid(guid){}
29  uint64_t GetGuid();
30  std::string GetName();
31  std::string GetType();
32  void SetName(std::string entityName);
33  void SetType(std::string entityType);
34  void SetParent(JSONEntity& parent);
35  void AddConnection(JSONEntity& headEntity, JSONEntity& connectedEntity);
36  std::map<std::string, std::string> extendedData;
37 
38  private:
39  uint64_t m_Guid;
40  std::string name;
41  std::string type;
42  };
43 
44  struct Model
45  {
46  std::map<uint64_t, JSONEntity> jsonEntities;
47  std::map<uint64_t, Relationship> relationships;
48  std::map<uint64_t, Label> labels;
49  std::map<uint64_t, Event> events;
50  std::map<uint64_t, EventClass> eventClasses;
51  };
52 
53  void PrintJSON(JSONEntity& entity, std::ostream& os);
54  std::string GetJSONString(JSONEntity& rootEntity);
55  std::string GetJSONEntityString(JSONEntity& entity, int& counter);
56 
57  virtual TimelineStatus CreateEntity(const Entity&) override;
58  virtual TimelineStatus CreateEventClass(const EventClass&) override;
59  virtual TimelineStatus CreateEvent(const Event&) override;
60  virtual TimelineStatus CreateLabel(const Label&) override;
61  virtual TimelineStatus CreateRelationship(const Relationship&) override;
62 
63  const Model& GetModel();
64 
65 private:
66  Model m_Model;
67 
68  void HandleRetentionLink(const Relationship& relationship);
69  void HandleLabelLink(const Relationship& relationship);
70  void HandleExecutionLink(const Relationship& relationship);
71  void HandleConnectionLabel(const Relationship& relationship);
72  void HandleBackendIdLabel(const Relationship& relationship);
73  void HandleNameLabel(const Relationship& relationship);
74  void HandleTypeLabel(const Relationship& relationship);
75 
76  std::string GetLayerJSONString(JSONEntity& entity, int& counter, std::string& jsonEntityString);
77  std::string GetWorkloadJSONString(const JSONEntity& entity, int& counter, std::string& jsonEntityString);
78  std::string GetWorkloadExecutionJSONString(const JSONEntity& entity, std::string& jsonEntityString) const;
79 };
80 
81 }
82 }
armnn::timelinedecoder::JSONTimelineDecoder::Model::events
std::map< uint64_t, Event > events
Definition: JSONTimelineDecoder.hpp:49
armnn::timelinedecoder::JSONTimelineDecoder::CreateLabel
virtual TimelineStatus CreateLabel(const Label &) override
Definition: JSONTimelineDecoder.cpp:55
armnn::timelinedecoder::JSONTimelineDecoder::JSONEntity::AddConnection
void AddConnection(JSONEntity &headEntity, JSONEntity &connectedEntity)
Definition: JSONTimelineDecoder.cpp:334
armnn::timelinedecoder::JSONTimelineDecoder::JSONEntity::SetType
void SetType(std::string entityType)
Definition: JSONTimelineDecoder.cpp:362
armnn::timelinedecoder::JSONTimelineDecoder::JSONEntity::GetGuid
uint64_t GetGuid()
Definition: JSONTimelineDecoder.cpp:342
armnn::timelinedecoder::JSONTimelineDecoder::CreateEntity
virtual TimelineStatus CreateEntity(const Entity &) override
Definition: JSONTimelineDecoder.cpp:29
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::timelinedecoder::JSONTimelineDecoder::CreateRelationship
virtual TimelineStatus CreateRelationship(const Relationship &) override
Definition: JSONTimelineDecoder.cpp:61
armnn::timelinedecoder::JSONTimelineDecoder::GetJSONString
std::string GetJSONString(JSONEntity &rootEntity)
Definition: JSONTimelineDecoder.cpp:224
armnn::timelinedecoder::JSONTimelineDecoder::JSONEntity
Definition: JSONTimelineDecoder.hpp:22
armnn::timelinedecoder::JSONTimelineDecoder::GetModel
const Model & GetModel()
Definition: JSONTimelineDecoder.cpp:347
armnn::timelinedecoder::JSONTimelineDecoder::JSONEntity::SetParent
void SetParent(JSONEntity &parent)
Definition: JSONTimelineDecoder.cpp:213
armnn::Event
Event class records measurements reported by BeginEvent()/EndEvent() and returns measurements when Ev...
Definition: ProfilingEvent.hpp:27
armnn::timelinedecoder::JSONTimelineDecoder::JSONEntity::extendedData
std::map< std::string, std::string > extendedData
Definition: JSONTimelineDecoder.hpp:36
armnn::timelinedecoder::JSONTimelineDecoder
Definition: JSONTimelineDecoder.hpp:19
armnn::timelinedecoder::JSONTimelineDecoder::PrintJSON
void PrintJSON(JSONEntity &entity, std::ostream &os)
Definition: JSONTimelineDecoder.cpp:218
armnn::timelinedecoder::JSONTimelineDecoder::Model::relationships
std::map< uint64_t, Relationship > relationships
Definition: JSONTimelineDecoder.hpp:47
armnn::timelinedecoder::JSONTimelineDecoder::Model::labels
std::map< uint64_t, Label > labels
Definition: JSONTimelineDecoder.hpp:48
Filesystem.hpp
armnn::timelinedecoder::JSONTimelineDecoder::JSONEntity::JSONEntity
JSONEntity(uint64_t guid)
Definition: JSONTimelineDecoder.hpp:28
armnn::timelinedecoder::JSONTimelineDecoder::CreateEvent
virtual TimelineStatus CreateEvent(const Event &) override
Definition: JSONTimelineDecoder.cpp:46
armnn::timelinedecoder::JSONTimelineDecoder::JSONEntity::GetType
std::string GetType()
Definition: JSONTimelineDecoder.cpp:367
armnn::timelinedecoder::JSONTimelineDecoder::JSONEntity::connected_entities
std::vector< uint64_t > connected_entities
Definition: JSONTimelineDecoder.hpp:25
armnn::timelinedecoder::JSONTimelineDecoder::GetJSONEntityString
std::string GetJSONEntityString(JSONEntity &entity, int &counter)
Definition: JSONTimelineDecoder.cpp:244
armnn::timelinedecoder::JSONTimelineDecoder::Model::jsonEntities
std::map< uint64_t, JSONEntity > jsonEntities
Definition: JSONTimelineDecoder.hpp:46
armnn::timelinedecoder::JSONTimelineDecoder::CreateEventClass
virtual TimelineStatus CreateEventClass(const EventClass &) override
Definition: JSONTimelineDecoder.cpp:37
armnn::timelinedecoder::JSONTimelineDecoder::JSONEntity::childEntities
std::vector< uint64_t > childEntities
Definition: JSONTimelineDecoder.hpp:26
armnn::timelinedecoder::JSONTimelineDecoder::JSONEntity::SetName
void SetName(std::string entityName)
Definition: JSONTimelineDecoder.cpp:352
armnn::timelinedecoder::JSONTimelineDecoder::Model::eventClasses
std::map< uint64_t, EventClass > eventClasses
Definition: JSONTimelineDecoder.hpp:50
armnn::timelinedecoder::JSONTimelineDecoder::Model
Definition: JSONTimelineDecoder.hpp:44
armnn::timelinedecoder::JSONTimelineDecoder::JSONEntity::GetName
std::string GetName()
Definition: JSONTimelineDecoder.cpp:357