ArmNN
 20.08
ProfilingTestUtils.hpp File Reference
#include "ProfilingUtils.hpp"
#include "Runtime.hpp"
#include <armnn/BackendId.hpp>
#include <armnn/Optional.hpp>
#include <armnn/Types.hpp>
#include <BufferManager.hpp>
#include <ProfilingService.hpp>

Go to the source code of this file.

Classes

class  ProfilingServiceRuntimeHelper
 

Namespaces

 armnn
 Copyright (c) 2020 ARM Limited.
 
 armnn::profiling
 

Functions

uint32_t GetStreamMetaDataPacketSize ()
 
std::vector< BackendIdGetSuitableBackendRegistered ()
 Returns a vector of CpuRef, CpuAcc or GpuAcc backends if they where registered. More...
 
unsigned int OffsetToNextWord (unsigned int numberOfBytes)
 
void VerifyTimelineHeaderBinary (const unsigned char *readableData, unsigned int &offset, uint32_t packetDataLength)
 
ProfilingGuid VerifyTimelineLabelBinaryPacketData (Optional< ProfilingGuid > guid, const std::string &label, const unsigned char *readableData, unsigned int &offset)
 
void VerifyTimelineEventClassBinaryPacketData (ProfilingGuid guid, ProfilingGuid nameGuid, const unsigned char *readableData, unsigned int &offset)
 
void VerifyTimelineRelationshipBinaryPacketData (ProfilingRelationshipType relationshipType, Optional< ProfilingGuid > relationshipGuid, Optional< ProfilingGuid > headGuid, Optional< ProfilingGuid > tailGuid, Optional< ProfilingGuid > attributeGuid, const unsigned char *readableData, unsigned int &offset)
 
ProfilingGuid VerifyTimelineEntityBinaryPacketData (Optional< ProfilingGuid > guid, const unsigned char *readableData, unsigned int &offset)
 
ProfilingGuid VerifyTimelineEventBinaryPacket (Optional< uint64_t > timestamp, Optional< int > threadId, Optional< ProfilingGuid > eventGuid, const unsigned char *readableData, unsigned int &offset)
 
void VerifyPostOptimisationStructureTestImpl (armnn::BackendId backendId)
 
bool CompareOutput (std::vector< std::string > output, std::vector< std::string > expectedOutput)
 

Function Documentation

◆ CompareOutput()

bool CompareOutput ( std::vector< std::string >  output,
std::vector< std::string >  expectedOutput 
)

Definition at line 1256 of file ProfilingTestUtils.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

1257 {
1258  if (output.size() != expectedOutput.size())
1259  {
1260  std::cerr << "output has [" << output.size() << "] lines, expected was ["
1261  << expectedOutput.size() << "] lines" << std::endl;
1262  std::cerr << std::endl << "actual" << std::endl << std::endl;
1263  for (auto line : output)
1264  {
1265  std::cerr << line << std::endl;
1266  }
1267  std::cerr << std::endl << "expected" << std::endl << std::endl;
1268  for (auto line : expectedOutput)
1269  {
1270  std::cerr << line << std::endl;
1271  }
1272  return false;
1273  }
1274  bool bRet = true;
1275  for (unsigned long i = 0; i < output.size(); ++i)
1276  {
1277  if (output[i] != expectedOutput[i])
1278  {
1279  bRet = false;
1280  std::cerr << i << ": actual [" << output[i] << "] expected [" << expectedOutput[i] << "]" << std::endl;
1281  }
1282  }
1283  return bRet;
1284 }

◆ GetStreamMetaDataPacketSize()

uint32_t GetStreamMetaDataPacketSize ( )

Definition at line 19 of file ProfilingTestUtils.cpp.

References armnn::profiling::GetHardwareVersion(), armnn::profiling::GetProcessName(), armnn::profiling::GetSoftwareInfo(), armnn::profiling::GetSoftwareVersion(), and armnn::numeric_cast().

Referenced by BOOST_AUTO_TEST_CASE().

20 {
21  uint32_t sizeUint32 = sizeof(uint32_t);
22  uint32_t payloadSize = 0;
23  payloadSize += boost::numeric_cast<uint32_t>(GetSoftwareInfo().size()) + 1;
24  payloadSize += boost::numeric_cast<uint32_t>(GetHardwareVersion().size()) + 1;
25  payloadSize += boost::numeric_cast<uint32_t>(GetSoftwareVersion().size()) + 1;
26  payloadSize += boost::numeric_cast<uint32_t>(GetProcessName().size()) + 1;
27 
28  // Add packetVersionEntries
29  payloadSize += 13 * 2 * sizeUint32;
30  // Add packetVersionCountSize
31  payloadSize += sizeUint32;
32 
33  uint32_t headerSize = 2 * sizeUint32;
34  uint32_t bodySize = 10 * sizeUint32;
35 
36  return headerSize + bodySize + payloadSize;
37 }
std::string GetHardwareVersion()
std::string GetProcessName()
std::string GetSoftwareInfo()
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:33
std::string GetSoftwareVersion()

◆ GetSuitableBackendRegistered()

std::vector<BackendId> GetSuitableBackendRegistered ( )

Returns a vector of CpuRef, CpuAcc or GpuAcc backends if they where registered.

Definition at line 39 of file ProfilingTestUtils.cpp.

References armnn::BackendRegistryInstance(), armnn::CpuAcc, armnn::CpuRef, armnn::GetComputeDeviceAsCString(), and armnn::GpuAcc.

Referenced by BOOST_AUTO_TEST_CASE().

40 {
41  std::vector<BackendId> suitableBackends;
43  {
44  suitableBackends.push_back(armnn::Compute::CpuRef);
45  }
47  {
48  suitableBackends.push_back(armnn::Compute::CpuAcc);
49  }
51  {
52  suitableBackends.push_back(armnn::Compute::GpuAcc);
53  }
54  return suitableBackends;
55 }
CPU Execution: Reference C++ kernels.
BackendRegistry & BackendRegistryInstance()
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.
CPU Execution: NEON: ArmCompute.

◆ OffsetToNextWord()

unsigned int OffsetToNextWord ( unsigned int  numberOfBytes)
inline

Definition at line 57 of file ProfilingTestUtils.cpp.

References armnn::profiling::uint32_t_size.

Referenced by VerifyTimelineLabelBinaryPacketData().

58 {
59  unsigned int uint32_t_size = sizeof(uint32_t);
60 
61  unsigned int remainder = numberOfBytes % uint32_t_size;
62  if (remainder == 0)
63  {
64  return numberOfBytes;
65  }
66 
67  return numberOfBytes + uint32_t_size - remainder;
68 }

◆ VerifyPostOptimisationStructureTestImpl()

void VerifyPostOptimisationStructureTestImpl ( armnn::BackendId  backendId)

Definition at line 359 of file ProfilingTestUtils.cpp.

References LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, LabelsAndEventClasses::BACKENDID_GUID, LabelsAndEventClasses::CHILD_GUID, IOutputSlot::Connect(), LabelsAndEventClasses::CONNECTION_GUID, INetwork::Create(), Runtime::EnqueueWorkload(), LabelsAndEventClasses::EXECUTION_OF_GUID, armnn::Float32, ProfilingServiceRuntimeHelper::ForceTransitionToState(), BackendId::Get(), armnnUtils::Processes::GetCurrentId(), Runtime::GetDeviceSpec(), IConnectableLayer::GetGuid(), IConnectableLayer::GetInputSlot(), Runtime::GetInputTensorInfo(), IConnectableLayer::GetOutputSlot(), Runtime::GetOutputTensorInfo(), ProfilingServiceRuntimeHelper::GetProfilingBufferManager(), armnn::GetProfilingService(), BufferManager::GetReadableBuffer(), LabelsAndEventClasses::INFERENCE_GUID, LabelsAndEventClasses::LAYER_GUID, Runtime::LoadNetwork(), Convolution2dDescriptor::m_BiasEnabled, IRuntime::CreationOptions::ExternalProfilingOptions::m_EnableProfiling, Convolution2dDescriptor::m_PadBottom, Convolution2dDescriptor::m_PadLeft, Convolution2dDescriptor::m_PadRight, Convolution2dDescriptor::m_PadTop, IRuntime::CreationOptions::m_ProfilingOptions, Convolution2dDescriptor::m_StrideX, Convolution2dDescriptor::m_StrideY, IRuntime::CreationOptions::ExternalProfilingOptions::m_TimelineEnabled, LabelsAndEventClasses::NAME_GUID, LabelsAndEventClasses::NETWORK_GUID, armnn::Optimize(), LabelsAndEventClasses::PROCESS_ID_GUID, ProfilingService::ResetExternalProfilingOptions(), IOutputSlot::SetTensorInfo(), armnn::Success, armnn::profiling::ThreadIdSize, LabelsAndEventClasses::TYPE_GUID, VerifyTimelineEntityBinaryPacketData(), VerifyTimelineEventBinaryPacket(), VerifyTimelineHeaderBinary(), VerifyTimelineLabelBinaryPacketData(), VerifyTimelineRelationshipBinaryPacketData(), LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, and LabelsAndEventClasses::WORKLOAD_GUID.

Referenced by BOOST_AUTO_TEST_CASE().

360 {
361  using namespace armnn;
362 
363  // Create runtime in which test will run
365  options.m_ProfilingOptions.m_EnableProfiling = true;
366  options.m_ProfilingOptions.m_TimelineEnabled = true;
367  armnn::Runtime runtime(options);
369 
370  profiling::ProfilingServiceRuntimeHelper profilingServiceHelper(GetProfilingService(&runtime));
371  profilingServiceHelper.ForceTransitionToState(ProfilingState::NotConnected);
372  profilingServiceHelper.ForceTransitionToState(ProfilingState::WaitingForAck);
373  profilingServiceHelper.ForceTransitionToState(ProfilingState::Active);
374 
375  // build up the structure of the network
377 
378  // Convolution details
379  TensorInfo inputInfo({ 1, 2, 5, 1 }, DataType::Float32);
380  TensorInfo weightInfo({ 3, 2, 3, 1 }, DataType::Float32);
381  TensorInfo biasInfo({ 3 }, DataType::Float32);
382  TensorInfo outputInfo({ 1, 3, 7, 1 }, DataType::Float32);
383  std::vector<float> weightsData{
384  1.0f, 0.0f, 0.0f,
385  0.0f, 2.0f, -1.5f,
386 
387  0.0f, 0.0f, 0.0f,
388  0.2f, 0.2f, 0.2f,
389 
390  0.5f, 0.0f, 0.5f,
391  0.0f, -1.0f, 0.0f
392  };
393  ConstTensor weights(weightInfo, weightsData);
394 
395  Optional<ConstTensor> optionalBiases;
396  std::vector<float> biasesData{ 1.0f, 0.0f, 0.0f };
397  ConstTensor biases(biasInfo, biasesData);
398  optionalBiases = Optional<ConstTensor>(biases);
399 
400  // Input layer
401  IConnectableLayer* input = net->AddInputLayer(0, "input");
402 
403  // Convolution2d layer
404  Convolution2dDescriptor conv2dDesc;
405  conv2dDesc.m_StrideX = 1;
406  conv2dDesc.m_StrideY = 1;
407  conv2dDesc.m_PadLeft = 0;
408  conv2dDesc.m_PadRight = 0;
409  conv2dDesc.m_PadTop = 2;
410  conv2dDesc.m_PadBottom = 2;
411  conv2dDesc.m_BiasEnabled = true;
412  IConnectableLayer* conv2d = net->AddConvolution2dLayer(conv2dDesc, weights, optionalBiases);
413 
414  // Activation layer
415  armnn::ActivationDescriptor activationDesc;
416  armnn::IConnectableLayer* const activation = net->AddActivationLayer(activationDesc, "activation");
417 
418  // Output layer
419  IConnectableLayer* output = net->AddOutputLayer(0, "output");
420 
421  input->GetOutputSlot(0).Connect(conv2d->GetInputSlot(0));
422  conv2d->GetOutputSlot(0).Connect(activation->GetInputSlot(0));
423  activation->GetOutputSlot(0).Connect(output->GetInputSlot(0));
424 
425  input->GetOutputSlot(0).SetTensorInfo(inputInfo);
426  conv2d->GetOutputSlot(0).SetTensorInfo(outputInfo);
427  activation->GetOutputSlot(0).SetTensorInfo(outputInfo);
428 
429  // optimize the network
430  std::vector<armnn::BackendId> backends = { backendId };
431  IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime.GetDeviceSpec());
432 
433  ProfilingGuid optNetGuid = optNet->GetGuid();
434 
435  // Load it into the runtime. It should success.
436  armnn::NetworkId netId;
437  BOOST_TEST(runtime.LoadNetwork(netId, std::move(optNet)) == Status::Success);
438 
439  profiling::BufferManager& bufferManager = profilingServiceHelper.GetProfilingBufferManager();
440  auto readableBuffer = bufferManager.GetReadableBuffer();
441 
442  // Profiling is enabled, the post-optimisation structure should be created
443  BOOST_CHECK(readableBuffer != nullptr);
444  unsigned int size = readableBuffer->GetSize();
445 
446  const unsigned char* readableData = readableBuffer->GetReadableData();
447  BOOST_CHECK(readableData != nullptr);
448 
449  unsigned int offset = 0;
450 
451  // Verify Header
452  VerifyTimelineHeaderBinary(readableData, offset, size - 8);
453  BOOST_TEST_MESSAGE("HEADER OK");
454 
455  // Post-optimisation network
456  // Network entity
457  VerifyTimelineEntityBinaryPacketData(optNetGuid, readableData, offset);
458  BOOST_TEST_MESSAGE("NETWORK ENTITY OK");
459 
460  // Entity - Type relationship
461  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
462  EmptyOptional(),
463  optNetGuid,
466  readableData,
467  offset);
468  BOOST_TEST_MESSAGE("NETWORK TYPE RELATIONSHIP OK");
469 
470  // Network - START OF LIFE
472  EmptyOptional(),
473  EmptyOptional(),
474  readableData,
475  offset);
476  BOOST_TEST_MESSAGE("NETWORK START OF LIFE EVENT OK");
477 
478  // Network - START OF LIFE event relationship
479  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
480  EmptyOptional(),
481  optNetGuid,
482  networkSolEventGuid,
484  readableData,
485  offset);
486  BOOST_TEST_MESSAGE("NETWORK START OF LIFE RELATIONSHIP OK");
487 
488  // Process ID Label
489  int processID = armnnUtils::Processes::GetCurrentId();
490  std::stringstream ss;
491  ss << processID;
492  std::string processIdLabel = ss.str();
493  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), processIdLabel, readableData, offset);
494  BOOST_TEST_MESSAGE("PROCESS ID LABEL OK");
495 
496  // Entity - Process ID relationship
497  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
498  EmptyOptional(),
499  optNetGuid,
500  EmptyOptional(),
502  readableData,
503  offset);
504  BOOST_TEST_MESSAGE("NETWORK PROCESS ID RELATIONSHIP OK");
505 
506  // Input layer
507  // Input layer entity
508  VerifyTimelineEntityBinaryPacketData(input->GetGuid(), readableData, offset);
509  BOOST_TEST_MESSAGE("INPUT ENTITY OK");
510 
511  // Name Entity
512  ProfilingGuid inputLabelGuid = VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "input", readableData, offset);
513  BOOST_TEST_MESSAGE("INPUT NAME LABEL OK");
514 
515  // Entity - Name relationship
516  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
517  EmptyOptional(),
518  input->GetGuid(),
519  inputLabelGuid,
521  readableData,
522  offset);
523  BOOST_TEST_MESSAGE("INPUT NAME RELATIONSHIP OK");
524 
525  // Entity - Type relationship
526  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
527  EmptyOptional(),
528  input->GetGuid(),
531  readableData,
532  offset);
533  BOOST_TEST_MESSAGE("INPUT TYPE RELATIONSHIP OK");
534 
535  // Network - Input layer relationship
536  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
537  EmptyOptional(),
538  optNetGuid,
539  input->GetGuid(),
541  readableData,
542  offset);
543  BOOST_TEST_MESSAGE("NETWORK - INPUT CHILD RELATIONSHIP OK");
544 
545  // Conv2d layer
546  // Conv2d layer entity
547  VerifyTimelineEntityBinaryPacketData(conv2d->GetGuid(), readableData, offset);
548 
549  // Name entity
551  EmptyOptional(), "<Unnamed>", readableData, offset);
552  BOOST_TEST_MESSAGE("CONV2D NAME LABEL OK");
553 
554  // Entity - Name relationship
555  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
556  EmptyOptional(),
557  conv2d->GetGuid(),
558  conv2dNameLabelGuid,
560  readableData,
561  offset);
562  BOOST_TEST_MESSAGE("CONV2D NAME RELATIONSHIP OK");
563 
564  // Entity - Type relationship
565  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
566  EmptyOptional(),
567  conv2d->GetGuid(),
570  readableData,
571  offset);
572  BOOST_TEST_MESSAGE("CONV2D TYPE RELATIONSHIP OK");
573 
574  // Network - Conv2d layer relationship
575  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
576  EmptyOptional(),
577  optNetGuid,
578  conv2d->GetGuid(),
580  readableData,
581  offset);
582  BOOST_TEST_MESSAGE("NETWORK - CONV2D CHILD RELATIONSHIP OK");
583 
584  // Input layer - Conv2d layer relationship
585  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
586  EmptyOptional(),
587  input->GetGuid(),
588  conv2d->GetGuid(),
590  readableData,
591  offset);
592  BOOST_TEST_MESSAGE("INPUT - CONV2D LAYER CONNECTION OK");
593 
594  // Conv2d workload
595  // Conv2d workload entity
596  ProfilingGuid conv2DWorkloadGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
597  BOOST_TEST_MESSAGE("CONV2D WORKLOAD ENTITY OK");
598 
599  // Entity - Type relationship
600  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
601  EmptyOptional(),
602  conv2DWorkloadGuid,
604  LabelsAndEventClasses::TYPE_GUID,
605  readableData,
606  offset);
607  BOOST_TEST_MESSAGE("CONV2D WORKLOAD TYPE RELATIONSHIP OK");
608 
609  // BackendId entity
611  EmptyOptional(), backendId.Get(), readableData, offset);
612 
613  // Entity - BackendId relationship
614  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
615  EmptyOptional(),
616  conv2DWorkloadGuid,
617  backendIdLabelGuid,
619  readableData,
620  offset);
621  BOOST_TEST_MESSAGE("CONV2D WORKLOAD BACKEND ID RELATIONSHIP OK");
622 
623 
624  // Conv2d layer - Conv2d workload relationship
625  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
626  EmptyOptional(),
627  conv2d->GetGuid(),
628  conv2DWorkloadGuid,
630  readableData,
631  offset);
632  BOOST_TEST_MESSAGE("CONV2D LAYER - WORKLOAD CHILD RELATIONSHIP OK");
633 
634  // Activation layer
635  // Activation layer entity
636  VerifyTimelineEntityBinaryPacketData(activation->GetGuid(), readableData, offset);
637  BOOST_TEST_MESSAGE("ACTIVATION ENTITY OK");
638 
639  // Name entity
641  EmptyOptional(), "activation", readableData, offset);
642  BOOST_TEST_MESSAGE("ACTIVATION NAME LABEL OK");
643 
644  // Entity - Name relationship
645  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
646  EmptyOptional(),
647  activation->GetGuid(),
648  activationLabelGuid,
650  readableData,
651  offset);
652  BOOST_TEST_MESSAGE("ACTIVATION LAYER - NAME RELATIONSHIP OK");
653 
654  // Entity - Type relationship
655  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
656  EmptyOptional(),
657  activation->GetGuid(),
660  readableData,
661  offset);
662  BOOST_TEST_MESSAGE("ACTIVATION LAYER TYPE RELATIONSHIP OK");
663 
664  // Network - Activation layer relationship
665  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
666  EmptyOptional(),
667  optNetGuid,
668  activation->GetGuid(),
670  readableData,
671  offset);
672  BOOST_TEST_MESSAGE("NETWORK - ACTIVATION LAYER CHILD RELATIONSHIP OK");
673 
674  // Conv2d layer - Activation layer relationship
675  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
676  EmptyOptional(),
677  conv2d->GetGuid(),
678  activation->GetGuid(),
680  readableData,
681  offset);
682  BOOST_TEST_MESSAGE("CONV2D LAYER - ACTIVATION LAYER CONNECTION OK");
683 
684  // Activation workload
685  // Activation workload entity
686  ProfilingGuid activationWorkloadGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
687  BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD ENTITY OK");
688 
689  // Entity - Type relationship
690  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
691  EmptyOptional(),
692  activationWorkloadGuid,
694  LabelsAndEventClasses::TYPE_GUID,
695  readableData,
696  offset);
697  BOOST_TEST_MESSAGE("ACTIVATION WORKLAD TYPE RELATIONSHIP OK");
698 
699  // BackendId entity
700  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset);
701  BOOST_TEST_MESSAGE("BACKEND ID LABEL OK");
702 
703  // Entity - BackendId relationship
704  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
705  EmptyOptional(),
706  activationWorkloadGuid,
707  backendIdLabelGuid,
709  readableData,
710  offset);
711  BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD BACKEND ID RELATIONSHIP OK");
712 
713  // Activation layer - Activation workload relationship
714  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
715  EmptyOptional(),
716  activation->GetGuid(),
717  activationWorkloadGuid,
719  readableData,
720  offset);
721  BOOST_TEST_MESSAGE("ACTIVATION LAYER - WORKLOAD CHILD RELATIONSHIP OK");
722 
723  // Output layer
724  // Output layer entity
725  VerifyTimelineEntityBinaryPacketData(output->GetGuid(), readableData, offset);
726  BOOST_TEST_MESSAGE("OUTPUT LAYER ENTITY OK");
727 
728  // Name entity
730  EmptyOptional(), "output", readableData, offset);
731 
732  // Entity - Name relationship
733  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
734  EmptyOptional(),
735  output->GetGuid(),
736  outputLabelGuid,
738  readableData,
739  offset);
740  BOOST_TEST_MESSAGE("OUTPUT LAYER NAME RELATIONSHIP OK");
741 
742  // Entity - Type relationship
743  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
744  EmptyOptional(),
745  output->GetGuid(),
748  readableData,
749  offset);
750  BOOST_TEST_MESSAGE("OUTPUT LAYER TYPE RELATIONSHIP OK");
751 
752  // Network - Output layer relationship
753  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
754  EmptyOptional(),
755  optNetGuid,
756  output->GetGuid(),
758  readableData,
759  offset);
760  BOOST_TEST_MESSAGE("NETWORK - OUTPUT LAYER CHILD RELATIONSHIP OK");
761 
762  // Activation layer - Output layer relationship
763  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
764  EmptyOptional(),
765  activation->GetGuid(),
766  output->GetGuid(),
768  readableData,
769  offset);
770  BOOST_TEST_MESSAGE("ACTIVATION LAYER - OUTPUT LAYER CONNECTION OK");
771 
772  bufferManager.MarkRead(readableBuffer);
773 
774  // Creates structures for input & output.
775  std::vector<float> inputData(inputInfo.GetNumElements());
776  std::vector<float> outputData(outputInfo.GetNumElements());
777 
778  InputTensors inputTensors
779  {
780  {0, ConstTensor(runtime.GetInputTensorInfo(netId, 0), inputData.data())}
781  };
782  OutputTensors outputTensors
783  {
784  {0, Tensor(runtime.GetOutputTensorInfo(netId, 0), outputData.data())}
785  };
786 
787  // Does the inference.
788  runtime.EnqueueWorkload(netId, inputTensors, outputTensors);
789 
790  // Get readable buffer for input workload
791  auto inputReadableBuffer = bufferManager.GetReadableBuffer();
792  BOOST_CHECK(inputReadableBuffer != nullptr);
793 
794  // Get readable buffer for output workload
795  auto outputReadableBuffer = bufferManager.GetReadableBuffer();
796  BOOST_CHECK(outputReadableBuffer != nullptr);
797 
798  // Get readable buffer for inference timeline
799  auto inferenceReadableBuffer = bufferManager.GetReadableBuffer();
800  BOOST_CHECK(inferenceReadableBuffer != nullptr);
801 
802  // Validate input workload data
803  size = inputReadableBuffer->GetSize();
804  BOOST_CHECK(size == 164);
805 
806  readableData = inputReadableBuffer->GetReadableData();
807  BOOST_CHECK(readableData != nullptr);
808 
809  offset = 0;
810 
811  // Verify Header
812  VerifyTimelineHeaderBinary(readableData, offset, 156);
813  BOOST_TEST_MESSAGE("INPUT WORKLOAD HEADER OK");
814 
815  // Input workload
816  // Input workload entity
817  ProfilingGuid inputWorkloadGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
818  BOOST_TEST_MESSAGE("INPUT WORKLOAD TYPE RELATIONSHIP OK");
819 
820  // Entity - Type relationship
821  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
822  EmptyOptional(),
823  inputWorkloadGuid,
825  LabelsAndEventClasses::TYPE_GUID,
826  readableData,
827  offset);
828  BOOST_TEST_MESSAGE("INPUT WORKLOAD TYPE RELATIONSHIP OK");
829 
830  // BackendId entity
831  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset);
832 
833  // Entity - BackendId relationship
834  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
835  EmptyOptional(),
836  inputWorkloadGuid,
837  backendIdLabelGuid,
839  readableData,
840  offset);
841  BOOST_TEST_MESSAGE("INPUT WORKLOAD BACKEND ID RELATIONSHIP OK");
842 
843  // Input layer - Input workload relationship
844  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
845  EmptyOptional(),
846  input->GetGuid(),
847  inputWorkloadGuid,
849  readableData,
850  offset);
851  BOOST_TEST_MESSAGE("INPUT LAYER - INPUT WORKLOAD CHILD RELATIONSHIP OK");
852 
853  bufferManager.MarkRead(inputReadableBuffer);
854 
855  // Validate output workload data
856  size = outputReadableBuffer->GetSize();
857  BOOST_CHECK(size == 164);
858 
859  readableData = outputReadableBuffer->GetReadableData();
860  BOOST_CHECK(readableData != nullptr);
861 
862  offset = 0;
863 
864  // Verify Header
865  VerifyTimelineHeaderBinary(readableData, offset, 156);
866  BOOST_TEST_MESSAGE("OUTPUT WORKLOAD HEADER OK");
867 
868  // Output workload
869  // Output workload entity
870  ProfilingGuid outputWorkloadGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
871  BOOST_TEST_MESSAGE("OUTPUT WORKLOAD ENTITY OK");
872 
873  // Entity - Type relationship
874  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
875  EmptyOptional(),
876  outputWorkloadGuid,
878  LabelsAndEventClasses::TYPE_GUID,
879  readableData,
880  offset);
881  BOOST_TEST_MESSAGE("OUTPUT WORKLOAD TYPE RELATIONSHIP OK");
882 
883  // BackendId entity
884  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset);
885  BOOST_TEST_MESSAGE("OUTPUT WORKLOAD LABEL OK");
886 
887  // Entity - BackendId relationship
888  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
889  EmptyOptional(),
890  outputWorkloadGuid,
891  backendIdLabelGuid,
893  readableData,
894  offset);
895  BOOST_TEST_MESSAGE("OUTPUT WORKLOAD BACKEND ID RELATIONSHIP OK");
896 
897  // Output layer - Output workload relationship
898  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
899  EmptyOptional(),
900  output->GetGuid(),
901  outputWorkloadGuid,
903  readableData,
904  offset);
905  BOOST_TEST_MESSAGE("OUTPUT LAYER - OUTPUT WORKLOAD CHILD RELATIONSHIP OK");
906 
907  bufferManager.MarkRead(outputReadableBuffer);
908 
909  // Validate inference data
910  size = inferenceReadableBuffer->GetSize();
911 
912  BOOST_CHECK(size == 1228 + 10 * ThreadIdSize);
913 
914  readableData = inferenceReadableBuffer->GetReadableData();
915  BOOST_CHECK(readableData != nullptr);
916 
917  offset = 0;
918 
919  // Verify Header
920  VerifyTimelineHeaderBinary(readableData, offset, 1220 + 10 * ThreadIdSize);
921  BOOST_TEST_MESSAGE("INFERENCE HEADER OK");
922 
923  // Inference timeline trace
924  // Inference entity
925  ProfilingGuid inferenceGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
926  BOOST_TEST_MESSAGE("INFERENCE ENTITY OK");
927 
928  // Entity - Type relationship
929  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
930  EmptyOptional(),
931  inferenceGuid,
933  LabelsAndEventClasses::TYPE_GUID,
934  readableData,
935  offset);
936  BOOST_TEST_MESSAGE("INFERENCE TYPE RELATIONSHIP OK");
937 
938  // Network - Inference relationship
939  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
940  EmptyOptional(),
941  optNetGuid,
942  inferenceGuid,
944  readableData,
945  offset);
946  BOOST_TEST_MESSAGE("NETWORK - INFERENCE EXECUTION_OF RELATIONSHIP OK");
947 
948  // Start Inference life
949  // Event packet - timeline, threadId, eventGuid
950  ProfilingGuid inferenceEventGuid = VerifyTimelineEventBinaryPacket(
951  EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
952  BOOST_TEST_MESSAGE("INFERENCE START OF LIFE EVENT OK");
953 
954  // Inference - event relationship
955  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
956  EmptyOptional(),
957  inferenceGuid,
958  inferenceEventGuid,
960  readableData,
961  offset);
962  BOOST_TEST_MESSAGE("INFERENCE START OF LIFE RELATIONSHIP OK");
963 
964  // Execution
965  // Input workload execution
966  // Input workload execution entity
967  ProfilingGuid inputWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
968  EmptyOptional(), readableData, offset);
969  BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION ENTITY OK");
970 
971  // Entity - Type relationship
972  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
973  EmptyOptional(),
974  inputWorkloadExecutionGuid,
976  LabelsAndEventClasses::TYPE_GUID,
977  readableData,
978  offset);
979  BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION TYPE RELATIONSHIP OK");
980 
981  // Inference - Workload execution relationship
982  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
983  EmptyOptional(),
984  inferenceGuid,
985  inputWorkloadExecutionGuid,
986  LabelsAndEventClasses::CHILD_GUID,
987  readableData,
988  offset);
989  BOOST_TEST_MESSAGE("INPUT WORKLOAD - INPUT WORKLOAD EXECUTION RELATIONSHIP OK");
990 
991  // Workload - Workload execution relationship
992  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
993  EmptyOptional(),
994  inputWorkloadGuid,
995  inputWorkloadExecutionGuid,
997  readableData,
998  offset);
999  BOOST_TEST_MESSAGE("INPUT WORKLOAD - INPUT WORKLOAD EXECUTION RELATIONSHIP OK");
1000 
1001  // Start Input workload execution life
1002  // Event packet - timeline, threadId, eventGuid
1003  ProfilingGuid inputWorkloadExecutionSOLEventId = VerifyTimelineEventBinaryPacket(
1004  EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1005  BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION - START OF LIFE EVENT OK");
1006 
1007  // Input workload execution - event relationship
1008  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1009  EmptyOptional(),
1010  inputWorkloadExecutionGuid,
1011  inputWorkloadExecutionSOLEventId,
1013  readableData,
1014  offset);
1015  BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION - START OF LIFE EVENT RELATIONSHIP OK");
1016 
1017  // End of Input workload execution life
1018  // Event packet - timeline, threadId, eventGuid
1019  ProfilingGuid inputWorkloadExecutionEOLEventId = VerifyTimelineEventBinaryPacket(
1020  EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1021  BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION - END OF LIFE EVENT OK");
1022 
1023  // Input workload execution - event relationship
1024  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1025  EmptyOptional(),
1026  inputWorkloadExecutionGuid,
1027  inputWorkloadExecutionEOLEventId,
1029  readableData,
1030  offset);
1031  BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION - END OF LIFE EVENT RELATIONSHIP OK");
1032 
1033  // Conv2d workload execution
1034  // Conv2d workload execution entity
1035  ProfilingGuid conv2DWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
1036  EmptyOptional(), readableData, offset);
1037  BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION ENTITY OK");
1038 
1039  // Entity - Type relationship
1040  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1041  EmptyOptional(),
1042  conv2DWorkloadExecutionGuid,
1044  LabelsAndEventClasses::TYPE_GUID,
1045  readableData,
1046  offset);
1047  BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION TYPE RELATIONSHIP OK");
1048 
1049  // Inference - Workload execution relationship
1050  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1051  EmptyOptional(),
1052  inferenceGuid,
1053  conv2DWorkloadExecutionGuid,
1054  LabelsAndEventClasses::CHILD_GUID,
1055  readableData,
1056  offset);
1057  BOOST_TEST_MESSAGE("INFERENCE - CONV2D WORKLOAD EXECUTION CHILD RELATIONSHIP OK");
1058 
1059  // Workload - Workload execution relationship
1060  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1061  EmptyOptional(),
1062  conv2DWorkloadGuid,
1063  conv2DWorkloadExecutionGuid,
1065  readableData,
1066  offset);
1067  BOOST_TEST_MESSAGE("CONV2D WORKLOAD - CONV2D WORKLOAD EXECUTION RELATIONSHIP OK");
1068 
1069  // Start Conv2d workload execution life
1070  // Event packet - timeline, threadId, eventGuid
1071  ProfilingGuid conv2DWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket(
1072  EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1073  BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION START OF LIFE EVENT OK");
1074 
1075  // Conv2d workload execution - event relationship
1076  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1077  EmptyOptional(),
1078  conv2DWorkloadExecutionGuid,
1079  conv2DWorkloadExecutionSOLEventGuid,
1081  readableData,
1082  offset);
1083  BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION START OF LIFE RELATIONSHIP OK");
1084 
1085  // End of Conv2d workload execution life
1086  // Event packet - timeline, threadId, eventGuid
1087  ProfilingGuid conv2DWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket(
1088  EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1089  BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION END OF LIFE EVENT OK");
1090 
1091  // Conv2d workload execution - event relationship
1092  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1093  EmptyOptional(),
1094  conv2DWorkloadExecutionGuid,
1095  conv2DWorkloadExecutionEOLEventGuid,
1097  readableData,
1098  offset);
1099  BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION END OF LIFE RELATIONSHIP OK");
1100 
1101  // Activation workload execution
1102  // Activation workload execution entity
1103  ProfilingGuid activationWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
1104  EmptyOptional(), readableData, offset);
1105  BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION ENTITY OK");
1106 
1107  // Entity - Type relationship
1108  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1109  EmptyOptional(),
1110  activationWorkloadExecutionGuid,
1112  LabelsAndEventClasses::TYPE_GUID,
1113  readableData,
1114  offset);
1115  BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION TYPE RELATIONSHIP OK");
1116 
1117  // Inference - Workload execution relationship
1118  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1119  EmptyOptional(),
1120  inferenceGuid,
1121  activationWorkloadExecutionGuid,
1122  LabelsAndEventClasses::CHILD_GUID,
1123  readableData,
1124  offset);
1125  BOOST_TEST_MESSAGE("INFERENCE - ACTIVATION WORKLOAD EXECUTION CHILD RELATIONSHIP OK");
1126 
1127  // Workload - Workload execution relationship
1128  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1129  EmptyOptional(),
1130  activationWorkloadGuid,
1131  activationWorkloadExecutionGuid,
1133  readableData,
1134  offset);
1135  BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD - ACTIVATION WORKLOAD EXECUTION RELATIONSHIP OK");
1136 
1137  // Start Activation workload execution life
1138  // Event packet - timeline, threadId, eventGuid
1139  ProfilingGuid activationWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket(
1140  EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1141  BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION START OF LIFE EVENT OK");
1142 
1143  // Activation workload execution - event relationship
1144  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1145  EmptyOptional(),
1146  activationWorkloadExecutionGuid,
1147  activationWorkloadExecutionSOLEventGuid,
1149  readableData,
1150  offset);
1151  BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION START OF LIFE RELATIONSHIP OK");
1152 
1153  // End of Activation workload execution life
1154  // Event packet - timeline, threadId, eventGuid
1155  ProfilingGuid activationWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket(
1156  EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1157  BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION END OF LIFE EVENT OK");
1158 
1159  // Activation workload execution - event relationship
1160  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1161  EmptyOptional(),
1162  activationWorkloadExecutionGuid,
1163  activationWorkloadExecutionEOLEventGuid,
1165  readableData,
1166  offset);
1167  BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION END OF LIFE RELATIONSHIP OK");
1168 
1169  // Output workload execution
1170  // Output workload execution entity
1171  ProfilingGuid outputWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
1172  EmptyOptional(), readableData, offset);
1173  BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION ENTITY OK");
1174 
1175  // Entity - Type relationship
1176  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1177  EmptyOptional(),
1178  outputWorkloadExecutionGuid,
1180  LabelsAndEventClasses::TYPE_GUID,
1181  readableData,
1182  offset);
1183  BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION TYPE RELATIONSHIP OK");
1184 
1185  // Inference - Workload execution relationship
1186  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1187  EmptyOptional(),
1188  inferenceGuid,
1189  outputWorkloadExecutionGuid,
1190  LabelsAndEventClasses::CHILD_GUID,
1191  readableData,
1192  offset);
1193  BOOST_TEST_MESSAGE("INFERENCE - OUTPUT WORKLOAD EXECUTION CHILD RELATIONSHIP OK");
1194 
1195  // Workload - Workload execution relationship
1196  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1197  EmptyOptional(),
1198  outputWorkloadGuid,
1199  outputWorkloadExecutionGuid,
1201  readableData,
1202  offset);
1203  BOOST_TEST_MESSAGE("OUTPUT WORKLOAD - OUTPUT WORKLOAD EXECUTION EXECUTION_OF RELATIONSHIP OK");
1204 
1205  // Start Output workload execution life
1206  // Event packet - timeline, threadId, eventGuid
1207  ProfilingGuid outputWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket(
1208  EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1209  BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION START OF LIFE EVENT OK");
1210 
1211  // Output workload execution - event relationship
1212  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1213  EmptyOptional(),
1214  outputWorkloadExecutionGuid,
1215  outputWorkloadExecutionSOLEventGuid,
1217  readableData,
1218  offset);
1219  BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION - START OF LIFE EVENT RELATIONSHIP OK");
1220 
1221  // End of Normalize workload execution life
1222  // Event packet - timeline, threadId, eventGuid
1223  ProfilingGuid outputWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket(
1224  EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1225  BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION END OF LIFE EVENT OK");
1226 
1227  // Output workload execution - event relationship
1228  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1229  EmptyOptional(),
1230  outputWorkloadExecutionGuid,
1231  outputWorkloadExecutionEOLEventGuid,
1233  readableData,
1234  offset);
1235  BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION - END OF LIFE EVENT RELATIONSHIP OK");
1236 
1237  // End of Inference life
1238  // Event packet - timeline, threadId, eventGuid
1239  ProfilingGuid inferenceEOLEventGuid = VerifyTimelineEventBinaryPacket(
1240  EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1241  BOOST_TEST_MESSAGE("INFERENCE END OF LIFE EVENT OK");
1242 
1243  // Inference - event relationship
1244  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1245  EmptyOptional(),
1246  inferenceGuid,
1247  inferenceEOLEventGuid,
1249  readableData,
1250  offset);
1251  BOOST_TEST_MESSAGE("INFERENCE - END OF LIFE EVENT RELATIONSHIP OK");
1252 
1253  bufferManager.MarkRead(inferenceReadableBuffer);
1254 }
static ARMNN_DLLEXPORT ProfilingStaticGuid INFERENCE_GUID
uint32_t m_PadBottom
Padding bottom value in the height dimension.
bool m_BiasEnabled
Enable/disable bias.
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:61
ProfilingGuid VerifyTimelineEntityBinaryPacketData(Optional< ProfilingGuid > guid, const unsigned char *readableData, unsigned int &offset)
A Convolution2dDescriptor for the Convolution2dLayer.
std::vector< std::pair< LayerBindingId, class ConstTensor > > InputTensors
Definition: Tensor.hpp:324
uint32_t m_PadRight
Padding right value in the width dimension.
int NetworkId
Definition: IRuntime.hpp:20
Copyright (c) 2020 ARM Limited.
static ARMNN_DLLEXPORT ProfilingStaticGuid CONNECTION_GUID
static ARMNN_DLLEXPORT ProfilingStaticGuid WORKLOAD_GUID
static ARMNN_DLLEXPORT ProfilingStaticGuid WORKLOAD_EXECUTION_GUID
static ARMNN_DLLEXPORT ProfilingStaticGuid ARMNN_PROFILING_EOL_EVENT_CLASS
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
static ARMNN_DLLEXPORT ProfilingStaticGuid NAME_GUID
static ARMNN_DLLEXPORT ProfilingStaticGuid ARMNN_PROFILING_SOL_EVENT_CLASS
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
Definition: Tensor.hpp:290
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.
static ARMNN_DLLEXPORT ProfilingStaticGuid LAYER_GUID
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:1014
profiling::ProfilingService & GetProfilingService(armnn::Runtime *runtime)
Definition: TestUtils.cpp:25
void VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType relationshipType, Optional< ProfilingGuid > relationshipGuid, Optional< ProfilingGuid > headGuid, Optional< ProfilingGuid > tailGuid, Optional< ProfilingGuid > attributeGuid, const unsigned char *readableData, unsigned int &offset)
virtual LayerGuid GetGuid() const =0
Returns the unique id of the layer.
static ARMNN_DLLEXPORT ProfilingStaticGuid EXECUTION_OF_GUID
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:298
std::vector< std::pair< LayerBindingId, class Tensor > > OutputTensors
Definition: Tensor.hpp:325
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
Definition: INetwork.hpp:593
void ResetExternalProfilingOptions(const ExternalProfilingOptions &options, bool resetProfilingService=false)
IPacketBufferPtr GetReadableBuffer() override
constexpr unsigned int ThreadIdSize
An ActivationDescriptor for the ActivationLayer.
Definition: Descriptors.hpp:20
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)
static ARMNN_DLLEXPORT ProfilingStaticGuid NETWORK_GUID
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
Definition: Optional.hpp:32
static ARMNN_DLLEXPORT ProfilingStaticGuid TYPE_GUID
const std::string & Get() const
Definition: BackendId.hpp:136
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
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:101
ProfilingGuid VerifyTimelineEventBinaryPacket(Optional< uint64_t > timestamp, Optional< int > threadId, Optional< ProfilingGuid > eventGuid, const unsigned char *readableData, unsigned int &offset)
virtual int Connect(IInputSlot &destination)=0
ProfilingGuid VerifyTimelineLabelBinaryPacketData(Optional< ProfilingGuid > guid, const std::string &label, const unsigned char *readableData, unsigned int &offset)
static ARMNN_DLLEXPORT ProfilingStaticGuid PROCESS_ID_GUID
ExternalProfilingOptions m_ProfilingOptions
Definition: IRuntime.hpp:83
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:50
static ARMNN_DLLEXPORT ProfilingStaticGuid BACKENDID_GUID
uint32_t m_PadLeft
Padding left value in the width dimension.
static ARMNN_DLLEXPORT ProfilingStaticGuid CHILD_GUID

◆ VerifyTimelineEntityBinaryPacketData()

ProfilingGuid VerifyTimelineEntityBinaryPacketData ( Optional< ProfilingGuid guid,
const unsigned char *  readableData,
unsigned int &  offset 
)

Definition at line 265 of file ProfilingTestUtils.cpp.

References ARMNN_ASSERT, OptionalBase::has_value(), armnn::profiling::ReadUint32(), armnn::profiling::ReadUint64(), armnn::profiling::uint32_t_size, and OptionalReferenceSwitch< std::is_reference< T >::value, T >::value().

Referenced by BOOST_AUTO_TEST_CASE(), and VerifyPostOptimisationStructureTestImpl().

268 {
269  ARMNN_ASSERT(readableData);
270 
271  // Utils
272  unsigned int uint32_t_size = sizeof(uint32_t);
273  unsigned int uint64_t_size = sizeof(uint64_t);
274 
275  // Reading TimelineEntityClassBinaryPacket
276  // Check the decl_id
277  uint32_t entityDeclId = ReadUint32(readableData, offset);
278  BOOST_CHECK(entityDeclId == 1);
279 
280  // Check the profiling GUID
281  offset += uint32_t_size;
282  uint64_t readProfilingGuid = ReadUint64(readableData, offset);
283 
284  if (guid.has_value())
285  {
286  BOOST_CHECK(readProfilingGuid == guid.value());
287  }
288  else
289  {
290  BOOST_CHECK(readProfilingGuid != ProfilingGuid(0));
291  }
292 
293  offset += uint64_t_size;
294 
295  ProfilingGuid entityGuid(readProfilingGuid);
296  return entityGuid;
297 }
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
bool has_value() const noexcept
Definition: Optional.hpp:53
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)

◆ VerifyTimelineEventBinaryPacket()

ProfilingGuid VerifyTimelineEventBinaryPacket ( Optional< uint64_t >  timestamp,
Optional< int >  threadId,
Optional< ProfilingGuid eventGuid,
const unsigned char *  readableData,
unsigned int &  offset 
)

Definition at line 299 of file ProfilingTestUtils.cpp.

References ARMNN_ASSERT, armnnUtils::Threads::GetCurrentThreadId(), OptionalBase::has_value(), armnn::profiling::ReadBytes(), armnn::profiling::ReadUint32(), armnn::profiling::ReadUint64(), armnn::profiling::ThreadIdSize, armnn::profiling::uint32_t_size, and OptionalReferenceSwitch< std::is_reference< T >::value, T >::value().

Referenced by BOOST_AUTO_TEST_CASE(), and VerifyPostOptimisationStructureTestImpl().

304 {
305  ARMNN_ASSERT(readableData);
306 
307  // Utils
308  unsigned int uint32_t_size = sizeof(uint32_t);
309  unsigned int uint64_t_size = sizeof(uint64_t);
310 
311  // Reading TimelineEventBinaryPacket
312  // Check the decl_id
313  uint32_t entityDeclId = ReadUint32(readableData, offset);
314  BOOST_CHECK(entityDeclId == 4);
315 
316  // Check the timestamp
317  offset += uint32_t_size;
318  uint64_t readTimestamp = ReadUint64(readableData, offset);
319  if (timestamp.has_value())
320  {
321  BOOST_CHECK(readTimestamp == timestamp.value());
322  }
323  else
324  {
325  BOOST_CHECK(readTimestamp != 0);
326  }
327 
328  // Check the thread id
329  offset += uint64_t_size;
330  std::vector<uint8_t> readThreadId(ThreadIdSize, 0);
331  ReadBytes(readableData, offset, ThreadIdSize, readThreadId.data());
332  if (threadId.has_value())
333  {
334  BOOST_CHECK(readThreadId == threadId.value());
335  }
336  else
337  {
338  BOOST_CHECK(readThreadId == armnnUtils::Threads::GetCurrentThreadId());
339  }
340 
341  // Check the event GUID
342  offset += ThreadIdSize;
343  uint64_t readEventGuid = ReadUint64(readableData, offset);
344  if (eventGuid.has_value())
345  {
346  BOOST_CHECK(readEventGuid == eventGuid.value());
347  }
348  else
349  {
350  BOOST_CHECK(readEventGuid != ProfilingGuid(0));
351  }
352 
353  offset += uint64_t_size;
354 
355  ProfilingGuid eventid(readEventGuid);
356  return eventid;
357 }
int GetCurrentThreadId()
Definition: Threads.cpp:26
void ReadBytes(const IPacketBufferPtr &packetBuffer, unsigned int offset, unsigned int valueSize, uint8_t outValue[])
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
bool has_value() const noexcept
Definition: Optional.hpp:53
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
constexpr unsigned int ThreadIdSize
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)

