19 m_LabelMap.emplace(label.m_Guid, label);
24 auto iter = m_LabelMap.find(guid);
25 if (iter != m_LabelMap.end())
27 return &iter->second.m_Name;
37 m_Entities.emplace(guid, guid);
42 auto iter = m_Entities.find(
id);
43 if (iter != m_Entities.end())
45 return &(iter->second);
55 m_Relationships.emplace(relationship.m_Guid, relationship);
56 if (relationship.m_RelationshipType == arm::pipe::ITimelineDecoder::RelationshipType::LabelLink)
58 HandleLabelLink(relationship);
60 else if (relationship.m_RelationshipType == arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink)
67 HandleConnection(relationship);
71 HandleChild(relationship);
75 HandleExecutionOf(relationship);
81 ss <<
"Encountered a RetentionLink of unknown type [" << relationship.m_AttributeGuid <<
"]";
82 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
85 else if (relationship.m_RelationshipType == arm::pipe::ITimelineDecoder::RelationshipType::ExecutionLink)
87 HandleExecutionLink(relationship);
91 void TimelineModel::HandleLabelLink(
const arm::pipe::ITimelineDecoder::Relationship& relationship)
95 std::string* value =
nullptr;
96 std::string* attribute =
nullptr;
97 value =
FindLabel(relationship.m_TailGuid);
101 std::stringstream ss;
102 ss <<
"could not find label link [" << relationship.m_Guid <<
103 "] value [" << relationship.m_TailGuid <<
"]";
104 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
106 if (relationship.m_AttributeGuid != 0)
108 attribute =
FindLabel(relationship.m_AttributeGuid);
109 if (attribute ==
nullptr)
112 std::stringstream ss;
113 ss <<
"could not find label link [" << relationship.m_Guid <<
114 "] attribute [" << relationship.m_AttributeGuid <<
"]";
115 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
121 std::stringstream ss;
122 ss <<
"label link [" << relationship.m_Guid <<
"] has a zero attribute guid";
123 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
125 if (entity !=
nullptr && attribute !=
nullptr && value !=
nullptr)
133 m_InferenceGuids.push_back(relationship.m_HeadGuid);
137 if (entity ==
nullptr)
140 std::stringstream ss;
141 ss <<
"could not find label link [" << relationship.m_Guid <<
142 "] entity [" << relationship.m_HeadGuid <<
"] ";
143 if (value !=
nullptr)
145 ss <<
"value [" << *value <<
"] ";
147 if (attribute !=
nullptr)
149 ss <<
"attribute [" << *attribute <<
"] ";
151 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
155 void TimelineModel::HandleConnection(
const arm::pipe::ITimelineDecoder::Relationship& relationship)
158 if (outputLayer ==
nullptr)
160 std::stringstream ss;
161 ss <<
"could not find output entity [" << relationship.m_HeadGuid <<
"]";
162 ss <<
" of connection [" << relationship.m_Guid <<
"]";
163 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
167 if (inputLayer ==
nullptr)
169 std::stringstream ss;
170 ss <<
"could not find input entity [" << relationship.m_TailGuid <<
"]";
171 ss <<
" of connection [" << relationship.m_Guid <<
"]";
172 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
175 Connection connection(relationship.m_Guid, outputLayer, inputLayer);
179 void TimelineModel::HandleChild(
const arm::pipe::ITimelineDecoder::Relationship& relationship)
182 if (parentEntity ==
nullptr)
184 std::stringstream ss;
185 ss <<
"could not find parent entity [" << relationship.m_HeadGuid <<
"]";
186 ss <<
" of child relationship [" << relationship.m_Guid <<
"]";
187 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
191 if (childEntity ==
nullptr)
193 std::stringstream ss;
194 ss <<
"could not find child entity [" << relationship.m_TailGuid <<
"]";
195 ss <<
" of child relationship [" << relationship.m_Guid <<
"]";
196 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
199 parentEntity->
AddChild(childEntity);
202 void TimelineModel::HandleExecutionOf(
const arm::pipe::ITimelineDecoder::Relationship& relationship)
205 if (parentEntity ==
nullptr)
207 std::stringstream ss;
208 ss <<
"could not find parent entity [" << relationship.m_HeadGuid <<
"]";
209 ss <<
" of execution relationship [" << relationship.m_Guid <<
"]";
210 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
214 if (executedEntity ==
nullptr)
216 std::stringstream ss;
217 ss <<
"could not find executed entity [" << relationship.m_TailGuid <<
"]";
218 ss <<
" of execution relationship [" << relationship.m_Guid <<
"]";
219 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
225 void TimelineModel::HandleExecutionLink(
const arm::pipe::ITimelineDecoder::Relationship& relationship)
229 if (parentEntity ==
nullptr)
231 std::stringstream ss;
232 ss <<
"could not find entity [" << relationship.m_HeadGuid <<
"]";
233 ss <<
" of ExecutionLink [" << relationship.m_Guid <<
"]";
234 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
239 if (eventObj ==
nullptr)
241 std::stringstream ss;
242 ss <<
"could not find event [" << relationship.m_TailGuid <<
"]";
243 ss <<
" of ExecutionLink [" << relationship.m_Guid <<
"]";
244 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
249 if (eventClassObj ==
nullptr)
251 std::stringstream ss;
252 ss <<
"could not find event class [" << relationship.m_TailGuid <<
"]";
253 ss <<
" of ExecutionLink [" << relationship.m_Guid <<
"]";
254 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
263 auto iter = m_Relationships.find(
id);
264 if (iter != m_Relationships.end())
266 return &(iter->second);
276 auto it = std::find(m_InferenceGuids.begin(), m_InferenceGuids.end(), guid);
277 return it != m_InferenceGuids.end();
282 std::string* eventClassName =
FindLabel(eventClass.m_NameGuid);
283 if (eventClassName !=
nullptr)
285 EventClassObj eventClassObj(eventClass.m_Guid, *eventClassName);
286 m_EventClasses.emplace(eventClassObj.
GetGuid(), eventClassObj);
290 std::stringstream ss;
291 ss <<
"could not find name [" << eventClass.m_NameGuid <<
"]";
292 ss <<
" of of event class [" << eventClass.m_Guid <<
"]";
293 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
299 auto iter = m_EventClasses.find(
id);
300 if (iter != m_EventClasses.end())
302 return &(iter->second);
312 EventObj evt(event.m_Guid, event.m_TimeStamp, event.m_ThreadId);
313 m_Events.emplace(event.m_Guid, evt);
318 auto iter = m_Events.find(
id);
319 if (iter != m_Events.end())
321 return &(iter->second);
331 std::vector<std::string> desc;
334 auto& entity = entry.second;
336 for (
auto& connection : entity.GetConnections())
340 for (
auto child : entity.GetChildren())
344 for (
auto execution : entity.GetExecutions())
348 for (
auto event : entity.GetEvents())
358 std::stringstream ss;
359 ss <<
"Entity [" << entity.
GetGuid() <<
"]";
364 ss <<
" " << attributeEntry.second.first <<
" = [processId]";
367 ss <<
" " << attributeEntry.second.first <<
" = " << attributeEntry.second.second;
375 std::stringstream ss;
382 std::stringstream ss;
383 ss <<
" connection [" << connection.
GetGuid() <<
"] from entity [";
390 std::stringstream ss;
397 std::stringstream ss;
398 ss <<
" event: [" <<
event->GetGuid() <<
"] class [" <<
event->GetEventClass() <<
"]";
void AddEvent(EventObj *event)
static ARMNN_DLLEXPORT std::string TYPE_LABEL
std::string GetConnectionDescription(const Connection &connection)
EventObj * FindEvent(uint64_t id)
void AddLabel(const arm::pipe::ITimelineDecoder::Label &label)
const Attributes & GetAttributes() const
ModelRelationship * FindRelationship(uint64_t id)
Entity * FindEntity(uint64_t id)
std::string * FindLabel(uint64_t guid)
bool IsInferenceGuid(uint64_t guid) const
Copyright (c) 2021 ARM Limited and Contributors.
EventClassObj * FindEventClass(uint64_t id)
static ARMNN_DLLEXPORT ProfilingStaticGuid CONNECTION_GUID
const Entities & GetEntities() const
void AddChild(Entity *child)
void AddEventClass(const arm::pipe::ITimelineDecoder::EventClass &eventClass)
void AddEvent(const arm::pipe::ITimelineDecoder::Event &event)
void AddEntity(uint64_t guid)
static ARMNN_DLLEXPORT ProfilingStaticGuid EXECUTION_OF_GUID
void AddConnection(const Connection &connection)
void AddAttribute(const std::string &type, const std::string &value)
const Entity * GetTail() const
static ARMNN_DLLEXPORT std::string PROCESS_ID_LABEL
std::string GetExecutionDescription(Entity *execution)
std::vector< std::string > GetModelDescription(const TimelineModel &model)
void SetEventClass(EventClassObj *evtClass)
std::string GetEntityDescription(const Entity &entity)
std::string GetEventDescription(EventObj *event)
void AddExecution(Entity *execution)
const Entity * GetHead() const
void AddRelationship(const arm::pipe::ITimelineDecoder::Relationship &relationship)
static ARMNN_DLLEXPORT std::string INFERENCE
std::string GetChildDescription(Entity *entity)
static ARMNN_DLLEXPORT ProfilingStaticGuid CHILD_GUID