ArmNN
 20.05
ProfilingTestUtils.cpp File Reference
#include "ProfilingTestUtils.hpp"
#include "ProfilingUtils.hpp"
#include <armnn/Descriptors.hpp>
#include <LabelsAndEventClasses.hpp>
#include <ProfilingService.hpp>
#include <test/TestUtils.hpp>
#include <boost/test/unit_test.hpp>

Go to the source code of this file.

Functions

uint32_t GetStreamMetaDataPacketSize ()
 
unsigned int OffsetToNextWord (unsigned int numberOfBytes)
 
void VerifyTimelineHeaderBinary (const unsigned char *readableData, unsigned int &offset, uint32_t packetDataLength)
 
void VerifyTimelineLabelBinaryPacketData (Optional< ProfilingGuid > guid, const std::string &label, const unsigned char *readableData, unsigned int &offset)
 
void VerifyTimelineEventClassBinaryPacketData (ProfilingGuid guid, const unsigned char *readableData, unsigned int &offset)
 
void VerifyTimelineRelationshipBinaryPacketData (ProfilingRelationshipType relationshipType, Optional< ProfilingGuid > relationshipGuid, Optional< ProfilingGuid > headGuid, Optional< ProfilingGuid > tailGuid, const unsigned char *readableData, unsigned int &offset)
 
void VerifyTimelineEntityBinaryPacketData (Optional< ProfilingGuid > guid, const unsigned char *readableData, unsigned int &offset)
 
void VerifyTimelineEventBinaryPacket (Optional< uint64_t > timestamp, Optional< std::thread::id > threadId, Optional< ProfilingGuid > eventGuid, const unsigned char *readableData, unsigned int &offset)
 
void VerifyPostOptimisationStructureTestImpl (armnn::BackendId backendId)
 

Function Documentation

◆ GetStreamMetaDataPacketSize()

uint32_t GetStreamMetaDataPacketSize ( )

Definition at line 17 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().

18 {
19  uint32_t sizeUint32 = sizeof(uint32_t);
20  uint32_t payloadSize = 0;
21  payloadSize += boost::numeric_cast<uint32_t>(GetSoftwareInfo().size()) + 1;
22  payloadSize += boost::numeric_cast<uint32_t>(GetHardwareVersion().size()) + 1;
23  payloadSize += boost::numeric_cast<uint32_t>(GetSoftwareVersion().size()) + 1;
24  payloadSize += boost::numeric_cast<uint32_t>(GetProcessName().size()) + 1;
25 
26  // Add packetVersionEntries
27  payloadSize += 6 * 2 * sizeUint32;
28  // Add packetVersionCountSize
29  payloadSize += sizeUint32;
30 
31  uint32_t headerSize = 2 * sizeUint32;
32  uint32_t bodySize = 10 * sizeUint32;
33 
34  return headerSize + bodySize + payloadSize;
35 }
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()

◆ OffsetToNextWord()

unsigned int OffsetToNextWord ( unsigned int  numberOfBytes)
inline

Definition at line 37 of file ProfilingTestUtils.cpp.

References armnn::profiling::uint32_t_size.

Referenced by VerifyTimelineLabelBinaryPacketData().

38 {
39  unsigned int uint32_t_size = sizeof(uint32_t);
40 
41  unsigned int remainder = numberOfBytes % uint32_t_size;
42  if (remainder == 0)
43  {
44  return numberOfBytes;
45  }
46 
47  return numberOfBytes + uint32_t_size - remainder;
48 }

◆ VerifyPostOptimisationStructureTestImpl()

void VerifyPostOptimisationStructureTestImpl ( armnn::BackendId  backendId)

Definition at line 312 of file ProfilingTestUtils.cpp.

References LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, LabelsAndEventClasses::BACKENDID_GUID, BOOST_CHECK(), IOutputSlot::Connect(), LabelsAndEventClasses::CONNECTION_GUID, INetwork::Create(), armnn::profiling::DataLink, Runtime::EnqueueWorkload(), armnn::profiling::ExecutionLink, armnn::Float32, ProfilingServiceRuntimeHelper::ForceTransitionToState(), BackendId::Get(), Runtime::GetDeviceSpec(), IConnectableLayer::GetGuid(), IConnectableLayer::GetInputSlot(), Runtime::GetInputTensorInfo(), IConnectableLayer::GetOutputSlot(), Runtime::GetOutputTensorInfo(), ProfilingServiceRuntimeHelper::GetProfilingBufferManager(), armnn::GetProfilingService(), BufferManager::GetReadableBuffer(), LabelsAndEventClasses::INFERENCE_GUID, armnn::profiling::LabelLink, 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, armnn::Optimize(), options, ProfilingService::ResetExternalProfilingOptions(), armnn::profiling::RetentionLink, IOutputSlot::SetTensorInfo(), armnn::Success, armnn::profiling::ThreadIdSize, LabelsAndEventClasses::TYPE_GUID, VerifyTimelineEntityBinaryPacketData(), VerifyTimelineEventBinaryPacket(), VerifyTimelineHeaderBinary(), VerifyTimelineLabelBinaryPacketData(), VerifyTimelineRelationshipBinaryPacketData(), and LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID.

Referenced by BOOST_AUTO_TEST_CASE().

