8 #include <common/include/LabelsAndEventClasses.hpp> 20 m_LabelMap.emplace(label.m_Guid, label);
25 auto iter = m_LabelMap.find(guid);
26 if (iter != m_LabelMap.end())
28 return &iter->second.m_Name;
38 m_Entities.emplace(guid, guid);
43 auto iter = m_Entities.find(
id);
44 if (iter != m_Entities.end())
46 return &(iter->second);
56 m_Relationships.emplace(relationship.m_Guid, relationship);
57 if (relationship.m_RelationshipType == arm::pipe::ITimelineDecoder::RelationshipType::LabelLink)
59 HandleLabelLink(relationship);
61 else if (relationship.m_RelationshipType == arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink)
66 if (relationship.m_AttributeGuid == armnn::profiling::LabelsAndEventClasses::CONNECTION_GUID)
68 HandleConnection(relationship);
70 else if (relationship.m_AttributeGuid == armnn::profiling::LabelsAndEventClasses::CHILD_GUID)
72 HandleChild(relationship);
74 else if (relationship.m_AttributeGuid == armnn::profiling::LabelsAndEventClasses::EXECUTION_OF_GUID)
76 HandleExecutionOf(relationship);
82 ss <<
"Encountered a RetentionLink of unknown type [" << relationship.m_AttributeGuid <<
"]";
83 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
86 else if (relationship.m_RelationshipType == arm::pipe::ITimelineDecoder::RelationshipType::ExecutionLink)
88 HandleExecutionLink(relationship);
92 void TimelineModel::HandleLabelLink(
const arm::pipe::ITimelineDecoder::Relationship& relationship)
96 std::string* value =
nullptr;
97 std::string* attribute =
nullptr;
98 value =
FindLabel(relationship.m_TailGuid);
102 std::stringstream ss;
103 ss <<
"could not find label link [" << relationship.m_Guid <<
104 "] value [" << relationship.m_TailGuid <<
"]";
105 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
107 if (relationship.m_AttributeGuid != 0)
109 attribute =
FindLabel(relationship.m_AttributeGuid);
110 if (attribute ==
nullptr)
113 std::stringstream ss;
114 ss <<
"could not find label link [" << relationship.m_Guid <<
115 "] attribute [" << relationship.m_AttributeGuid <<
"]";
116 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
122 std::stringstream ss;
123 ss <<
"label link [" << relationship.m_Guid <<
"] has a zero attribute guid";
124 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
126 if (entity !=
nullptr && attribute !=
nullptr && value !=
nullptr)
131 if (armnn::profiling::LabelsAndEventClasses::TYPE_LABEL.compare(*attribute) == 0 &&
132 armnn::profiling::LabelsAndEventClasses::INFERENCE.compare(*value) == 0)
134 m_InferenceGuids.push_back(relationship.m_HeadGuid);
138 if (entity ==
nullptr)
141 std::stringstream ss;
142 ss <<
"could not find label link [" << relationship.m_Guid <<
143 "] entity [" << relationship.m_HeadGuid <<
"] ";
144 if (value !=
nullptr)
146 ss <<
"value [" << *value <<
"] ";
148 if (attribute !=
nullptr)
150 ss <<
"attribute [" << *attribute <<
"] ";
152 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
156 void TimelineModel::HandleConnection(
const arm::pipe::ITimelineDecoder::Relationship& relationship)
159 if (outputLayer ==
nullptr)
161 std::stringstream ss;
162 ss <<
"could not find output entity [" << relationship.m_HeadGuid <<
"]";
163 ss <<
" of connection [" << relationship.m_Guid <<
"]";
164 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
168 if (inputLayer ==
nullptr)
170 std::stringstream ss;
171 ss <<
"could not find input entity [" << relationship.m_TailGuid <<
"]";
172 ss <<
" of connection [" << relationship.m_Guid <<
"]";
173 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
176 Connection connection(relationship.m_Guid, outputLayer, inputLayer);
180 void TimelineModel::HandleChild(
const arm::pipe::ITimelineDecoder::Relationship& relationship)
183 if (parentEntity ==
nullptr)
185 std::stringstream ss;
186 ss <<
"could not find parent entity [" << relationship.m_HeadGuid <<
"]";
187 ss <<
" of child relationship [" << relationship.m_Guid <<
"]";
188 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
192 if (childEntity ==
nullptr)
194 std::stringstream ss;
195 ss <<
"could not find child entity [" << relationship.m_TailGuid <<
"]";
196 ss <<
" of child relationship [" << relationship.m_Guid <<
"]";
197 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
200 parentEntity->
AddChild(childEntity);
203 void TimelineModel::HandleExecutionOf(
const arm::pipe::ITimelineDecoder::Relationship& relationship)
206 if (parentEntity ==
nullptr)
208 std::stringstream ss;
209 ss <<
"could not find parent entity [" << relationship.m_HeadGuid <<
"]";
210 ss <<
" of execution relationship [" << relationship.m_Guid <<
"]";
211 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
215 if (executedEntity ==
nullptr)
217 std::stringstream ss;
218 ss <<
"could not find executed entity [" << relationship.m_TailGuid <<
"]";
219 ss <<
" of execution relationship [" << relationship.m_Guid <<
"]";
220 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
226 void TimelineModel::HandleExecutionLink(
const arm::pipe::ITimelineDecoder::Relationship& relationship)
230 if (parentEntity ==
nullptr)
232 std::stringstream ss;
233 ss <<
"could not find entity [" << relationship.m_HeadGuid <<
"]";
234 ss <<
" of ExecutionLink [" << relationship.m_Guid <<
"]";
235 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
240 if (eventObj ==
nullptr)
242 std::stringstream ss;
243 ss <<
"could not find event [" << relationship.m_TailGuid <<
"]";
244 ss <<
" of ExecutionLink [" << relationship.m_Guid <<
"]";
245 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
250 if (eventClassObj ==
nullptr)
252 std::stringstream ss;
253 ss <<
"could not find event class [" << relationship.m_TailGuid <<
"]";
254 ss <<
" of ExecutionLink [" << relationship.m_Guid <<
"]";
255 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
264 auto iter = m_Relationships.find(
id);
265 if (iter != m_Relationships.end())
267 return &(iter->second);
277 auto it = std::find(m_InferenceGuids.begin(), m_InferenceGuids.end(), guid);
278 return it != m_InferenceGuids.end();
283 std::string* eventClassName =
FindLabel(eventClass.m_NameGuid);
284 if (eventClassName !=
nullptr)
286 EventClassObj eventClassObj(eventClass.m_Guid, *eventClassName);
287 m_EventClasses.emplace(eventClassObj.
GetGuid(), eventClassObj);
291 std::stringstream ss;
292 ss <<
"could not find name [" << eventClass.m_NameGuid <<
"]";
293 ss <<
" of of event class [" << eventClass.m_Guid <<
"]";
294 m_Errors.push_back(arm::pipe::ProfilingException(ss.str()));
300 auto iter = m_EventClasses.find(
id);
301 if (iter != m_EventClasses.end())
303 return &(iter->second);
313 EventObj evt(event.m_Guid, event.m_TimeStamp, event.m_ThreadId);
314 m_Events.emplace(event.m_Guid, evt);
319 auto iter = m_Events.find(
id);
320 if (iter != m_Events.end())
322 return &(iter->second);
332 std::vector<std::string> desc;
335 auto& entity = entry.second;
337 for (
auto& connection : entity.GetConnections())
341 for (
auto child : entity.GetChildren())
345 for (
auto execution : entity.GetExecutions())
349 for (
auto event : entity.GetEvents())
359 std::stringstream ss;
360 ss <<
"Entity [" << entity.
GetGuid() <<
"]";
363 if (profiling::LabelsAndEventClasses::PROCESS_ID_LABEL == attributeEntry.second.first)
365 ss <<
" " << attributeEntry.second.first <<
" = [processId]";
368 ss <<
" " << attributeEntry.second.first <<
" = " << attributeEntry.second.second;
376 std::stringstream ss;
383 std::stringstream ss;
384 ss <<
" connection [" << connection.
GetGuid() <<
"] from entity [";
391 std::stringstream ss;
398 std::stringstream ss;
399 ss <<
" event: [" <<
event->GetGuid() <<
"] class [" <<
event->GetEventClass() <<
"]";
void AddEvent(EventObj *event)
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)
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)
void AddConnection(const Connection &connection)
void AddAttribute(const std::string &type, const std::string &value)
const Entity * GetTail() const
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)
std::string GetChildDescription(Entity *entity)