◆ VerifyTimelineEventClassBinaryPacketData()

void VerifyTimelineEventClassBinaryPacketData ( ProfilingGuid  guid,
ProfilingGuid  nameGuid,
const unsigned char *  readableData,
unsigned int &  offset 
)

Definition at line 143 of file ProfilingTestUtils.cpp.

References ARMNN_ASSERT, armnn::profiling::ReadUint32(), armnn::profiling::ReadUint64(), and armnn::profiling::uint32_t_size.

Referenced by BOOST_AUTO_TEST_CASE().

147 {
148  ARMNN_ASSERT(readableData);
149 
150  // Utils
151  unsigned int uint32_t_size = sizeof(uint32_t);
152  unsigned int uint64_t_size = sizeof(uint64_t);
153 
154  // Check the decl id
155  uint32_t eventClassDeclId = ReadUint32(readableData, offset);
156  BOOST_CHECK(eventClassDeclId == 2);
157 
158  // Check the profiling GUID
159  offset += uint32_t_size;
160  uint64_t readProfilingGuid = ReadUint64(readableData, offset);
161  BOOST_CHECK(readProfilingGuid == guid);
162 
163  offset += uint64_t_size;
164  uint64_t readProfiilngNameGuid = ReadUint64(readableData, offset);
165  BOOST_CHECK(readProfiilngNameGuid == nameGuid);
166 
167  // Update the offset to allow parsing to be continued after this function returns
168  offset += uint64_t_size;
169 }
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)

