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