ArmNN
 24.02
JSONTimelineDecoderTests.cpp File Reference
#include <JSONTimelineDecoder.hpp>
#include <server/include/timelineDecoder/TimelineCaptureCommandHandler.hpp>
#include <server/include/timelineDecoder/TimelineDecoder.hpp>
#include <armnnUtils/Filesystem.hpp>
#include <doctest/doctest.h>
#include <fstream>
Include dependency graph for JSONTimelineDecoderTests.cpp:

Go to the source code of this file.

Functions

 TEST_SUITE ("JSONTimelineDecoderTests")
 

Function Documentation

◆ TEST_SUITE()

TEST_SUITE ( "JSONTimelineDecoderTests"  )

Definition at line 15 of file JSONTimelineDecoderTests.cpp.

16 {
17 using namespace armnn;
18 using namespace timelinedecoder;
19 
20 void RunSimpleModelThroughDecoder(JSONTimelineDecoder& timelineDecoder)
21 {
22  /*
23  * Building Simple model structure to test
24  */
25  arm::pipe::ITimelineDecoder::Label name;
26  name.m_Guid = uint64_t(10420554295983197538U);
27  name.m_Name = "name";
28  timelineDecoder.CreateLabel(name);
29 
30  arm::pipe::ITimelineDecoder::Label type;
31  type.m_Guid = uint64_t(14196220359693045352U);
32  type.m_Name = "type";
33  timelineDecoder.CreateLabel(type);
34 
35  arm::pipe::ITimelineDecoder::Label index;
36  index.m_Guid = uint64_t(13922236767355949814U);
37  index.m_Name = "index";
38  timelineDecoder.CreateLabel(index);
39 
40  arm::pipe::ITimelineDecoder::Label backendId;
41  backendId.m_Guid = uint64_t(10874037804557439415U);
42  backendId.m_Name = "backendId";
43  timelineDecoder.CreateLabel(backendId);
44 
45  arm::pipe::ITimelineDecoder::Label layer;
46  layer.m_Guid = uint64_t(14761340794127440397U);
47  layer.m_Name = "layer";
48  timelineDecoder.CreateLabel(layer);
49 
50  arm::pipe::ITimelineDecoder::Label workload;
51  workload.m_Guid = uint64_t(15704252740552608110U);
52  workload.m_Name = "workload";
53  timelineDecoder.CreateLabel(workload);
54 
55  arm::pipe::ITimelineDecoder::Label network;
56  network.m_Guid = uint64_t(16862199137063532871U);
57  network.m_Name = "network";
58  timelineDecoder.CreateLabel(network);
59 
60  arm::pipe::ITimelineDecoder::Label connection;
61  connection.m_Guid = uint64_t(15733717748792475675U);
62  connection.m_Name = "connection";
63  timelineDecoder.CreateLabel(connection);
64 
65  arm::pipe::ITimelineDecoder::Label inference;
66  inference.m_Guid = uint64_t(15026600058430441282U);
67  inference.m_Name = "inference";
68  timelineDecoder.CreateLabel(inference);
69 
70  arm::pipe::ITimelineDecoder::Label workload_execution;
71  workload_execution.m_Guid = uint64_t(10172155312650606003U);
72  workload_execution.m_Name = "workload_execution";
73  timelineDecoder.CreateLabel(workload_execution);
74 
75  arm::pipe::ITimelineDecoder::EventClass eventClass1;
76  eventClass1.m_Guid = uint64_t(17170418158534996719U);
77  timelineDecoder.CreateEventClass(eventClass1);
78 
79  arm::pipe::ITimelineDecoder::EventClass eventClass2;
80  eventClass2.m_Guid = uint64_t(10812061579584851344U);
81  timelineDecoder.CreateEventClass(eventClass2);
82 
83  arm::pipe::ITimelineDecoder::Entity entity6;
84  entity6.m_Guid = uint64_t(6);
85  timelineDecoder.CreateEntity(entity6);
86 
87  arm::pipe::ITimelineDecoder::Relationship relationship7;
88  relationship7.m_Guid = uint64_t(7);
89  relationship7.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
90  relationship7.m_HeadGuid = uint64_t(6);
91  relationship7.m_TailGuid = uint64_t(16862199137063532871U);
92  timelineDecoder.CreateRelationship(relationship7);
93 
94  arm::pipe::ITimelineDecoder::Relationship relationship8;
95  relationship8.m_Guid = uint64_t(8);
96  relationship8.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
97  relationship8.m_HeadGuid = uint64_t(7);
98  relationship8.m_TailGuid = uint64_t(14196220359693045352U);
99  timelineDecoder.CreateRelationship(relationship8);
100 
101  // Adding normalization layer
102  arm::pipe::ITimelineDecoder::Entity entity0;
103  entity0.m_Guid = uint64_t(0);
104  timelineDecoder.CreateEntity(entity0);
105 
106  arm::pipe::ITimelineDecoder::Label input;
107  input.m_Guid = uint64_t(18179123836411086572U);
108  input.m_Name = "input";
109  timelineDecoder.CreateLabel(input);
110 
111  arm::pipe::ITimelineDecoder::Relationship relationship9;
112  relationship9.m_Guid = uint64_t(9);
113  relationship9.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
114  relationship9.m_HeadGuid = uint64_t(0);
115  relationship9.m_TailGuid = uint64_t(18179123836411086572U);
116  timelineDecoder.CreateRelationship(relationship9);
117 
118  arm::pipe::ITimelineDecoder::Relationship relationship10;
119  relationship10.m_Guid = uint64_t(10);
120  relationship10.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
121  relationship10.m_HeadGuid = uint64_t(9);
122  relationship10.m_TailGuid = uint64_t(10420554295983197538U);
123  timelineDecoder.CreateRelationship(relationship10);
124 
125  arm::pipe::ITimelineDecoder::Relationship relationship11;
126  relationship11.m_Guid = uint64_t(11);
127  relationship11.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
128  relationship11.m_HeadGuid = uint64_t(0);
129  relationship11.m_TailGuid = uint64_t(14761340794127440397U);
130  timelineDecoder.CreateRelationship(relationship11);
131 
132  arm::pipe::ITimelineDecoder::Relationship relationship12;
133  relationship12.m_Guid = uint64_t(12);
134  relationship12.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
135  relationship12.m_HeadGuid = uint64_t(11);
136  relationship12.m_TailGuid = uint64_t(14196220359693045352U);
137  timelineDecoder.CreateRelationship(relationship12);
138 
139  arm::pipe::ITimelineDecoder::Relationship relationship13;
140  relationship13.m_Guid = uint64_t(13);
141  relationship13.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
142  relationship13.m_HeadGuid = uint64_t(6);
143  relationship13.m_TailGuid = uint64_t(0);
144  timelineDecoder.CreateRelationship(relationship13);
145 
146 
147  // Adding normalization layer
148  arm::pipe::ITimelineDecoder::Entity entity1;
149  entity1.m_Guid = uint64_t(1);
150  timelineDecoder.CreateEntity(entity1);
151 
152  arm::pipe::ITimelineDecoder::Label normalization;
153  normalization.m_Guid = uint64_t(15955949569988957863U);
154  normalization.m_Name = "normalization";
155  timelineDecoder.CreateLabel(normalization);
156 
157  arm::pipe::ITimelineDecoder::Relationship relationship14;
158  relationship14.m_Guid = uint64_t(14);
159  relationship14.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
160  relationship14.m_HeadGuid = uint64_t(1);
161  relationship14.m_TailGuid = uint64_t(15955949569988957863U);
162  timelineDecoder.CreateRelationship(relationship14);
163 
164  arm::pipe::ITimelineDecoder::Relationship relationship15;
165  relationship15.m_Guid = uint64_t(15);
166  relationship15.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
167  relationship15.m_HeadGuid = uint64_t(14);
168  relationship15.m_TailGuid = uint64_t(10420554295983197538U);
169  timelineDecoder.CreateRelationship(relationship15);
170 
171  arm::pipe::ITimelineDecoder::Relationship relationship16;
172  relationship16.m_Guid = uint64_t(16);
173  relationship16.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
174  relationship16.m_HeadGuid = uint64_t(1);
175  relationship16.m_TailGuid = uint64_t(14761340794127440397U);
176  timelineDecoder.CreateRelationship(relationship16);
177 
178  arm::pipe::ITimelineDecoder::Relationship relationship17;
179  relationship17.m_Guid = uint64_t(17);
180  relationship17.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
181  relationship17.m_HeadGuid = uint64_t(16);
182  relationship17.m_TailGuid = uint64_t(14196220359693045352U);
183  timelineDecoder.CreateRelationship(relationship17);
184 
185  arm::pipe::ITimelineDecoder::Relationship relationship18;
186  relationship18.m_Guid = uint64_t(18);
187  relationship18.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
188  relationship18.m_HeadGuid = uint64_t(6);
189  relationship18.m_TailGuid = uint64_t(1);
190  timelineDecoder.CreateRelationship(relationship18);
191 
192  arm::pipe::ITimelineDecoder::Relationship relationship19;
193  relationship19.m_Guid = uint64_t(19);
194  relationship19.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
195  relationship19.m_HeadGuid = uint64_t(0);
196  relationship19.m_TailGuid = uint64_t(1);
197  timelineDecoder.CreateRelationship(relationship19);
198 
199  arm::pipe::ITimelineDecoder::Relationship relationship20;
200  relationship20.m_Guid = uint64_t(20);
201  relationship20.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
202  relationship20.m_HeadGuid = uint64_t(19);
203  relationship20.m_TailGuid = uint64_t(15733717748792475675U);
204  timelineDecoder.CreateRelationship(relationship20);
205 
206  arm::pipe::ITimelineDecoder::Relationship relationship21;
207  relationship21.m_Guid = uint64_t(21);
208  relationship21.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
209  relationship21.m_HeadGuid = uint64_t(20);
210  relationship21.m_TailGuid = uint64_t(14196220359693045352U);
211  timelineDecoder.CreateRelationship(relationship21);
212 
213 
214  arm::pipe::ITimelineDecoder::Entity entity22;
215  entity22.m_Guid = uint64_t(22);
216  timelineDecoder.CreateEntity(entity22);
217 
218  arm::pipe::ITimelineDecoder::Relationship relationship23;
219  relationship23.m_Guid = uint64_t(23);
220  relationship23.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
221  relationship23.m_HeadGuid = uint64_t(22);
222  relationship23.m_TailGuid = uint64_t(15704252740552608110U);
223  timelineDecoder.CreateRelationship(relationship23);
224 
225  arm::pipe::ITimelineDecoder::Relationship relationship24;
226  relationship24.m_Guid = uint64_t(24);
227  relationship24.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
228  relationship24.m_HeadGuid = uint64_t(23);
229  relationship24.m_TailGuid = uint64_t(14196220359693045352U);
230  timelineDecoder.CreateRelationship(relationship24);
231 
232 
233  arm::pipe::ITimelineDecoder::Label CpuRef;
234  CpuRef.m_Guid = uint64_t(9690680943817437852U);
235  CpuRef.m_Name = "CpuRef";
236  timelineDecoder.CreateLabel(CpuRef);
237 
238 
239  arm::pipe::ITimelineDecoder::Relationship relationship25;
240  relationship25.m_Guid = uint64_t(25);
241  relationship25.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
242  relationship25.m_HeadGuid = uint64_t(22);
243  relationship25.m_TailGuid = uint64_t(9690680943817437852U);
244  timelineDecoder.CreateRelationship(relationship25);
245 
246  arm::pipe::ITimelineDecoder::Relationship relationship26;
247  relationship26.m_Guid = uint64_t(26);
248  relationship26.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
249  relationship26.m_HeadGuid = uint64_t(25);
250  relationship26.m_TailGuid = uint64_t(10874037804557439415U);
251  timelineDecoder.CreateRelationship(relationship26);
252 
253  arm::pipe::ITimelineDecoder::Relationship relationship27;
254  relationship27.m_Guid = uint64_t(27);
255  relationship27.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink ;
256  relationship27.m_HeadGuid = uint64_t(1);
257  relationship27.m_TailGuid = uint64_t(22);
258  timelineDecoder.CreateRelationship(relationship27);
259 
260  // Adding output layer
261  arm::pipe::ITimelineDecoder::Entity entity2;
262  entity2.m_Guid = uint64_t(2);
263  timelineDecoder.CreateEntity(entity2);
264 
265  arm::pipe::ITimelineDecoder::Label output;
266  output.m_Guid = uint64_t(18419179028513879730U);
267  output.m_Name = "output";
268  timelineDecoder.CreateLabel(output);
269 
270  arm::pipe::ITimelineDecoder::Relationship relationship28;
271  relationship28.m_Guid = uint64_t(28);
272  relationship28.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
273  relationship28.m_HeadGuid = uint64_t(2);
274  relationship28.m_TailGuid = uint64_t(18419179028513879730U);
275  timelineDecoder.CreateRelationship(relationship28);
276 
277  arm::pipe::ITimelineDecoder::Relationship relationship29;
278  relationship29.m_Guid = uint64_t(29);
279  relationship29.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
280  relationship29.m_HeadGuid = uint64_t(28);
281  relationship29.m_TailGuid = uint64_t(10420554295983197538U);
282  timelineDecoder.CreateRelationship(relationship29);
283 
284  arm::pipe::ITimelineDecoder::Relationship relationship30;
285  relationship30.m_Guid = uint64_t(30);
286  relationship30.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
287  relationship30.m_HeadGuid = uint64_t(2);
288  relationship30.m_TailGuid = uint64_t(14761340794127440397U);
289  timelineDecoder.CreateRelationship(relationship30);
290 
291  arm::pipe::ITimelineDecoder::Relationship relationship31;
292  relationship31.m_Guid = uint64_t(31);
293  relationship31.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
294  relationship31.m_HeadGuid = uint64_t(30);
295  relationship31.m_TailGuid = uint64_t(14196220359693045352U);
296  timelineDecoder.CreateRelationship(relationship31);
297 
298  arm::pipe::ITimelineDecoder::Relationship relationship32;
299  relationship32.m_Guid = uint64_t(32);
300  relationship32.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
301  relationship32.m_HeadGuid = uint64_t(6);
302  relationship32.m_TailGuid = uint64_t(2);
303  timelineDecoder.CreateRelationship(relationship32);
304 
305  arm::pipe::ITimelineDecoder::Relationship relationship33;
306  relationship33.m_Guid = uint64_t(33);
307  relationship33.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
308  relationship33.m_HeadGuid = uint64_t(1);
309  relationship33.m_TailGuid = uint64_t(2);
310  timelineDecoder.CreateRelationship(relationship33);
311 
312  arm::pipe::ITimelineDecoder::Relationship relationship34;
313  relationship34.m_Guid = uint64_t(34);
314  relationship34.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
315  relationship34.m_HeadGuid = uint64_t(33);
316  relationship34.m_TailGuid = uint64_t(15733717748792475675U);
317  timelineDecoder.CreateRelationship(relationship34);
318 
319  arm::pipe::ITimelineDecoder::Relationship relationship35;
320  relationship35.m_Guid = uint64_t(35);
321  relationship35.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
322  relationship35.m_HeadGuid = uint64_t(34);
323  relationship35.m_TailGuid = uint64_t(14196220359693045352U);
324  timelineDecoder.CreateRelationship(relationship35);
325 
326 
327  arm::pipe::ITimelineDecoder::Entity entity36;
328  entity36.m_Guid = uint64_t(36);
329  timelineDecoder.CreateEntity(entity36);
330 
331  arm::pipe::ITimelineDecoder::Relationship relationship37;
332  relationship37.m_Guid = uint64_t(37);
333  relationship37.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
334  relationship37.m_HeadGuid = uint64_t(36);
335  relationship37.m_TailGuid = uint64_t(15704252740552608110U);
336  timelineDecoder.CreateRelationship(relationship37);
337 
338  arm::pipe::ITimelineDecoder::Relationship relationship38;
339  relationship38.m_Guid = uint64_t(38);
340  relationship38.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
341  relationship38.m_HeadGuid = uint64_t(37);
342  relationship38.m_TailGuid = uint64_t(14196220359693045352U);
343  timelineDecoder.CreateRelationship(relationship38);
344 
345  arm::pipe::ITimelineDecoder::Relationship relationship39;
346  relationship39.m_Guid = uint64_t(39);
347  relationship39.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
348  relationship39.m_HeadGuid = uint64_t(36);
349  relationship39.m_TailGuid = uint64_t(9690680943817437852U);
350  timelineDecoder.CreateRelationship(relationship39);
351 
352  arm::pipe::ITimelineDecoder::Relationship relationship40;
353  relationship40.m_Guid = uint64_t(40);
354  relationship40.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
355  relationship40.m_HeadGuid = uint64_t(39);
356  relationship40.m_TailGuid = uint64_t(10874037804557439415U);
357  timelineDecoder.CreateRelationship(relationship40);
358 
359  arm::pipe::ITimelineDecoder::Relationship relationship41;
360  relationship41.m_Guid = uint64_t(41);
361  relationship41.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
362  relationship41.m_HeadGuid = uint64_t(0);
363  relationship41.m_TailGuid = uint64_t(36);
364  timelineDecoder.CreateRelationship(relationship41);
365 
366 
367  arm::pipe::ITimelineDecoder::Entity entity42;
368  entity42.m_Guid = uint64_t(42);
369  timelineDecoder.CreateEntity(entity42);
370 
371  arm::pipe::ITimelineDecoder::Relationship relationship43;
372  relationship43.m_Guid = uint64_t(43);
373  relationship43.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
374  relationship43.m_HeadGuid = uint64_t(42);
375  relationship43.m_TailGuid = uint64_t(15704252740552608110U);
376  timelineDecoder.CreateRelationship(relationship43);
377 
378  arm::pipe::ITimelineDecoder::Relationship relationship44;
379  relationship44.m_Guid = uint64_t(44);
380  relationship44.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
381  relationship44.m_HeadGuid = uint64_t(43);
382  relationship44.m_TailGuid = uint64_t(14196220359693045352U);
383  timelineDecoder.CreateRelationship(relationship44);
384 
385  arm::pipe::ITimelineDecoder::Relationship relationship45;
386  relationship45.m_Guid = uint64_t(45);
387  relationship45.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
388  relationship45.m_HeadGuid = uint64_t(42);
389  relationship45.m_TailGuid = uint64_t(9690680943817437852U);
390  timelineDecoder.CreateRelationship(relationship45);
391 
392  arm::pipe::ITimelineDecoder::Relationship relationship46;
393  relationship46.m_Guid = uint64_t(46);
394  relationship46.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
395  relationship46.m_HeadGuid = uint64_t(45);
396  relationship46.m_TailGuid = uint64_t(10874037804557439415U);
397  timelineDecoder.CreateRelationship(relationship46);
398 
399  arm::pipe::ITimelineDecoder::Relationship relationship47;
400  relationship47.m_Guid = uint64_t(47);
401  relationship47.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
402  relationship47.m_HeadGuid = uint64_t(2);
403  relationship47.m_TailGuid = uint64_t(42);
404  timelineDecoder.CreateRelationship(relationship47);
405 
406  arm::pipe::ITimelineDecoder::Entity entity48;
407  entity48.m_Guid = uint64_t(48);
408  timelineDecoder.CreateEntity(entity48);
409 
410  arm::pipe::ITimelineDecoder::Relationship relationship49;
411  relationship49.m_Guid = uint64_t(49);
412  relationship49.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
413  relationship49.m_HeadGuid = uint64_t(48);
414  relationship49.m_TailGuid = uint64_t(15026600058430441282U);
415  timelineDecoder.CreateRelationship(relationship49);
416 
417  arm::pipe::ITimelineDecoder::Relationship relationship50;
418  relationship50.m_Guid = uint64_t(50);
419  relationship50.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
420  relationship50.m_HeadGuid = uint64_t(49);
421  relationship50.m_TailGuid = uint64_t(14196220359693045352U);
422  timelineDecoder.CreateRelationship(relationship50);
423 
424  arm::pipe::ITimelineDecoder::Relationship relationship51;
425  relationship51.m_Guid = uint64_t(51);
426  relationship51.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
427  relationship51.m_HeadGuid = uint64_t(6);
428  relationship51.m_TailGuid = uint64_t(48);
429  timelineDecoder.CreateRelationship(relationship51);
430 
431  arm::pipe::ITimelineDecoder::Relationship relationship53;
432  relationship53.m_Guid = uint64_t(53);
433  relationship53.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::DataLink;
434  relationship53.m_HeadGuid = uint64_t(48);
435  relationship53.m_TailGuid = uint64_t(52);
436  timelineDecoder.CreateRelationship(relationship53);
437 
438  arm::pipe::ITimelineDecoder::Relationship relationship54;
439  relationship54.m_Guid = uint64_t(54);
440  relationship54.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::ExecutionLink;
441  relationship54.m_HeadGuid = uint64_t(52);
442  relationship54.m_TailGuid = uint64_t(17170418158534996719U);
443  timelineDecoder.CreateRelationship(relationship54);
444 
445 
446  arm::pipe::ITimelineDecoder::Entity entity55;
447  entity55.m_Guid = uint64_t(55);
448  timelineDecoder.CreateEntity(entity55);
449 
450  arm::pipe::ITimelineDecoder::Relationship relationship56;
451  relationship56.m_Guid = uint64_t(56);
452  relationship56.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
453  relationship56.m_HeadGuid = uint64_t(55);
454  relationship56.m_TailGuid = uint64_t(10172155312650606003U);
455  timelineDecoder.CreateRelationship(relationship56);
456 
457  arm::pipe::ITimelineDecoder::Relationship relationship57;
458  relationship57.m_Guid = uint64_t(57);
459  relationship57.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
460  relationship57.m_HeadGuid = uint64_t(56);
461  relationship57.m_TailGuid = uint64_t(14196220359693045352U);
462  timelineDecoder.CreateRelationship(relationship57);
463 
464  arm::pipe::ITimelineDecoder::Relationship relationship58;
465  relationship58.m_Guid = uint64_t(58);
466  relationship58.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
467  relationship58.m_HeadGuid = uint64_t(48);
468  relationship58.m_TailGuid = uint64_t(55);
469  timelineDecoder.CreateRelationship(relationship58);
470 
471  arm::pipe::ITimelineDecoder::Relationship relationship59;
472  relationship59.m_Guid = uint64_t(59);
473  relationship59.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
474  relationship59.m_HeadGuid = uint64_t(36);
475  relationship59.m_TailGuid = uint64_t(55);
476  timelineDecoder.CreateRelationship(relationship59);
477 
478  arm::pipe::ITimelineDecoder::Event event60;
479  event60.m_Guid = uint64_t(60);
480  event60.m_TimeStamp = uint64_t(96557081111036);
481  event60.m_ThreadId = uint64_t(140522431862592);
482  timelineDecoder.CreateEvent(event60);
483 
484  arm::pipe::ITimelineDecoder::Relationship relationship61;
485  relationship61.m_Guid = uint64_t(61);
486  relationship61.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::ExecutionLink;
487  relationship61.m_HeadGuid = uint64_t(55);
488  relationship61.m_TailGuid = uint64_t(60);
489  timelineDecoder.CreateRelationship(relationship61);
490 
491  arm::pipe::ITimelineDecoder::Relationship relationship62;
492  relationship62.m_Guid = uint64_t(62);
493  relationship62.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::DataLink;
494  relationship62.m_HeadGuid = uint64_t(60);
495  relationship62.m_TailGuid = uint64_t(17170418158534996719U);
496  timelineDecoder.CreateRelationship(relationship62);
497 
498  arm::pipe::ITimelineDecoder::Event event63;
499  event63.m_Guid = uint64_t(63);
500  event63.m_TimeStamp = uint64_t(96557081149730);
501  event63.m_ThreadId = uint64_t(140522431862592);
502  timelineDecoder.CreateEvent(event63);
503 
504  arm::pipe::ITimelineDecoder::Relationship relationship64;
505  relationship64.m_Guid = uint64_t(61);
506  relationship64.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::ExecutionLink;
507  relationship64.m_HeadGuid = uint64_t(55);
508  relationship64.m_TailGuid = uint64_t(63);
509  timelineDecoder.CreateRelationship(relationship64);
510 
511  arm::pipe::ITimelineDecoder::Relationship relationship65;
512  relationship65.m_Guid = uint64_t(62);
513  relationship65.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::DataLink;
514  relationship65.m_HeadGuid = uint64_t(63);
515  relationship65.m_TailGuid = uint64_t(10812061579584851344U);
516  timelineDecoder.CreateRelationship(relationship65);
517 
518 
519  arm::pipe::ITimelineDecoder::Entity entity66;
520  entity66.m_Guid = uint64_t(66);
521  timelineDecoder.CreateEntity(entity66);
522 
523  arm::pipe::ITimelineDecoder::Relationship relationship67;
524  relationship67.m_Guid = uint64_t(67);
525  relationship67.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
526  relationship67.m_HeadGuid = uint64_t(66);
527  relationship67.m_TailGuid = uint64_t(10172155312650606003U);
528  timelineDecoder.CreateRelationship(relationship67);
529 
530  arm::pipe::ITimelineDecoder::Relationship relationship68;
531  relationship68.m_Guid = uint64_t(68);
532  relationship68.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
533  relationship68.m_HeadGuid = uint64_t(67);
534  relationship68.m_TailGuid = uint64_t(14196220359693045352U);
535  timelineDecoder.CreateRelationship(relationship68);
536 
537  arm::pipe::ITimelineDecoder::Relationship relationship69;
538  relationship69.m_Guid = uint64_t(69);
539  relationship69.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
540  relationship69.m_HeadGuid = uint64_t(48);
541  relationship69.m_TailGuid = uint64_t(66);
542  timelineDecoder.CreateRelationship(relationship69);
543 
544  arm::pipe::ITimelineDecoder::Relationship relationship70;
545  relationship70.m_Guid = uint64_t(70);
546  relationship70.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
547  relationship70.m_HeadGuid = uint64_t(22);
548  relationship70.m_TailGuid = uint64_t(66);
549  timelineDecoder.CreateRelationship(relationship70);
550 
551 
552  arm::pipe::ITimelineDecoder::Event event71;
553  event71.m_Guid = uint64_t(71);
554  event71.m_TimeStamp = uint64_t(96557081156464);
555  event71.m_ThreadId = uint64_t(140522431862592);
556  timelineDecoder.CreateEvent(event71);
557 
558  arm::pipe::ITimelineDecoder::Relationship relationship72;
559  relationship72.m_Guid = uint64_t(72);
560  relationship72.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::ExecutionLink;
561  relationship72.m_HeadGuid = uint64_t(66);
562  relationship72.m_TailGuid = uint64_t(71);
563  timelineDecoder.CreateRelationship(relationship72);
564 
565  arm::pipe::ITimelineDecoder::Relationship relationship73;
566  relationship73.m_Guid = uint64_t(73);
567  relationship73.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::DataLink;
568  relationship73.m_HeadGuid = uint64_t(71);
569  relationship73.m_TailGuid = uint64_t(17170418158534996719U);
570  timelineDecoder.CreateRelationship(relationship73);
571 
572  arm::pipe::ITimelineDecoder::Event event74;
573  event74.m_Guid = uint64_t(74);
574  event74.m_TimeStamp = uint64_t(96557081220825);
575  event74.m_ThreadId = uint64_t(140522431862592);
576  timelineDecoder.CreateEvent(event74);
577 
578  arm::pipe::ITimelineDecoder::Relationship relationship75;
579  relationship75.m_Guid = uint64_t(75);
580  relationship75.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::ExecutionLink;
581  relationship75.m_HeadGuid = uint64_t(66);
582  relationship75.m_TailGuid = uint64_t(74);
583  timelineDecoder.CreateRelationship(relationship75);
584 
585  arm::pipe::ITimelineDecoder::Relationship relationship76;
586  relationship76.m_Guid = uint64_t(76);
587  relationship76.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::DataLink;
588  relationship76.m_HeadGuid = uint64_t(74);
589  relationship76.m_TailGuid = uint64_t(10812061579584851344U);
590  timelineDecoder.CreateRelationship(relationship76);
591 
592  arm::pipe::ITimelineDecoder::Entity entity77;
593  entity77.m_Guid = uint64_t(77);
594  timelineDecoder.CreateEntity(entity77);
595 
596  arm::pipe::ITimelineDecoder::Relationship relationship78;
597  relationship78.m_Guid = uint64_t(78);
598  relationship78.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
599  relationship78.m_HeadGuid = uint64_t(77);
600  relationship78.m_TailGuid = uint64_t(10172155312650606003U);
601  timelineDecoder.CreateRelationship(relationship78);
602 
603  arm::pipe::ITimelineDecoder::Relationship relationship79;
604  relationship79.m_Guid = uint64_t(79);
605  relationship79.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::LabelLink;
606  relationship79.m_HeadGuid = uint64_t(78);
607  relationship79.m_TailGuid = uint64_t(14196220359693045352U);
608  timelineDecoder.CreateRelationship(relationship79);
609 
610  arm::pipe::ITimelineDecoder::Relationship relationship80;
611  relationship80.m_Guid = uint64_t(80);
612  relationship80.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
613  relationship80.m_HeadGuid = uint64_t(48);
614  relationship80.m_TailGuid = uint64_t(77);
615  timelineDecoder.CreateRelationship(relationship80);
616 
617  arm::pipe::ITimelineDecoder::Relationship relationship81;
618  relationship81.m_Guid = uint64_t(81);
619  relationship81.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::RetentionLink;
620  relationship81.m_HeadGuid = uint64_t(42);
621  relationship81.m_TailGuid = uint64_t(77);
622  timelineDecoder.CreateRelationship(relationship81);
623 
624  arm::pipe::ITimelineDecoder::Event event82;
625  event82.m_Guid = uint64_t(82);
626  event82.m_TimeStamp = uint64_t(96557081227643);
627  event82.m_ThreadId = uint64_t(140522431862592);
628  timelineDecoder.CreateEvent(event82);
629 
630  arm::pipe::ITimelineDecoder::Relationship relationship83;
631  relationship83.m_Guid = uint64_t(83);
632  relationship83.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::ExecutionLink;
633  relationship83.m_HeadGuid = uint64_t(77);
634  relationship83.m_TailGuid = uint64_t(82);
635  timelineDecoder.CreateRelationship(relationship83);
636 
637  arm::pipe::ITimelineDecoder::Relationship relationship84;
638  relationship84.m_Guid = uint64_t(84);
639  relationship84.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::DataLink;
640  relationship84.m_HeadGuid = uint64_t(82);
641  relationship84.m_TailGuid = uint64_t(17170418158534996719U);
642  timelineDecoder.CreateRelationship(relationship84);
643 
644  arm::pipe::ITimelineDecoder::Event event85;
645  event85.m_Guid = uint64_t(85);
646  event85.m_TimeStamp = uint64_t(96557081240332);
647  event85.m_ThreadId = uint64_t(140522431862592);
648  timelineDecoder.CreateEvent(event85);
649 
650  arm::pipe::ITimelineDecoder::Relationship relationship86;
651  relationship86.m_Guid = uint64_t(86);
652  relationship86.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::ExecutionLink;
653  relationship86.m_HeadGuid = uint64_t(77);
654  relationship86.m_TailGuid = uint64_t(85);
655  timelineDecoder.CreateRelationship(relationship86);
656 
657  arm::pipe::ITimelineDecoder::Relationship relationship87;
658  relationship87.m_Guid = uint64_t(87);
659  relationship87.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::DataLink;
660  relationship87.m_HeadGuid = uint64_t(85);
661  relationship87.m_TailGuid = uint64_t(10812061579584851344U);
662  timelineDecoder.CreateRelationship(relationship87);
663 
664  arm::pipe::ITimelineDecoder::Event event88;
665  event88.m_Guid = uint64_t(88);
666  event88.m_TimeStamp = uint64_t(96557081243146);
667  event88.m_ThreadId = uint64_t(140522431862592);
668  timelineDecoder.CreateEvent(event88);
669 
670  arm::pipe::ITimelineDecoder::Relationship relationship89;
671  relationship89.m_Guid = uint64_t(89);
672  relationship89.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::ExecutionLink;
673  relationship89.m_HeadGuid = uint64_t(48);
674  relationship89.m_TailGuid = uint64_t(88);
675  timelineDecoder.CreateRelationship(relationship89);
676 
677  arm::pipe::ITimelineDecoder::Relationship relationship90;
678  relationship90.m_Guid = uint64_t(90);
679  relationship90.m_RelationshipType = arm::pipe::ITimelineDecoder::RelationshipType::DataLink;
680  relationship90.m_HeadGuid = uint64_t(88);
681  relationship90.m_TailGuid = uint64_t(10812061579584851344U);
682  timelineDecoder.CreateRelationship(relationship90);
683 }
684 
685 TEST_CASE("JSONTimelineDecoderTestStructure")
686 {
687  JSONTimelineDecoder timelineDecoder;
688  RunSimpleModelThroughDecoder(timelineDecoder);
689 
690  JSONTimelineDecoder::Model model = timelineDecoder.GetModel();
691  CHECK(model.jsonEntities.size() == 20);
692  JSONTimelineDecoder::JSONEntity rootEntity = model.jsonEntities.at(6);
693  CHECK(rootEntity.childEntities.size() == 4);
694 
695  // Testing input layer model
696  JSONTimelineDecoder::JSONEntity entity0 = model.jsonEntities.at(rootEntity.childEntities[0]);
697  CHECK(entity0.GetName() == "input");
698  CHECK(entity0.GetType() == "layer");
699 
700  CHECK(entity0.childEntities.size() == 1);
701  JSONTimelineDecoder::JSONEntity input_workload_entity = model.jsonEntities.at(entity0.childEntities[0]);
702  CHECK(input_workload_entity.childEntities.size() == 1);
703  CHECK(input_workload_entity.GetType() == "workload");
704  CHECK(input_workload_entity.extendedData.at("backendId") == "CpuRef");
705 
706  JSONTimelineDecoder::JSONEntity input_workload_execution_entity = model.jsonEntities
707  .at(input_workload_entity.childEntities[0]);
708  CHECK(input_workload_execution_entity.childEntities.size() == 2);
709  CHECK(input_workload_execution_entity.GetType() == "workload_execution");
710 
711  JSONTimelineDecoder::JSONEntity input_workload_execution_event0 = model.jsonEntities
712  .at(input_workload_execution_entity.childEntities[0]);
713  CHECK(input_workload_execution_event0.GetType() == "Event");
714  CHECK(input_workload_execution_event0.childEntities.size() == 0);
715  CHECK(model.events.at(input_workload_execution_event0.GetGuid()).m_ThreadId > uint64_t(0));
716  CHECK(model.events.at(input_workload_execution_event0.GetGuid()).m_TimeStamp > uint64_t(0));
717 
718  JSONTimelineDecoder::JSONEntity input_workload_execution_event1 = model.jsonEntities
719  .at(input_workload_execution_entity.childEntities[1]);
720  CHECK(input_workload_execution_event0.GetType() == "Event");
721  CHECK(input_workload_execution_event1.childEntities.size() == 0);
722  CHECK(model.events.at(input_workload_execution_event1.GetGuid()).m_ThreadId > uint64_t(0));
723  CHECK(model.events.at(input_workload_execution_event1.GetGuid()).m_TimeStamp > uint64_t(0));
724 
725  // Testing normalization layer model
726  JSONTimelineDecoder::JSONEntity entity1 = model.jsonEntities.at(rootEntity.childEntities[1]);
727  CHECK(entity1.GetName() == "normalization");
728  CHECK(entity1.GetType() == "layer");
729 
730  JSONTimelineDecoder::JSONEntity normalization_workload_entity = model.jsonEntities
731  .at(entity1.childEntities[0]);
732  CHECK(normalization_workload_entity.GetType() == "workload");
733  CHECK(normalization_workload_entity.extendedData.at("backendId") == "CpuRef");
734 
735  JSONTimelineDecoder::JSONEntity normalization_workload_execution_entity = model.jsonEntities
736  .at(normalization_workload_entity.childEntities[0]);
737  CHECK(normalization_workload_execution_entity.GetType() == "workload_execution");
738 
739  JSONTimelineDecoder::JSONEntity normalization_workload_execution_event0 = model.jsonEntities
740  .at(normalization_workload_execution_entity.childEntities[0]);
741  CHECK(normalization_workload_execution_event0.GetType() == "Event");
742  CHECK(model.events.at(normalization_workload_execution_event0.GetGuid()).m_ThreadId > uint64_t(0));
743  CHECK(model.events.at(normalization_workload_execution_event0.GetGuid()).m_TimeStamp > uint64_t(0));
744 
745  JSONTimelineDecoder::JSONEntity normalization_workload_execution_event1 = model.jsonEntities
746  .at(normalization_workload_execution_entity.childEntities[1]);
747  CHECK(normalization_workload_execution_event1.GetType() == "Event");
748  CHECK(model.events.at(normalization_workload_execution_event1.GetGuid()).m_ThreadId > uint64_t(0));
749  CHECK(model.events.at(normalization_workload_execution_event1.GetGuid()).m_TimeStamp > uint64_t(0));
750 
751  // Testing output layer model
752  JSONTimelineDecoder::JSONEntity entity2 = model.jsonEntities.at(rootEntity.childEntities[2]);
753  CHECK(entity2.GetName() == "output");
754  CHECK(entity2.GetType() == "layer");
755 
756  JSONTimelineDecoder::JSONEntity output_workload_entity = model.jsonEntities.at(entity2.childEntities[0]);
757  CHECK(output_workload_entity.GetType() == "workload");
758  CHECK(output_workload_entity.extendedData.at("backendId") == "CpuRef");
759 
760  JSONTimelineDecoder::JSONEntity output_workload_execution_entity = model.jsonEntities
761  .at(output_workload_entity.childEntities[0]);
762  CHECK(output_workload_execution_entity.GetType() == "workload_execution");
763 
764  JSONTimelineDecoder::JSONEntity output_workload_execution_event0 = model.jsonEntities
765  .at(output_workload_execution_entity.childEntities[0]);
766  CHECK(output_workload_execution_event0.GetType() == "Event");
767  CHECK(model.events.at(output_workload_execution_event0.GetGuid()).m_ThreadId > uint64_t(0));
768  CHECK(model.events.at(output_workload_execution_event0.GetGuid()).m_TimeStamp > uint64_t(0));
769 
770  JSONTimelineDecoder::JSONEntity output_workload_execution_event1 = model.jsonEntities
771  .at(output_workload_execution_entity.childEntities[1]);
772  CHECK(output_workload_execution_event1.GetType() == "Event");
773  CHECK(model.events.at(output_workload_execution_event1.GetGuid()).m_ThreadId > uint64_t(0));
774  CHECK(model.events.at(output_workload_execution_event1.GetGuid()).m_TimeStamp > uint64_t(0));
775 
776  JSONTimelineDecoder::JSONEntity entity48 = model.jsonEntities.at(rootEntity.childEntities[3]);
777  CHECK(entity48.GetName() == "");
778  CHECK(entity48.GetType() == "inference");
779 }
780 
781 TEST_CASE("JSONTimelineDecoderTestJSON")
782 {
783  JSONTimelineDecoder timelineDecoder;
784  RunSimpleModelThroughDecoder(timelineDecoder);
785 
786  JSONTimelineDecoder::Model model = timelineDecoder.GetModel();
787  JSONTimelineDecoder::JSONEntity rootEntity = model.jsonEntities.at(6);
788 
789  std::string jsonString = timelineDecoder.GetJSONString(rootEntity);
790  CHECK(jsonString != "");
791  CHECK(jsonString.find("input_0: {")!=std::string::npos);
792  CHECK(jsonString.find("type: Measurement,\n"
793  "\t\t\tbackendId :CpuRef,")!=std::string::npos);
794  CHECK(jsonString.find("normalization_2: {")!=std::string::npos);
795  CHECK(jsonString.find("output_4: {")!=std::string::npos);
796 
797  // Create a temporary file to write Json output to
798  fs::path tempFile = armnnUtils::Filesystem::NamedTempFile("JSONTimelineDecoderTestJSON.json");
799  // open temp file
800  std::ofstream ofs{tempFile};
801  // tell the timeline decoder to print into our temp file (you could also use std::cout)
802  timelineDecoder.PrintJSON(rootEntity, ofs);
803  // close temp file
804  ofs.close();
805 
806  // Now everything in opposite order
807  fs::ifstream inFile;
808  //reopen the file this time for reading
809  inFile.open(tempFile);
810 
811  std::stringstream strStream;
812  strStream << inFile.rdbuf(); //read the file
813  inFile.close();
814  std::string outfileJson = strStream.str();
815 
816  CHECK(outfileJson != "");
817  CHECK(outfileJson.find("input_0: {")!=std::string::npos);
818  CHECK(outfileJson.find("type: Measurement,\n"
819  "\t\t\tbackendId :CpuRef,")!=std::string::npos);
820  CHECK(outfileJson.find("normalization_2: {")!=std::string::npos);
821  CHECK(outfileJson.find("output_4: {")!=std::string::npos);
822 
823  // Remove temporary file
824  fs::remove(tempFile);
825 }
826 }

References armnn::CpuRef, and armnnUtils::Filesystem::NamedTempFile().

armnn::Compute::CpuRef
@ CpuRef
CPU Execution: Reference C++ kernels.
armnn_driver::Model
::android::nn::Model Model
Helper classes.
Definition: ConversionUtils.hpp:45
armnnUtils::Filesystem::NamedTempFile
fs::path NamedTempFile(const char *fileName)
Returns a path to a file in the system temporary folder. If the file existed it will be deleted.
Definition: Filesystem.cpp:25
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6