ArmNN
 20.05
JSONTimelineDecoder Class Reference

#include <JSONTimelineDecoder.hpp>

Inheritance diagram for JSONTimelineDecoder:
ITimelineDecoder

Classes

struct  JSONEntity
 
struct  Model
 

Public Member Functions

void PrintJSON (JSONEntity &entity)
 
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 ()
 
void SetOutgoingCaptureFile (const std::string &basicString)
 
- Public Member Functions inherited from ITimelineDecoder
virtual ~ITimelineDecoder ()=default
 

Additional Inherited Members

- Public Types inherited from ITimelineDecoder
enum  TimelineStatus { TimelineStatus_Success, TimelineStatus_Fail }
 
enum  RelationshipType { RetentionLink, ExecutionLink, DataLink, LabelLink }
 
- Static Public Member Functions inherited from ITimelineDecoder
static char const * GetRelationshipAsCString (RelationshipType rType)
 

Detailed Description

Definition at line 19 of file JSONTimelineDecoder.hpp.

Member Function Documentation

◆ CreateEntity()

JSONTimelineDecoder::TimelineStatus CreateEntity ( const Entity entity)
overridevirtual

Implements ITimelineDecoder.

Definition at line 30 of file JSONTimelineDecoder.cpp.

References JSONTimelineDecoder::Model::jsonEntities, ITimelineDecoder::Entity::m_Guid, JSONTimelineDecoder::JSONEntity::SetType(), and ITimelineDecoder::TimelineStatus_Success.

Referenced by RunSimpleModelThroughDecoder().

31 {
32  JSONEntity jsonEntity(entity.m_Guid);
33  jsonEntity.SetType(ENTITY);
34  this->m_Model.jsonEntities.insert({entity.m_Guid, jsonEntity});
36 }

◆ CreateEvent()

JSONTimelineDecoder::TimelineStatus CreateEvent ( const Event event)
overridevirtual

Implements ITimelineDecoder.

Definition at line 47 of file JSONTimelineDecoder.cpp.

References JSONTimelineDecoder::Model::events, JSONTimelineDecoder::JSONEntity::GetGuid(), JSONTimelineDecoder::Model::jsonEntities, ITimelineDecoder::Event::m_Guid, JSONTimelineDecoder::JSONEntity::SetType(), and ITimelineDecoder::TimelineStatus_Success.

Referenced by RunSimpleModelThroughDecoder().

48 {
49  JSONEntity jsonEntity(event.m_Guid);
50  jsonEntity.SetType(EVENT);
51  this->m_Model.events.insert({event.m_Guid, event});
52  this->m_Model.jsonEntities.insert({jsonEntity.GetGuid(), jsonEntity});
54 }

◆ CreateEventClass()

JSONTimelineDecoder::TimelineStatus CreateEventClass ( const EventClass eventClass)
overridevirtual

Implements ITimelineDecoder.

Definition at line 38 of file JSONTimelineDecoder.cpp.

References JSONTimelineDecoder::Model::eventClasses, JSONTimelineDecoder::Model::jsonEntities, ITimelineDecoder::EventClass::m_Guid, JSONTimelineDecoder::JSONEntity::SetType(), and ITimelineDecoder::TimelineStatus_Success.

Referenced by RunSimpleModelThroughDecoder().

39 {
40  JSONEntity jsonEntity(eventClass.m_Guid);
41  jsonEntity.SetType(EVENTCLASS);
42  this->m_Model.eventClasses.insert({eventClass.m_Guid, eventClass});
43  this->m_Model.jsonEntities.insert({eventClass.m_Guid, jsonEntity});
45 }

◆ CreateLabel()

◆ CreateRelationship()

JSONTimelineDecoder::TimelineStatus CreateRelationship ( const Relationship relationship)
overridevirtual

Implements ITimelineDecoder.

Definition at line 62 of file JSONTimelineDecoder.cpp.

References JSONTimelineDecoder::JSONEntity::AddConnection(), ITimelineDecoder::ExecutionLink, JSONTimelineDecoder::JSONEntity::extendedData, JSONTimelineDecoder::Model::jsonEntities, ITimelineDecoder::LabelLink, JSONTimelineDecoder::Model::labels, ITimelineDecoder::Relationship::m_Guid, ITimelineDecoder::Relationship::m_HeadGuid, ITimelineDecoder::Relationship::m_RelationshipType, ITimelineDecoder::Relationship::m_TailGuid, JSONTimelineDecoder::Model::relationships, ITimelineDecoder::RetentionLink, JSONTimelineDecoder::JSONEntity::SetName(), JSONTimelineDecoder::JSONEntity::SetParent(), JSONTimelineDecoder::JSONEntity::SetType(), and ITimelineDecoder::TimelineStatus_Success.