313 {
314  using namespace armnn;
315 
316  // Create runtime in which test will run
318  options.m_ProfilingOptions.m_EnableProfiling = true;
319  options.m_ProfilingOptions.m_TimelineEnabled = true;
320  armnn::Runtime runtime(options);
322 
323  profiling::ProfilingServiceRuntimeHelper profilingServiceHelper(GetProfilingService(&runtime));
324  profilingServiceHelper.ForceTransitionToState(ProfilingState::NotConnected);
325  profilingServiceHelper.ForceTransitionToState(ProfilingState::WaitingForAck);
326  profilingServiceHelper.ForceTransitionToState(ProfilingState::Active);
327 
328  // build up the structure of the network
330 
331  // Convolution details
332  TensorInfo inputInfo({ 1, 2, 5, 1 }, DataType::Float32);
333  TensorInfo weightInfo({ 3, 2, 3, 1 }, DataType::Float32);
334  TensorInfo biasInfo({ 3 }, DataType::Float32);
335  TensorInfo outputInfo({ 1, 3, 7, 1 }, DataType::Float32);
336  std::vector<float> weightsData{
337  1.0f, 0.0f, 0.0f,
338  0.0f, 2.0f, -1.5f,
339 
340  0.0f, 0.0f, 0.0f,
341  0.2f, 0.2f, 0.2f,
342 
343  0.5f, 0.0f, 0.5f,
344  0.0f, -1.0f, 0.0f
345  };
346  ConstTensor weights(weightInfo, weightsData);
347 
348  Optional<ConstTensor> optionalBiases;
349  std::vector<float> biasesData{ 1.0f, 0.0f, 0.0f };
350  ConstTensor biases(biasInfo, biasesData);
351  optionalBiases = Optional<ConstTensor>(biases);
352 
353  // Input layer
354  IConnectableLayer* input = net->AddInputLayer(0, "input");
355 
356  // Convolution2d layer
357  Convolution2dDescriptor conv2dDesc;
358  conv2dDesc.m_StrideX = 1;
359  conv2dDesc.m_StrideY = 1;
360  conv2dDesc.m_PadLeft = 0;
361  conv2dDesc.m_PadRight = 0;
362  conv2dDesc.m_PadTop = 2;
363  conv2dDesc.m_PadBottom = 2;
364  conv2dDesc.m_BiasEnabled = true;
365  IConnectableLayer* conv2d = net->AddConvolution2dLayer(conv2dDesc, weights, optionalBiases);
366 
367  // Activation layer
368  armnn::ActivationDescriptor activationDesc;
369  armnn::IConnectableLayer* const activation = net->AddActivationLayer(activationDesc, "activation");
370 
371  // Output layer
372  IConnectableLayer* output = net->AddOutputLayer(0, "output");
373 
374  input->GetOutputSlot(0).Connect(conv2d->GetInputSlot(0));
375  conv2d->GetOutputSlot(0).Connect(activation->GetInputSlot(0));
376  activation->GetOutputSlot(0).Connect(output->GetInputSlot(0));
377 
378  input->GetOutputSlot(0).SetTensorInfo(inputInfo);
379  conv2d->GetOutputSlot(0).SetTensorInfo(outputInfo);
380  activation->GetOutputSlot(0).SetTensorInfo(outputInfo);
381 
382  // optimize the network
383  std::vector<armnn::BackendId> backends = { backendId };
384  IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime.GetDeviceSpec());
385 
386  ProfilingGuid optNetGuid = optNet->GetGuid();
387 
388  // Load it into the runtime. It should success.
389  armnn::NetworkId netId;
390  BOOST_TEST(runtime.LoadNetwork(netId, std::move(optNet)) == Status::Success);
391 
392  profiling::BufferManager& bufferManager = profilingServiceHelper.GetProfilingBufferManager();
393  auto readableBuffer = bufferManager.GetReadableBuffer();
394 
395  // Profiling is enable, the post-optimisation structure should be created
396  BOOST_CHECK(readableBuffer != nullptr);
397 
398  unsigned int size = readableBuffer->GetSize();
399  BOOST_CHECK(size == 1556);
400 
401  const unsigned char* readableData = readableBuffer->GetReadableData();
402  BOOST_CHECK(readableData != nullptr);
403 
404  unsigned int offset = 0;
405 
406  // Verify Header
407  VerifyTimelineHeaderBinary(readableData, offset, 1548);
408 
409  // Post-optimisation network
410  // Network entity
411  VerifyTimelineEntityBinaryPacketData(optNetGuid, readableData, offset);
412 
413  // Entity - Type relationship
415  EmptyOptional(),
416  optNetGuid,
417  EmptyOptional(),
418  readableData,
419  offset);
420 
421  // Type label relationship
423  EmptyOptional(),
424  EmptyOptional(),
426  readableData,
427  offset);
428 
429  // Input layer
430  // Input layer entity
431  VerifyTimelineEntityBinaryPacketData(input->GetGuid(), readableData, offset);
432 
433  // Name Entity
434  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "input", readableData, offset);
435 
436  // Entity - Name relationship
438  EmptyOptional(),
439  input->GetGuid(),
440  EmptyOptional(),
441  readableData,
442  offset);
443 
444  // Name label relationship
446  EmptyOptional(),
447  EmptyOptional(),
449  readableData,
450  offset);
451 
452  // Entity - Type relationship
454  EmptyOptional(),
455  input->GetGuid(),
456  EmptyOptional(),
457  readableData,
458  offset);
459 
460  // Type label relationship
462  EmptyOptional(),
463  EmptyOptional(),
465  readableData,
466  offset);
467 
468  // Network - Input layer relationship
470  EmptyOptional(),
471  optNetGuid,
472  input->GetGuid(),
473  readableData,
474  offset);
475 
476  // Conv2d layer
477  // Conv2d layer entity
478  VerifyTimelineEntityBinaryPacketData(conv2d->GetGuid(), readableData, offset);
479 
480  // Name entity
481  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "<Unnamed>", readableData, offset);
482 
483  // Entity - Name relationship
485  EmptyOptional(),
486  conv2d->GetGuid(),
487  EmptyOptional(),
488  readableData,
489  offset);
490 
491  // Name label relationship
493  EmptyOptional(),
494  EmptyOptional(),
496  readableData,
497  offset);
498 
499  // Entity - Type relationship
501  EmptyOptional(),
502  conv2d->GetGuid(),
503  EmptyOptional(),
504  readableData,
505  offset);
506 
507  // Type label relationship
509  EmptyOptional(),
510  EmptyOptional(),
512  readableData,
513  offset);
514 
515  // Network - Conv2d layer relationship
517  EmptyOptional(),
518  optNetGuid,
519  conv2d->GetGuid(),
520  readableData,
521  offset);
522 
523  // Input layer - Conv2d layer relationship
525  EmptyOptional(),
526  input->GetGuid(),
527  conv2d->GetGuid(),
528  readableData,
529  offset);
530 
531  // Entity - Type relationship
533  EmptyOptional(),
534  EmptyOptional(),
536  readableData,
537  offset);
538 
539  // Type label relationship
541  EmptyOptional(),
542  EmptyOptional(),
544  readableData,
545  offset);
546 
547  // Conv2d workload
548  // Conv2d workload entity
549  VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
550 
551  // Entity - Type relationship
553  EmptyOptional(),
554  EmptyOptional(),
555  EmptyOptional(),
556  readableData,
557  offset);
558 
559  // Type label relationship
561  EmptyOptional(),
562  EmptyOptional(),
564  readableData,
565  offset);
566 
567  // BackendId entity
568  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset);
569 
570  // Entity - BackendId relationship
572  EmptyOptional(),
573  EmptyOptional(),
574  EmptyOptional(),
575  readableData,
576  offset);
577 
578  // BackendId label relationship
580  EmptyOptional(),
581  EmptyOptional(),
583  readableData,
584  offset);
585 
586  // Conv2d layer - Conv2d workload relationship
588  EmptyOptional(),
589  conv2d->GetGuid(),
590  EmptyOptional(),
591  readableData,
592  offset);
593 
594  // Activation layer
595  // Activation layer entity
596  VerifyTimelineEntityBinaryPacketData(activation->GetGuid(), readableData, offset);
597 
598  // Name entity
599  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "activation", readableData, offset);
600 
601  // Entity - Name relationship
603  EmptyOptional(),
604  activation->GetGuid(),
605  EmptyOptional(),
606  readableData,
607  offset);
608 
609  // Name label relationship
611  EmptyOptional(),
612  EmptyOptional(),
614  readableData,
615  offset);
616 
617  // Entity - Type relationship
619  EmptyOptional(),
620  activation->GetGuid(),
621  EmptyOptional(),
622  readableData,
623  offset);
624 
625  // Type label relationship
627  EmptyOptional(),
628  EmptyOptional(),
630  readableData,
631  offset);
632 
633  // Network - Activation layer relationship
635  EmptyOptional(),
636  optNetGuid,
637  activation->GetGuid(),
638  readableData,
639  offset);
640 
641  // Conv2d layer - Activation layer relationship
643  EmptyOptional(),
644  conv2d->GetGuid(),
645  activation->GetGuid(),
646  readableData,
647  offset);
648 
649  // Entity - Type relationship
651  EmptyOptional(),
652  EmptyOptional(),
654  readableData,
655  offset);
656 
657  // Type label relationship
659  EmptyOptional(),
660  EmptyOptional(),
662  readableData,
663  offset);
664 
665  // Activation workload
666  // Activation workload entity
667  VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
668 
669  // Entity - Type relationship
671  EmptyOptional(),
672  EmptyOptional(),
673  EmptyOptional(),
674  readableData,
675  offset);
676 
677  // Type label relationship
679  EmptyOptional(),
680  EmptyOptional(),
682  readableData,
683  offset);
684 
685  // BackendId entity
686  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset);
687 
688  // Entity - BackendId relationship
690  EmptyOptional(),
691  EmptyOptional(),
692  EmptyOptional(),
693  readableData,
694  offset);
695 
696  // BackendId label relationship
698  EmptyOptional(),
699  EmptyOptional(),
701  readableData,
702  offset);
703 
704  // Activation layer - Activation workload relationship
706  EmptyOptional(),
707  activation->GetGuid(),
708  EmptyOptional(),
709  readableData,
710  offset);
711 
712  // Output layer
713  // Output layer entity
714  VerifyTimelineEntityBinaryPacketData(output->GetGuid(), readableData, offset);
715 
716  // Name entity
717  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "output", readableData, offset);
718 
719  // Entity - Name relationship
721  EmptyOptional(),
722  output->GetGuid(),
723  EmptyOptional(),
724  readableData,
725  offset);
726 
727  // Name label relationship
729  EmptyOptional(),
730  EmptyOptional(),
732  readableData,
733  offset);
734 
735  // Entity - Type relationship
737  EmptyOptional(),
738  output->GetGuid(),
739  EmptyOptional(),
740  readableData,
741  offset);
742 
743  // Type label relationship
745  EmptyOptional(),
746  EmptyOptional(),
748  readableData,
749  offset);
750 
751  // Network - Output layer relationship
753  EmptyOptional(),
754  optNetGuid,
755  output->GetGuid(),
756  readableData,
757  offset);
758 
759  // Activation layer - Output layer relationship
761  EmptyOptional(),
762  activation->GetGuid(),
763  output->GetGuid(),
764  readableData,
765  offset);
766 
767  // Entity - Type relationship
769  EmptyOptional(),
770  EmptyOptional(),
772  readableData,
773  offset);
774 
775  // Type label relationship
777  EmptyOptional(),
778  EmptyOptional(),
780  readableData,
781  offset);
782 
783  bufferManager.MarkRead(readableBuffer);
784 
785  // Creates structures for input & output.
786  std::vector<float> inputData(inputInfo.GetNumElements());
787  std::vector<float> outputData(outputInfo.GetNumElements());
788 
789  InputTensors inputTensors
790  {
791  {0, ConstTensor(runtime.GetInputTensorInfo(netId, 0), inputData.data())}
792  };
793  OutputTensors outputTensors
794  {
795  {0, Tensor(runtime.GetOutputTensorInfo(netId, 0), outputData.data())}
796  };
797 
798  // Does the inference.
799  runtime.EnqueueWorkload(netId, inputTensors, outputTensors);
800 
801  // Get readable buffer for input workload
802  auto inputReadableBuffer = bufferManager.GetReadableBuffer();
803  BOOST_CHECK(inputReadableBuffer != nullptr);
804 
805  // Get readable buffer for output workload
806  auto outputReadableBuffer = bufferManager.GetReadableBuffer();
807  BOOST_CHECK(outputReadableBuffer != nullptr);
808 
809  // Get readable buffer for inference timeline
810  auto inferenceReadableBuffer = bufferManager.GetReadableBuffer();
811  BOOST_CHECK(inferenceReadableBuffer != nullptr);
812 
813  // Validate input workload data
814  size = inputReadableBuffer->GetSize();
815  BOOST_CHECK(size == 204);
816 
817  readableData = inputReadableBuffer->GetReadableData();
818  BOOST_CHECK(readableData != nullptr);
819 
820  offset = 0;
821 
822  // Verify Header
823  VerifyTimelineHeaderBinary(readableData, offset, 196);
824 
825  // Input workload
826  // Input workload entity
827  VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
828 
829  // Entity - Type relationship
831  EmptyOptional(),
832  EmptyOptional(),
833  EmptyOptional(),
834  readableData,
835  offset);
836 
837  // Type label relationship
839  EmptyOptional(),
840  EmptyOptional(),
842  readableData,
843  offset);
844 
845  // BackendId entity
846  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset);
847 
848  // Entity - BackendId relationship
850  EmptyOptional(),
851  EmptyOptional(),
852  EmptyOptional(),
853  readableData,
854  offset);
855 
856  // BackendId label relationship
858  EmptyOptional(),
859  EmptyOptional(),
861  readableData,
862  offset);
863 
864  // Input layer - Input workload relationship
866  EmptyOptional(),
867  input->GetGuid(),
868  EmptyOptional(),
869  readableData,
870  offset);
871 
872  bufferManager.MarkRead(inputReadableBuffer);
873 
874  // Validate output workload data
875  size = outputReadableBuffer->GetSize();
876  BOOST_CHECK(size == 204);
877 
878  readableData = outputReadableBuffer->GetReadableData();
879  BOOST_CHECK(readableData != nullptr);
880 
881  offset = 0;
882 
883  // Verify Header
884  VerifyTimelineHeaderBinary(readableData, offset, 196);
885 
886  // Output workload
887  // Output workload entity
888  VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
889 
890  // Entity - Type relationship
892  EmptyOptional(),
893  EmptyOptional(),
894  EmptyOptional(),
895  readableData,
896  offset);
897 
898  // Type label relationship
900  EmptyOptional(),
901  EmptyOptional(),
903  readableData,
904  offset);
905 
906  // BackendId entity
907  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset);
908 
909  // Entity - BackendId relationship
911  EmptyOptional(),
912  EmptyOptional(),
913  EmptyOptional(),
914  readableData,
915  offset);
916 
917  // BackendId label relationship
919  EmptyOptional(),
920  EmptyOptional(),
922  readableData,
923  offset);
924 
925  // Output layer - Output workload relationship
927  EmptyOptional(),
928  output->GetGuid(),
929  EmptyOptional(),
930  readableData,
931  offset);
932 
933  bufferManager.MarkRead(outputReadableBuffer);
934 
935  // Validate inference data
936  size = inferenceReadableBuffer->GetSize();
937 
938  BOOST_CHECK(size == 1516 + 10 * ThreadIdSize);
939 
940  readableData = inferenceReadableBuffer->GetReadableData();
941  BOOST_CHECK(readableData != nullptr);
942 
943  offset = 0;
944 
945  // Verify Header
946  VerifyTimelineHeaderBinary(readableData, offset, 1508 + 10 * ThreadIdSize);
947 
948  // Inference timeline trace
949  // Inference entity
950  VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
951 
952  // Entity - Type relationship
954  EmptyOptional(),
955  EmptyOptional(),
957  readableData,
958  offset);
959 
960  // Type label relationship
962  EmptyOptional(),
963  EmptyOptional(),
965  readableData,
966  offset);
967 
968  // Network - Inference relationship
970  EmptyOptional(),
971  optNetGuid,
972  EmptyOptional(),
973  readableData,
974  offset);
975 
976  // Start Inference life
977  // Event packet - timeline, threadId, eventGuid
979 
980  // Inference - event relationship
982  EmptyOptional(),
983  EmptyOptional(),
984  EmptyOptional(),
985  readableData,
986  offset);
987 
988  // Event - event class relationship
990  EmptyOptional(),
991  EmptyOptional(),
993  readableData,
994  offset);
995 
996  // Execution
997  // Input workload execution
998  // Input workload execution entity
999  VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
1000 
1001  // Entity - Type relationship
1003  EmptyOptional(),
1004  EmptyOptional(),
1006  readableData,
1007  offset);
1008 
1009  // Type label relationship
1011  EmptyOptional(),
1012  EmptyOptional(),
1014  readableData,
1015  offset);
1016 
1017  // Inference - Workload execution relationship
1019  EmptyOptional(),
1020  EmptyOptional(),
1021  EmptyOptional(),
1022  readableData,
1023  offset);
1024 
1025  // Workload - Workload execution relationship
1027  EmptyOptional(),
1028  EmptyOptional(),
1029  EmptyOptional(),
1030  readableData,
1031  offset);
1032 
1033  // Start Input workload execution life
1034  // Event packet - timeline, threadId, eventGuid
1036 
1037  // Input workload execution - event relationship
1039  EmptyOptional(),
1040  EmptyOptional(),
1041  EmptyOptional(),
1042  readableData,
1043  offset);
1044 
1045  // Event - event class relationship
1047  EmptyOptional(),
1048  EmptyOptional(),
1050  readableData,
1051  offset);
1052 
1053  // End of Input workload execution life
1054  // Event packet - timeline, threadId, eventGuid
1056 
1057  // Input workload execution - event relationship
1059  EmptyOptional(),
1060  EmptyOptional(),
1061  EmptyOptional(),
1062  readableData,
1063  offset);
1064 
1065  // Event - event class relationship
1067  EmptyOptional(),
1068  EmptyOptional(),
1070  readableData,
1071  offset);
1072 
1073  // Conv2d workload execution
1074  // Conv2d workload execution entity
1075  VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
1076 
1077  // Entity - Type relationship
1079  EmptyOptional(),
1080  EmptyOptional(),
1082  readableData,
1083  offset);
1084 
1085  // Type label relationship
1087  EmptyOptional(),
1088  EmptyOptional(),
1090  readableData,
1091  offset);
1092 
1093  // Inference - Workload execution relationship
1095  EmptyOptional(),
1096  EmptyOptional(),
1097  EmptyOptional(),
1098  readableData,
1099  offset);
1100 
1101  // Workload - Workload execution relationship
1103  EmptyOptional(),
1104  EmptyOptional(),
1105  EmptyOptional(),
1106  readableData,
1107  offset);
1108 
1109  // Start Conv2d workload execution life
1110  // Event packet - timeline, threadId, eventGuid
1112 
1113  // Conv2d workload execution - event relationship
1115  EmptyOptional(),
1116  EmptyOptional(),
1117  EmptyOptional(),
1118  readableData,
1119  offset);
1120 
1121  // Event - event class relationship
1123  EmptyOptional(),
1124  EmptyOptional(),
1126  readableData,
1127  offset);
1128 
1129  // End of Conv2d workload execution life
1130  // Event packet - timeline, threadId, eventGuid
1132 
1133  // Conv2d workload execution - event relationship
1135  EmptyOptional(),
1136  EmptyOptional(),
1137  EmptyOptional(),
1138  readableData,
1139  offset);
1140 
1141  // Event - event class relationship
1143  EmptyOptional(),
1144  EmptyOptional(),
1146  readableData,
1147  offset);
1148 
1149  // Activation workload execution
1150  // Activation workload execution entity
1151  VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
1152 
1153  // Entity - Type relationship
1155  EmptyOptional(),
1156  EmptyOptional(),
1158  readableData,
1159  offset);
1160 
1161  // Type label relationship
1163  EmptyOptional(),
1164  EmptyOptional(),
1166  readableData,
1167  offset);
1168 
1169  // Inference - Workload execution relationship
1171  EmptyOptional(),
1172  EmptyOptional(),
1173  EmptyOptional(),
1174  readableData,
1175  offset);
1176 
1177  // Workload - Workload execution relationship
1179  EmptyOptional(),
1180  EmptyOptional(),
1181  EmptyOptional(),
1182  readableData,
1183  offset);
1184 
1185  // Start Activation workload execution life
1186  // Event packet - timeline, threadId, eventGuid
1188 
1189  // Activation workload execution - event relationship
1191  EmptyOptional(),
1192  EmptyOptional(),
1193  EmptyOptional(),
1194  readableData,
1195  offset);
1196 
1197  // Event - event class relationship
1199  EmptyOptional(),
1200  EmptyOptional(),
1202  readableData,
1203  offset);
1204 
1205  // End of Activation workload execution life
1206  // Event packet - timeline, threadId, eventGuid
1208 
1209  // Activation workload execution - event relationship
1211  EmptyOptional(),
1212  EmptyOptional(),
1213  EmptyOptional(),
1214  readableData,
1215  offset);
1216 
1217  // Event - event class relationship
1219  EmptyOptional(),
1220  EmptyOptional(),
1222  readableData,
1223  offset);
1224 
1225  // Output workload execution
1226  // Output workload execution entity
1227  VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
1228 
1229  // Entity - Type relationship
1231  EmptyOptional(),
1232  EmptyOptional(),
1234  readableData,
1235  offset);
1236 
1237  // Type label relationship
1239  EmptyOptional(),
1240  EmptyOptional(),
1242  readableData,
1243  offset);
1244 
1245  // Inference - Workload execution relationship
1247  EmptyOptional(),
1248  EmptyOptional(),
1249  EmptyOptional(),
1250  readableData,
1251  offset);
1252 
1253  // Workload - Workload execution relationship
1255  EmptyOptional(),
1256  EmptyOptional(),
1257  EmptyOptional(),
1258  readableData,
1259  offset);
1260 
1261  // Start Output workload execution life
1262  // Event packet - timeline, threadId, eventGuid
1264 
1265  // Output workload execution - event relationship
1267  EmptyOptional(),
1268  EmptyOptional(),
1269  EmptyOptional(),
1270  readableData,
1271  offset);
1272 
1273  // Event - event class relationship
1275  EmptyOptional(),
1276  EmptyOptional(),
1278  readableData,
1279  offset);
1280 
1281  // End of Normalize workload execution life
1282  // Event packet - timeline, threadId, eventGuid
1284 
1285  // Output workload execution - event relationship
1287  EmptyOptional(),
1288  EmptyOptional(),
1289  EmptyOptional(),
1290  readableData,
1291  offset);
1292 
1293  // Event - event class relationship
1295  EmptyOptional(),
1296  EmptyOptional(),
1298  readableData,
1299  offset);
1300 
1301  // End of Inference life
1302  // Event packet - timeline, threadId, eventGuid
1304 
1305  // Inference - event relationship
1307  EmptyOptional(),
1308  EmptyOptional(),
1309  EmptyOptional(),
1310  readableData,
1311  offset);
1312 
1313  // Event - event class relationship
1315  EmptyOptional(),
1316  EmptyOptional(),
1318  readableData,
1319  offset);
1320 
1321  bufferManager.MarkRead(inferenceReadableBuffer);
1322 }
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
void 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:225
uint32_t m_PadRight
Padding right value in the width dimension.
int NetworkId
Definition: IRuntime.hpp:20
void VerifyTimelineLabelBinaryPacketData(Optional< ProfilingGuid > guid, const std::string &label, const unsigned char *readableData, unsigned int &offset)
Copyright (c) 2020 ARM Limited.
Head execution start depends on Tail execution completion.
static ARMNN_DLLEXPORT ProfilingStaticGuid CONNECTION_GUID
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
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:191
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.
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:1003
profiling::ProfilingService & GetProfilingService(armnn::Runtime *runtime)
Definition: TestUtils.cpp:25
virtual LayerGuid GetGuid() const =0
Returns the unique id of the layer.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:199
std::vector< std::pair< LayerBindingId, class Tensor > > OutputTensors
Definition: Tensor.hpp:226
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
Definition: INetwork.hpp:573
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)
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
Definition: Optional.hpp:32
void VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType relationshipType, Optional< ProfilingGuid > relationshipGuid, Optional< ProfilingGuid > headGuid, Optional< ProfilingGuid > tailGuid, const unsigned char *readableData, unsigned int &offset)
static ARMNN_DLLEXPORT ProfilingStaticGuid TYPE_GUID
void VerifyTimelineEventBinaryPacket(Optional< uint64_t > timestamp, Optional< std::thread::id > threadId, Optional< ProfilingGuid > eventGuid, const unsigned char *readableData, unsigned int &offset)
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
virtual int Connect(IInputSlot &destination)=0
armnn::Runtime::CreationOptions::ExternalProfilingOptions options
ExternalProfilingOptions m_ProfilingOptions
Definition: IRuntime.hpp:83
static ARMNN_DLLEXPORT ProfilingStaticGuid BACKENDID_GUID
static INetworkPtr Create()
Definition: Network.cpp:50
uint32_t m_PadLeft
Padding left value in the width dimension.

◆ VerifyTimelineEntityBinaryPacketData()

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

Definition at line 224 of file ProfilingTestUtils.cpp.

References ARMNN_ASSERT, BOOST_CHECK(), 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().

227 {
228  ARMNN_ASSERT(readableData);
229 
230  // Utils
231  unsigned int uint32_t_size = sizeof(uint32_t);
232  unsigned int uint64_t_size = sizeof(uint64_t);
233 
234  // Reading TimelineEntityClassBinaryPacket
235  // Check the decl_id
236  uint32_t entityDeclId = ReadUint32(readableData, offset);
237  BOOST_CHECK(entityDeclId == 1);
238 
239  // Check the profiling GUID
240  offset += uint32_t_size;
241  uint64_t readProfilingGuid = ReadUint64(readableData, offset);
242 
243  if (guid.has_value())
244  {
245  BOOST_CHECK(readProfilingGuid == guid.value());
246  }
247  else
248  {
249  BOOST_CHECK(readProfilingGuid != ProfilingGuid(0));
250  }
251 
252  offset += uint64_t_size;
253 }
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
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()

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

Definition at line 255 of file ProfilingTestUtils.cpp.

References ARMNN_ASSERT, BOOST_CHECK(), 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().

260 {
261  ARMNN_ASSERT(readableData);
262 
263  // Utils
264  unsigned int uint32_t_size = sizeof(uint32_t);
265  unsigned int uint64_t_size = sizeof(uint64_t);
266 
267  // Reading TimelineEventBinaryPacket
268  // Check the decl_id
269  uint32_t entityDeclId = ReadUint32(readableData, offset);
270  BOOST_CHECK(entityDeclId == 4);
271 
272  // Check the timestamp
273  offset += uint32_t_size;
274  uint64_t readTimestamp = ReadUint64(readableData, offset);
275  if (timestamp.has_value())
276  {
277  BOOST_CHECK(readTimestamp == timestamp.value());
278  }
279  else
280  {
281  BOOST_CHECK(readTimestamp != 0);
282  }
283 
284  // Check the thread id
285  offset += uint64_t_size;
286  std::vector<uint8_t> readThreadId(ThreadIdSize, 0);
287  ReadBytes(readableData, offset, ThreadIdSize, readThreadId.data());
288  if (threadId.has_value())
289  {
290  BOOST_CHECK(readThreadId == threadId.value());
291  }
292  else
293  {
294  BOOST_CHECK(readThreadId == std::this_thread::get_id());
295  }
296 
297  // Check the event GUID
298  offset += ThreadIdSize;
299  uint64_t readEventGuid = ReadUint64(readableData, offset);
300  if (eventGuid.has_value())
301  {
302  BOOST_CHECK(readEventGuid == eventGuid.value());
303  }
304  else
305  {
306  BOOST_CHECK(readEventGuid != ProfilingGuid(0));
307  }
308 
309  offset += uint64_t_size;
310 }
void ReadBytes(const IPacketBufferPtr &packetBuffer, unsigned int offset, unsigned int valueSize, uint8_t outValue[])
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
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,
const unsigned char *  readableData,
unsigned int &  offset 
)

