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

Go to the source code of this file.

Functions

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

◆ OffsetToNextWord()

unsigned int OffsetToNextWord ( unsigned int  numberOfBytes)
inline

Definition at line 15 of file ProfilingTestUtils.cpp.

References armnn::profiling::uint32_t_size.

Referenced by VerifyTimelineLabelBinaryPacketData().

16 {
17  unsigned int uint32_t_size = sizeof(uint32_t);
18 
19  unsigned int remainder = numberOfBytes % uint32_t_size;
20  if (remainder == 0)
21  {
22  return numberOfBytes;
23  }
24 
25  return numberOfBytes + uint32_t_size - remainder;
26 }

◆ VerifyPostOptimisationStructureTestImpl()

void VerifyPostOptimisationStructureTestImpl ( armnn::BackendId  backendId)

Definition at line 290 of file ProfilingTestUtils.cpp.

References LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, LabelsAndEventClasses::BACKENDID_GUID, BOOST_CHECK(), ProfilingService::ConfigureProfilingService(), IOutputSlot::Connect(), LabelsAndEventClasses::CONNECTION_GUID, INetwork::Create(), IRuntime::Create(), armnn::profiling::DataLink, armnn::profiling::ExecutionLink, armnn::Float32, BackendId::Get(), IConnectableLayer::GetGuid(), IConnectableLayer::GetInputSlot(), IConnectableLayer::GetOutputSlot(), BufferManager::GetReadableBuffer(), LabelsAndEventClasses::INFERENCE_GUID, ProfilingService::Instance(), armnn::profiling::LabelLink, 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, BufferManager::MarkRead(), LabelsAndEventClasses::NAME_GUID, armnn::Optimize(), options, profilingService, armnn::profiling::RetentionLink, IOutputSlot::SetTensorInfo(), armnn::Success, LabelsAndEventClasses::TYPE_GUID, VerifyTimelineEntityBinaryPacketData(), VerifyTimelineEventBinaryPacket(), VerifyTimelineHeaderBinary(), VerifyTimelineLabelBinaryPacketData(), VerifyTimelineRelationshipBinaryPacketData(), and LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID.

Referenced by BOOST_AUTO_TEST_CASE().