Referenced by RunSimpleModelThroughDecoder().

63 {
64  if (relationship.m_RelationshipType == ITimelineDecoder::RelationshipType::RetentionLink)
65  {
66  HandleRetentionLink(relationship);
67  }
68  else if (relationship.m_RelationshipType == ITimelineDecoder::RelationshipType::LabelLink)
69  {
70  HandleLabelLink(relationship);
71  }
72  else if (relationship.m_RelationshipType == ITimelineDecoder::RelationshipType::ExecutionLink)
73  {
74  HandleExecutionLink(relationship);
75  }
76  else
77  {
78  /*
79  * TODO Handle DataLink
80  */
81  m_Model.relationships.insert({relationship.m_Guid, relationship});
82  }
83 
85 }

◆ GetJSONEntityString()

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

Definition at line 274 of file JSONTimelineDecoder.cpp.

References JSONTimelineDecoder::JSONEntity::childEntities, JSONTimelineDecoder::Model::events, JSONTimelineDecoder::JSONEntity::extendedData, JSONTimelineDecoder::JSONEntity::GetGuid(), JSONTimelineDecoder::JSONEntity::GetName(), JSONTimelineDecoder::JSONEntity::GetType(), JSONTimelineDecoder::Model::jsonEntities, and ITimelineDecoder::Event::m_TimeStamp.

Referenced by JSONTimelineDecoder::GetJSONString().

275 {
276  std::string jsonEntityString;
277  if(entity.GetType() == LAYER)
278  {
279  return GetLayerJSONString(entity, counter, jsonEntityString);
280  }
281  else if (entity.GetType() == WORKLOAD)
282  {
283  return GetWorkloadJSONString(entity, counter, jsonEntityString);
284  }
285  else if (entity.GetType() == WORKLOAD_EXECUTION)
286  {
287  return GetWorkloadExecutionJSONString(entity, jsonEntityString);
288  }
289  else if (entity.GetType() == INFERENCE)
290  {
291  return jsonEntityString;
292  }
293  else
294  {
295  for (uint64_t child_entity_id : entity.childEntities)
296  {
297  JSONEntity& childEntity = this->m_Model.jsonEntities.at(child_entity_id);
298  jsonEntityString.append(GetJSONEntityString(childEntity, ++counter));
299  }
300  return jsonEntityString;
301  }
302 }
std::string GetJSONEntityString(JSONEntity &entity, int &counter)

◆ GetJSONString()

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

Definition at line 254 of file JSONTimelineDecoder.cpp.

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

Referenced by BOOST_AUTO_TEST_CASE(), and JSONTimelineDecoder::PrintJSON().

255 {
256  int counter = 0;
257  std::string json;
258  json.append("{\n");
259  if(rootEntity.GetType() != "")
260  {
261  json.append("\tArmNN");
262  json.append(": {\n");
263 
264  for (uint64_t childEntityId : rootEntity.childEntities)
265  {
266  JSONEntity& childEntity = this->m_Model.jsonEntities.at(childEntityId);
267  json.append(GetJSONEntityString(childEntity, counter));
268  }
269  }
270  json.append("}\n");
271  return json;
272 }
std::string GetJSONEntityString(JSONEntity &entity, int &counter)

◆ GetModel()

const JSONTimelineDecoder::Model & GetModel ( )

Definition at line 376 of file JSONTimelineDecoder.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

377 {
378  return m_Model;
379 }

◆ PrintJSON()

void PrintJSON ( JSONTimelineDecoder::JSONEntity rootEntity)

Definition at line 246 of file JSONTimelineDecoder.cpp.

References JSONTimelineDecoder::GetJSONString().

Referenced by BOOST_AUTO_TEST_CASE().

247 {
248  std::string jsonString = GetJSONString(rootEntity);
249  boost::filesystem::ofstream ofs{this->outputJSONFile};
250  ofs << jsonString;
251  ofs.close();
252 }
std::string GetJSONString(JSONEntity &rootEntity)

◆ SetOutgoingCaptureFile()

void SetOutgoingCaptureFile ( const std::string &  basicString)

Definition at line 381 of file JSONTimelineDecoder.cpp.

382 {
383  this->outputJSONFile = outgoingCaptureFile;
384 }

The documentation for this class was generated from the following files: