ArmNN
 22.05
ProfilingTestUtils.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
8 #include "ProfilingTestUtils.hpp"
9 
10 #include <armnn/Descriptors.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 
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 
46 std::vector<BackendId> GetSuitableBackendRegistered()
47 {
48  std::vector<BackendId> suitableBackends;
50  {
51  suitableBackends.push_back(armnn::Compute::CpuRef);
52  }
54  {
55  suitableBackends.push_back(armnn::Compute::CpuAcc);
56  }
58  {
59  suitableBackends.push_back(armnn::Compute::GpuAcc);
60  }
61  return suitableBackends;
62 }
63 
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 
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 
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  {
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 
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 
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 
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 
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 
372 {
373  using namespace armnn;
374 
375  // Create runtime in which test will run
377  options.m_ProfilingOptions.m_EnableProfiling = true;
378  options.m_ProfilingOptions.m_TimelineEnabled = true;
379  armnn::RuntimeImpl runtime(options);
380  GetProfilingService(&runtime).ResetExternalProfilingOptions(
382 
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
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;
428  IConnectableLayer* conv2d = net->AddConvolution2dLayer(conv2dDesc, weights, optionalBiases);
430  // Abs layer
432  armnn::IConnectableLayer* const abs = net->AddElementwiseUnaryLayer(absDesc, "abs");
433 
434  // Output layer
435  IConnectableLayer* output = net->AddOutputLayer(0, "output");
436 
437  input->GetOutputSlot(0).Connect(conv2d->GetInputSlot(0));
438  conv2d->GetOutputSlot(0).Connect(abs->GetInputSlot(0));
439  abs->GetOutputSlot(0).Connect(output->GetInputSlot(0));
440 
441  input->GetOutputSlot(0).SetTensorInfo(inputInfo);
442  conv2d->GetOutputSlot(0).SetTensorInfo(outputInfo);
443  abs->GetOutputSlot(0).SetTensorInfo(outputInfo);
444 
445  // optimize the network
446  std::vector<armnn::BackendId> backends = { backendId };
447  IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime.GetDeviceSpec());
448 
449  ProfilingGuid optNetGuid = optNet->GetGuid();
450 
451  // Load it into the runtime. It should success.
452  armnn::NetworkId netId;
453  CHECK(runtime.LoadNetwork(netId, std::move(optNet)) == Status::Success);
454 
455  BufferManager& bufferManager = profilingServiceHelper.GetProfilingBufferManager();
456  auto readableBuffer = bufferManager.GetReadableBuffer();
457 
458  // Profiling is enabled, the post-optimisation structure should be created
459  CHECK(readableBuffer != nullptr);
460  unsigned int size = readableBuffer->GetSize();
461 
462  const unsigned char* readableData = readableBuffer->GetReadableData();
463  CHECK(readableData != nullptr);
464 
465  unsigned int offset = 0;
466 
467  // Verify Header
468  VerifyTimelineHeaderBinary(readableData, offset, size - 8);
469 
470  // Post-optimisation network
471  // Network entity
472  VerifyTimelineEntityBinaryPacketData(optNetGuid, readableData, offset);
473 
474  // Entity - Type relationship
475  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
476  arm::pipe::EmptyOptional(),
477  optNetGuid,
478  LabelsAndEventClasses::NETWORK_GUID,
479  LabelsAndEventClasses::TYPE_GUID,
480  readableData,
481  offset);
482 
483  // Network - START OF LIFE
484  ProfilingGuid networkSolEventGuid = VerifyTimelineEventBinaryPacket(arm::pipe::EmptyOptional(),
485  arm::pipe::EmptyOptional(),
486  arm::pipe::EmptyOptional(),
487  readableData,
488  offset);
489 
490  // Network - START OF LIFE event relationship
491  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
492  arm::pipe::EmptyOptional(),
493  optNetGuid,
494  networkSolEventGuid,
495  LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
496  readableData,
497  offset);
498 
499  // Process ID Label
500  int processID = arm::pipe::GetCurrentProcessId();
501  std::stringstream ss;
502  ss << processID;
503  std::string processIdLabel = ss.str();
505  arm::pipe::EmptyOptional(), processIdLabel, readableData, offset);
506 
507  // Entity - Process ID relationship
508  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
509  arm::pipe::EmptyOptional(),
510  optNetGuid,
511  arm::pipe::EmptyOptional(),
512  LabelsAndEventClasses::PROCESS_ID_GUID,
513  readableData,
514  offset);
515 
516  // Input layer
517  // Input layer entity
518  VerifyTimelineEntityBinaryPacketData(input->GetGuid(), readableData, offset);
519  // Name Entity
520  ProfilingGuid inputLabelGuid = VerifyTimelineLabelBinaryPacketData(
521  arm::pipe::EmptyOptional(), "input", readableData, offset);
522 
523  // Entity - Name relationship
524  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
525  arm::pipe::EmptyOptional(),
526  input->GetGuid(),
527  inputLabelGuid,
528  LabelsAndEventClasses::NAME_GUID,
529  readableData,
530  offset);
531 
532  // Entity - Type relationship
533  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
534  arm::pipe::EmptyOptional(),
535  input->GetGuid(),
536  LabelsAndEventClasses::LAYER_GUID,
537  LabelsAndEventClasses::TYPE_GUID,
538  readableData,
539  offset);
540 
541  // Network - Input layer relationship
542  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
543  arm::pipe::EmptyOptional(),
544  optNetGuid,
545  input->GetGuid(),
546  LabelsAndEventClasses::CHILD_GUID,
547  readableData,
548  offset);
549 
550  // Weights layer
551  // We will not check the GUID from the packets since we haven't direct access to the layer
552  // The GUID will change depending on the number of tests ran since we do are not explicitly resetting the
553  // ProfilingGuid counter at the beginning of this test
554 
555 
556  // Weights layer entity
557  VerifyTimelineEntityBinaryPacketData( arm::pipe::EmptyOptional(), readableData, offset);
558 
559  // Name entity
560  ProfilingGuid weightsNameLabelGuid = VerifyTimelineLabelBinaryPacketData(
561  arm::pipe::EmptyOptional(), "Weights", readableData, offset);
562 
563  // Entity - Name relationship
564  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
565  arm::pipe::EmptyOptional(),
566  arm::pipe::EmptyOptional(),
567  weightsNameLabelGuid,
568  LabelsAndEventClasses::NAME_GUID,
569  readableData,
570  offset);
571 
572  // Entity - Type relationship
573  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
574  arm::pipe::EmptyOptional(),
575  arm::pipe::EmptyOptional(),
576  LabelsAndEventClasses::LAYER_GUID,
577  LabelsAndEventClasses::TYPE_GUID,
578  readableData,
579  offset);
580 
581  // Network - Weights layer relationship
582  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
583  arm::pipe::EmptyOptional(),
584  optNetGuid,
585  arm::pipe::EmptyOptional(),
586  LabelsAndEventClasses::CHILD_GUID,
587  readableData,
588  offset);
589 
590  // Weights workload
591  // Weights workload entity
592  ProfilingGuid weightsWorkloadGuid = VerifyTimelineEntityBinaryPacketData(
593  arm::pipe::EmptyOptional(), readableData, offset);
594 
595  // Entity - Type relationship
596  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
597  arm::pipe::EmptyOptional(),
598  weightsWorkloadGuid,
599  LabelsAndEventClasses::WORKLOAD_GUID,
600  LabelsAndEventClasses::TYPE_GUID,
601  readableData,
602  offset);
603 
604  // BackendId entity
605  ProfilingGuid backendIdLabelGuid = VerifyTimelineLabelBinaryPacketData(
606  arm::pipe::EmptyOptional(), backendId.Get(), readableData, offset);
607 
608  // Entity - BackendId relationship
609  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
610  arm::pipe::EmptyOptional(),
611  weightsWorkloadGuid,
612  backendIdLabelGuid,
613  LabelsAndEventClasses::BACKENDID_GUID,
614  readableData,
615  offset);
616 
617 
618  // Weights layer - Weights workload relationship
619  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
620  arm::pipe::EmptyOptional(),
621  arm::pipe::EmptyOptional(),
622  weightsWorkloadGuid,
623  LabelsAndEventClasses::CHILD_GUID,
624  readableData,
625  offset);
626 
627  // Bias layer
628  // We will not check the GUID from the packets since we haven't direct access to the layer
629  // The GUID will change depending on the number of tests ran since we do are not explicitly resetting the
630  // ProfilingGuid counter at the beginning of this test
631 
632  // Bias layer entity
633  VerifyTimelineEntityBinaryPacketData(arm::pipe::EmptyOptional(), readableData, offset);
634 
635  // Name entity
636  ProfilingGuid biasNameLabelGuid = VerifyTimelineLabelBinaryPacketData(
637  arm::pipe::EmptyOptional(), "Bias", readableData, offset);
638 
639  // Entity - Name relationship
640  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
641  arm::pipe::EmptyOptional(),
642  arm::pipe::EmptyOptional(),
643  biasNameLabelGuid,
644  LabelsAndEventClasses::NAME_GUID,
645  readableData,
646  offset);
647 
648  // Entity - Type relationship
649  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
650  arm::pipe::EmptyOptional(),
651  arm::pipe::EmptyOptional(),
652  LabelsAndEventClasses::LAYER_GUID,
653  LabelsAndEventClasses::TYPE_GUID,
654  readableData,
655  offset);
656 
657  // Network - Bias layer relationship
658  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
659  arm::pipe::EmptyOptional(),
660  optNetGuid,
661  arm::pipe::EmptyOptional(),
662  LabelsAndEventClasses::CHILD_GUID,
663  readableData,
664  offset);
665 
666  // Bias workload
667  // Bias workload entity
668  ProfilingGuid biasWorkloadGuid = VerifyTimelineEntityBinaryPacketData(
669  arm::pipe::EmptyOptional(), readableData, offset);
670 
671  // Entity - Type relationship
672  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
673  arm::pipe::EmptyOptional(),
674  biasWorkloadGuid,
675  LabelsAndEventClasses::WORKLOAD_GUID,
676  LabelsAndEventClasses::TYPE_GUID,
677  readableData,
678  offset);
679 
680  // BackendId entity
681  backendIdLabelGuid = VerifyTimelineLabelBinaryPacketData(
682  arm::pipe::EmptyOptional(), backendId.Get(), readableData, offset);
683 
684  // Entity - BackendId relationship
685  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
686  arm::pipe::EmptyOptional(),
687  biasWorkloadGuid,
688  backendIdLabelGuid,
689  LabelsAndEventClasses::BACKENDID_GUID,
690  readableData,
691  offset);
692 
693 
694  // Bias layer - Bias workload relationship
695  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
696  arm::pipe::EmptyOptional(),
697  arm::pipe::EmptyOptional(),
698  biasWorkloadGuid,
699  LabelsAndEventClasses::CHILD_GUID,
700  readableData,
701  offset);
702 
703  // Conv2d layer
704  // Conv2d layer entity
705  VerifyTimelineEntityBinaryPacketData(conv2d->GetGuid(), readableData, offset);
706 
707  // Name entity
708  ProfilingGuid conv2dNameLabelGuid = VerifyTimelineLabelBinaryPacketData(
709  arm::pipe::EmptyOptional(), "<Unnamed>", readableData, offset);
710 
711  // Entity - Name relationship
712  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
713  arm::pipe::EmptyOptional(),
714  conv2d->GetGuid(),
715  conv2dNameLabelGuid,
716  LabelsAndEventClasses::NAME_GUID,
717  readableData,
718  offset);
719 
720  // Entity - Type relationship
721  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
722  arm::pipe::EmptyOptional(),
723  conv2d->GetGuid(),
724  LabelsAndEventClasses::LAYER_GUID,
725  LabelsAndEventClasses::TYPE_GUID,
726  readableData,
727  offset);
728 
729  // Network - Conv2d layer relationship
730  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
731  arm::pipe::EmptyOptional(),
732  optNetGuid,
733  conv2d->GetGuid(),
734  LabelsAndEventClasses::CHILD_GUID,
735  readableData,
736  offset);
737 
738  // Input layer - Conv2d layer relationship
739  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
740  arm::pipe::EmptyOptional(),
741  input->GetGuid(),
742  conv2d->GetGuid(),
743  LabelsAndEventClasses::CONNECTION_GUID,
744  readableData,
745  offset);
746 
747  // Weights layer - Conv2d layer relationship
748  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
749  arm::pipe::EmptyOptional(),
750  arm::pipe::EmptyOptional(),
751  conv2d->GetGuid(),
752  LabelsAndEventClasses::CONNECTION_GUID,
753  readableData,
754  offset);
755 
756  // Bias 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  // Conv2d workload
766  // Conv2d workload entity
767  ProfilingGuid conv2DWorkloadGuid = VerifyTimelineEntityBinaryPacketData(
768  arm::pipe::EmptyOptional(), readableData, offset);
769 
770  // Entity - Type relationship
771  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
772  arm::pipe::EmptyOptional(),
773  conv2DWorkloadGuid,
774  LabelsAndEventClasses::WORKLOAD_GUID,
775  LabelsAndEventClasses::TYPE_GUID,
776  readableData,
777  offset);
778 
779  // BackendId entity
780  backendIdLabelGuid = VerifyTimelineLabelBinaryPacketData(
781  arm::pipe::EmptyOptional(), backendId.Get(), readableData, offset);
782 
783  // Entity - BackendId relationship
784  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
785  arm::pipe::EmptyOptional(),
786  conv2DWorkloadGuid,
787  backendIdLabelGuid,
788  LabelsAndEventClasses::BACKENDID_GUID,
789  readableData,
790  offset);
791 
792 
793  // Conv2d layer - Conv2d workload relationship
794  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
795  arm::pipe::EmptyOptional(),
796  conv2d->GetGuid(),
797  conv2DWorkloadGuid,
798  LabelsAndEventClasses::CHILD_GUID,
799  readableData,
800  offset);
801 
802  // Abs layer
803  // Abs layer entity
804  VerifyTimelineEntityBinaryPacketData(abs->GetGuid(), readableData, offset);
805 
806  // Name entity
807  ProfilingGuid absLabelGuid = VerifyTimelineLabelBinaryPacketData(
808  arm::pipe::EmptyOptional(), "abs", readableData, offset);
809 
810  // Entity - Name relationship
811  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
812  arm::pipe::EmptyOptional(),
813  abs->GetGuid(),
814  absLabelGuid,
815  LabelsAndEventClasses::NAME_GUID,
816  readableData,
817  offset);
818 
819  // Entity - Type relationship
820  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
821  arm::pipe::EmptyOptional(),
822  abs->GetGuid(),
823  LabelsAndEventClasses::LAYER_GUID,
824  LabelsAndEventClasses::TYPE_GUID,
825  readableData,
826  offset);
827 
828  // Network - Abs layer relationship
829  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
830  arm::pipe::EmptyOptional(),
831  optNetGuid,
832  abs->GetGuid(),
833  LabelsAndEventClasses::CHILD_GUID,
834  readableData,
835  offset);
836 
837  // Conv2d layer - Abs layer relationship
838  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
839  arm::pipe::EmptyOptional(),
840  conv2d->GetGuid(),
841  abs->GetGuid(),
842  LabelsAndEventClasses::CONNECTION_GUID,
843  readableData,
844  offset);
845 
846  // Abs workload
847  // Abs workload entity
848  ProfilingGuid absWorkloadGuid = VerifyTimelineEntityBinaryPacketData(
849  arm::pipe::EmptyOptional(), readableData, offset);
850 
851  // Entity - Type relationship
852  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
853  arm::pipe::EmptyOptional(),
854  absWorkloadGuid,
855  LabelsAndEventClasses::WORKLOAD_GUID,
856  LabelsAndEventClasses::TYPE_GUID,
857  readableData,
858  offset);
859 
860  // BackendId entity
861  VerifyTimelineLabelBinaryPacketData(arm::pipe::EmptyOptional(), backendId.Get(), readableData, offset);
862 
863  // Entity - BackendId relationship
864  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
865  arm::pipe::EmptyOptional(),
866  absWorkloadGuid,
867  backendIdLabelGuid,
868  LabelsAndEventClasses::BACKENDID_GUID,
869  readableData,
870  offset);
871 
872  // Abs layer - Abs workload relationship
873  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
874  arm::pipe::EmptyOptional(),
875  abs->GetGuid(),
876  absWorkloadGuid,
877  LabelsAndEventClasses::CHILD_GUID,
878  readableData,
879  offset);
880 
881  // Output layer
882  // Output layer entity
883  VerifyTimelineEntityBinaryPacketData(output->GetGuid(), readableData, offset);
884 
885  // Name entity
886  ProfilingGuid outputLabelGuid = VerifyTimelineLabelBinaryPacketData(
887  arm::pipe::EmptyOptional(), "output", readableData, offset);
888 
889  // Entity - Name relationship
890  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
891  arm::pipe::EmptyOptional(),
892  output->GetGuid(),
893  outputLabelGuid,
894  LabelsAndEventClasses::NAME_GUID,
895  readableData,
896  offset);
897 
898  // Entity - Type relationship
899  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
900  arm::pipe::EmptyOptional(),
901  output->GetGuid(),
902  LabelsAndEventClasses::LAYER_GUID,
903  LabelsAndEventClasses::TYPE_GUID,
904  readableData,
905  offset);
906 
907  // Network - Output layer relationship
908  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
909  arm::pipe::EmptyOptional(),
910  optNetGuid,
911  output->GetGuid(),
912  LabelsAndEventClasses::CHILD_GUID,
913  readableData,
914  offset);
915 
916  // Abs layer - Output layer relationship
917  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
918  arm::pipe::EmptyOptional(),
919  abs->GetGuid(),
920  output->GetGuid(),
921  LabelsAndEventClasses::CONNECTION_GUID,
922  readableData,
923  offset);
924 
925  bufferManager.MarkRead(readableBuffer);
926 
927  // Creates structures for input & output.
928  std::vector<float> inputData(inputInfo.GetNumElements());
929  std::vector<float> outputData(outputInfo.GetNumElements());
930 
931  TensorInfo inputTensorInfo = runtime.GetInputTensorInfo(netId, 0);
932  inputTensorInfo.SetConstant(true);
933  InputTensors inputTensors
934  {
935  {0, ConstTensor(inputTensorInfo, inputData.data())}
936  };
937  OutputTensors outputTensors
938  {
939  {0, Tensor(runtime.GetOutputTensorInfo(netId, 0), outputData.data())}
940  };
941 
942  // Does the inference.
943  runtime.EnqueueWorkload(netId, inputTensors, outputTensors);
944 
945  // Get readable buffer for input workload
946  auto inputReadableBuffer = bufferManager.GetReadableBuffer();
947  CHECK(inputReadableBuffer != nullptr);
948 
949  // Get readable buffer for output workload
950  auto outputReadableBuffer = bufferManager.GetReadableBuffer();
951  CHECK(outputReadableBuffer != nullptr);
952 
953  // Get readable buffer for inference timeline
954  auto inferenceReadableBuffer = bufferManager.GetReadableBuffer();
955  CHECK(inferenceReadableBuffer != nullptr);
956 
957  // Validate input workload data
958  size = inputReadableBuffer->GetSize();
959  CHECK(size == 164);
960 
961  readableData = inputReadableBuffer->GetReadableData();
962  CHECK(readableData != nullptr);
963 
964  offset = 0;
965 
966  // Verify Header
967  VerifyTimelineHeaderBinary(readableData, offset, 156);
968 
969  // Input workload
970  // Input workload entity
971  ProfilingGuid inputWorkloadGuid = VerifyTimelineEntityBinaryPacketData(
972  arm::pipe::EmptyOptional(), readableData, offset);
973 
974  // Entity - Type relationship
975  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
976  arm::pipe::EmptyOptional(),
977  inputWorkloadGuid,
978  LabelsAndEventClasses::WORKLOAD_GUID,
979  LabelsAndEventClasses::TYPE_GUID,
980  readableData,
981  offset);
982 
983  // BackendId entity
984  VerifyTimelineLabelBinaryPacketData(arm::pipe::EmptyOptional(), backendId.Get(), readableData, offset);
985 
986  // Entity - BackendId relationship
987  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
988  arm::pipe::EmptyOptional(),
989  inputWorkloadGuid,
990  backendIdLabelGuid,
991  LabelsAndEventClasses::BACKENDID_GUID,
992  readableData,
993  offset);
994 
995  // Input layer - Input workload relationship
996  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
997  arm::pipe::EmptyOptional(),
998  input->GetGuid(),
999  inputWorkloadGuid,
1000  LabelsAndEventClasses::CHILD_GUID,
1001  readableData,
1002  offset);
1003 
1004  bufferManager.MarkRead(inputReadableBuffer);
1005 
1006  // Validate output workload data
1007  size = outputReadableBuffer->GetSize();
1008  CHECK(size == 164);
1009 
1010  readableData = outputReadableBuffer->GetReadableData();
1011  CHECK(readableData != nullptr);
1012 
1013  offset = 0;
1014 
1015  // Verify Header
1016  VerifyTimelineHeaderBinary(readableData, offset, 156);
1017 
1018  // Output workload
1019  // Output workload entity
1020  ProfilingGuid outputWorkloadGuid = VerifyTimelineEntityBinaryPacketData(
1021  arm::pipe::EmptyOptional(), readableData, offset);
1022 
1023  // Entity - Type relationship
1024  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1025  arm::pipe::EmptyOptional(),
1026  outputWorkloadGuid,
1027  LabelsAndEventClasses::WORKLOAD_GUID,
1028  LabelsAndEventClasses::TYPE_GUID,
1029  readableData,
1030  offset);
1031 
1032  // BackendId entity
1033  VerifyTimelineLabelBinaryPacketData(arm::pipe::EmptyOptional(), backendId.Get(), readableData, offset);
1034 
1035  // Entity - BackendId relationship
1036  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1037  arm::pipe::EmptyOptional(),
1038  outputWorkloadGuid,
1039  backendIdLabelGuid,
1040  LabelsAndEventClasses::BACKENDID_GUID,
1041  readableData,
1042  offset);
1043 
1044  // Output layer - Output workload relationship
1045  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1046  arm::pipe::EmptyOptional(),
1047  output->GetGuid(),
1048  outputWorkloadGuid,
1049  LabelsAndEventClasses::CHILD_GUID,
1050  readableData,
1051  offset);
1052 
1053  bufferManager.MarkRead(outputReadableBuffer);
1054 
1055  // Validate inference data
1056  size = inferenceReadableBuffer->GetSize();
1057 
1058  CHECK(size == 1748 + 10 * ThreadIdSize);
1059 
1060  readableData = inferenceReadableBuffer->GetReadableData();
1061  CHECK(readableData != nullptr);
1062 
1063  offset = 0;
1064 
1065  // Verify Header
1066  VerifyTimelineHeaderBinary(readableData, offset, 1740 + 10 * ThreadIdSize);
1067 
1068  // Inference timeline trace
1069  // Inference entity
1070  ProfilingGuid inferenceGuid = VerifyTimelineEntityBinaryPacketData(
1071  arm::pipe::EmptyOptional(), readableData, offset);
1072 
1073  // Entity - Type relationship
1074  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1075  arm::pipe::EmptyOptional(),
1076  inferenceGuid,
1077  LabelsAndEventClasses::INFERENCE_GUID,
1078  LabelsAndEventClasses::TYPE_GUID,
1079  readableData,
1080  offset);
1081 
1082  // Network - Inference relationship
1083  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1084  arm::pipe::EmptyOptional(),
1085  optNetGuid,
1086  inferenceGuid,
1087  LabelsAndEventClasses::EXECUTION_OF_GUID,
1088  readableData,
1089  offset);
1090 
1091  // Start Inference life
1092  // Event packet - timeline, threadId, eventGuid
1093  ProfilingGuid inferenceEventGuid = VerifyTimelineEventBinaryPacket(
1094  arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1095 
1096  // Inference - event relationship
1097  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1098  arm::pipe::EmptyOptional(),
1099  inferenceGuid,
1100  inferenceEventGuid,
1101  LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1102  readableData,
1103  offset);
1104 
1105  // Execution
1106  // Input workload execution
1107  // Input workload execution entity
1108  ProfilingGuid inputWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
1109  arm::pipe::EmptyOptional(), readableData, offset);
1110 
1111  // Entity - Type relationship
1112  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1113  arm::pipe::EmptyOptional(),
1114  inputWorkloadExecutionGuid,
1115  LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
1116  LabelsAndEventClasses::TYPE_GUID,
1117  readableData,
1118  offset);
1119 
1120  // Inference - Workload execution relationship
1121  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1122  arm::pipe::EmptyOptional(),
1123  inferenceGuid,
1124  inputWorkloadExecutionGuid,
1125  LabelsAndEventClasses::CHILD_GUID,
1126  readableData,
1127  offset);
1128 
1129  // Workload - Workload execution relationship
1130  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1131  arm::pipe::EmptyOptional(),
1132  inputWorkloadGuid,
1133  inputWorkloadExecutionGuid,
1134  LabelsAndEventClasses::EXECUTION_OF_GUID,
1135  readableData,
1136  offset);
1137 
1138  // Start Input workload execution life
1139  // Event packet - timeline, threadId, eventGuid
1140  ProfilingGuid inputWorkloadExecutionSOLEventId = VerifyTimelineEventBinaryPacket(
1141  arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1142 
1143  // Input workload execution - event relationship
1144  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1145  arm::pipe::EmptyOptional(),
1146  inputWorkloadExecutionGuid,
1147  inputWorkloadExecutionSOLEventId,
1148  LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1149  readableData,
1150  offset);
1151 
1152  // End of Input workload execution life
1153  // Event packet - timeline, threadId, eventGuid
1154  ProfilingGuid inputWorkloadExecutionEOLEventId = VerifyTimelineEventBinaryPacket(
1155  arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1156 
1157  // Input workload execution - event relationship
1158  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1159  arm::pipe::EmptyOptional(),
1160  inputWorkloadExecutionGuid,
1161  inputWorkloadExecutionEOLEventId,
1162  LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1163  readableData,
1164  offset);
1165 
1166  // Weights workload execution
1167  // Weights workload execution entity
1168  ProfilingGuid weightsWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
1169  arm::pipe::EmptyOptional(), readableData, offset);
1170 
1171  // Entity - Type relationship
1172  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1173  arm::pipe::EmptyOptional(),
1174  weightsWorkloadExecutionGuid,
1175  LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
1176  LabelsAndEventClasses::TYPE_GUID,
1177  readableData,
1178  offset);
1179 
1180  // Inference - Workload execution relationship
1181  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1182  arm::pipe::EmptyOptional(),
1183  inferenceGuid,
1184  weightsWorkloadExecutionGuid,
1185  LabelsAndEventClasses::CHILD_GUID,
1186  readableData,
1187  offset);
1188 
1189  // Workload - Workload execution relationship
1190  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1191  arm::pipe::EmptyOptional(),
1192  weightsWorkloadGuid,
1193  weightsWorkloadExecutionGuid,
1194  LabelsAndEventClasses::EXECUTION_OF_GUID,
1195  readableData,
1196  offset);
1197 
1198  // Start Weights workload execution life
1199  // Event packet - timeline, threadId, eventGuid
1200  ProfilingGuid weightsWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket(
1201  arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1202 
1203  // Weights workload execution - event relationship
1204  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1205  arm::pipe::EmptyOptional(),
1206  weightsWorkloadExecutionGuid,
1207  weightsWorkloadExecutionSOLEventGuid,
1208  LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1209  readableData,
1210  offset);
1211 
1212  // End of Weights workload execution life
1213  // Event packet - timeline, threadId, eventGuid
1214  ProfilingGuid weightsWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket(
1215  arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1216 
1217  // Weights workload execution - event relationship
1218  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1219  arm::pipe::EmptyOptional(),
1220  weightsWorkloadExecutionGuid,
1221  weightsWorkloadExecutionEOLEventGuid,
1222  LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1223  readableData,
1224  offset);
1225 
1226  // Bias workload execution
1227  // Bias workload execution entity
1228  ProfilingGuid biasWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
1229  arm::pipe::EmptyOptional(), readableData, offset);
1230 
1231  // Entity - Type relationship
1232  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1233  arm::pipe::EmptyOptional(),
1234  biasWorkloadExecutionGuid,
1235  LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
1236  LabelsAndEventClasses::TYPE_GUID,
1237  readableData,
1238  offset);
1239 
1240  // Inference - Workload execution relationship
1241  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1242  arm::pipe::EmptyOptional(),
1243  inferenceGuid,
1244  biasWorkloadExecutionGuid,
1245  LabelsAndEventClasses::CHILD_GUID,
1246  readableData,
1247  offset);
1248 
1249  // Workload - Workload execution relationship
1250  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1251  arm::pipe::EmptyOptional(),
1252  biasWorkloadGuid,
1253  biasWorkloadExecutionGuid,
1254  LabelsAndEventClasses::EXECUTION_OF_GUID,
1255  readableData,
1256  offset);
1257 
1258  // Start Bias workload execution life
1259  // Event packet - timeline, threadId, eventGuid
1260  ProfilingGuid biasWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket(
1261  arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1262 
1263  // Bias workload execution - event relationship
1264  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1265  arm::pipe::EmptyOptional(),
1266  biasWorkloadExecutionGuid,
1267  biasWorkloadExecutionSOLEventGuid,
1268  LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1269  readableData,
1270  offset);
1271 
1272  // End of Bias workload execution life
1273  // Event packet - timeline, threadId, eventGuid
1274  ProfilingGuid biasWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket(
1275  arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1276 
1277  // Bias workload execution - event relationship
1278  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1279  arm::pipe::EmptyOptional(),
1280  biasWorkloadExecutionGuid,
1281  biasWorkloadExecutionEOLEventGuid,
1282  LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1283  readableData,
1284  offset);
1285 
1286  // Conv2d workload execution
1287  // Conv2d workload execution entity
1288  ProfilingGuid conv2DWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
1289  arm::pipe::EmptyOptional(), readableData, offset);
1290 
1291  // Entity - Type relationship
1292  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1293  arm::pipe::EmptyOptional(),
1294  conv2DWorkloadExecutionGuid,
1295  LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
1296  LabelsAndEventClasses::TYPE_GUID,
1297  readableData,
1298  offset);
1299 
1300  // Inference - Workload execution relationship
1301  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1302  arm::pipe::EmptyOptional(),
1303  inferenceGuid,
1304  conv2DWorkloadExecutionGuid,
1305  LabelsAndEventClasses::CHILD_GUID,
1306  readableData,
1307  offset);
1308 
1309  // Workload - Workload execution relationship
1310  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1311  arm::pipe::EmptyOptional(),
1312  conv2DWorkloadGuid,
1313  conv2DWorkloadExecutionGuid,
1314  LabelsAndEventClasses::EXECUTION_OF_GUID,
1315  readableData,
1316  offset);
1317 
1318  // Start Conv2d workload execution life
1319  // Event packet - timeline, threadId, eventGuid
1320  ProfilingGuid conv2DWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket(
1321  arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1322 
1323  // Conv2d workload execution - event relationship
1324  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1325  arm::pipe::EmptyOptional(),
1326  conv2DWorkloadExecutionGuid,
1327  conv2DWorkloadExecutionSOLEventGuid,
1328  LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1329  readableData,
1330  offset);
1331 
1332  // End of Conv2d workload execution life
1333  // Event packet - timeline, threadId, eventGuid
1334  ProfilingGuid conv2DWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket(
1335  arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1336 
1337  // Conv2d workload execution - event relationship
1338  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1339  arm::pipe::EmptyOptional(),
1340  conv2DWorkloadExecutionGuid,
1341  conv2DWorkloadExecutionEOLEventGuid,
1342  LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1343  readableData,
1344  offset);
1345 
1346  // Abs workload execution
1347  // Abs workload execution entity
1348  ProfilingGuid absWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
1349  arm::pipe::EmptyOptional(), readableData, offset);
1350 
1351  // Entity - Type relationship
1352  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1353  arm::pipe::EmptyOptional(),
1354  absWorkloadExecutionGuid,
1355  LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
1356  LabelsAndEventClasses::TYPE_GUID,
1357  readableData,
1358  offset);
1359 
1360  // Inference - Workload execution relationship
1361  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1362  arm::pipe::EmptyOptional(),
1363  inferenceGuid,
1364  absWorkloadExecutionGuid,
1365  LabelsAndEventClasses::CHILD_GUID,
1366  readableData,
1367  offset);
1368 
1369  // Workload - Workload execution relationship
1370  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1371  arm::pipe::EmptyOptional(),
1372  absWorkloadGuid,
1373  absWorkloadExecutionGuid,
1374  LabelsAndEventClasses::EXECUTION_OF_GUID,
1375  readableData,
1376  offset);
1377 
1378  // Start Abs workload execution life
1379  // Event packet - timeline, threadId, eventGuid
1380  ProfilingGuid absWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket(
1381  arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1382 
1383  // Abs workload execution - event relationship
1384  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1385  arm::pipe::EmptyOptional(),
1386  absWorkloadExecutionGuid,
1387  absWorkloadExecutionSOLEventGuid,
1388  LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1389  readableData,
1390  offset);
1391 
1392  // End of Abs workload execution life
1393  // Event packet - timeline, threadId, eventGuid
1394  ProfilingGuid absWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket(
1395  arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1396 
1397  // Abs workload execution - event relationship
1398  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1399  arm::pipe::EmptyOptional(),
1400  absWorkloadExecutionGuid,
1401  absWorkloadExecutionEOLEventGuid,
1402  LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1403  readableData,
1404  offset);
1405 
1406  // Output workload execution
1407  // Output workload execution entity
1408  ProfilingGuid outputWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
1409  arm::pipe::EmptyOptional(), readableData, offset);
1410 
1411  // Entity - Type relationship
1412  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1413  arm::pipe::EmptyOptional(),
1414  outputWorkloadExecutionGuid,
1415  LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
1416  LabelsAndEventClasses::TYPE_GUID,
1417  readableData,
1418  offset);
1419 
1420  // Inference - Workload execution relationship
1421  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1422  arm::pipe::EmptyOptional(),
1423  inferenceGuid,
1424  outputWorkloadExecutionGuid,
1425  LabelsAndEventClasses::CHILD_GUID,
1426  readableData,
1427  offset);
1428 
1429  // Workload - Workload execution relationship
1430  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1431  arm::pipe::EmptyOptional(),
1432  outputWorkloadGuid,
1433  outputWorkloadExecutionGuid,
1434  LabelsAndEventClasses::EXECUTION_OF_GUID,
1435  readableData,
1436  offset);
1437 
1438  // Start Output workload execution life
1439  // Event packet - timeline, threadId, eventGuid
1440  ProfilingGuid outputWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket(
1441  arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1442 
1443  // Output workload execution - event relationship
1444  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1445  arm::pipe::EmptyOptional(),
1446  outputWorkloadExecutionGuid,
1447  outputWorkloadExecutionSOLEventGuid,
1448  LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1449  readableData,
1450  offset);
1451 
1452  // End of Normalize workload execution life
1453  // Event packet - timeline, threadId, eventGuid
1454  ProfilingGuid outputWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket(
1455  arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1456 
1457  // Output workload execution - event relationship
1458  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1459  arm::pipe::EmptyOptional(),
1460  outputWorkloadExecutionGuid,
1461  outputWorkloadExecutionEOLEventGuid,
1462  LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1463  readableData,
1464  offset);
1465 
1466  // End of Inference life
1467  // Event packet - timeline, threadId, eventGuid
1468  ProfilingGuid inferenceEOLEventGuid = VerifyTimelineEventBinaryPacket(
1469  arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
1470 
1471  // Inference - event relationship
1472  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1473  arm::pipe::EmptyOptional(),
1474  inferenceGuid,
1475  inferenceEOLEventGuid,
1476  LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1477  readableData,
1478  offset);
1479 
1480  bufferManager.MarkRead(inferenceReadableBuffer);
1481 }
1482 
1483 bool CompareOutput(std::vector<std::string> output, std::vector<std::string> expectedOutput)
1484 {
1485  if (output.size() != expectedOutput.size())
1486  {
1487  std::cerr << "output has [" << output.size() << "] lines, expected was ["
1488  << expectedOutput.size() << "] lines" << std::endl;
1489  std::cerr << std::endl << "actual" << std::endl << std::endl;
1490  for (auto line : output)
1491  {
1492  std::cerr << line << std::endl;
1493  }
1494  std::cerr << std::endl << "expected" << std::endl << std::endl;
1495  for (auto line : expectedOutput)
1496  {
1497  std::cerr << line << std::endl;
1498  }
1499  return false;
1500  }
1501  bool bRet = true;
1502  for (unsigned long i = 0; i < output.size(); ++i)
1503  {
1504  if (output[i] != expectedOutput[i])
1505  {
1506  bRet = false;
1507  std::cerr << i << ": actual [" << output[i] << "] expected [" << expectedOutput[i] << "]" << std::endl;
1508  }
1509  }
1510  return bRet;
1511 }
uint32_t m_PadBottom
Padding bottom value in the height dimension.
bool m_BiasEnabled
Enable/disable bias.
armnn::TensorInfo GetInputTensorInfo(NetworkId networkId, LayerBindingId layerId) const
Definition: Runtime.cpp:599
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:66
void VerifyTimelineEventClassBinaryPacketData(ProfilingGuid guid, ProfilingGuid nameGuid, const unsigned char *readableData, unsigned int &offset)
void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId)
CPU Execution: Reference C++ kernels.
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
A Convolution2dDescriptor for the Convolution2dLayer.
uint32_t GetStreamMetaDataPacketSize()
ProfilingGuid VerifyTimelineEntityBinaryPacketData(arm::pipe::Optional< ProfilingGuid > guid, const unsigned char *readableData, unsigned int &offset)
BackendRegistry & BackendRegistryInstance()
Status LoadNetwork(NetworkId &networkIdOut, IOptimizedNetworkPtr network)
Loads a complete network into the Runtime.
Definition: Runtime.cpp:163
std::vector< std::pair< LayerBindingId, class ConstTensor > > InputTensors
Definition: Tensor.hpp:392
uint32_t m_PadRight
Padding right value in the width dimension.
armnn::TensorInfo GetOutputTensorInfo(NetworkId networkId, LayerBindingId layerId) const
Definition: Runtime.cpp:604
Copyright (c) 2021 ARM Limited and Contributors.
std::vector< BackendId > GetSuitableBackendRegistered()
Returns a vector of CpuRef, CpuAcc or GpuAcc backends if they where registered.
bool m_EnableProfiling
Indicates whether external profiling is enabled or not.
Definition: IRuntime.hpp:138
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
Definition: Tensor.hpp:319
unsigned int OffsetToNextWord(unsigned int numberOfBytes)
void 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)
uint32_t m_PadTop
Padding top value in the height dimension.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34
IOptimizedNetworkPtr Optimize(const INetwork &network, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptions &options=OptimizerOptions(), Optional< std::vector< std::string > &> messages=EmptyOptional())
Create an optimized version of the network.
Definition: Network.cpp:1847
bool CompareOutput(std::vector< std::string > output, std::vector< std::string > expectedOutput)
const IDeviceSpec & GetDeviceSpec() const
Definition: Runtime.hpp:90
virtual LayerGuid GetGuid() const =0
Returns the unique id of the layer.
int NetworkId
Definition: IRuntime.hpp:27
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:327
std::vector< std::pair< LayerBindingId, class Tensor > > OutputTensors
Definition: Tensor.hpp:393
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
Definition: INetwork.hpp:242
ProfilingGuid VerifyTimelineLabelBinaryPacketData(arm::pipe::Optional< ProfilingGuid > guid, const std::string &label, const unsigned char *readableData, unsigned int &offset)
ProfilingOptions ConvertExternalProfilingOptions(const armnn::IRuntime::CreationOptions::ExternalProfilingOptions &options)
constexpr char const * GetComputeDeviceAsCString(Compute compute)
Deprecated function that will be removed together with the Compute enum.
Definition: BackendId.hpp:34
GPU Execution: OpenCL: ArmCompute.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
void VerifyTimelineHeaderBinary(const unsigned char *readableData, unsigned int &offset, uint32_t packetDataLength)
Status EnqueueWorkload(NetworkId networkId, const InputTensors &inputTensors, const OutputTensors &outputTensors, std::vector< ImportedInputId > preImportedInputIds={}, std::vector< ImportedOutputId > preImportedOutputIds={})
Definition: Runtime.cpp:630
A ElementwiseUnaryDescriptor for the ElementwiseUnaryLayer.
void ForceTransitionToState(ProfilingState newState)
CPU Execution: NEON: ArmCompute.
const std::string & Get() const
Definition: BackendId.hpp:138
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
void SetConstant(const bool IsConstant=true)
Marks the data corresponding to this tensor info as constant.
Definition: Tensor.cpp:514
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35
bool m_TimelineEnabled
Indicates whether external timeline profiling is enabled or not.
Definition: IRuntime.hpp:140
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
Get the const output slot handle by slot index.
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:241
virtual int Connect(IInputSlot &destination)=0
ExternalProfilingOptions m_ProfilingOptions
Definition: IRuntime.hpp:153
arm::pipe::IProfilingService & GetProfilingService(armnn::RuntimeImpl *runtime)
Definition: TestUtils.cpp:59
ProfilingGuid VerifyTimelineEventBinaryPacket(arm::pipe::Optional< uint64_t > timestamp, arm::pipe::Optional< int > threadId, arm::pipe::Optional< ProfilingGuid > eventGuid, const unsigned char *readableData, unsigned int &offset)
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:476
uint32_t m_PadLeft
Padding left value in the width dimension.