◆ VerifyTimelineHeaderBinary()

void VerifyTimelineHeaderBinary ( const unsigned char *  readableData,
unsigned int &  offset,
uint32_t  packetDataLength 
)

Definition at line 70 of file ProfilingTestUtils.cpp.

References ARMNN_ASSERT, armnn::profiling::ReadUint32(), and armnn::profiling::uint32_t_size.

Referenced by BOOST_AUTO_TEST_CASE(), and VerifyPostOptimisationStructureTestImpl().

73 {
74  ARMNN_ASSERT(readableData);
75 
76  // Utils
77  unsigned int uint32_t_size = sizeof(uint32_t);
78 
79  // Check the TimelineEventClassBinaryPacket header
80  uint32_t timelineBinaryPacketHeaderWord0 = ReadUint32(readableData, offset);
81  uint32_t timelineBinaryPacketFamily = (timelineBinaryPacketHeaderWord0 >> 26) & 0x0000003F;
82  uint32_t timelineBinaryPacketClass = (timelineBinaryPacketHeaderWord0 >> 19) & 0x0000007F;
83  uint32_t timelineBinaryPacketType = (timelineBinaryPacketHeaderWord0 >> 16) & 0x00000007;
84  uint32_t timelineBinaryPacketStreamId = (timelineBinaryPacketHeaderWord0 >> 0) & 0x00000007;
85  BOOST_CHECK(timelineBinaryPacketFamily == 1);
86  BOOST_CHECK(timelineBinaryPacketClass == 0);
87  BOOST_CHECK(timelineBinaryPacketType == 1);
88  BOOST_CHECK(timelineBinaryPacketStreamId == 0);
89  offset += uint32_t_size;
90  uint32_t timelineBinaryPacketHeaderWord1 = ReadUint32(readableData, offset);
91  uint32_t timelineBinaryPacketSequenceNumber = (timelineBinaryPacketHeaderWord1 >> 24) & 0x00000001;
92  uint32_t timelineBinaryPacketDataLength = (timelineBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF;
93  BOOST_CHECK(timelineBinaryPacketSequenceNumber == 0);
94  BOOST_CHECK(timelineBinaryPacketDataLength == packetDataLength);
95  offset += uint32_t_size;
96 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)

◆ VerifyTimelineLabelBinaryPacketData()

ProfilingGuid VerifyTimelineLabelBinaryPacketData ( Optional< ProfilingGuid guid,
const std::string &  label,
const unsigned char *  readableData,
unsigned int &  offset 
)

Definition at line 98 of file ProfilingTestUtils.cpp.

References ARMNN_ASSERT, ProfilingService::GetStaticId(), OptionalBase::has_value(), armnn::numeric_cast(), OffsetToNextWord(), armnn::profiling::ReadUint32(), armnn::profiling::ReadUint64(), armnn::profiling::uint32_t_size, and OptionalReferenceSwitch< std::is_reference< T >::value, T >::value().

Referenced by BOOST_AUTO_TEST_CASE(), and VerifyPostOptimisationStructureTestImpl().

102 {
103  ARMNN_ASSERT(readableData);
104 
105  // Utils
106  unsigned int uint32_t_size = sizeof(uint32_t);
107  unsigned int uint64_t_size = sizeof(uint64_t);
108  unsigned int label_size = boost::numeric_cast<unsigned int>(label.size());
109 
110  // Check the decl id
111  uint32_t eventClassDeclId = ReadUint32(readableData, offset);
112  BOOST_CHECK(eventClassDeclId == 0);
113 
114  // Check the profiling GUID
115  offset += uint32_t_size;
116  uint64_t readProfilingGuid = ReadUint64(readableData, offset);
117  if (guid.has_value())
118  {
119  BOOST_CHECK(readProfilingGuid == guid.value());
120  }
121  else
122  {
123  armnn::profiling::ProfilingService profilingService;
124  BOOST_CHECK(readProfilingGuid == profilingService.GetStaticId(label));
125  }
126 
127  // Check the SWTrace label
128  offset += uint64_t_size;
129  uint32_t swTraceLabelLength = ReadUint32(readableData, offset);
130  BOOST_CHECK(swTraceLabelLength == label_size + 1); // Label length including the null-terminator
131  offset += uint32_t_size;
132  BOOST_CHECK(std::memcmp(readableData + offset, // Offset to the label in the buffer
133  label.data(), // The original label
134  swTraceLabelLength - 1) == 0); // The length of the label
135 
136  // SWTrace strings are written in blocks of words, so the offset has to be updated to the next whole word
137  offset += OffsetToNextWord(swTraceLabelLength);
138 
139  ProfilingGuid labelGuid(readProfilingGuid);
140  return labelGuid;
141 }
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
unsigned int OffsetToNextWord(unsigned int numberOfBytes)
static ProfilingStaticGuid GetStaticId(const std::string &str)
bool has_value() const noexcept
Definition: Optional.hpp:53
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:33
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)