291 {
292  using namespace armnn;
293 
294  // Create runtime in which test will run
296  options.m_ProfilingOptions.m_EnableProfiling = true;
298  profilingService.ConfigureProfilingService(options.m_ProfilingOptions, true);
300 
301  // build up the structure of the network
303 
304  // Convolution details
305  TensorInfo inputInfo({ 1, 2, 5, 1 }, DataType::Float32);
306  TensorInfo weightInfo({ 3, 2, 3, 1 }, DataType::Float32);
307  TensorInfo biasInfo({ 3 }, DataType::Float32);
308  TensorInfo outputInfo({ 1, 3, 7, 1 }, DataType::Float32);
309  std::vector<float> weightsData{
310  1.0f, 0.0f, 0.0f,
311  0.0f, 2.0f, -1.5f,
312 
313  0.0f, 0.0f, 0.0f,
314  0.2f, 0.2f, 0.2f,
315 
316  0.5f, 0.0f, 0.5f,
317  0.0f, -1.0f, 0.0f
318  };
319  ConstTensor weights(weightInfo, weightsData);
320 
321  Optional<ConstTensor> optionalBiases;
322  std::vector<float> biasesData{ 1.0f, 0.0f, 0.0f };
323  ConstTensor biases(biasInfo, biasesData);
324  optionalBiases = Optional<ConstTensor>(biases);
325 
326  // Input layer
327  IConnectableLayer* input = net->AddInputLayer(0, "input");
328 
329  // Convolution2d layer
330  Convolution2dDescriptor conv2dDesc;
331  conv2dDesc.m_StrideX = 1;
332  conv2dDesc.m_StrideY = 1;
333  conv2dDesc.m_PadLeft = 0;
334  conv2dDesc.m_PadRight = 0;
335  conv2dDesc.m_PadTop = 2;
336  conv2dDesc.m_PadBottom = 2;
337  conv2dDesc.m_BiasEnabled = true;
338  IConnectableLayer* conv2d = net->AddConvolution2dLayer(conv2dDesc, weights, optionalBiases);
339 
340  // Activation layer
341  armnn::ActivationDescriptor activationDesc;
342  armnn::IConnectableLayer* const activation = net->AddActivationLayer(activationDesc, "activation");
343 
344  // Output layer
345  IConnectableLayer* output = net->AddOutputLayer(0, "output");
346 
347  input->GetOutputSlot(0).Connect(conv2d->GetInputSlot(0));
348  conv2d->GetOutputSlot(0).Connect(activation->GetInputSlot(0));
349  activation->GetOutputSlot(0).Connect(output->GetInputSlot(0));
350 
351  input->GetOutputSlot(0).SetTensorInfo(inputInfo);
352  conv2d->GetOutputSlot(0).SetTensorInfo(outputInfo);
353  activation->GetOutputSlot(0).SetTensorInfo(outputInfo);
354 
355  // optimize the network
356  std::vector<armnn::BackendId> backends = { backendId };
357  IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec());
358 
359  ProfilingGuid optNetGuid = optNet->GetGuid();
360 
361  // Load it into the runtime. It should success.
362  armnn::NetworkId netId;
363  BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet)) == Status::Success);
364 
365  profiling::ProfilingServiceRuntimeHelper profilingServiceHelper;
366  profiling::BufferManager& bufferManager = profilingServiceHelper.GetProfilingBufferManager();
367  auto readableBuffer = bufferManager.GetReadableBuffer();
368 
369  // Profiling is enable, the post-optimisation structure should be created
370  BOOST_CHECK(readableBuffer != nullptr);
371 
372  unsigned int size = readableBuffer->GetSize();
373  BOOST_CHECK(size == 1556);
374 
375  const unsigned char* readableData = readableBuffer->GetReadableData();
376  BOOST_CHECK(readableData != nullptr);
377 
378  unsigned int offset = 0;
379 
380  // Verify Header
381  VerifyTimelineHeaderBinary(readableData, offset, 1548);
382 
383  // Post-optimisation network
384  // Network entity
385  VerifyTimelineEntityBinaryPacketData(optNetGuid, readableData, offset);
386 
387  // Entity - Type relationship
389  EmptyOptional(),
390  optNetGuid,
391  EmptyOptional(),
392  readableData,
393  offset);
394 
395  // Type label relationship
397  EmptyOptional(),
398  EmptyOptional(),
400  readableData,
401  offset);
402 
403  // Input layer
404  // Input layer entity
405  VerifyTimelineEntityBinaryPacketData(input->GetGuid(), readableData, offset);
406 
407  // Name Entity
408  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "input", readableData, offset);
409 
410  // Entity - Name relationship
412  EmptyOptional(),
413  input->GetGuid(),
414  EmptyOptional(),
415  readableData,
416  offset);
417 
418  // Name label relationship
420  EmptyOptional(),
421  EmptyOptional(),
423  readableData,
424  offset);
425 
426  // Entity - Type relationship
428  EmptyOptional(),
429  input->GetGuid(),
430  EmptyOptional(),
431  readableData,
432  offset);
433 
434  // Type label relationship
436  EmptyOptional(),
437  EmptyOptional(),
439  readableData,
440  offset);
441 
442  // Network - Input layer relationship
444  EmptyOptional(),
445  optNetGuid,
446  input->GetGuid(),
447  readableData,
448  offset);
449 
450  // Conv2d layer
451  // Conv2d layer entity
452  VerifyTimelineEntityBinaryPacketData(conv2d->GetGuid(), readableData, offset);
453 
454  // Name entity
455  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "<Unnamed>", readableData, offset);
456 
457  // Entity - Name relationship
459  EmptyOptional(),
460  conv2d->GetGuid(),
461  EmptyOptional(),
462  readableData,
463  offset);
464 
465  // Name label relationship
467  EmptyOptional(),
468  EmptyOptional(),
470  readableData,
471  offset);
472 
473  // Entity - Type relationship
475  EmptyOptional(),
476  conv2d->GetGuid(),
477  EmptyOptional(),
478  readableData,
479  offset);
480 
481  // Type label relationship
483  EmptyOptional(),
484  EmptyOptional(),
486  readableData,
487  offset);
488 
489  // Network - Conv2d layer relationship
491  EmptyOptional(),
492  optNetGuid,
493  conv2d->GetGuid(),
494  readableData,
495  offset);
496 
497  // Input layer - Conv2d layer relationship
499  EmptyOptional(),
500  input->GetGuid(),
501  conv2d->GetGuid(),
502  readableData,
503  offset);
504 
505  // Entity - Type relationship
507  EmptyOptional(),
508  EmptyOptional(),
510  readableData,
511  offset);
512 
513  // Type label relationship
515  EmptyOptional(),
516  EmptyOptional(),
518  readableData,
519  offset);
520 
521  // Conv2d workload
522  // Conv2d workload entity
523  VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
524 
525  // Entity - Type relationship
527  EmptyOptional(),
528  EmptyOptional(),
529  EmptyOptional(),
530  readableData,
531  offset);
532 
533  // Type label relationship
535  EmptyOptional(),
536  EmptyOptional(),
538  readableData,
539  offset);
540 
541  // BackendId entity
542  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset);
543 
544  // Entity - BackendId relationship
546  EmptyOptional(),
547  EmptyOptional(),
548  EmptyOptional(),
549  readableData,
550  offset);
551 
552  // BackendId label relationship
554  EmptyOptional(),
555  EmptyOptional(),
557  readableData,
558  offset);
559 
560  // Conv2d layer - Conv2d workload relationship
562  EmptyOptional(),
563  conv2d->GetGuid(),
564  EmptyOptional(),
565  readableData,
566  offset);
567 
568  // Activation layer
569  // Activation layer entity
570  VerifyTimelineEntityBinaryPacketData(activation->GetGuid(), readableData, offset);
571 
572  // Name entity
573  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "activation", readableData, offset);
574 
575  // Entity - Name relationship
577  EmptyOptional(),
578  activation->GetGuid(),
579  EmptyOptional(),
580  readableData,
581  offset);
582 
583  // Name label relationship
585  EmptyOptional(),
586  EmptyOptional(),
588  readableData,
589  offset);
590 
591  // Entity - Type relationship
593  EmptyOptional(),
594  activation->GetGuid(),
595  EmptyOptional(),
596  readableData,
597  offset);
598 
599  // Type label relationship
601  EmptyOptional(),
602  EmptyOptional(),
604  readableData,
605  offset);
606 
607  // Network - Activation layer relationship
609  EmptyOptional(),
610  optNetGuid,
611  activation->GetGuid(),
612  readableData,
613  offset);
614 
615  // Conv2d layer - Activation layer relationship
617  EmptyOptional(),
618  conv2d->GetGuid(),
619  activation->GetGuid(),
620  readableData,
621  offset);
622 
623  // Entity - Type relationship
625  EmptyOptional(),
626  EmptyOptional(),
628  readableData,
629  offset);
630 
631  // Type label relationship
633  EmptyOptional(),
634  EmptyOptional(),
636  readableData,
637  offset);
638 
639  // Activation workload
640  // Activation workload entity
641  VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
642 
643  // Entity - Type relationship
645  EmptyOptional(),
646  EmptyOptional(),
647  EmptyOptional(),
648  readableData,
649  offset);
650 
651  // Type label relationship
653  EmptyOptional(),
654  EmptyOptional(),
656  readableData,
657  offset);
658 
659  // BackendId entity
660  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset);
661 
662  // Entity - BackendId relationship
664  EmptyOptional(),
665  EmptyOptional(),
666  EmptyOptional(),
667  readableData,
668  offset);
669 
670  // BackendId label relationship
672  EmptyOptional(),
673  EmptyOptional(),
675  readableData,
676  offset);
677 
678  // Activation layer - Activation workload relationship
680  EmptyOptional(),
681  activation->GetGuid(),
682  EmptyOptional(),
683  readableData,
684  offset);
685 
686  // Output layer
687  // Output layer entity
688  VerifyTimelineEntityBinaryPacketData(output->GetGuid(), readableData, offset);
689 
690  // Name entity
691  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "output", readableData, offset);
692 
693  // Entity - Name relationship
695  EmptyOptional(),
696  output->GetGuid(),
697  EmptyOptional(),
698  readableData,
699  offset);
700 
701  // Name label relationship
703  EmptyOptional(),
704  EmptyOptional(),
706  readableData,
707  offset);
708 
709  // Entity - Type relationship
711  EmptyOptional(),
712  output->GetGuid(),
713  EmptyOptional(),
714  readableData,
715  offset);
716 
717  // Type label relationship
719  EmptyOptional(),
720  EmptyOptional(),
722  readableData,
723  offset);
724 
725  // Network - Output layer relationship
727  EmptyOptional(),
728  optNetGuid,
729  output->GetGuid(),
730  readableData,
731  offset);
732 
733  // Activation layer - Output layer relationship
735  EmptyOptional(),
736  activation->GetGuid(),
737  output->GetGuid(),
738  readableData,
739  offset);
740 
741  // Entity - Type relationship
743  EmptyOptional(),
744  EmptyOptional(),
746  readableData,
747  offset);
748 
749  // Type label relationship
751  EmptyOptional(),
752  EmptyOptional(),
754  readableData,
755  offset);
756 
757  bufferManager.MarkRead(readableBuffer);
758 
759  // Creates structures for input & output.
760  std::vector<float> inputData(inputInfo.GetNumElements());
761  std::vector<float> outputData(outputInfo.GetNumElements());
762 
763  InputTensors inputTensors
764  {
765  { 0, ConstTensor(runtime->GetInputTensorInfo(netId, 0), inputData.data()) }
766  };
767  OutputTensors outputTensors
768  {
769  { 0, Tensor(runtime->GetOutputTensorInfo(netId, 0), outputData.data()) }
770  };
771 
772  // Does the inference.
773  runtime->EnqueueWorkload(netId, inputTensors, outputTensors);
774 
775  // Get readable buffer for inference timeline
776  auto inferenceReadableBuffer = bufferManager.GetReadableBuffer();
777  BOOST_CHECK(inferenceReadableBuffer != nullptr);
778 
779  // Get readable buffer for output workload
780  auto outputReadableBuffer = bufferManager.GetReadableBuffer();
781  BOOST_CHECK(outputReadableBuffer != nullptr);
782 
783  // Get readable buffer for input workload
784  auto inputReadableBuffer = bufferManager.GetReadableBuffer();
785  BOOST_CHECK(inputReadableBuffer != nullptr);
786 
787  // Validate input workload data
788  size = inputReadableBuffer->GetSize();
789  BOOST_CHECK(size == 204);
790 
791  readableData = inputReadableBuffer->GetReadableData();
792  BOOST_CHECK(readableData != nullptr);
793 
794  offset = 0;
795 
796  // Verify Header
797  VerifyTimelineHeaderBinary(readableData, offset, 196);
798 
799  // Input workload
800  // Input workload entity
801  VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
802 
803  // Entity - Type relationship
805  EmptyOptional(),
806  EmptyOptional(),
807  EmptyOptional(),
808  readableData,
809  offset);
810 
811  // Type label relationship
813  EmptyOptional(),
814  EmptyOptional(),
816  readableData,
817  offset);
818 
819  // BackendId entity
820  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset);
821 
822  // Entity - BackendId relationship
824  EmptyOptional(),
825  EmptyOptional(),
826  EmptyOptional(),
827  readableData,
828  offset);
829 
830  // BackendId label relationship
832  EmptyOptional(),
833  EmptyOptional(),
835  readableData,
836  offset);
837 
838  // Input layer - Input workload relationship
840  EmptyOptional(),
841  input->GetGuid(),
842  EmptyOptional(),
843  readableData,
844  offset);
845 
846  bufferManager.MarkRead(inputReadableBuffer);
847 
848  // Validate output workload data
849  size = outputReadableBuffer->GetSize();
850  BOOST_CHECK(size == 204);
851 
852  readableData = outputReadableBuffer->GetReadableData();
853  BOOST_CHECK(readableData != nullptr);
854 
855  offset = 0;
856 
857  // Verify Header
858  VerifyTimelineHeaderBinary(readableData, offset, 196);
859 
860  // Output workload
861  // Output workload entity
862  VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
863 
864  // Entity - Type relationship
866  EmptyOptional(),
867  EmptyOptional(),
868  EmptyOptional(),
869  readableData,
870  offset);
871 
872  // Type label relationship
874  EmptyOptional(),
875  EmptyOptional(),
877  readableData,
878  offset);
879 
880  // BackendId entity
881  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset);
882 
883  // Entity - BackendId relationship
885  EmptyOptional(),
886  EmptyOptional(),
887  EmptyOptional(),
888  readableData,
889  offset);
890 
891  // BackendId label relationship
893  EmptyOptional(),
894  EmptyOptional(),
896  readableData,
897  offset);
898 
899  // Output layer - Output workload relationship
901  EmptyOptional(),
902  output->GetGuid(),
903  EmptyOptional(),
904  readableData,
905  offset);
906 
907  bufferManager.MarkRead(outputReadableBuffer);
908 
909  // Validate inference data
910  size = inferenceReadableBuffer->GetSize();
911  BOOST_CHECK(size == 1596);
912 
913  readableData = inferenceReadableBuffer->GetReadableData();
914  BOOST_CHECK(readableData != nullptr);
915 
916  offset = 0;
917 
918  // Verify Header
919  VerifyTimelineHeaderBinary(readableData, offset, 1588);
920 
921  // Inference timeline trace
922  // Inference entity
923  VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
924 
925  // Entity - Type relationship
927  EmptyOptional(),
928  EmptyOptional(),
930  readableData,
931  offset);
932 
933  // Type label relationship
935  EmptyOptional(),
936  EmptyOptional(),
938  readableData,
939  offset);
940 
941  // Network - Inference relationship
943  EmptyOptional(),
944  optNetGuid,
945  EmptyOptional(),
946  readableData,
947  offset);
948 
949  // Start Inference life
950  // Event packet - timeline, threadId, eventGuid
952 
953  // Inference - event relationship
955  EmptyOptional(),
956  EmptyOptional(),
957  EmptyOptional(),
958  readableData,
959  offset);
960 
961  // Event - event class relationship
963  EmptyOptional(),
964  EmptyOptional(),
966  readableData,
967  offset);
968 
969  // Execution
970  // Input workload execution
971  // Input workload execution entity
972  VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
973 
974  // Entity - Type relationship
976  EmptyOptional(),
977  EmptyOptional(),
979  readableData,
980  offset);
981 
982  // Type label relationship
984  EmptyOptional(),
985  EmptyOptional(),
987  readableData,
988  offset);
989 
990  // Inference - Workload execution relationship
992  EmptyOptional(),
993  EmptyOptional(),
994  EmptyOptional(),
995  readableData,
996  offset);
997 
998  // Workload - Workload execution relationship
1000  EmptyOptional(),
1001  EmptyOptional(),
1002  EmptyOptional(),
1003  readableData,
1004  offset);
1005 
1006  // Start Input workload execution life
1007  // Event packet - timeline, threadId, eventGuid
1009 
1010  // Input workload execution - event relationship
1012  EmptyOptional(),
1013  EmptyOptional(),
1014  EmptyOptional(),
1015  readableData,
1016  offset);
1017 
1018  // Event - event class relationship
1020  EmptyOptional(),
1021  EmptyOptional(),
1023  readableData,
1024  offset);
1025 
1026  // End of Input workload execution life
1027  // Event packet - timeline, threadId, eventGuid
1029 
1030  // Input workload execution - event relationship
1032  EmptyOptional(),
1033  EmptyOptional(),
1034  EmptyOptional(),
1035  readableData,
1036  offset);
1037 
1038  // Event - event class relationship
1040  EmptyOptional(),
1041  EmptyOptional(),
1043  readableData,
1044  offset);
1045 
1046  // Conv2d workload execution
1047  // Conv2d workload execution entity
1048  VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
1049 
1050  // Entity - Type relationship
1052  EmptyOptional(),
1053  EmptyOptional(),
1055  readableData,
1056  offset);
1057 
1058  // Type label relationship
1060  EmptyOptional(),
1061  EmptyOptional(),
1063  readableData,
1064  offset);
1065 
1066  // Inference - Workload execution relationship
1068  EmptyOptional(),
1069  EmptyOptional(),
1070  EmptyOptional(),
1071  readableData,
1072  offset);
1073 
1074  // Workload - Workload execution relationship
1076  EmptyOptional(),
1077  EmptyOptional(),
1078  EmptyOptional(),
1079  readableData,
1080  offset);
1081 
1082  // Start Conv2d workload execution life
1083  // Event packet - timeline, threadId, eventGuid
1085 
1086  // Conv2d workload execution - event relationship
1088  EmptyOptional(),
1089  EmptyOptional(),
1090  EmptyOptional(),
1091  readableData,
1092  offset);
1093 
1094  // Event - event class relationship
1096  EmptyOptional(),
1097  EmptyOptional(),
1099  readableData,
1100  offset);
1101 
1102  // End of Conv2d workload execution life
1103  // Event packet - timeline, threadId, eventGuid
1105 
1106  // Conv2d workload execution - event relationship
1108  EmptyOptional(),
1109  EmptyOptional(),
1110  EmptyOptional(),
1111  readableData,
1112  offset);
1113 
1114  // Event - event class relationship
1116  EmptyOptional(),
1117  EmptyOptional(),
1119  readableData,
1120  offset);
1121 
1122  // Activation workload execution
1123  // Activation workload execution entity
1124  VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
1125 
1126  // Entity - Type relationship
1128  EmptyOptional(),
1129  EmptyOptional(),
1131  readableData,
1132  offset);
1133 
1134  // Type label relationship
1136  EmptyOptional(),
1137  EmptyOptional(),
1139  readableData,
1140  offset);
1141 
1142  // Inference - Workload execution relationship
1144  EmptyOptional(),
1145  EmptyOptional(),
1146  EmptyOptional(),
1147  readableData,
1148  offset);
1149 
1150  // Workload - Workload execution relationship
1152  EmptyOptional(),
1153  EmptyOptional(),
1154  EmptyOptional(),
1155  readableData,
1156  offset);
1157 
1158  // Start Activation workload execution life
1159  // Event packet - timeline, threadId, eventGuid
1161 
1162  // Activation workload execution - event relationship
1164  EmptyOptional(),
1165  EmptyOptional(),
1166  EmptyOptional(),
1167  readableData,
1168  offset);
1169 
1170  // Event - event class relationship
1172  EmptyOptional(),
1173  EmptyOptional(),
1175  readableData,
1176  offset);
1177 
1178  // End of Activation workload execution life
1179  // Event packet - timeline, threadId, eventGuid
1181 
1182  // Activation workload execution - event relationship
1184  EmptyOptional(),
1185  EmptyOptional(),
1186  EmptyOptional(),
1187  readableData,
1188  offset);
1189 
1190  // Event - event class relationship
1192  EmptyOptional(),
1193  EmptyOptional(),
1195  readableData,
1196  offset);
1197 
1198  // Output workload execution
1199  // Output workload execution entity
1200  VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
1201 
1202  // Entity - Type relationship
1204  EmptyOptional(),
1205  EmptyOptional(),
1207  readableData,
1208  offset);
1209 
1210  // Type label relationship
1212  EmptyOptional(),
1213  EmptyOptional(),
1215  readableData,
1216  offset);
1217 
1218  // Inference - Workload execution relationship
1220  EmptyOptional(),
1221  EmptyOptional(),
1222  EmptyOptional(),
1223  readableData,
1224  offset);
1225 
1226  // Workload - Workload execution relationship
1228  EmptyOptional(),
1229  EmptyOptional(),
1230  EmptyOptional(),
1231  readableData,
1232  offset);
1233 
1234  // Start Output workload execution life
1235  // Event packet - timeline, threadId, eventGuid
1237 
1238  // Output workload execution - event relationship
1240  EmptyOptional(),
1241  EmptyOptional(),
1242  EmptyOptional(),
1243  readableData,
1244  offset);
1245 
1246  // Event - event class relationship
1248  EmptyOptional(),
1249  EmptyOptional(),
1251  readableData,
1252  offset);
1253 
1254  // End of Normalize workload execution life
1255  // Event packet - timeline, threadId, eventGuid
1257 
1258  // Output workload execution - event relationship
1260  EmptyOptional(),
1261  EmptyOptional(),
1262  EmptyOptional(),
1263  readableData,
1264  offset);
1265 
1266  // Event - event class relationship
1268  EmptyOptional(),
1269  EmptyOptional(),
1271  readableData,
1272  offset);
1273 
1274  // End of Inference life
1275  // Event packet - timeline, threadId, eventGuid
1277 
1278  // Inference - event relationship
1280  EmptyOptional(),
1281  EmptyOptional(),
1282  EmptyOptional(),
1283  readableData,
1284  offset);
1285 
1286  // Event - event class relationship
1288  EmptyOptional(),
1289  EmptyOptional(),
1291  readableData,
1292  offset);
1293 
1294  bufferManager.MarkRead(inferenceReadableBuffer);
1295 }
static ARMNN_DLLEXPORT ProfilingStaticGuid INFERENCE_GUID
uint32_t m_PadBottom
Padding bottom value in the height dimension.
bool m_BiasEnabled
Enable/disable bias.
static IRuntimePtr Create(const CreationOptions &options)
Definition: Runtime.cpp:32
static ProfilingService & Instance()
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::unique_ptr< IRuntime, void(*)(IRuntime *runtime)> IRuntimePtr
Definition: IRuntime.hpp:24
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:19
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.
ProfilingService & profilingService
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:890
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:566
IPacketBufferPtr GetReadableBuffer() override
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)
void MarkRead(IPacketBufferPtr &packetBuffer) override
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:76
ProfilingState ConfigureProfilingService(const ExternalProfilingOptions &options, bool resetProfilingService=false)
static ARMNN_DLLEXPORT ProfilingStaticGuid BACKENDID_GUID
static INetworkPtr Create()
Definition: Network.cpp:49
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 201 of file ProfilingTestUtils.cpp.

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

