blob: a6e2579b459e20099ab7d59fdbf1a97cf5427e09 [file] [log] [blame]
Éanna Ó Catháin0de47122020-04-01 15:40:12 +01001//
Jan Eilers1f249442020-07-01 15:37:50 +01002// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
Éanna Ó Catháin0de47122020-04-01 15:40:12 +01003// SPDX-License-Identifier: MIT
4//
5
6#pragma once
7
Finn Williams0c8cb992020-05-07 10:38:15 +01008#include <armnn/profiling/ITimelineDecoder.hpp>
Éanna Ó Catháin0de47122020-04-01 15:40:12 +01009
Francis Murtagh532a29d2020-06-29 11:50:01 +010010#include <Filesystem.hpp>
Éanna Ó Catháin0de47122020-04-01 15:40:12 +010011#include <map>
12#include <vector>
13
14namespace armnn
15{
16namespace timelinedecoder
17{
18class JSONTimelineDecoder : public ITimelineDecoder
19{
20public:
21 struct JSONEntity
22 {
23 public:
24 std::vector<uint64_t> connected_entities;
25 std::vector<uint64_t> childEntities;
26
27 JSONEntity(uint64_t guid): m_Guid(guid){}
28 uint64_t GetGuid();
29 std::string GetName();
30 std::string GetType();
31 void SetName(std::string entityName);
32 void SetType(std::string entityType);
33 void SetParent(JSONEntity& parent);
34 void AddConnection(JSONEntity& headEntity, JSONEntity& connectedEntity);
35 std::map<std::string, std::string> extendedData;
36
37 private:
38 uint64_t m_Guid;
39 std::string name;
40 std::string type;
41 };
42
43 struct Model
44 {
45 std::map<uint64_t, JSONEntity> jsonEntities;
46 std::map<uint64_t, Relationship> relationships;
47 std::map<uint64_t, Label> labels;
48 std::map<uint64_t, Event> events;
49 std::map<uint64_t, EventClass> eventClasses;
50 };
51
Jan Eilers1f249442020-07-01 15:37:50 +010052 void PrintJSON(JSONEntity& entity, std::ostream& os);
Éanna Ó Catháin0de47122020-04-01 15:40:12 +010053 std::string GetJSONString(JSONEntity& rootEntity);
54 std::string GetJSONEntityString(JSONEntity& entity, int& counter);
55
56 virtual TimelineStatus CreateEntity(const Entity&) override;
57 virtual TimelineStatus CreateEventClass(const EventClass&) override;
58 virtual TimelineStatus CreateEvent(const Event&) override;
59 virtual TimelineStatus CreateLabel(const Label&) override;
60 virtual TimelineStatus CreateRelationship(const Relationship&) override;
61
62 const Model& GetModel();
Éanna Ó Catháin0de47122020-04-01 15:40:12 +010063
64private:
65 Model m_Model;
Éanna Ó Catháin0de47122020-04-01 15:40:12 +010066
67 void HandleRetentionLink(const Relationship& relationship);
68 void HandleLabelLink(const Relationship& relationship);
69 void HandleExecutionLink(const Relationship& relationship);
70 void HandleConnectionLabel(const Relationship& relationship);
71 void HandleBackendIdLabel(const Relationship& relationship);
72 void HandleNameLabel(const Relationship& relationship);
73 void HandleTypeLabel(const Relationship& relationship);
74
75 std::string GetLayerJSONString(JSONEntity& entity, int& counter, std::string& jsonEntityString);
76 std::string GetWorkloadJSONString(const JSONEntity& entity, int& counter, std::string& jsonEntityString);
77 std::string GetWorkloadExecutionJSONString(const JSONEntity& entity, std::string& jsonEntityString) const;
78};
79
80}
81}