Definition at line 120 of file ProfilingTestUtils.cpp.

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

Referenced by BOOST_AUTO_TEST_CASE().

123 {
124  ARMNN_ASSERT(readableData);
125 
126  // Utils
127  unsigned int uint32_t_size = sizeof(uint32_t);
128  unsigned int uint64_t_size = sizeof(uint64_t);
129 
130  // Check the decl id
131  uint32_t eventClassDeclId = ReadUint32(readableData, offset);
132  BOOST_CHECK(eventClassDeclId == 2);
133 
134  // Check the profiling GUID
135  offset += uint32_t_size;
136  uint64_t readProfilingGuid = ReadUint64(readableData, offset);
137  BOOST_CHECK(readProfilingGuid == guid);
138 
139  // Update the offset to allow parsing to be continued after this function returns
140  offset += uint64_t_size;
141 }
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
#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 50 of file ProfilingTestUtils.cpp.

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

Referenced by BOOST_AUTO_TEST_CASE(), and VerifyPostOptimisationStructureTestImpl().

53 {
54  ARMNN_ASSERT(readableData);
55 
56  // Utils
57  unsigned int uint32_t_size = sizeof(uint32_t);
58 
59  // Check the TimelineEventClassBinaryPacket header
60  uint32_t entityBinaryPacketHeaderWord0 = ReadUint32(readableData, offset);
61  uint32_t entityBinaryPacketFamily = (entityBinaryPacketHeaderWord0 >> 26) & 0x0000003F;
62  uint32_t entityBinaryPacketClass = (entityBinaryPacketHeaderWord0 >> 19) & 0x0000007F;
63  uint32_t entityBinaryPacketType = (entityBinaryPacketHeaderWord0 >> 16) & 0x00000007;
64  uint32_t entityBinaryPacketStreamId = (entityBinaryPacketHeaderWord0 >> 0) & 0x00000007;
65  BOOST_CHECK(entityBinaryPacketFamily == 1);
66  BOOST_CHECK(entityBinaryPacketClass == 0);
67  BOOST_CHECK(entityBinaryPacketType == 1);
68  BOOST_CHECK(entityBinaryPacketStreamId == 0);
69  offset += uint32_t_size;
70  uint32_t entityBinaryPacketHeaderWord1 = ReadUint32(readableData, offset);
71  uint32_t eventBinaryPacketSequenceNumber = (entityBinaryPacketHeaderWord1 >> 24) & 0x00000001;
72  uint32_t eventBinaryPacketDataLength = (entityBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF;
73  BOOST_CHECK(eventBinaryPacketSequenceNumber == 0);
74  BOOST_CHECK(eventBinaryPacketDataLength == packetDataLength);
75  offset += uint32_t_size;
76 }
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)

◆ VerifyTimelineLabelBinaryPacketData()

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

Definition at line 78 of file ProfilingTestUtils.cpp.

References ARMNN_ASSERT, BOOST_CHECK(), ProfilingService::GetStaticId(), OptionalBase::has_value(), armnn::numeric_cast(), OffsetToNextWord(), profilingService, 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().

82 {
83  ARMNN_ASSERT(readableData);
84 
85  // Utils
86  unsigned int uint32_t_size = sizeof(uint32_t);
87  unsigned int uint64_t_size = sizeof(uint64_t);
88  unsigned int label_size = boost::numeric_cast<unsigned int>(label.size());
89 
90  // Check the decl id
91  uint32_t eventClassDeclId = ReadUint32(readableData, offset);
92  BOOST_CHECK(eventClassDeclId == 0);
93 
94  // Check the profiling GUID
95  offset += uint32_t_size;
96  uint64_t readProfilingGuid = ReadUint64(readableData, offset);
97  if (guid.has_value())
98  {
99  BOOST_CHECK(readProfilingGuid == guid.value());
100  }
101  else
102  {
104  BOOST_CHECK(readProfilingGuid == profilingService.GetStaticId(label));
105  }
106 
107  // Check the SWTrace label
108  offset += uint64_t_size;
109  uint32_t swTraceLabelLength = ReadUint32(readableData, offset);
110  BOOST_CHECK(swTraceLabelLength == label_size + 1); // Label length including the null-terminator
111  offset += uint32_t_size;
112  BOOST_CHECK(std::memcmp(readableData + offset, // Offset to the label in the buffer
113  label.data(), // The original label
114  swTraceLabelLength - 1) == 0); // The length of the label
115 
116  // SWTrace strings are written in blocks of words, so the offset has to be updated to the next whole word
117  offset += OffsetToNextWord(swTraceLabelLength);
118 }
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
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)
armnn::profiling::ProfilingService profilingService

