ArmNN
 24.02
JSONTimelineDecoder Class Reference

#include <JSONTimelineDecoder.hpp>

Inheritance diagram for JSONTimelineDecoder:
[legend]
Collaboration diagram for JSONTimelineDecoder:
[legend]

Classes

struct  JSONEntity
 
struct  Model
 

Public Member Functions

void PrintJSON (JSONEntity &entity, std::ostream &os)
 
std::string GetJSONString (JSONEntity &rootEntity)
 
std::string GetJSONEntityString (JSONEntity &entity, int &counter)
 
virtual TimelineStatus CreateEntity (const Entity &) override
 
virtual TimelineStatus CreateEventClass (const EventClass &) override
 
virtual TimelineStatus CreateEvent (const Event &) override
 
virtual TimelineStatus CreateLabel (const Label &) override
 
virtual TimelineStatus CreateRelationship (const Relationship &) override
 
const ModelGetModel ()
 

Detailed Description

Definition at line 19 of file JSONTimelineDecoder.hpp.

Member Function Documentation

◆ CreateEntity()

JSONTimelineDecoder::TimelineStatus CreateEntity ( const Entity &  entity)
overridevirtual

Definition at line 29 of file JSONTimelineDecoder.cpp.

30 {
31  JSONEntity jsonEntity(entity.m_Guid);
32  jsonEntity.SetType(ENTITY);
33  this->m_Model.jsonEntities.insert({entity.m_Guid, jsonEntity});
34  return TimelineStatus::TimelineStatus_Success;
35 }

References JSONTimelineDecoder::Model::jsonEntities, and JSONTimelineDecoder::JSONEntity::SetType().

◆ CreateEvent()

JSONTimelineDecoder::TimelineStatus CreateEvent ( const Event event)
overridevirtual

Definition at line 46 of file JSONTimelineDecoder.cpp.

47 {
48  JSONEntity jsonEntity(event.m_Guid);
49  jsonEntity.SetType(EVENT);
50  this->m_Model.events.insert({event.m_Guid, event});
51  this->m_Model.jsonEntities.insert({jsonEntity.GetGuid(), jsonEntity});
52  return TimelineStatus::TimelineStatus_Success;
53 }

References JSONTimelineDecoder::Model::events, JSONTimelineDecoder::JSONEntity::GetGuid(), JSONTimelineDecoder::Model::jsonEntities, and JSONTimelineDecoder::JSONEntity::SetType().

◆ CreateEventClass()

JSONTimelineDecoder::TimelineStatus CreateEventClass ( const EventClass &  eventClass)
overridevirtual

Definition at line 37 of file JSONTimelineDecoder.cpp.

38 {
39  JSONEntity jsonEntity(eventClass.m_Guid);
40  jsonEntity.SetType(EVENTCLASS);
41  this->m_Model.eventClasses.insert({eventClass.m_Guid, eventClass});
42  this->m_Model.jsonEntities.insert({eventClass.m_Guid, jsonEntity});
43  return TimelineStatus::TimelineStatus_Success;
44 }

References JSONTimelineDecoder::Model::eventClasses, JSONTimelineDecoder::Model::jsonEntities, and JSONTimelineDecoder::JSONEntity::SetType().

◆ CreateLabel()

JSONTimelineDecoder::TimelineStatus CreateLabel ( const Label &  label)
overridevirtual

Definition at line 55 of file JSONTimelineDecoder.cpp.

56 {
57  this->m_Model.labels.insert({label.m_Guid, label});
58  return TimelineStatus::TimelineStatus_Success;
59 }

References JSONTimelineDecoder::Model::labels.

◆ CreateRelationship()

JSONTimelineDecoder::TimelineStatus CreateRelationship ( const Relationship &  relationship)
overridevirtual

Definition at line 61 of file JSONTimelineDecoder.cpp.

62 {
63  if (relationship.m_RelationshipType == ITimelineDecoder::RelationshipType::RetentionLink)
64  {
65  HandleRetentionLink(relationship);
66  }
67  else if (relationship.m_RelationshipType == ITimelineDecoder::RelationshipType::LabelLink)
68  {
69  HandleLabelLink(relationship);
70  }
71  else if (relationship.m_RelationshipType == ITimelineDecoder::RelationshipType::ExecutionLink)
72  {
73  HandleExecutionLink(relationship);
74  }
75  else
76  {
77  m_Model.relationships.insert({relationship.m_Guid, relationship});
78  }
79 
80  return TimelineStatus::TimelineStatus_Success;
81 }

