xref: /aosp_15_r20/external/armnn/src/profiling/test/ProfilingTestUtils.cpp (revision 89c4ff92f2867872bb9e2354d150bf0c8c502810)
1 //
2 // Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include <ArmNNProfilingServiceInitialiser.hpp>
7 #include "ProfilingOptionsConverter.hpp"
8 #include "ProfilingTestUtils.hpp"
9 
10 #include <armnn/Descriptors.hpp>
11 #include <armnn/profiling/ArmNNProfiling.hpp>
12 
13 #include <client/src/ProfilingService.hpp>
14 #include <client/src/ProfilingUtils.hpp>
15 
16 #include <common/include/Assert.hpp>
17 #include <common/include/LabelsAndEventClasses.hpp>
18 #include <common/include/NumericCast.hpp>
19 #include <common/include/Processes.hpp>
20 #include <common/include/Threads.hpp>
21 
22 #include <TestUtils.hpp>
23 
24 #include <doctest/doctest.h>
25 
GetStreamMetaDataPacketSize()26 uint32_t GetStreamMetaDataPacketSize()
27 {
28     uint32_t sizeUint32 = sizeof(uint32_t);
29     uint32_t payloadSize = 0;
30     payloadSize += arm::pipe::numeric_cast<uint32_t>(arm::pipe::ARMNN_SOFTWARE_INFO.size()) + 1;
31     payloadSize += arm::pipe::numeric_cast<uint32_t>(arm::pipe::ARMNN_HARDWARE_VERSION.size()) + 1;
32     payloadSize += arm::pipe::numeric_cast<uint32_t>(arm::pipe::ARMNN_SOFTWARE_VERSION.size()) + 1;
33     payloadSize += arm::pipe::numeric_cast<uint32_t>(GetProcessName().size()) + 1;
34 
35     // Add packetVersionEntries
36     payloadSize += 13 * 2 * sizeUint32;
37     // Add packetVersionCountSize
38     payloadSize += sizeUint32;
39 
40     uint32_t headerSize = 2 * sizeUint32;
41     uint32_t bodySize = 10 * sizeUint32;
42 
43     return headerSize + bodySize + payloadSize;
44 }
45 
GetSuitableBackendRegistered()46 std::vector<BackendId> GetSuitableBackendRegistered()
47 {
48     std::vector<BackendId> suitableBackends;
49     if (BackendRegistryInstance().IsBackendRegistered(GetComputeDeviceAsCString(armnn::Compute::CpuRef)))
50     {
51         suitableBackends.push_back(armnn::Compute::CpuRef);
52     }
53     if (BackendRegistryInstance().IsBackendRegistered(GetComputeDeviceAsCString(armnn::Compute::CpuAcc)))
54     {
55         suitableBackends.push_back(armnn::Compute::CpuAcc);
56     }
57     if (BackendRegistryInstance().IsBackendRegistered(GetComputeDeviceAsCString(armnn::Compute::GpuAcc)))
58     {
59         suitableBackends.push_back(armnn::Compute::GpuAcc);
60     }
61     return suitableBackends;
62 }
63 
OffsetToNextWord(unsigned int numberOfBytes)64 inline unsigned int OffsetToNextWord(unsigned int numberOfBytes)
65 {
66     unsigned int uint32_t_size = sizeof(uint32_t);
67 
68     unsigned int remainder = numberOfBytes % uint32_t_size;
69     if (remainder == 0)
70     {
71         return numberOfBytes;
72     }
73 
74     return numberOfBytes + uint32_t_size - remainder;
75 }
76 
VerifyTimelineHeaderBinary(const unsigned char * readableData,unsigned int & offset,uint32_t packetDataLength)77 void VerifyTimelineHeaderBinary(const unsigned char* readableData,
78                                 unsigned int& offset,
79                                 uint32_t packetDataLength)
80 {
81     ARM_PIPE_ASSERT(readableData);
82 
83     // Utils
84     unsigned int uint32_t_size = sizeof(uint32_t);
85 
86     // Check the TimelineEventClassBinaryPacket header
87     uint32_t timelineBinaryPacketHeaderWord0 = ReadUint32(readableData, offset);
88     uint32_t timelineBinaryPacketFamily      = (timelineBinaryPacketHeaderWord0 >> 26) & 0x0000003F;
89     uint32_t timelineBinaryPacketClass       = (timelineBinaryPacketHeaderWord0 >> 19) & 0x0000007F;
90     uint32_t timelineBinaryPacketType        = (timelineBinaryPacketHeaderWord0 >> 16) & 0x00000007;
91     uint32_t timelineBinaryPacketStreamId    = (timelineBinaryPacketHeaderWord0 >>  0) & 0x00000007;
92     CHECK(timelineBinaryPacketFamily   == 1);
93     CHECK(timelineBinaryPacketClass    == 0);
94     CHECK(timelineBinaryPacketType     == 1);
95     CHECK(timelineBinaryPacketStreamId == 0);
96     offset += uint32_t_size;
97     uint32_t timelineBinaryPacketHeaderWord1   = ReadUint32(readableData, offset);
98     uint32_t timelineBinaryPacketSequenceNumber = (timelineBinaryPacketHeaderWord1 >> 24) & 0x00000001;
99     uint32_t timelineBinaryPacketDataLength     = (timelineBinaryPacketHeaderWord1 >>  0) & 0x00FFFFFF;
100     CHECK(timelineBinaryPacketSequenceNumber == 0);
101     CHECK(timelineBinaryPacketDataLength     == packetDataLength);
102     offset += uint32_t_size;
103 }
104 
VerifyTimelineLabelBinaryPacketData(arm::pipe::Optional<ProfilingGuid> guid,const std::string & label,const unsigned char * readableData,unsigned int & offset)105 ProfilingGuid VerifyTimelineLabelBinaryPacketData(arm::pipe::Optional<ProfilingGuid> guid,
106                                                   const std::string& label,
107                                                   const unsigned char* readableData,
108                                                   unsigned int& offset)
109 {
110     ARM_PIPE_ASSERT(readableData);
111 
112     // Utils
113     unsigned int uint32_t_size = sizeof(uint32_t);
114     unsigned int uint64_t_size = sizeof(uint64_t);
115     unsigned int label_size    = arm::pipe::numeric_cast<unsigned int>(label.size());
116 
117     // Check the decl id
118     uint32_t eventClassDeclId = ReadUint32(readableData, offset);
119     CHECK(eventClassDeclId == 0);
120 
121     // Check the profiling GUID
122     offset += uint32_t_size;
123     uint64_t readProfilingGuid = ReadUint64(readableData, offset);
124     if (guid.has_value())
125     {
126         CHECK(readProfilingGuid == guid.value());
127     }
128     else
129     {
130         ArmNNProfilingServiceInitialiser initialiser;
131         ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER,
132                                           initialiser,
133                                           arm::pipe::ARMNN_SOFTWARE_INFO,
134                                           arm::pipe::ARMNN_SOFTWARE_VERSION,
135                                           arm::pipe::ARMNN_HARDWARE_VERSION);
136         CHECK(readProfilingGuid == profilingService.GetStaticId(label));
137     }
138 
139     // Check the SWTrace label
140     offset += uint64_t_size;
141     uint32_t swTraceLabelLength = ReadUint32(readableData, offset);
142     CHECK(swTraceLabelLength == label_size + 1);               // Label length including the null-terminator
143     offset += uint32_t_size;
144     CHECK(std::memcmp(readableData + offset,                  // Offset to the label in the buffer
145                                label.data(),                           // The original label
146                                swTraceLabelLength - 1) == 0);          // The length of the label
147 
148     // SWTrace strings are written in blocks of words, so the offset has to be updated to the next whole word
149     offset += OffsetToNextWord(swTraceLabelLength);
150 
151     ProfilingGuid labelGuid(readProfilingGuid);
152     return labelGuid;
153 }
154 
VerifyTimelineEventClassBinaryPacketData(ProfilingGuid guid,ProfilingGuid nameGuid,const unsigned char * readableData,unsigned int & offset)155 void VerifyTimelineEventClassBinaryPacketData(ProfilingGuid guid,
156                                               ProfilingGuid nameGuid,
157                                               const unsigned char* readableData,
158                                               unsigned int& offset)
159 {
160     ARM_PIPE_ASSERT(readableData);
161 
162     // Utils
163     unsigned int uint32_t_size = sizeof(uint32_t);
164     unsigned int uint64_t_size = sizeof(uint64_t);
165 
166     // Check the decl id
167     uint32_t eventClassDeclId = ReadUint32(readableData, offset);
168     CHECK(eventClassDeclId == 2);
169 
170     // Check the profiling GUID
171     offset += uint32_t_size;
172     uint64_t readProfilingGuid = ReadUint64(readableData, offset);
173     CHECK(readProfilingGuid == guid);
174 
175     offset += uint64_t_size;
176     uint64_t readProfiilngNameGuid = ReadUint64(readableData, offset);
177     CHECK(readProfiilngNameGuid == nameGuid);
178 
179     // Update the offset to allow parsing to be continued after this function returns
180     offset += uint64_t_size;
181 }
182 
VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType relationshipType,arm::pipe::Optional<ProfilingGuid> relationshipGuid,arm::pipe::Optional<ProfilingGuid> headGuid,arm::pipe::Optional<ProfilingGuid> tailGuid,arm::pipe::Optional<ProfilingGuid> attributeGuid,const unsigned char * readableData,unsigned int & offset)183 void VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType relationshipType,
184                                                 arm::pipe::Optional<ProfilingGuid> relationshipGuid,
185                                                 arm::pipe::Optional<ProfilingGuid> headGuid,
186                                                 arm::pipe::Optional<ProfilingGuid> tailGuid,
187                                                 arm::pipe::Optional<ProfilingGuid> attributeGuid,
188                                                 const unsigned char* readableData,
189                                                 unsigned int& offset)
190 {
191     ARM_PIPE_ASSERT(readableData);
192 
193     uint32_t relationshipTypeUint = 0;
194     switch (relationshipType)
195     {
196         case ProfilingRelationshipType::RetentionLink:
197             relationshipTypeUint = 0;
198             break;
199         case ProfilingRelationshipType::ExecutionLink:
200             relationshipTypeUint = 1;
201             break;
202         case ProfilingRelationshipType::DataLink:
203             relationshipTypeUint = 2;
204             break;
205         case ProfilingRelationshipType::LabelLink:
206             relationshipTypeUint = 3;
207             break;
208         default:
209             FAIL("Unknown relationship type");
210     }
211 
212     // Utils
213     unsigned int uint32_t_size = sizeof(uint32_t);
214     unsigned int uint64_t_size = sizeof(uint64_t);
215 
216     // Check the decl id
217     uint32_t eventClassDeclId = ReadUint32(readableData, offset);
218     CHECK(eventClassDeclId == 3);
219 
220     // Check the relationship type
221     offset += uint32_t_size;
222     uint32_t readRelationshipTypeUint = ReadUint32(readableData, offset);
223     CHECK(readRelationshipTypeUint == relationshipTypeUint);
224 
225     // Check the relationship GUID
226     offset += uint32_t_size;
227     uint64_t readRelationshipGuid = ReadUint64(readableData, offset);
228     if (relationshipGuid.has_value())
229     {
230         CHECK(readRelationshipGuid == relationshipGuid.value());
231     }
232     else
233     {
234         CHECK(readRelationshipGuid != ProfilingGuid(0));
235     }
236 
237     // Check the head GUID of the relationship
238     offset += uint64_t_size;
239     uint64_t readHeadRelationshipGuid = ReadUint64(readableData, offset);
240     if (headGuid.has_value())
241     {
242         CHECK(readHeadRelationshipGuid == headGuid.value());
243     }
244     else
245     {
246         CHECK(readHeadRelationshipGuid != ProfilingGuid(0));
247     }
248 
249     // Check the tail GUID of the relationship
250     offset += uint64_t_size;
251     uint64_t readTailRelationshipGuid = ReadUint64(readableData, offset);
252     if (tailGuid.has_value())
253     {
254         CHECK(readTailRelationshipGuid == tailGuid.value());
255     }
256     else
257     {
258         CHECK(readTailRelationshipGuid != ProfilingGuid(0));
259     }
260 
261     // Check the attribute GUID of the relationship
262     offset += uint64_t_size;
263     uint64_t readAttributeRelationshipGuid = ReadUint64(readableData, offset);
264     if (attributeGuid.has_value())
265     {
266         CHECK(readAttributeRelationshipGuid == attributeGuid.value());
267     }
268     else
269     {
270         CHECK(readAttributeRelationshipGuid == ProfilingGuid(0));
271     }
272 
273     // Update the offset to allow parsing to be continued after this function returns
274     offset += uint64_t_size;
275 }
276 
VerifyTimelineEntityBinaryPacketData(arm::pipe::Optional<ProfilingGuid> guid,const unsigned char * readableData,unsigned int & offset)277 ProfilingGuid VerifyTimelineEntityBinaryPacketData(arm::pipe::Optional<ProfilingGuid> guid,
278                                                    const unsigned char* readableData,
279                                                    unsigned int& offset)
280 {
281     ARM_PIPE_ASSERT(readableData);
282 
283     // Utils
284     unsigned int uint32_t_size = sizeof(uint32_t);
285     unsigned int uint64_t_size = sizeof(uint64_t);
286 
287     // Reading TimelineEntityClassBinaryPacket
288     // Check the decl_id
289     uint32_t entityDeclId = ReadUint32(readableData, offset);
290     CHECK(entityDeclId == 1);
291 
292     // Check the profiling GUID
293     offset += uint32_t_size;
294     uint64_t readProfilingGuid = ReadUint64(readableData, offset);
295 
296     if (guid.has_value())
297     {
298         CHECK(readProfilingGuid == guid.value());
299     }
300     else
301     {
302         CHECK(readProfilingGuid != ProfilingGuid(0));
303     }
304 
305     offset += uint64_t_size;
306 
307     ProfilingGuid entityGuid(readProfilingGuid);
308     return entityGuid;
309 }
310 
VerifyTimelineEventBinaryPacket(arm::pipe::Optional<uint64_t> timestamp,arm::pipe::Optional<int> threadId,arm::pipe::Optional<ProfilingGuid> eventGuid,const unsigned char * readableData,unsigned int & offset)311 ProfilingGuid VerifyTimelineEventBinaryPacket(arm::pipe::Optional<uint64_t> timestamp,
312                                               arm::pipe::Optional<int> threadId,
313                                               arm::pipe::Optional<ProfilingGuid> eventGuid,
314                                               const unsigned char* readableData,
315                                               unsigned int& offset)
316 {
317     ARM_PIPE_ASSERT(readableData);
318 
319     // Utils
320     unsigned int uint32_t_size = sizeof(uint32_t);
321     unsigned int uint64_t_size = sizeof(uint64_t);
322 
323     // Reading TimelineEventBinaryPacket
324     // Check the decl_id
325     uint32_t entityDeclId = ReadUint32(readableData, offset);
326     CHECK(entityDeclId == 4);
327 
328     // Check the timestamp
329     offset += uint32_t_size;
330     uint64_t readTimestamp = ReadUint64(readableData, offset);
331     if (timestamp.has_value())
332     {
333         CHECK(readTimestamp == timestamp.value());
334     }
335     else
336     {
337         CHECK(readTimestamp != 0);
338     }
339 
340     // Check the thread id
341     offset += uint64_t_size;
342     std::vector<uint8_t> readThreadId(ThreadIdSize, 0);
343     ReadBytes(readableData, offset, ThreadIdSize, readThreadId.data());
344     if (threadId.has_value())
345     {
346         CHECK(readThreadId == threadId.value());
347     }
348     else
349     {
350         CHECK(readThreadId == arm::pipe::GetCurrentThreadId());
351     }
352 
353     // Check the event GUID
354     offset += ThreadIdSize;
355     uint64_t readEventGuid = ReadUint64(readableData, offset);
356     if (eventGuid.has_value())
357     {
358         CHECK(readEventGuid == eventGuid.value());
359     }
360     else
361     {
362         CHECK(readEventGuid != ProfilingGuid(0));
363     }
364 
365     offset += uint64_t_size;
366 
367     ProfilingGuid eventid(readEventGuid);
368     return eventid;
369 }
370 
VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId)371 void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId)
372 {
373     using namespace armnn;
374 
375     // Create runtime in which test will run
376     armnn::IRuntime::CreationOptions options;
377     options.m_ProfilingOptions.m_EnableProfiling = true;
378     options.m_ProfilingOptions.m_TimelineEnabled = true;
379     armnn::RuntimeImpl runtime(options);
380     GetProfilingService(&runtime).ResetExternalProfilingOptions(
381         ConvertExternalProfilingOptions(options.m_ProfilingOptions), false);
382 
383     ArmNNProfilingServiceInitialiser initialiser;
384     ProfilingServiceRuntimeHelper profilingServiceHelper(
385         arm::pipe::MAX_ARMNN_COUNTER, initialiser, GetProfilingService(&runtime));
386     profilingServiceHelper.ForceTransitionToState(ProfilingState::NotConnected);
387     profilingServiceHelper.ForceTransitionToState(ProfilingState::WaitingForAck);
388     profilingServiceHelper.ForceTransitionToState(ProfilingState::Active);
389 
390     // build up the structure of the network
391     INetworkPtr net(INetwork::Create());
392 
393     // Convolution details
394     TensorInfo inputInfo({ 1, 2, 5, 1 }, DataType::Float32);
395     TensorInfo weightInfo({ 3, 2, 3, 1 }, DataType::Float32, 0.0f, 0, true);
396     TensorInfo biasInfo({ 3 }, DataType::Float32, 0.0f, 0, true);
397     TensorInfo outputInfo({ 1, 3, 7, 1 }, DataType::Float32);
398     std::vector<float> weightsData{
399         1.0f, 0.0f, 0.0f,
400         0.0f, 2.0f, -1.5f,
401 
402         0.0f, 0.0f, 0.0f,
403         0.2f, 0.2f, 0.2f,
404 
405         0.5f, 0.0f, 0.5f,
406         0.0f, -1.0f, 0.0f
407     };
408     ConstTensor weights(weightInfo, weightsData);
409 
410     armnn::Optional<ConstTensor> optionalBiases;
411     std::vector<float> biasesData{ 1.0f, 0.0f, 0.0f };
412     ConstTensor biases(biasInfo, biasesData);
413     optionalBiases = armnn::Optional<ConstTensor>(biases);
414 
415     // Input layer
416     IConnectableLayer* input = net->AddInputLayer(0, "input");
417 
418     // Convolution2d layer
419     Convolution2dDescriptor conv2dDesc;
420     conv2dDesc.m_StrideX = 1;
421     conv2dDesc.m_StrideY = 1;
422     conv2dDesc.m_PadLeft = 0;
423     conv2dDesc.m_PadRight = 0;
424     conv2dDesc.m_PadTop = 2;
425     conv2dDesc.m_PadBottom = 2;
426     conv2dDesc.m_BiasEnabled = true;
427 
428     IConnectableLayer* conv2d = net->AddConvolution2dLayer(conv2dDesc);
429 
430     armnn::IConnectableLayer* weightsLayer = net->AddConstantLayer(weights, "Weights");
431     armnn::IConnectableLayer* biasLayer = net->AddConstantLayer(biases, "Bias");
432 
433     weightsLayer->GetOutputSlot(0).SetTensorInfo(weightInfo);
434     weightsLayer->GetOutputSlot(0).Connect(conv2d->GetInputSlot(1u));
435 
436     biasLayer->GetOutputSlot(0).SetTensorInfo(biasInfo);
437     biasLayer->GetOutputSlot(0).Connect(conv2d->GetInputSlot(2u));
438 
439     // Abs layer
440     armnn::ElementwiseUnaryDescriptor absDesc;
441     armnn::IConnectableLayer* const abs = net->AddElementwiseUnaryLayer(absDesc, "abs");
442 
443     // Output layer
444     IConnectableLayer* output = net->AddOutputLayer(0, "output");
445 
446     input->GetOutputSlot(0).Connect(conv2d->GetInputSlot(0));
447     conv2d->GetOutputSlot(0).Connect(abs->GetInputSlot(0));
448     abs->GetOutputSlot(0).Connect(output->GetInputSlot(0));
449 
450     input->GetOutputSlot(0).SetTensorInfo(inputInfo);
451     conv2d->GetOutputSlot(0).SetTensorInfo(outputInfo);
452     abs->GetOutputSlot(0).SetTensorInfo(outputInfo);
453 
454     // optimize the network
455     std::vector<armnn::BackendId> backends = { backendId };
456     IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime.GetDeviceSpec());
457 
458     ProfilingGuid optNetGuid = optNet->GetGuid();
459 
460     // Load it into the runtime. It should success.
461     armnn::NetworkId netId;
462     CHECK(runtime.LoadNetwork(netId, std::move(optNet)) == Status::Success);
463 
464     BufferManager& bufferManager = profilingServiceHelper.GetProfilingBufferManager();
465     auto readableBuffer = bufferManager.GetReadableBuffer();
466 
467     // Profiling is enabled, the post-optimisation structure should be created
468     CHECK(readableBuffer != nullptr);
469     unsigned int size = readableBuffer->GetSize();
470 
471     const unsigned char* readableData = readableBuffer->GetReadableData();
472     CHECK(readableData != nullptr);
473 
474     unsigned int offset = 0;
475 
476     // Verify Header
477     VerifyTimelineHeaderBinary(readableData, offset, size - 8);
478 
479     // Post-optimisation network
480     // Network entity
481     VerifyTimelineEntityBinaryPacketData(optNetGuid, readableData, offset);
482 
483     // Entity - Type relationship
484     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
485                                                arm::pipe::EmptyOptional(),
486                                                optNetGuid,
487                                                LabelsAndEventClasses::NETWORK_GUID,
488                                                LabelsAndEventClasses::TYPE_GUID,
489                                                readableData,
490                                                offset);
491 
492     // Network - START OF LIFE
493     ProfilingGuid networkSolEventGuid = VerifyTimelineEventBinaryPacket(arm::pipe::EmptyOptional(),
494                                                                         arm::pipe::EmptyOptional(),
495                                                                         arm::pipe::EmptyOptional(),
496                                                                         readableData,
497                                                                         offset);
498 
499     // Network - START OF LIFE event relationship
500     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
501                                                arm::pipe::EmptyOptional(),
502                                                optNetGuid,
503                                                networkSolEventGuid,
504                                                LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
505                                                readableData,
506                                                offset);
507 
508     // Process ID Label
509     int processID = arm::pipe::GetCurrentProcessId();
510     std::stringstream ss;
511     ss << processID;
512     std::string processIdLabel = ss.str();
513     VerifyTimelineLabelBinaryPacketData(
514         arm::pipe::EmptyOptional(), processIdLabel, readableData, offset);
515 
516     // Entity - Process ID relationship
517     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
518                                                arm::pipe::EmptyOptional(),
519                                                optNetGuid,
520                                                arm::pipe::EmptyOptional(),
521                                                LabelsAndEventClasses::PROCESS_ID_GUID,
522                                                readableData,
523                                                offset);
524 
525     // Input layer
526     // Input layer entity
527     VerifyTimelineEntityBinaryPacketData(input->GetGuid(), readableData, offset);
528     // Name Entity
529     ProfilingGuid inputLabelGuid = VerifyTimelineLabelBinaryPacketData(
530         arm::pipe::EmptyOptional(), "input", readableData, offset);
531 
532     // Entity - Name relationship
533     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
534                                                arm::pipe::EmptyOptional(),
535                                                input->GetGuid(),
536                                                inputLabelGuid,
537                                                LabelsAndEventClasses::NAME_GUID,
538                                                readableData,
539                                                offset);
540 
541     // Entity - Type relationship
542     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
543                                                arm::pipe::EmptyOptional(),
544                                                input->GetGuid(),
545                                                LabelsAndEventClasses::LAYER_GUID,
546                                                LabelsAndEventClasses::TYPE_GUID,
547                                                readableData,
548                                                offset);
549 
550     // Network - Input layer relationship
551     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
552                                                arm::pipe::EmptyOptional(),
553                                                optNetGuid,
554                                                input->GetGuid(),
555                                                LabelsAndEventClasses::CHILD_GUID,
556                                                readableData,
557                                                offset);
558 
559     // Weights layer
560     //  We will not check the GUID from the packets since we haven't direct access to the layer
561     //  The GUID will change depending on the number of tests ran since we do are not explicitly resetting the
562     //  ProfilingGuid counter at the beginning of this test
563 
564 
565     // Weights layer entity
566     VerifyTimelineEntityBinaryPacketData( arm::pipe::EmptyOptional(), readableData, offset);
567 
568     // Name entity
569     ProfilingGuid weightsNameLabelGuid = VerifyTimelineLabelBinaryPacketData(
570         arm::pipe::EmptyOptional(), "Weights", readableData, offset);
571 
572     // Entity - Name relationship
573     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
574                                                arm::pipe::EmptyOptional(),
575                                                arm::pipe::EmptyOptional(),
576                                                weightsNameLabelGuid,
577                                                LabelsAndEventClasses::NAME_GUID,
578                                                readableData,
579                                                offset);
580 
581     // Entity - Type relationship
582     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
583                                                arm::pipe::EmptyOptional(),
584                                                arm::pipe::EmptyOptional(),
585                                                LabelsAndEventClasses::LAYER_GUID,
586                                                LabelsAndEventClasses::TYPE_GUID,
587                                                readableData,
588                                                offset);
589 
590     // Network - Weights layer relationship
591     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
592                                                arm::pipe::EmptyOptional(),
593                                                optNetGuid,
594                                                arm::pipe::EmptyOptional(),
595                                                LabelsAndEventClasses::CHILD_GUID,
596                                                readableData,
597                                                offset);
598 
599     // Weights workload
600     // Weights workload entity
601     ProfilingGuid weightsWorkloadGuid = VerifyTimelineEntityBinaryPacketData(
602         arm::pipe::EmptyOptional(), readableData, offset);
603 
604     // Entity - Type relationship
605     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
606                                                arm::pipe::EmptyOptional(),
607                                                weightsWorkloadGuid,
608                                                LabelsAndEventClasses::WORKLOAD_GUID,
609                                                LabelsAndEventClasses::TYPE_GUID,
610                                                readableData,
611                                                offset);
612 
613     // BackendId entity
614     ProfilingGuid backendIdLabelGuid = VerifyTimelineLabelBinaryPacketData(
615         arm::pipe::EmptyOptional(), backendId.Get(), readableData, offset);
616 
617     // Entity - BackendId relationship
618     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
619                                                arm::pipe::EmptyOptional(),
620                                                weightsWorkloadGuid,
621                                                backendIdLabelGuid,
622                                                LabelsAndEventClasses::BACKENDID_GUID,
623                                                readableData,
624                                                offset);
625 
626 
627     // Weights layer - Weights workload relationship
628     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
629                                                arm::pipe::EmptyOptional(),
630                                                arm::pipe::EmptyOptional(),
631                                                weightsWorkloadGuid,
632                                                LabelsAndEventClasses::CHILD_GUID,
633                                                readableData,
634                                                offset);
635 
636     // Bias layer
637     //  We will not check the GUID from the packets since we haven't direct access to the layer
638     //  The GUID will change depending on the number of tests ran since we do are not explicitly resetting the
639     //  ProfilingGuid counter at the beginning of this test
640 
641     // Bias layer entity
642     VerifyTimelineEntityBinaryPacketData(arm::pipe::EmptyOptional(), readableData, offset);
643 
644     // Name entity
645     ProfilingGuid biasNameLabelGuid = VerifyTimelineLabelBinaryPacketData(
646         arm::pipe::EmptyOptional(), "Bias", readableData, offset);
647 
648     // Entity - Name relationship
649     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
650                                                arm::pipe::EmptyOptional(),
651                                                arm::pipe::EmptyOptional(),
652                                                biasNameLabelGuid,
653                                                LabelsAndEventClasses::NAME_GUID,
654                                                readableData,
655                                                offset);
656 
657     // Entity - Type relationship
658     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
659                                                arm::pipe::EmptyOptional(),
660                                                arm::pipe::EmptyOptional(),
661                                                LabelsAndEventClasses::LAYER_GUID,
662                                                LabelsAndEventClasses::TYPE_GUID,
663                                                readableData,
664                                                offset);
665 
666     // Network - Bias layer relationship
667     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
668                                                arm::pipe::EmptyOptional(),
669                                                optNetGuid,
670                                                arm::pipe::EmptyOptional(),
671                                                LabelsAndEventClasses::CHILD_GUID,
672                                                readableData,
673                                                offset);
674 
675     // Bias workload
676     // Bias workload entity
677     ProfilingGuid biasWorkloadGuid = VerifyTimelineEntityBinaryPacketData(
678         arm::pipe::EmptyOptional(), readableData, offset);
679 
680     // Entity - Type relationship
681     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
682                                                arm::pipe::EmptyOptional(),
683                                                biasWorkloadGuid,
684                                                LabelsAndEventClasses::WORKLOAD_GUID,
685                                                LabelsAndEventClasses::TYPE_GUID,
686                                                readableData,
687                                                offset);
688 
689     // BackendId entity
690     backendIdLabelGuid = VerifyTimelineLabelBinaryPacketData(
691         arm::pipe::EmptyOptional(), backendId.Get(), readableData, offset);
692 
693     // Entity - BackendId relationship
694     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
695                                                arm::pipe::EmptyOptional(),
696                                                biasWorkloadGuid,
697                                                backendIdLabelGuid,
698                                                LabelsAndEventClasses::BACKENDID_GUID,
699                                                readableData,
700                                                offset);
701 
702 
703     // Bias layer - Bias workload relationship
704     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
705                                                arm::pipe::EmptyOptional(),
706                                                arm::pipe::EmptyOptional(),
707                                                biasWorkloadGuid,
708                                                LabelsAndEventClasses::CHILD_GUID,
709                                                readableData,
710                                                offset);
711 
712     // Conv2d layer
713     // Conv2d layer entity
714     VerifyTimelineEntityBinaryPacketData(conv2d->GetGuid(), readableData, offset);
715 
716     // Name entity
717     ProfilingGuid conv2dNameLabelGuid = VerifyTimelineLabelBinaryPacketData(
718         arm::pipe::EmptyOptional(), "<Unnamed>", readableData, offset);
719 
720     // Entity - Name relationship
721     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
722                                                arm::pipe::EmptyOptional(),
723                                                conv2d->GetGuid(),
724                                                conv2dNameLabelGuid,
725                                                LabelsAndEventClasses::NAME_GUID,
726                                                readableData,
727                                                offset);
728 
729     // Entity - Type relationship
730     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
731                                                arm::pipe::EmptyOptional(),
732                                                conv2d->GetGuid(),
733                                                LabelsAndEventClasses::LAYER_GUID,
734                                                LabelsAndEventClasses::TYPE_GUID,
735                                                readableData,
736                                                offset);
737 
738     // Network - Conv2d layer relationship
739     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
740                                                arm::pipe::EmptyOptional(),
741                                                optNetGuid,
742                                                conv2d->GetGuid(),
743                                                LabelsAndEventClasses::CHILD_GUID,
744                                                readableData,
745                                                offset);
746 
747     // Input layer - Conv2d layer relationship
748     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
749                                                arm::pipe::EmptyOptional(),
750                                                input->GetGuid(),
751                                                conv2d->GetGuid(),
752                                                LabelsAndEventClasses::CONNECTION_GUID,
753                                                readableData,
754                                                offset);
755 
756     // Weights layer - Conv2d layer relationship
757     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
758                                                arm::pipe::EmptyOptional(),
759                                                arm::pipe::EmptyOptional(),
760                                                conv2d->GetGuid(),
761                                                LabelsAndEventClasses::CONNECTION_GUID,
762                                                readableData,
763                                                offset);
764 
765     // Bias layer - Conv2d layer relationship
766     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
767                                                arm::pipe::EmptyOptional(),
768                                                arm::pipe::EmptyOptional(),
769                                                conv2d->GetGuid(),
770                                                LabelsAndEventClasses::CONNECTION_GUID,
771                                                readableData,
772                                                offset);
773 
774     // Conv2d workload
775     // Conv2d workload entity
776     ProfilingGuid conv2DWorkloadGuid = VerifyTimelineEntityBinaryPacketData(
777         arm::pipe::EmptyOptional(), readableData, offset);
778 
779     // Entity - Type relationship
780     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
781                                                arm::pipe::EmptyOptional(),
782                                                conv2DWorkloadGuid,
783                                                LabelsAndEventClasses::WORKLOAD_GUID,
784                                                LabelsAndEventClasses::TYPE_GUID,
785                                                readableData,
786                                                offset);
787 
788     // BackendId entity
789     backendIdLabelGuid = VerifyTimelineLabelBinaryPacketData(
790         arm::pipe::EmptyOptional(), backendId.Get(), readableData, offset);
791 
792     // Entity - BackendId relationship
793     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
794                                                arm::pipe::EmptyOptional(),
795                                                conv2DWorkloadGuid,
796                                                backendIdLabelGuid,
797                                                LabelsAndEventClasses::BACKENDID_GUID,
798                                                readableData,
799                                                offset);
800 
801 
802     // Conv2d layer - Conv2d workload relationship
803     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
804                                                arm::pipe::EmptyOptional(),
805                                                conv2d->GetGuid(),
806                                                conv2DWorkloadGuid,
807                                                LabelsAndEventClasses::CHILD_GUID,
808                                                readableData,
809                                                offset);
810 
811     // Abs layer
812     // Abs layer entity
813     VerifyTimelineEntityBinaryPacketData(abs->GetGuid(), readableData, offset);
814 
815     // Name entity
816     ProfilingGuid absLabelGuid = VerifyTimelineLabelBinaryPacketData(
817         arm::pipe::EmptyOptional(), "abs", readableData, offset);
818 
819     // Entity - Name relationship
820     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
821                                                arm::pipe::EmptyOptional(),
822                                                abs->GetGuid(),
823                                                absLabelGuid,
824                                                LabelsAndEventClasses::NAME_GUID,
825                                                readableData,
826                                                offset);
827 
828     // Entity - Type relationship
829     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
830                                                arm::pipe::EmptyOptional(),
831                                                abs->GetGuid(),
832                                                LabelsAndEventClasses::LAYER_GUID,
833                                                LabelsAndEventClasses::TYPE_GUID,
834                                                readableData,
835                                                offset);
836 
837     // Network - Abs layer relationship
838     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
839                                                arm::pipe::EmptyOptional(),
840                                                optNetGuid,
841                                                abs->GetGuid(),
842                                                LabelsAndEventClasses::CHILD_GUID,
843                                                readableData,
844                                                offset);
845 
846     // Conv2d layer - Abs layer relationship
847     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
848                                                arm::pipe::EmptyOptional(),
849                                                conv2d->GetGuid(),
850                                                abs->GetGuid(),
851                                                LabelsAndEventClasses::CONNECTION_GUID,
852                                                readableData,
853                                                offset);
854 
855     // Abs workload
856     // Abs workload entity
857     ProfilingGuid absWorkloadGuid = VerifyTimelineEntityBinaryPacketData(
858         arm::pipe::EmptyOptional(), readableData, offset);
859 
860     // Entity - Type relationship
861     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
862                                                arm::pipe::EmptyOptional(),
863                                                absWorkloadGuid,
864                                                LabelsAndEventClasses::WORKLOAD_GUID,
865                                                LabelsAndEventClasses::TYPE_GUID,
866                                                readableData,
867                                                offset);
868 
869     // BackendId entity
870     VerifyTimelineLabelBinaryPacketData(arm::pipe::EmptyOptional(), backendId.Get(), readableData, offset);
871 
872     // Entity - BackendId relationship
873     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
874                                                arm::pipe::EmptyOptional(),
875                                                absWorkloadGuid,
876                                                backendIdLabelGuid,
877                                                LabelsAndEventClasses::BACKENDID_GUID,
878                                                readableData,
879                                                offset);
880 
881     // Abs layer - Abs workload relationship
882     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
883                                                arm::pipe::EmptyOptional(),
884                                                abs->GetGuid(),
885                                                absWorkloadGuid,
886                                                LabelsAndEventClasses::CHILD_GUID,
887                                                readableData,
888                                                offset);
889 
890     // Output layer
891     // Output layer entity
892     VerifyTimelineEntityBinaryPacketData(output->GetGuid(), readableData, offset);
893 
894     // Name entity
895     ProfilingGuid outputLabelGuid = VerifyTimelineLabelBinaryPacketData(
896         arm::pipe::EmptyOptional(), "output", readableData, offset);
897 
898     // Entity - Name relationship
899     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
900                                                arm::pipe::EmptyOptional(),
901                                                output->GetGuid(),
902                                                outputLabelGuid,
903                                                LabelsAndEventClasses::NAME_GUID,
904                                                readableData,
905                                                offset);
906 
907     // Entity - Type relationship
908     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
909                                                arm::pipe::EmptyOptional(),
910                                                output->GetGuid(),
911                                                LabelsAndEventClasses::LAYER_GUID,
912                                                LabelsAndEventClasses::TYPE_GUID,
913                                                readableData,
914                                                offset);
915 
916     // Network - Output layer relationship
917     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
918                                                arm::pipe::EmptyOptional(),
919                                                optNetGuid,
920                                                output->GetGuid(),
921                                                LabelsAndEventClasses::CHILD_GUID,
922                                                readableData,
923                                                offset);
924 
925     // Abs layer - Output layer relationship
926     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
927                                                arm::pipe::EmptyOptional(),
928                                                abs->GetGuid(),
929                                                output->GetGuid(),
930                                                LabelsAndEventClasses::CONNECTION_GUID,
931                                                readableData,
932                                                offset);
933 
934     bufferManager.MarkRead(readableBuffer);
935 
936     // Creates structures for input & output.
937     std::vector<float> inputData(inputInfo.GetNumElements());
938     std::vector<float> outputData(outputInfo.GetNumElements());
939 
940     TensorInfo inputTensorInfo = runtime.GetInputTensorInfo(netId, 0);
941     inputTensorInfo.SetConstant(true);
942     InputTensors inputTensors
943         {
944         {0, ConstTensor(inputTensorInfo, inputData.data())}
945         };
946     OutputTensors outputTensors
947         {
948         {0, Tensor(runtime.GetOutputTensorInfo(netId, 0), outputData.data())}
949         };
950 
951     // Does the inference.
952     runtime.EnqueueWorkload(netId, inputTensors, outputTensors);
953 
954     // Get readable buffer for input workload
955     auto inputReadableBuffer = bufferManager.GetReadableBuffer();
956     CHECK(inputReadableBuffer != nullptr);
957 
958     // Get readable buffer for output workload
959     auto outputReadableBuffer = bufferManager.GetReadableBuffer();
960     CHECK(outputReadableBuffer != nullptr);
961 
962     // Get readable buffer for inference timeline
963     auto inferenceReadableBuffer = bufferManager.GetReadableBuffer();
964     CHECK(inferenceReadableBuffer != nullptr);
965 
966     // Validate input workload data
967     size = inputReadableBuffer->GetSize();
968     CHECK(size == 164);
969 
970     readableData = inputReadableBuffer->GetReadableData();
971     CHECK(readableData != nullptr);
972 
973     offset = 0;
974 
975     // Verify Header
976     VerifyTimelineHeaderBinary(readableData, offset, 156);
977 
978     // Input workload
979     // Input workload entity
980     ProfilingGuid inputWorkloadGuid = VerifyTimelineEntityBinaryPacketData(
981         arm::pipe::EmptyOptional(), readableData, offset);
982 
983     // Entity - Type relationship
984     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
985                                                arm::pipe::EmptyOptional(),
986                                                inputWorkloadGuid,
987                                                LabelsAndEventClasses::WORKLOAD_GUID,
988                                                LabelsAndEventClasses::TYPE_GUID,
989                                                readableData,
990                                                offset);
991 
992     // BackendId entity
993     VerifyTimelineLabelBinaryPacketData(arm::pipe::EmptyOptional(), backendId.Get(), readableData, offset);
994 
995     // Entity - BackendId relationship
996     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
997                                                arm::pipe::EmptyOptional(),
998                                                inputWorkloadGuid,
999                                                backendIdLabelGuid,
1000                                                LabelsAndEventClasses::BACKENDID_GUID,
1001                                                readableData,
1002                                                offset);
1003 
1004     // Input layer - Input workload relationship
1005     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1006                                                arm::pipe::EmptyOptional(),
1007                                                input->GetGuid(),
1008                                                inputWorkloadGuid,
1009                                                LabelsAndEventClasses::CHILD_GUID,
1010                                                readableData,
1011                                                offset);
1012 
1013     bufferManager.MarkRead(inputReadableBuffer);
1014 
1015     // Validate output workload data
1016     size = outputReadableBuffer->GetSize();
1017     CHECK(size == 164);
1018 
1019     readableData = outputReadableBuffer->GetReadableData();
1020     CHECK(readableData != nullptr);
1021 
1022     offset = 0;
1023 
1024     // Verify Header
1025     VerifyTimelineHeaderBinary(readableData, offset, 156);
1026 
1027     // Output workload
1028     // Output workload entity
1029     ProfilingGuid outputWorkloadGuid = VerifyTimelineEntityBinaryPacketData(
1030         arm::pipe::EmptyOptional(), readableData, offset);
1031 
1032     // Entity - Type relationship
1033     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1034                                                arm::pipe::EmptyOptional(),
1035                                                outputWorkloadGuid,
1036                                                LabelsAndEventClasses::WORKLOAD_GUID,
1037                                                LabelsAndEventClasses::TYPE_GUID,
1038                                                readableData,
1039                                                offset);
1040 
1041     // BackendId entity
1042     VerifyTimelineLabelBinaryPacketData(arm::pipe::EmptyOptional(), backendId.Get(), readableData, offset);
1043 
1044     // Entity - BackendId relationship
1045     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1046                                                arm::pipe::EmptyOptional(),
1047                                                outputWorkloadGuid,
1048                                                backendIdLabelGuid,
1049                                                LabelsAndEventClasses::BACKENDID_GUID,
1050                                                readableData,
1051                                                offset);
1052 
1053     // Output layer - Output workload relationship
1054     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1055                                                arm::pipe::EmptyOptional(),
1056                                                output->GetGuid(),
1057                                                outputWorkloadGuid,
1058                                                LabelsAndEventClasses::CHILD_GUID,
1059                                                readableData,
1060                                                offset);
1061 
1062     bufferManager.MarkRead(outputReadableBuffer);
1063 
1064     // Validate inference data
1065     size = inferenceReadableBuffer->GetSize();
1066 
1067     CHECK(size == 1748 + 10 * ThreadIdSize);
1068 
1069     readableData = inferenceReadableBuffer->GetReadableData();
1070     CHECK(readableData != nullptr);
1071 
1072     offset = 0;
1073 
1074     // Verify Header
1075     VerifyTimelineHeaderBinary(readableData, offset, 1740 + 10 * ThreadIdSize);
1076 
1077     // Inference timeline trace
1078     // Inference entity
1079     ProfilingGuid inferenceGuid = VerifyTimelineEntityBinaryPacketData(
1080         arm::pipe::EmptyOptional(), readableData, offset);
1081 
1082     // Entity - Type relationship
1083     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1084                                                arm::pipe::EmptyOptional(),
1085                                                inferenceGuid,
1086                                                LabelsAndEventClasses::INFERENCE_GUID,
1087                                                LabelsAndEventClasses::TYPE_GUID,
1088                                                readableData,
1089                                                offset);
1090 
1091     // Network - Inference relationship
1092     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1093                                                arm::pipe::EmptyOptional(),
1094                                                optNetGuid,
1095                                                inferenceGuid,
1096                                                LabelsAndEventClasses::EXECUTION_OF_GUID,
1097                                                readableData,
1098                                                offset);
1099 
1100     // Start Inference life
1101     // Event packet - timeline, threadId, eventGuid
1102     ProfilingGuid inferenceEventGuid = VerifyTimelineEventBinaryPacket(
1103         arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1104 
1105     // Inference - event relationship
1106     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1107                                                arm::pipe::EmptyOptional(),
1108                                                inferenceGuid,
1109                                                inferenceEventGuid,
1110                                                LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1111                                                readableData,
1112                                                offset);
1113 
1114     // Execution
1115     // Input workload execution
1116     // Input workload execution entity
1117     ProfilingGuid inputWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
1118         arm::pipe::EmptyOptional(), readableData, offset);
1119 
1120     // Entity - Type relationship
1121     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1122                                                arm::pipe::EmptyOptional(),
1123                                                inputWorkloadExecutionGuid,
1124                                                LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
1125                                                LabelsAndEventClasses::TYPE_GUID,
1126                                                readableData,
1127                                                offset);
1128 
1129     // Inference - Workload execution relationship
1130     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1131                                                arm::pipe::EmptyOptional(),
1132                                                inferenceGuid,
1133                                                inputWorkloadExecutionGuid,
1134                                                LabelsAndEventClasses::CHILD_GUID,
1135                                                readableData,
1136                                                offset);
1137 
1138     // Workload - Workload execution relationship
1139     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1140                                                arm::pipe::EmptyOptional(),
1141                                                inputWorkloadGuid,
1142                                                inputWorkloadExecutionGuid,
1143                                                LabelsAndEventClasses::EXECUTION_OF_GUID,
1144                                                readableData,
1145                                                offset);
1146 
1147     // Start Input workload execution life
1148     // Event packet - timeline, threadId, eventGuid
1149     ProfilingGuid inputWorkloadExecutionSOLEventId = VerifyTimelineEventBinaryPacket(
1150         arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1151 
1152     // Input workload execution - event relationship
1153     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1154                                                arm::pipe::EmptyOptional(),
1155                                                inputWorkloadExecutionGuid,
1156                                                inputWorkloadExecutionSOLEventId,
1157                                                LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1158                                                readableData,
1159                                                offset);
1160 
1161     // End of Input workload execution life
1162     // Event packet - timeline, threadId, eventGuid
1163     ProfilingGuid inputWorkloadExecutionEOLEventId = VerifyTimelineEventBinaryPacket(
1164         arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1165 
1166     // Input workload execution - event relationship
1167     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1168                                                arm::pipe::EmptyOptional(),
1169                                                inputWorkloadExecutionGuid,
1170                                                inputWorkloadExecutionEOLEventId,
1171                                                LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1172                                                readableData,
1173                                                offset);
1174 
1175    // Weights workload execution
1176     // Weights workload execution entity
1177     ProfilingGuid weightsWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
1178         arm::pipe::EmptyOptional(), readableData, offset);
1179 
1180     // Entity - Type relationship
1181     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1182                                                arm::pipe::EmptyOptional(),
1183                                                weightsWorkloadExecutionGuid,
1184                                                LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
1185                                                LabelsAndEventClasses::TYPE_GUID,
1186                                                readableData,
1187                                                offset);
1188 
1189     // Inference - Workload execution relationship
1190     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1191                                                arm::pipe::EmptyOptional(),
1192                                                inferenceGuid,
1193                                                weightsWorkloadExecutionGuid,
1194                                                LabelsAndEventClasses::CHILD_GUID,
1195                                                readableData,
1196                                                offset);
1197 
1198     // Workload - Workload execution relationship
1199     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1200                                                arm::pipe::EmptyOptional(),
1201                                                weightsWorkloadGuid,
1202                                                weightsWorkloadExecutionGuid,
1203                                                LabelsAndEventClasses::EXECUTION_OF_GUID,
1204                                                readableData,
1205                                                offset);
1206 
1207     // Start Weights workload execution life
1208     // Event packet - timeline, threadId, eventGuid
1209     ProfilingGuid weightsWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket(
1210         arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1211 
1212     // Weights workload execution - event relationship
1213     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1214                                                arm::pipe::EmptyOptional(),
1215                                                weightsWorkloadExecutionGuid,
1216                                                weightsWorkloadExecutionSOLEventGuid,
1217                                                LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1218                                                readableData,
1219                                                offset);
1220 
1221     // End of Weights workload execution life
1222     // Event packet - timeline, threadId, eventGuid
1223     ProfilingGuid weightsWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket(
1224         arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1225 
1226     // Weights workload execution - event relationship
1227     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1228                                                arm::pipe::EmptyOptional(),
1229                                                weightsWorkloadExecutionGuid,
1230                                                weightsWorkloadExecutionEOLEventGuid,
1231                                                LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1232                                                readableData,
1233                                                offset);
1234 
1235    // Bias workload execution
1236     // Bias workload execution entity
1237     ProfilingGuid biasWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
1238         arm::pipe::EmptyOptional(), readableData, offset);
1239 
1240     // Entity - Type relationship
1241     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1242                                                arm::pipe::EmptyOptional(),
1243                                                biasWorkloadExecutionGuid,
1244                                                LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
1245                                                LabelsAndEventClasses::TYPE_GUID,
1246                                                readableData,
1247                                                offset);
1248 
1249     // Inference - Workload execution relationship
1250     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1251                                                arm::pipe::EmptyOptional(),
1252                                                inferenceGuid,
1253                                                biasWorkloadExecutionGuid,
1254                                                LabelsAndEventClasses::CHILD_GUID,
1255                                                readableData,
1256                                                offset);
1257 
1258     // Workload - Workload execution relationship
1259     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1260                                                arm::pipe::EmptyOptional(),
1261                                                biasWorkloadGuid,
1262                                                biasWorkloadExecutionGuid,
1263                                                LabelsAndEventClasses::EXECUTION_OF_GUID,
1264                                                readableData,
1265                                                offset);
1266 
1267     // Start Bias workload execution life
1268     // Event packet - timeline, threadId, eventGuid
1269     ProfilingGuid biasWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket(
1270         arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1271 
1272     // Bias workload execution - event relationship
1273     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1274                                                arm::pipe::EmptyOptional(),
1275                                                biasWorkloadExecutionGuid,
1276                                                biasWorkloadExecutionSOLEventGuid,
1277                                                LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1278                                                readableData,
1279                                                offset);
1280 
1281     // End of Bias workload execution life
1282     // Event packet - timeline, threadId, eventGuid
1283     ProfilingGuid biasWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket(
1284         arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1285 
1286     // Bias workload execution - event relationship
1287     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1288                                                arm::pipe::EmptyOptional(),
1289                                                biasWorkloadExecutionGuid,
1290                                                biasWorkloadExecutionEOLEventGuid,
1291                                                LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1292                                                readableData,
1293                                                offset);
1294 
1295     // Conv2d workload execution
1296     // Conv2d workload execution entity
1297     ProfilingGuid conv2DWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
1298         arm::pipe::EmptyOptional(), readableData, offset);
1299 
1300     // Entity - Type relationship
1301     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1302                                                arm::pipe::EmptyOptional(),
1303                                                conv2DWorkloadExecutionGuid,
1304                                                LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
1305                                                LabelsAndEventClasses::TYPE_GUID,
1306                                                readableData,
1307                                                offset);
1308 
1309     // Inference - Workload execution relationship
1310     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1311                                                arm::pipe::EmptyOptional(),
1312                                                inferenceGuid,
1313                                                conv2DWorkloadExecutionGuid,
1314                                                LabelsAndEventClasses::CHILD_GUID,
1315                                                readableData,
1316                                                offset);
1317 
1318     // Workload - Workload execution relationship
1319     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1320                                                arm::pipe::EmptyOptional(),
1321                                                conv2DWorkloadGuid,
1322                                                conv2DWorkloadExecutionGuid,
1323                                                LabelsAndEventClasses::EXECUTION_OF_GUID,
1324                                                readableData,
1325                                                offset);
1326 
1327     // Start Conv2d workload execution life
1328     // Event packet - timeline, threadId, eventGuid
1329     ProfilingGuid conv2DWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket(
1330         arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1331 
1332     // Conv2d workload execution - event relationship
1333     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1334                                                arm::pipe::EmptyOptional(),
1335                                                conv2DWorkloadExecutionGuid,
1336                                                conv2DWorkloadExecutionSOLEventGuid,
1337                                                LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1338                                                readableData,
1339                                                offset);
1340 
1341     // End of Conv2d workload execution life
1342     // Event packet - timeline, threadId, eventGuid
1343     ProfilingGuid conv2DWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket(
1344         arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1345 
1346     // Conv2d workload execution - event relationship
1347     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1348                                                arm::pipe::EmptyOptional(),
1349                                                conv2DWorkloadExecutionGuid,
1350                                                conv2DWorkloadExecutionEOLEventGuid,
1351                                                LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1352                                                readableData,
1353                                                offset);
1354 
1355     // Abs workload execution
1356     // Abs workload execution entity
1357     ProfilingGuid absWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
1358         arm::pipe::EmptyOptional(), readableData, offset);
1359 
1360     // Entity - Type relationship
1361     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1362                                                arm::pipe::EmptyOptional(),
1363                                                absWorkloadExecutionGuid,
1364                                                LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
1365                                                LabelsAndEventClasses::TYPE_GUID,
1366                                                readableData,
1367                                                offset);
1368 
1369     // Inference - Workload execution relationship
1370     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1371                                                arm::pipe::EmptyOptional(),
1372                                                inferenceGuid,
1373                                                absWorkloadExecutionGuid,
1374                                                LabelsAndEventClasses::CHILD_GUID,
1375                                                readableData,
1376                                                offset);
1377 
1378     // Workload - Workload execution relationship
1379     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1380                                                arm::pipe::EmptyOptional(),
1381                                                absWorkloadGuid,
1382                                                absWorkloadExecutionGuid,
1383                                                LabelsAndEventClasses::EXECUTION_OF_GUID,
1384                                                readableData,
1385                                                offset);
1386 
1387     // Start Abs workload execution life
1388     // Event packet - timeline, threadId, eventGuid
1389     ProfilingGuid absWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket(
1390         arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1391 
1392     // Abs workload execution - event relationship
1393     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1394                                                arm::pipe::EmptyOptional(),
1395                                                absWorkloadExecutionGuid,
1396                                                absWorkloadExecutionSOLEventGuid,
1397                                                LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1398                                                readableData,
1399                                                offset);
1400 
1401     // End of Abs workload execution life
1402     // Event packet - timeline, threadId, eventGuid
1403     ProfilingGuid absWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket(
1404         arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1405 
1406     // Abs workload execution - event relationship
1407     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1408                                                arm::pipe::EmptyOptional(),
1409                                                absWorkloadExecutionGuid,
1410                                                absWorkloadExecutionEOLEventGuid,
1411                                                LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1412                                                readableData,
1413                                                offset);
1414 
1415     // Output workload execution
1416     // Output workload execution entity
1417     ProfilingGuid outputWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
1418         arm::pipe::EmptyOptional(), readableData, offset);
1419 
1420     // Entity - Type relationship
1421     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1422                                                arm::pipe::EmptyOptional(),
1423                                                outputWorkloadExecutionGuid,
1424                                                LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
1425                                                LabelsAndEventClasses::TYPE_GUID,
1426                                                readableData,
1427                                                offset);
1428 
1429     // Inference - Workload execution relationship
1430     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1431                                                arm::pipe::EmptyOptional(),
1432                                                inferenceGuid,
1433                                                outputWorkloadExecutionGuid,
1434                                                LabelsAndEventClasses::CHILD_GUID,
1435                                                readableData,
1436                                                offset);
1437 
1438     // Workload - Workload execution relationship
1439     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1440                                                arm::pipe::EmptyOptional(),
1441                                                outputWorkloadGuid,
1442                                                outputWorkloadExecutionGuid,
1443                                                LabelsAndEventClasses::EXECUTION_OF_GUID,
1444                                                readableData,
1445                                                offset);
1446 
1447     // Start Output workload execution life
1448     // Event packet - timeline, threadId, eventGuid
1449     ProfilingGuid outputWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket(
1450         arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1451 
1452     // Output workload execution - event relationship
1453     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1454                                                arm::pipe::EmptyOptional(),
1455                                                outputWorkloadExecutionGuid,
1456                                                outputWorkloadExecutionSOLEventGuid,
1457                                                LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1458                                                readableData,
1459                                                offset);
1460 
1461     // End of Normalize workload execution life
1462     // Event packet - timeline, threadId, eventGuid
1463     ProfilingGuid outputWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket(
1464         arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1465 
1466     // Output workload execution - event relationship
1467     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1468                                                arm::pipe::EmptyOptional(),
1469                                                outputWorkloadExecutionGuid,
1470                                                outputWorkloadExecutionEOLEventGuid,
1471                                                LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1472                                                readableData,
1473                                                offset);
1474 
1475     // End of Inference life
1476     // Event packet - timeline, threadId, eventGuid
1477     ProfilingGuid inferenceEOLEventGuid = VerifyTimelineEventBinaryPacket(
1478         arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1479 
1480     // Inference - event relationship
1481     VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1482                                                arm::pipe::EmptyOptional(),
1483                                                inferenceGuid,
1484                                                inferenceEOLEventGuid,
1485                                                LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1486                                                readableData,
1487                                                offset);
1488 
1489     bufferManager.MarkRead(inferenceReadableBuffer);
1490 }
1491 
CompareOutput(std::vector<std::string> output,std::vector<std::string> expectedOutput)1492 bool CompareOutput(std::vector<std::string> output, std::vector<std::string> expectedOutput)
1493 {
1494     if (output.size() != expectedOutput.size())
1495     {
1496         std::cerr << "output has [" << output.size() << "] lines, expected was ["
1497                   << expectedOutput.size() << "] lines" << std::endl;
1498         std::cerr << std::endl << "actual" << std::endl << std::endl;
1499         for (auto line : output)
1500         {
1501             std::cerr << line << std::endl;
1502         }
1503         std::cerr << std::endl << "expected" << std::endl << std::endl;
1504         for (auto line : expectedOutput)
1505         {
1506             std::cerr << line << std::endl;
1507         }
1508         return false;
1509     }
1510     bool bRet = true;
1511     for (unsigned long i = 0; i < output.size(); ++i)
1512     {
1513         if (output[i] != expectedOutput[i])
1514         {
1515             bRet = false;
1516             std::cerr << i << ": actual [" << output[i] << "] expected [" << expectedOutput[i] << "]" << std::endl;
1517         }
1518     }
1519     return bRet;
1520 }
1521