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