2 // Copyright © 2019 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
6 #include "ProfilingTestUtils.hpp"
7 #include "ProfilingUtils.hpp"
9 #include <armnn/Descriptors.hpp>
10 #include <LabelsAndEventClasses.hpp>
11 #include <ProfilingService.hpp>
13 #include <test/TestUtils.hpp>
15 #include <boost/test/unit_test.hpp>
17 inline unsigned int OffsetToNextWord(unsigned int numberOfBytes)
19 unsigned int uint32_t_size = sizeof(uint32_t);
21 unsigned int remainder = numberOfBytes % uint32_t_size;
27 return numberOfBytes + uint32_t_size - remainder;
30 void VerifyTimelineHeaderBinary(const unsigned char* readableData,
32 uint32_t packetDataLength)
34 BOOST_ASSERT(readableData);
37 unsigned int uint32_t_size = sizeof(uint32_t);
39 // Check the TimelineEventClassBinaryPacket header
40 uint32_t entityBinaryPacketHeaderWord0 = ReadUint32(readableData, offset);
41 uint32_t entityBinaryPacketFamily = (entityBinaryPacketHeaderWord0 >> 26) & 0x0000003F;
42 uint32_t entityBinaryPacketClass = (entityBinaryPacketHeaderWord0 >> 19) & 0x0000007F;
43 uint32_t entityBinaryPacketType = (entityBinaryPacketHeaderWord0 >> 16) & 0x00000007;
44 uint32_t entityBinaryPacketStreamId = (entityBinaryPacketHeaderWord0 >> 0) & 0x00000007;
45 BOOST_CHECK(entityBinaryPacketFamily == 1);
46 BOOST_CHECK(entityBinaryPacketClass == 0);
47 BOOST_CHECK(entityBinaryPacketType == 1);
48 BOOST_CHECK(entityBinaryPacketStreamId == 0);
49 offset += uint32_t_size;
50 uint32_t entityBinaryPacketHeaderWord1 = ReadUint32(readableData, offset);
51 uint32_t eventBinaryPacketSequenceNumber = (entityBinaryPacketHeaderWord1 >> 24) & 0x00000001;
52 uint32_t eventBinaryPacketDataLength = (entityBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF;
53 BOOST_CHECK(eventBinaryPacketSequenceNumber == 0);
54 BOOST_CHECK(eventBinaryPacketDataLength == packetDataLength);
55 offset += uint32_t_size;
58 void VerifyTimelineLabelBinaryPacketData(Optional<ProfilingGuid> guid,
59 const std::string& label,
60 const unsigned char* readableData,
63 BOOST_ASSERT(readableData);
66 unsigned int uint32_t_size = sizeof(uint32_t);
67 unsigned int uint64_t_size = sizeof(uint64_t);
68 unsigned int label_size = boost::numeric_cast<unsigned int>(label.size());
71 uint32_t eventClassDeclId = ReadUint32(readableData, offset);
72 BOOST_CHECK(eventClassDeclId == 0);
74 // Check the profiling GUID
75 offset += uint32_t_size;
76 uint64_t readProfilingGuid = ReadUint64(readableData, offset);
79 BOOST_CHECK(readProfilingGuid == guid.value());
83 armnn::profiling::ProfilingService profilingService;
84 BOOST_CHECK(readProfilingGuid == profilingService.GetStaticId(label));
87 // Check the SWTrace label
88 offset += uint64_t_size;
89 uint32_t swTraceLabelLength = ReadUint32(readableData, offset);
90 BOOST_CHECK(swTraceLabelLength == label_size + 1); // Label length including the null-terminator
91 offset += uint32_t_size;
92 BOOST_CHECK(std::memcmp(readableData + offset, // Offset to the label in the buffer
93 label.data(), // The original label
94 swTraceLabelLength - 1) == 0); // The length of the label
96 // SWTrace strings are written in blocks of words, so the offset has to be updated to the next whole word
97 offset += OffsetToNextWord(swTraceLabelLength);
100 void VerifyTimelineEventClassBinaryPacketData(ProfilingGuid guid,
101 const unsigned char* readableData,
102 unsigned int& offset)
104 BOOST_ASSERT(readableData);
107 unsigned int uint32_t_size = sizeof(uint32_t);
108 unsigned int uint64_t_size = sizeof(uint64_t);
111 uint32_t eventClassDeclId = ReadUint32(readableData, offset);
112 BOOST_CHECK(eventClassDeclId == 2);
114 // Check the profiling GUID
115 offset += uint32_t_size;
116 uint64_t readProfilingGuid = ReadUint64(readableData, offset);
117 BOOST_CHECK(readProfilingGuid == guid);
119 // Update the offset to allow parsing to be continued after this function returns
120 offset += uint64_t_size;
123 void VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType relationshipType,
124 Optional<ProfilingGuid> relationshipGuid,
125 Optional<ProfilingGuid> headGuid,
126 Optional<ProfilingGuid> tailGuid,
127 const unsigned char* readableData,
128 unsigned int& offset)
130 BOOST_ASSERT(readableData);
132 uint32_t relationshipTypeUint = 0;
133 switch (relationshipType)
135 case ProfilingRelationshipType::RetentionLink:
136 relationshipTypeUint = 0;
138 case ProfilingRelationshipType::ExecutionLink:
139 relationshipTypeUint = 1;
141 case ProfilingRelationshipType::DataLink:
142 relationshipTypeUint = 2;
144 case ProfilingRelationshipType::LabelLink:
145 relationshipTypeUint = 3;
148 BOOST_ERROR("Unknown relationship type");
152 unsigned int uint32_t_size = sizeof(uint32_t);
153 unsigned int uint64_t_size = sizeof(uint64_t);
156 uint32_t eventClassDeclId = ReadUint32(readableData, offset);
157 BOOST_CHECK(eventClassDeclId == 3);
159 // Check the relationship type
160 offset += uint32_t_size;
161 uint32_t readRelationshipTypeUint = ReadUint32(readableData, offset);
162 BOOST_CHECK(readRelationshipTypeUint == relationshipTypeUint);
164 // Check the relationship GUID
165 offset += uint32_t_size;
166 uint64_t readRelationshipGuid = ReadUint64(readableData, offset);
167 if (relationshipGuid.has_value())
169 BOOST_CHECK(readRelationshipGuid == relationshipGuid.value());
173 BOOST_CHECK(readRelationshipGuid != ProfilingGuid(0));
176 // Check the head of relationship GUID
177 offset += uint64_t_size;
178 uint64_t readHeadRelationshipGuid = ReadUint64(readableData, offset);
179 if (headGuid.has_value())
181 BOOST_CHECK(readHeadRelationshipGuid == headGuid.value());
185 BOOST_CHECK(readHeadRelationshipGuid != ProfilingGuid(0));
188 // Check the tail of relationship GUID
189 offset += uint64_t_size;
190 uint64_t readTailRelationshipGuid = ReadUint64(readableData, offset);
191 if (tailGuid.has_value())
193 BOOST_CHECK(readTailRelationshipGuid == tailGuid.value());
197 BOOST_CHECK(readTailRelationshipGuid != ProfilingGuid(0));
200 // Update the offset to allow parsing to be continued after this function returns
201 offset += uint64_t_size;
204 void VerifyTimelineEntityBinaryPacketData(Optional<ProfilingGuid> guid,
205 const unsigned char* readableData,
206 unsigned int& offset)
208 BOOST_ASSERT(readableData);
211 unsigned int uint32_t_size = sizeof(uint32_t);
212 unsigned int uint64_t_size = sizeof(uint64_t);
214 // Reading TimelineEntityClassBinaryPacket
216 uint32_t entityDeclId = ReadUint32(readableData, offset);
217 BOOST_CHECK(entityDeclId == 1);
219 // Check the profiling GUID
220 offset += uint32_t_size;
221 uint64_t readProfilingGuid = ReadUint64(readableData, offset);
223 if (guid.has_value())
225 BOOST_CHECK(readProfilingGuid == guid.value());
229 BOOST_CHECK(readProfilingGuid != ProfilingGuid(0));
232 offset += uint64_t_size;
235 void VerifyTimelineEventBinaryPacket(Optional<uint64_t> timestamp,
236 Optional<std::thread::id> threadId,
237 Optional<ProfilingGuid> eventGuid,
238 const unsigned char* readableData,
239 unsigned int& offset)
241 BOOST_ASSERT(readableData);
244 unsigned int uint32_t_size = sizeof(uint32_t);
245 unsigned int uint64_t_size = sizeof(uint64_t);
246 unsigned int threadId_size = sizeof(std::thread::id);
248 // Reading TimelineEventBinaryPacket
250 uint32_t entityDeclId = ReadUint32(readableData, offset);
251 BOOST_CHECK(entityDeclId == 4);
253 // Check the timestamp
254 offset += uint32_t_size;
255 uint64_t readTimestamp = ReadUint64(readableData, offset);
256 if (timestamp.has_value())
258 BOOST_CHECK(readTimestamp == timestamp.value());
262 BOOST_CHECK(readTimestamp != 0);
265 // Check the thread id
266 offset += uint64_t_size;
267 std::vector<uint8_t> readThreadId(threadId_size, 0);
268 ReadBytes(readableData, offset, threadId_size, readThreadId.data());
269 if (threadId.has_value())
271 BOOST_CHECK(readThreadId == threadId.value());
275 BOOST_CHECK(readThreadId == std::this_thread::get_id());
278 // Check the event GUID
279 offset += threadId_size;
280 uint64_t readEventGuid = ReadUint64(readableData, offset);
281 if (eventGuid.has_value())
283 BOOST_CHECK(readEventGuid == eventGuid.value());
287 BOOST_CHECK(readEventGuid != ProfilingGuid(0));
290 offset += uint64_t_size;
293 void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId)
295 using namespace armnn;
297 // Create runtime in which test will run
298 armnn::IRuntime::CreationOptions options;
299 options.m_ProfilingOptions.m_EnableProfiling = true;
300 armnn::Runtime runtime(options);
302 // build up the structure of the network
303 INetworkPtr net(INetwork::Create());
305 // Convolution details
306 TensorInfo inputInfo({ 1, 2, 5, 1 }, DataType::Float32);
307 TensorInfo weightInfo({ 3, 2, 3, 1 }, DataType::Float32);
308 TensorInfo biasInfo({ 3 }, DataType::Float32);
309 TensorInfo outputInfo({ 1, 3, 7, 1 }, DataType::Float32);
310 std::vector<float> weightsData{
320 ConstTensor weights(weightInfo, weightsData);
322 Optional<ConstTensor> optionalBiases;
323 std::vector<float> biasesData{ 1.0f, 0.0f, 0.0f };
324 ConstTensor biases(biasInfo, biasesData);
325 optionalBiases = Optional<ConstTensor>(biases);
328 IConnectableLayer* input = net->AddInputLayer(0, "input");
330 // Convolution2d layer
331 Convolution2dDescriptor conv2dDesc;
332 conv2dDesc.m_StrideX = 1;
333 conv2dDesc.m_StrideY = 1;
334 conv2dDesc.m_PadLeft = 0;
335 conv2dDesc.m_PadRight = 0;
336 conv2dDesc.m_PadTop = 2;
337 conv2dDesc.m_PadBottom = 2;
338 conv2dDesc.m_BiasEnabled = true;
339 IConnectableLayer* conv2d = net->AddConvolution2dLayer(conv2dDesc, weights, optionalBiases);
342 armnn::ActivationDescriptor activationDesc;
343 armnn::IConnectableLayer* const activation = net->AddActivationLayer(activationDesc, "activation");
346 IConnectableLayer* output = net->AddOutputLayer(0, "output");
348 input->GetOutputSlot(0).Connect(conv2d->GetInputSlot(0));
349 conv2d->GetOutputSlot(0).Connect(activation->GetInputSlot(0));
350 activation->GetOutputSlot(0).Connect(output->GetInputSlot(0));
352 input->GetOutputSlot(0).SetTensorInfo(inputInfo);
353 conv2d->GetOutputSlot(0).SetTensorInfo(outputInfo);
354 activation->GetOutputSlot(0).SetTensorInfo(outputInfo);
356 // optimize the network
357 std::vector<armnn::BackendId> backends = { backendId };
358 IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime.GetDeviceSpec());
360 ProfilingGuid optNetGuid = optNet->GetGuid();
362 // Load it into the runtime. It should success.
363 armnn::NetworkId netId;
364 BOOST_TEST(runtime.LoadNetwork(netId, std::move(optNet)) == Status::Success);
366 profiling::ProfilingServiceRuntimeHelper profilingServiceHelper(GetProfilingService(&runtime));
367 profiling::BufferManager& bufferManager = profilingServiceHelper.GetProfilingBufferManager();
368 auto readableBuffer = bufferManager.GetReadableBuffer();
370 // Profiling is enable, the post-optimisation structure should be created
371 BOOST_CHECK(readableBuffer != nullptr);
373 unsigned int size = readableBuffer->GetSize();
374 BOOST_CHECK(size == 1556);
376 const unsigned char* readableData = readableBuffer->GetReadableData();
377 BOOST_CHECK(readableData != nullptr);
379 unsigned int offset = 0;
382 VerifyTimelineHeaderBinary(readableData, offset, 1548);
384 // Post-optimisation network
386 VerifyTimelineEntityBinaryPacketData(optNetGuid, readableData, offset);
388 // Entity - Type relationship
389 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
396 // Type label relationship
397 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
400 LabelsAndEventClasses::TYPE_GUID,
405 // Input layer entity
406 VerifyTimelineEntityBinaryPacketData(input->GetGuid(), readableData, offset);
409 VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "input", readableData, offset);
411 // Entity - Name relationship
412 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
419 // Name label relationship
420 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
423 LabelsAndEventClasses::NAME_GUID,
427 // Entity - Type relationship
428 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
435 // Type label relationship
436 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
439 LabelsAndEventClasses::TYPE_GUID,
443 // Network - Input layer relationship
444 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
452 // Conv2d layer entity
453 VerifyTimelineEntityBinaryPacketData(conv2d->GetGuid(), readableData, offset);
456 VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "<Unnamed>", readableData, offset);
458 // Entity - Name relationship
459 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
466 // Name label relationship
467 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
470 LabelsAndEventClasses::NAME_GUID,
474 // Entity - Type relationship
475 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
482 // Type label relationship
483 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
486 LabelsAndEventClasses::TYPE_GUID,
490 // Network - Conv2d layer relationship
491 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
498 // Input layer - Conv2d layer relationship
499 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
506 // Entity - Type relationship
507 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
510 LabelsAndEventClasses::CONNECTION_GUID,
514 // Type label relationship
515 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
518 LabelsAndEventClasses::TYPE_GUID,
523 // Conv2d workload entity
524 VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
526 // Entity - Type relationship
527 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
534 // Type label relationship
535 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
538 LabelsAndEventClasses::TYPE_GUID,
543 VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset);
545 // Entity - BackendId relationship
546 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
553 // BackendId label relationship
554 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
557 LabelsAndEventClasses::BACKENDID_GUID,
561 // Conv2d layer - Conv2d workload relationship
562 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
570 // Activation layer entity
571 VerifyTimelineEntityBinaryPacketData(activation->GetGuid(), readableData, offset);
574 VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "activation", readableData, offset);
576 // Entity - Name relationship
577 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
579 activation->GetGuid(),
584 // Name label relationship
585 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
588 LabelsAndEventClasses::NAME_GUID,
592 // Entity - Type relationship
593 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
595 activation->GetGuid(),
600 // Type label relationship
601 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
604 LabelsAndEventClasses::TYPE_GUID,
608 // Network - Activation layer relationship
609 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
612 activation->GetGuid(),
616 // Conv2d layer - Activation layer relationship
617 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
620 activation->GetGuid(),
624 // Entity - Type relationship
625 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
628 LabelsAndEventClasses::CONNECTION_GUID,
632 // Type label relationship
633 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
636 LabelsAndEventClasses::TYPE_GUID,
640 // Activation workload
641 // Activation workload entity
642 VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
644 // Entity - Type relationship
645 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
652 // Type label relationship
653 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
656 LabelsAndEventClasses::TYPE_GUID,
661 VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset);
663 // Entity - BackendId relationship
664 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
671 // BackendId label relationship
672 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
675 LabelsAndEventClasses::BACKENDID_GUID,
679 // Activation layer - Activation workload relationship
680 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
682 activation->GetGuid(),
688 // Output layer entity
689 VerifyTimelineEntityBinaryPacketData(output->GetGuid(), readableData, offset);
692 VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "output", readableData, offset);
694 // Entity - Name relationship
695 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
702 // Name label relationship
703 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
706 LabelsAndEventClasses::NAME_GUID,
710 // Entity - Type relationship
711 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
718 // Type label relationship
719 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
722 LabelsAndEventClasses::TYPE_GUID,
726 // Network - Output layer relationship
727 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
734 // Activation layer - Output layer relationship
735 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
737 activation->GetGuid(),
742 // Entity - Type relationship
743 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
746 LabelsAndEventClasses::CONNECTION_GUID,
750 // Type label relationship
751 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
754 LabelsAndEventClasses::TYPE_GUID,
758 bufferManager.MarkRead(readableBuffer);
760 // Creates structures for input & output.
761 std::vector<float> inputData(inputInfo.GetNumElements());
762 std::vector<float> outputData(outputInfo.GetNumElements());
764 InputTensors inputTensors
766 {0, ConstTensor(runtime.GetInputTensorInfo(netId, 0), inputData.data())}
768 OutputTensors outputTensors
770 {0, Tensor(runtime.GetOutputTensorInfo(netId, 0), outputData.data())}
773 // Does the inference.
774 runtime.EnqueueWorkload(netId, inputTensors, outputTensors);
776 // Get readable buffer for inference timeline
777 auto inferenceReadableBuffer = bufferManager.GetReadableBuffer();
778 BOOST_CHECK(inferenceReadableBuffer != nullptr);
780 // Get readable buffer for output workload
781 auto outputReadableBuffer = bufferManager.GetReadableBuffer();
782 BOOST_CHECK(outputReadableBuffer != nullptr);
784 // Get readable buffer for input workload
785 auto inputReadableBuffer = bufferManager.GetReadableBuffer();
786 BOOST_CHECK(inputReadableBuffer != nullptr);
788 // Validate input workload data
789 size = inputReadableBuffer->GetSize();
790 BOOST_CHECK(size == 204);
792 readableData = inputReadableBuffer->GetReadableData();
793 BOOST_CHECK(readableData != nullptr);
798 VerifyTimelineHeaderBinary(readableData, offset, 196);
801 // Input workload entity
802 VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
804 // Entity - Type relationship
805 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
812 // Type label relationship
813 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
816 LabelsAndEventClasses::TYPE_GUID,
821 VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset);
823 // Entity - BackendId relationship
824 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
831 // BackendId label relationship
832 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
835 LabelsAndEventClasses::BACKENDID_GUID,
839 // Input layer - Input workload relationship
840 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
847 bufferManager.MarkRead(inputReadableBuffer);
849 // Validate output workload data
850 size = outputReadableBuffer->GetSize();
851 BOOST_CHECK(size == 204);
853 readableData = outputReadableBuffer->GetReadableData();
854 BOOST_CHECK(readableData != nullptr);
859 VerifyTimelineHeaderBinary(readableData, offset, 196);
862 // Output workload entity
863 VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
865 // Entity - Type relationship
866 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
873 // Type label relationship
874 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
877 LabelsAndEventClasses::TYPE_GUID,
882 VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset);
884 // Entity - BackendId relationship
885 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
892 // BackendId label relationship
893 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
896 LabelsAndEventClasses::BACKENDID_GUID,
900 // Output layer - Output workload relationship
901 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
908 bufferManager.MarkRead(outputReadableBuffer);
910 // Validate inference data
911 size = inferenceReadableBuffer->GetSize();
912 BOOST_CHECK(size == 1596);
914 readableData = inferenceReadableBuffer->GetReadableData();
915 BOOST_CHECK(readableData != nullptr);
920 VerifyTimelineHeaderBinary(readableData, offset, 1588);
922 // Inference timeline trace
924 VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
926 // Entity - Type relationship
927 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
930 LabelsAndEventClasses::INFERENCE_GUID,
934 // Type label relationship
935 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
938 LabelsAndEventClasses::TYPE_GUID,
942 // Network - Inference relationship
943 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
950 // Start Inference life
951 // Event packet - timeline, threadId, eventGuid
952 VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
954 // Inference - event relationship
955 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
962 // Event - event class relationship
963 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink,
966 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
971 // Input workload execution
972 // Input workload execution entity
973 VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
975 // Entity - Type relationship
976 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
979 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
983 // Type label relationship
984 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
987 LabelsAndEventClasses::TYPE_GUID,
991 // Inference - Workload execution relationship
992 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
999 // Workload - Workload execution relationship
1000 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1007 // Start Input workload execution life
1008 // Event packet - timeline, threadId, eventGuid
1009 VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1011 // Input workload execution - event relationship
1012 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1019 // Event - event class relationship
1020 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink,
1023 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1027 // End of Input workload execution life
1028 // Event packet - timeline, threadId, eventGuid
1029 VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1031 // Input workload execution - event relationship
1032 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1039 // Event - event class relationship
1040 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink,
1043 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1047 // Conv2d workload execution
1048 // Conv2d workload execution entity
1049 VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
1051 // Entity - Type relationship
1052 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1055 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
1059 // Type label relationship
1060 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1063 LabelsAndEventClasses::TYPE_GUID,
1067 // Inference - Workload execution relationship
1068 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1075 // Workload - Workload execution relationship
1076 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1083 // Start Conv2d workload execution life
1084 // Event packet - timeline, threadId, eventGuid
1085 VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1087 // Conv2d workload execution - event relationship
1088 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1095 // Event - event class relationship
1096 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink,
1099 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1103 // End of Conv2d workload execution life
1104 // Event packet - timeline, threadId, eventGuid
1105 VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1107 // Conv2d workload execution - event relationship
1108 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1115 // Event - event class relationship
1116 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink,
1119 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1123 // Activation workload execution
1124 // Activation workload execution entity
1125 VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
1127 // Entity - Type relationship
1128 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1131 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
1135 // Type label relationship
1136 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1139 LabelsAndEventClasses::TYPE_GUID,
1143 // Inference - Workload execution relationship
1144 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1151 // Workload - Workload execution relationship
1152 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1159 // Start Activation workload execution life
1160 // Event packet - timeline, threadId, eventGuid
1161 VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1163 // Activation workload execution - event relationship
1164 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1171 // Event - event class relationship
1172 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink,
1175 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1179 // End of Activation workload execution life
1180 // Event packet - timeline, threadId, eventGuid
1181 VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1183 // Activation workload execution - event relationship
1184 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1191 // Event - event class relationship
1192 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink,
1195 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1199 // Output workload execution
1200 // Output workload execution entity
1201 VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
1203 // Entity - Type relationship
1204 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1207 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
1211 // Type label relationship
1212 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1215 LabelsAndEventClasses::TYPE_GUID,
1219 // Inference - Workload execution relationship
1220 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1227 // Workload - Workload execution relationship
1228 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1235 // Start Output workload execution life
1236 // Event packet - timeline, threadId, eventGuid
1237 VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1239 // Output workload execution - event relationship
1240 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1247 // Event - event class relationship
1248 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink,
1251 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1255 // End of Normalize workload execution life
1256 // Event packet - timeline, threadId, eventGuid
1257 VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1259 // Output workload execution - event relationship
1260 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1267 // Event - event class relationship
1268 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink,
1271 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1275 // End of Inference life
1276 // Event packet - timeline, threadId, eventGuid
1277 VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1279 // Inference - event relationship
1280 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1287 // Event - event class relationship
1288 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink,
1291 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1295 bufferManager.MarkRead(inferenceReadableBuffer);