◆ VerifyTimelineRelationshipBinaryPacketData()

void VerifyTimelineRelationshipBinaryPacketData ( ProfilingRelationshipType  relationshipType,
Optional< ProfilingGuid relationshipGuid,
Optional< ProfilingGuid headGuid,
Optional< ProfilingGuid tailGuid,
Optional< ProfilingGuid attributeGuid,
const unsigned char *  readableData,
unsigned int &  offset 
)

Definition at line 171 of file ProfilingTestUtils.cpp.

References ARMNN_ASSERT, OptionalBase::has_value(), armnn::profiling::ReadUint32(), armnn::profiling::ReadUint64(), armnn::profiling::uint32_t_size, and OptionalReferenceSwitch< std::is_reference< T >::value, T >::value().

Referenced by BOOST_AUTO_TEST_CASE(), and VerifyPostOptimisationStructureTestImpl().

178 {
179  ARMNN_ASSERT(readableData);
180 
181  uint32_t relationshipTypeUint = 0;
182  switch (relationshipType)
183  {
184  case ProfilingRelationshipType::RetentionLink:
185  relationshipTypeUint = 0;
186  break;
187  case ProfilingRelationshipType::ExecutionLink:
188  relationshipTypeUint = 1;
189  break;
190  case ProfilingRelationshipType::DataLink:
191  relationshipTypeUint = 2;
192  break;
193  case ProfilingRelationshipType::LabelLink:
194  relationshipTypeUint = 3;
195  break;
196  default:
197  BOOST_ERROR("Unknown relationship type");
198  }
199 
200  // Utils
201  unsigned int uint32_t_size = sizeof(uint32_t);
202  unsigned int uint64_t_size = sizeof(uint64_t);
203 
204  // Check the decl id
205  uint32_t eventClassDeclId = ReadUint32(readableData, offset);
206  BOOST_CHECK(eventClassDeclId == 3);
207 
208  // Check the relationship type
209  offset += uint32_t_size;
210  uint32_t readRelationshipTypeUint = ReadUint32(readableData, offset);
211  BOOST_CHECK(readRelationshipTypeUint == relationshipTypeUint);
212 
213  // Check the relationship GUID
214  offset += uint32_t_size;
215  uint64_t readRelationshipGuid = ReadUint64(readableData, offset);
216  if (relationshipGuid.has_value())
217  {
218  BOOST_CHECK(readRelationshipGuid == relationshipGuid.value());
219  }
220  else
221  {
222  BOOST_CHECK(readRelationshipGuid != ProfilingGuid(0));
223  }
224 
225  // Check the head GUID of the relationship
226  offset += uint64_t_size;
227  uint64_t readHeadRelationshipGuid = ReadUint64(readableData, offset);
228  if (headGuid.has_value())
229  {
230  BOOST_CHECK(readHeadRelationshipGuid == headGuid.value());
231  }
232  else
233  {
234  BOOST_CHECK(readHeadRelationshipGuid != ProfilingGuid(0));
235  }
236 
237  // Check the tail GUID of the relationship
238  offset += uint64_t_size;
239  uint64_t readTailRelationshipGuid = ReadUint64(readableData, offset);
240  if (tailGuid.has_value())
241  {
242  BOOST_CHECK(readTailRelationshipGuid == tailGuid.value());
243  }
244  else
245  {
246  BOOST_CHECK(readTailRelationshipGuid != ProfilingGuid(0));
247  }
248 
249  // Check the attribute GUID of the relationship
250  offset += uint64_t_size;
251  uint64_t readAttributeRelationshipGuid = ReadUint64(readableData, offset);
252  if (attributeGuid.has_value())
253  {
254  BOOST_CHECK(readAttributeRelationshipGuid == attributeGuid.value());
255  }
256  else
257  {
258  BOOST_CHECK(readAttributeRelationshipGuid == ProfilingGuid(0));
259  }
260 
261  // Update the offset to allow parsing to be continued after this function returns
262  offset += uint64_t_size;
263 }
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
bool has_value() const noexcept
Definition: Optional.hpp:53
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)