ArmNN
 20.05
JSONTimelineDecoder.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2020 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
9 
10 #include <map>
11 #include <vector>
12 #include <boost/filesystem/path.hpp>
13 #include <boost/filesystem.hpp>
14 
15 namespace armnn
16 {
17 namespace timelinedecoder
18 {
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);
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  void SetOutgoingCaptureFile(const std::string& basicString);
65 
66 private:
67  Model m_Model;
68  boost::filesystem::path fileDir = boost::filesystem::temp_directory_path();
69  boost::filesystem::path p{fileDir / boost::filesystem::unique_path("output.json")};
70 
71  std::string outputJSONFile = p.string();
72 
73  void HandleRetentionLink(const Relationship& relationship);
74  void HandleLabelLink(const Relationship& relationship);
75  void HandleExecutionLink(const Relationship& relationship);
76  void HandleConnectionLabel(const Relationship& relationship);
77  void HandleBackendIdLabel(const Relationship& relationship);
78  void HandleNameLabel(const Relationship& relationship);
79  void HandleTypeLabel(const Relationship& relationship);
80 
81  std::string GetLayerJSONString(JSONEntity& entity, int& counter, std::string& jsonEntityString);
82  std::string GetWorkloadJSONString(const JSONEntity& entity, int& counter, std::string& jsonEntityString);
83  std::string GetWorkloadExecutionJSONString(const JSONEntity& entity, std::string& jsonEntityString) const;
84 };
85 
86 }
87 }
void AddConnection(JSONEntity &headEntity, JSONEntity &connectedEntity)
Copyright (c) 2020 ARM Limited.
void SetOutgoingCaptureFile(const std::string &basicString)
std::string GetJSONEntityString(JSONEntity &entity, int &counter)
virtual TimelineStatus CreateEntity(const Entity &) override
virtual TimelineStatus CreateEventClass(const EventClass &) override
std::string GetJSONString(JSONEntity &rootEntity)
virtual TimelineStatus CreateLabel(const Label &) override
virtual TimelineStatus CreateEvent(const Event &) override
virtual TimelineStatus CreateRelationship(const Relationship &) override