204 {
205  BOOST_ASSERT(readableData);
206 
207  // Utils
208  unsigned int uint32_t_size = sizeof(uint32_t);
209  unsigned int uint64_t_size = sizeof(uint64_t);
210 
211  // Reading TimelineEntityClassBinaryPacket
212  // Check the decl_id
213  uint32_t entityDeclId = ReadUint32(readableData, offset);
214  BOOST_CHECK(entityDeclId == 1);
215 
216  // Check the profiling GUID
217  offset += uint32_t_size;
218  uint64_t readProfilingGuid = ReadUint64(readableData, offset);
219 
220  if (guid.has_value())
221  {
222  BOOST_CHECK(readProfilingGuid == guid.value());
223  }
224  else
225  {
226  BOOST_CHECK(readProfilingGuid != ProfilingGuid(0));
227  }
228 
229  offset += uint64_t_size;
230 }
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
bool has_value() const noexcept
Definition: Optional.hpp:53
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 232 of file ProfilingTestUtils.cpp.

References BOOST_CHECK(), OptionalBase::has_value(), armnn::profiling::ReadBytes(), 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().

237 {
238  BOOST_ASSERT(readableData);
239 
240  // Utils
241  unsigned int uint32_t_size = sizeof(uint32_t);
242  unsigned int uint64_t_size = sizeof(uint64_t);
243  unsigned int threadId_size = sizeof(std::thread::id);
244 
245  // Reading TimelineEventBinaryPacket
246  // Check the decl_id
247  uint32_t entityDeclId = ReadUint32(readableData, offset);
248  BOOST_CHECK(entityDeclId == 4);
249 
250  // Check the timestamp
251  offset += uint32_t_size;
252  uint64_t readTimestamp = ReadUint64(readableData, offset);
253  if (timestamp.has_value())
254  {
255  BOOST_CHECK(readTimestamp == timestamp.value());
256  }
257  else
258  {
259  BOOST_CHECK(readTimestamp != 0);
260  }
261 
262  // Check the thread id
263  offset += uint64_t_size;
264  std::vector<uint8_t> readThreadId(threadId_size, 0);
265  ReadBytes(readableData, offset, threadId_size, readThreadId.data());
266  if (threadId.has_value())
267  {
268  BOOST_CHECK(readThreadId == threadId.value());
269  }
270  else
271  {
272  BOOST_CHECK(readThreadId == std::this_thread::get_id());
273  }
274 
275  // Check the event GUID
276  offset += threadId_size;
277  uint64_t readEventGuid = ReadUint64(readableData, offset);
278  if (eventGuid.has_value())
279  {
280  BOOST_CHECK(readEventGuid == eventGuid.value());
281  }
282  else
283  {
284  BOOST_CHECK(readEventGuid != ProfilingGuid(0));
285  }
286 
287  offset += uint64_t_size;
288 }
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
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)

◆ VerifyTimelineEventClassBinaryPacketData()

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

Definition at line 97 of file ProfilingTestUtils.cpp.

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

Referenced by BOOST_AUTO_TEST_CASE().

100 {
101  BOOST_ASSERT(readableData);
102 
103  // Utils
104  unsigned int uint32_t_size = sizeof(uint32_t);
105  unsigned int uint64_t_size = sizeof(uint64_t);
106 
107  // Check the decl id
108  uint32_t eventClassDeclId = ReadUint32(readableData, offset);
109  BOOST_CHECK(eventClassDeclId == 2);
110 
111  // Check the profiling GUID
112  offset += uint32_t_size;
113  uint64_t readProfilingGuid = ReadUint64(readableData, offset);
114  BOOST_CHECK(readProfilingGuid == guid);
115 
116  // Update the offset to allow parsing to be continued after this function returns
117  offset += uint64_t_size;
118 }
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
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 28 of file ProfilingTestUtils.cpp.

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

Referenced by BOOST_AUTO_TEST_CASE(), and VerifyPostOptimisationStructureTestImpl().

31 {
32  BOOST_ASSERT(readableData);
33 
34  // Utils
35  unsigned int uint32_t_size = sizeof(uint32_t);
36 
37  // Check the TimelineEventClassBinaryPacket header
38  uint32_t entityBinaryPacketHeaderWord0 = ReadUint32(readableData, offset);
39  uint32_t entityBinaryPacketFamily = (entityBinaryPacketHeaderWord0 >> 26) & 0x0000003F;
40  uint32_t entityBinaryPacketClass = (entityBinaryPacketHeaderWord0 >> 19) & 0x0000007F;
41  uint32_t entityBinaryPacketType = (entityBinaryPacketHeaderWord0 >> 16) & 0x00000007;
42  uint32_t entityBinaryPacketStreamId = (entityBinaryPacketHeaderWord0 >> 0) & 0x00000007;
43  BOOST_CHECK(entityBinaryPacketFamily == 1);
44  BOOST_CHECK(entityBinaryPacketClass == 0);
45  BOOST_CHECK(entityBinaryPacketType == 1);
46  BOOST_CHECK(entityBinaryPacketStreamId == 0);
47  offset += uint32_t_size;
48  uint32_t entityBinaryPacketHeaderWord1 = ReadUint32(readableData, offset);
49  uint32_t eventBinaryPacketSequenceNumber = (entityBinaryPacketHeaderWord1 >> 24) & 0x00000001;
50  uint32_t eventBinaryPacketDataLength = (entityBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF;
51  BOOST_CHECK(eventBinaryPacketSequenceNumber == 0);
52  BOOST_CHECK(eventBinaryPacketDataLength == packetDataLength);
53  offset += uint32_t_size;
54 }
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
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 56 of file ProfilingTestUtils.cpp.

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

60 {
61  BOOST_ASSERT(readableData);
62 
63  // Utils
64  unsigned int uint32_t_size = sizeof(uint32_t);
65  unsigned int uint64_t_size = sizeof(uint64_t);
66  unsigned int label_size = boost::numeric_cast<unsigned int>(label.size());
67 
68  // Check the decl id
69  uint32_t eventClassDeclId = ReadUint32(readableData, offset);
70  BOOST_CHECK(eventClassDeclId == 0);
71 
72  // Check the profiling GUID
73  offset += uint32_t_size;
74  uint64_t readProfilingGuid = ReadUint64(readableData, offset);
75  if (guid.has_value())
76  {
77  BOOST_CHECK(readProfilingGuid == guid.value());
78  }
79  else
80  {
81  BOOST_CHECK(readProfilingGuid == ProfilingService::Instance().GenerateStaticId(label));
82  }
83 
84  // Check the SWTrace label
85  offset += uint64_t_size;
86  uint32_t swTraceLabelLength = ReadUint32(readableData, offset);
87  BOOST_CHECK(swTraceLabelLength == label_size + 1); // Label length including the null-terminator
88  offset += uint32_t_size;
89  BOOST_CHECK(std::memcmp(readableData + offset, // Offset to the label in the buffer
90  label.data(), // The original label
91  swTraceLabelLength - 1) == 0); // The length of the label
92 
93  // SWTrace strings are written in blocks of words, so the offset has to be updated to the next whole word
94  offset += OffsetToNextWord(swTraceLabelLength);
95 }
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
unsigned int OffsetToNextWord(unsigned int numberOfBytes)
bool has_value() const noexcept
Definition: Optional.hpp:53
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,
const unsigned char *  readableData,
unsigned int &  offset 
)