◆ VerifyTimelineRelationshipBinaryPacketData()

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

Definition at line 143 of file ProfilingTestUtils.cpp.

References ARMNN_ASSERT, BOOST_CHECK(), 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().

149 {
150  ARMNN_ASSERT(readableData);
151 
152  uint32_t relationshipTypeUint = 0;
153  switch (relationshipType)
154  {
155  case ProfilingRelationshipType::RetentionLink:
156  relationshipTypeUint = 0;
157  break;
158  case ProfilingRelationshipType::ExecutionLink:
159  relationshipTypeUint = 1;
160  break;
161  case ProfilingRelationshipType::DataLink:
162  relationshipTypeUint = 2;
163  break;
164  case ProfilingRelationshipType::LabelLink:
165  relationshipTypeUint = 3;
166  break;
167  default:
168  BOOST_ERROR("Unknown relationship type");
169  }
170 
171  // Utils
172  unsigned int uint32_t_size = sizeof(uint32_t);
173  unsigned int uint64_t_size = sizeof(uint64_t);
174 
175  // Check the decl id
176  uint32_t eventClassDeclId = ReadUint32(readableData, offset);
177  BOOST_CHECK(eventClassDeclId == 3);
178 
179  // Check the relationship type
180  offset += uint32_t_size;
181  uint32_t readRelationshipTypeUint = ReadUint32(readableData, offset);
182  BOOST_CHECK(readRelationshipTypeUint == relationshipTypeUint);
183 
184  // Check the relationship GUID
185  offset += uint32_t_size;
186  uint64_t readRelationshipGuid = ReadUint64(readableData, offset);
187  if (relationshipGuid.has_value())
188  {
189  BOOST_CHECK(readRelationshipGuid == relationshipGuid.value());
190  }
191  else
192  {
193  BOOST_CHECK(readRelationshipGuid != ProfilingGuid(0));
194  }
195 
196  // Check the head of relationship GUID
197  offset += uint64_t_size;
198  uint64_t readHeadRelationshipGuid = ReadUint64(readableData, offset);
199  if (headGuid.has_value())
200  {
201  BOOST_CHECK(readHeadRelationshipGuid == headGuid.value());
202  }
203  else
204  {
205  BOOST_CHECK(readHeadRelationshipGuid != ProfilingGuid(0));
206  }
207 
208  // Check the tail of relationship GUID
209  offset += uint64_t_size;
210  uint64_t readTailRelationshipGuid = ReadUint64(readableData, offset);
211  if (tailGuid.has_value())
212  {
213  BOOST_CHECK(readTailRelationshipGuid == tailGuid.value());
214  }
215  else
216  {
217  BOOST_CHECK(readTailRelationshipGuid != ProfilingGuid(0));
218  }
219 
220  // Update the offset to allow parsing to be continued after this function returns
221  offset += uint64_t_size;
222 }
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
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)