References JSONTimelineDecoder::Model::relationships.

◆ GetJSONEntityString()

std::string GetJSONEntityString ( JSONTimelineDecoder::JSONEntity entity,
int &  counter 
)

Definition at line 244 of file JSONTimelineDecoder.cpp.

245 {
246  std::string jsonEntityString;
247  if(entity.GetType() == LAYER)
248  {
249  return GetLayerJSONString(entity, counter, jsonEntityString);
250  }
251  else if (entity.GetType() == WORKLOAD)
252  {
253  return GetWorkloadJSONString(entity, counter, jsonEntityString);
254  }
255  else if (entity.GetType() == WORKLOAD_EXECUTION)
256  {
257  return GetWorkloadExecutionJSONString(entity, jsonEntityString);
258  }
259  else if (entity.GetType() == INFERENCE)
260  {
261  return jsonEntityString;
262  }
263  else
264  {
265  for (uint64_t child_entity_id : entity.childEntities)
266  {
267  JSONEntity& childEntity = this->m_Model.jsonEntities.at(child_entity_id);
268  jsonEntityString.append(GetJSONEntityString(childEntity, ++counter));
269  }
270  return jsonEntityString;
271  }
272 }

References JSONTimelineDecoder::JSONEntity::childEntities, JSONTimelineDecoder::JSONEntity::GetType(), and JSONTimelineDecoder::Model::jsonEntities.

Referenced by JSONTimelineDecoder::GetJSONString().

◆ GetJSONString()

std::string GetJSONString ( JSONTimelineDecoder::JSONEntity rootEntity)

Definition at line 224 of file JSONTimelineDecoder.cpp.

225 {
226  int counter = 0;
227  std::string json;
228  json.append("{\n");
229  if(rootEntity.GetType() != "")
230  {
231  json.append("\tArmNN");
232  json.append(": {\n");
233 
234  for (uint64_t childEntityId : rootEntity.childEntities)
235  {
236  JSONEntity& childEntity = this->m_Model.jsonEntities.at(childEntityId);
237  json.append(GetJSONEntityString(childEntity, counter));
238  }
239  }
240  json.append("}\n");
241  return json;
242 }

References JSONTimelineDecoder::JSONEntity::childEntities, JSONTimelineDecoder::GetJSONEntityString(), JSONTimelineDecoder::JSONEntity::GetType(), and JSONTimelineDecoder::Model::jsonEntities.

Referenced by JSONTimelineDecoder::PrintJSON().

◆ GetModel()

const JSONTimelineDecoder::Model & GetModel ( )

Definition at line 347 of file JSONTimelineDecoder.cpp.

348 {
349  return m_Model;
350 }

◆ PrintJSON()

void PrintJSON ( JSONTimelineDecoder::JSONEntity rootEntity,
std::ostream &  os 
)

Definition at line 218 of file JSONTimelineDecoder.cpp.

219 {
220  std::string jsonString = GetJSONString(rootEntity);
221  os << jsonString;
222 }

References JSONTimelineDecoder::GetJSONString().


The documentation for this class was generated from the following files:
armnn::timelinedecoder::JSONTimelineDecoder::GetJSONString
std::string GetJSONString(JSONEntity &rootEntity)
Definition: JSONTimelineDecoder.cpp:224
armnn::timelinedecoder::JSONTimelineDecoder::GetJSONEntityString
std::string GetJSONEntityString(JSONEntity &entity, int &counter)
Definition: JSONTimelineDecoder.cpp:244
armnn::timelinedecoder::JSONTimelineDecoder::Model::labels
std::map< uint64_t, Label > labels
Definition: JSONTimelineDecoder.hpp:48
armnn::timelinedecoder::JSONTimelineDecoder::Model::events
std::map< uint64_t, Event > events
Definition: JSONTimelineDecoder.hpp:49
armnn::timelinedecoder::JSONTimelineDecoder::Model::relationships
std::map< uint64_t, Relationship > relationships
Definition: JSONTimelineDecoder.hpp:47
armnn::timelinedecoder::JSONTimelineDecoder::Model::eventClasses
std::map< uint64_t, EventClass > eventClasses
Definition: JSONTimelineDecoder.hpp:50
armnn::timelinedecoder::JSONTimelineDecoder::Model::jsonEntities
std::map< uint64_t, JSONEntity > jsonEntities
Definition: JSONTimelineDecoder.hpp:46