Definition at line 120 of file ProfilingTestUtils.cpp.

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

126 {
127  BOOST_ASSERT(readableData);
128 
129  uint32_t relationshipTypeUint = 0;
130  switch (relationshipType)
131  {
132  case ProfilingRelationshipType::RetentionLink:
133  relationshipTypeUint = 0;
134  break;
135  case ProfilingRelationshipType::ExecutionLink:
136  relationshipTypeUint = 1;
137  break;
138  case ProfilingRelationshipType::DataLink:
139  relationshipTypeUint = 2;
140  break;
141  case ProfilingRelationshipType::LabelLink:
142  relationshipTypeUint = 3;
143  break;
144  default:
145  BOOST_ERROR("Unknown relationship type");
146  }
147 
148  // Utils
149  unsigned int uint32_t_size = sizeof(uint32_t);
150  unsigned int uint64_t_size = sizeof(uint64_t);
151 
152  // Check the decl id
153  uint32_t eventClassDeclId = ReadUint32(readableData, offset);
154  BOOST_CHECK(eventClassDeclId == 3);
155 
156  // Check the relationship type
157  offset += uint32_t_size;
158  uint32_t readRelationshipTypeUint = ReadUint32(readableData, offset);
159  BOOST_CHECK(readRelationshipTypeUint == relationshipTypeUint);
160 
161  // Check the relationship GUID
162  offset += uint32_t_size;
163  uint64_t readRelationshipGuid = ReadUint64(readableData, offset);
164  if (relationshipGuid.has_value())
165  {
166  BOOST_CHECK(readRelationshipGuid == relationshipGuid.value());
167  }
168  else
169  {
170  BOOST_CHECK(readRelationshipGuid != ProfilingGuid(0));
171  }
172 
173  // Check the head of relationship GUID
174  offset += uint64_t_size;
175  uint64_t readHeadRelationshipGuid = ReadUint64(readableData, offset);
176  if (headGuid.has_value())
177  {
178  BOOST_CHECK(readHeadRelationshipGuid == headGuid.value());
179  }
180  else
181  {
182  BOOST_CHECK(readHeadRelationshipGuid != ProfilingGuid(0));
183  }
184 
185  // Check the tail of relationship GUID
186  offset += uint64_t_size;
187  uint64_t readTailRelationshipGuid = ReadUint64(readableData, offset);
188  if (tailGuid.has_value())
189  {
190  BOOST_CHECK(readTailRelationshipGuid == tailGuid.value());
191  }
192  else
193  {
194  BOOST_CHECK(readTailRelationshipGuid != ProfilingGuid(0));
195  }
196 
197  // Update the offset to allow parsing to be continued after this function returns
198  offset += uint64_t_size;
199 }
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
bool has_value() const noexcept
Definition: Optional.hpp:53
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)