17 #include <common/include/LabelsAndEventClasses.hpp> 21 #include <doctest/doctest.h> 25 uint32_t sizeUint32 =
sizeof(uint32_t);
26 uint32_t payloadSize = 0;
33 payloadSize += 13 * 2 * sizeUint32;
35 payloadSize += sizeUint32;
37 uint32_t headerSize = 2 * sizeUint32;
38 uint32_t bodySize = 10 * sizeUint32;
40 return headerSize + bodySize + payloadSize;
45 std::vector<BackendId> suitableBackends;
58 return suitableBackends;
71 return numberOfBytes + uint32_t_size - remainder;
76 uint32_t packetDataLength)
84 uint32_t timelineBinaryPacketHeaderWord0 =
ReadUint32(readableData, offset);
85 uint32_t timelineBinaryPacketFamily = (timelineBinaryPacketHeaderWord0 >> 26) & 0x0000003F;
86 uint32_t timelineBinaryPacketClass = (timelineBinaryPacketHeaderWord0 >> 19) & 0x0000007F;
87 uint32_t timelineBinaryPacketType = (timelineBinaryPacketHeaderWord0 >> 16) & 0x00000007;
88 uint32_t timelineBinaryPacketStreamId = (timelineBinaryPacketHeaderWord0 >> 0) & 0x00000007;
89 CHECK(timelineBinaryPacketFamily == 1);
90 CHECK(timelineBinaryPacketClass == 0);
91 CHECK(timelineBinaryPacketType == 1);
92 CHECK(timelineBinaryPacketStreamId == 0);
94 uint32_t timelineBinaryPacketHeaderWord1 =
ReadUint32(readableData, offset);
95 uint32_t timelineBinaryPacketSequenceNumber = (timelineBinaryPacketHeaderWord1 >> 24) & 0x00000001;
96 uint32_t timelineBinaryPacketDataLength = (timelineBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF;
97 CHECK(timelineBinaryPacketSequenceNumber == 0);
98 CHECK(timelineBinaryPacketDataLength == packetDataLength);
103 const std::string& label,
104 const unsigned char* readableData,
105 unsigned int& offset)
111 unsigned int uint64_t_size =
sizeof(uint64_t);
115 uint32_t eventClassDeclId =
ReadUint32(readableData, offset);
116 CHECK(eventClassDeclId == 0);
120 uint64_t readProfilingGuid =
ReadUint64(readableData, offset);
123 CHECK(readProfilingGuid == guid.
value());
128 CHECK(readProfilingGuid == profilingService.
GetStaticId(label));
132 offset += uint64_t_size;
133 uint32_t swTraceLabelLength =
ReadUint32(readableData, offset);
134 CHECK(swTraceLabelLength == label_size + 1);
136 CHECK(std::memcmp(readableData + offset,
138 swTraceLabelLength - 1) == 0);
143 ProfilingGuid labelGuid(readProfilingGuid);
148 ProfilingGuid nameGuid,
149 const unsigned char* readableData,
150 unsigned int& offset)
156 unsigned int uint64_t_size =
sizeof(uint64_t);
159 uint32_t eventClassDeclId =
ReadUint32(readableData, offset);
160 CHECK(eventClassDeclId == 2);
164 uint64_t readProfilingGuid =
ReadUint64(readableData, offset);
165 CHECK(readProfilingGuid == guid);
167 offset += uint64_t_size;
168 uint64_t readProfiilngNameGuid =
ReadUint64(readableData, offset);
169 CHECK(readProfiilngNameGuid == nameGuid);
172 offset += uint64_t_size;
180 const unsigned char* readableData,
181 unsigned int& offset)
185 uint32_t relationshipTypeUint = 0;
186 switch (relationshipType)
188 case ProfilingRelationshipType::RetentionLink:
189 relationshipTypeUint = 0;
191 case ProfilingRelationshipType::ExecutionLink:
192 relationshipTypeUint = 1;
194 case ProfilingRelationshipType::DataLink:
195 relationshipTypeUint = 2;
197 case ProfilingRelationshipType::LabelLink:
198 relationshipTypeUint = 3;
201 FAIL(
"Unknown relationship type");
206 unsigned int uint64_t_size =
sizeof(uint64_t);
209 uint32_t eventClassDeclId =
ReadUint32(readableData, offset);
210 CHECK(eventClassDeclId == 3);
214 uint32_t readRelationshipTypeUint =
ReadUint32(readableData, offset);
215 CHECK(readRelationshipTypeUint == relationshipTypeUint);
219 uint64_t readRelationshipGuid =
ReadUint64(readableData, offset);
222 CHECK(readRelationshipGuid == relationshipGuid.
value());
226 CHECK(readRelationshipGuid != ProfilingGuid(0));
230 offset += uint64_t_size;
231 uint64_t readHeadRelationshipGuid =
ReadUint64(readableData, offset);
234 CHECK(readHeadRelationshipGuid == headGuid.
value());
238 CHECK(readHeadRelationshipGuid != ProfilingGuid(0));
242 offset += uint64_t_size;
243 uint64_t readTailRelationshipGuid =
ReadUint64(readableData, offset);
246 CHECK(readTailRelationshipGuid == tailGuid.
value());
250 CHECK(readTailRelationshipGuid != ProfilingGuid(0));
254 offset += uint64_t_size;
255 uint64_t readAttributeRelationshipGuid =
ReadUint64(readableData, offset);
258 CHECK(readAttributeRelationshipGuid == attributeGuid.
value());
262 CHECK(readAttributeRelationshipGuid == ProfilingGuid(0));
266 offset += uint64_t_size;
270 const unsigned char* readableData,
271 unsigned int& offset)
277 unsigned int uint64_t_size =
sizeof(uint64_t);
281 uint32_t entityDeclId =
ReadUint32(readableData, offset);
282 CHECK(entityDeclId == 1);
286 uint64_t readProfilingGuid =
ReadUint64(readableData, offset);
290 CHECK(readProfilingGuid == guid.
value());
294 CHECK(readProfilingGuid != ProfilingGuid(0));
297 offset += uint64_t_size;
299 ProfilingGuid entityGuid(readProfilingGuid);
306 const unsigned char* readableData,
307 unsigned int& offset)
313 unsigned int uint64_t_size =
sizeof(uint64_t);
317 uint32_t entityDeclId =
ReadUint32(readableData, offset);
318 CHECK(entityDeclId == 4);
322 uint64_t readTimestamp =
ReadUint64(readableData, offset);
325 CHECK(readTimestamp == timestamp.
value());
329 CHECK(readTimestamp != 0);
333 offset += uint64_t_size;
338 CHECK(readThreadId == threadId.
value());
347 uint64_t readEventGuid =
ReadUint64(readableData, offset);
350 CHECK(readEventGuid == eventGuid.
value());
354 CHECK(readEventGuid != ProfilingGuid(0));
357 offset += uint64_t_size;
359 ProfilingGuid eventid(readEventGuid);
365 using namespace armnn;
387 std::vector<float> weightsData{
400 std::vector<float> biasesData{ 1.0f, 0.0f, 0.0f };
416 IConnectableLayer* conv2d = net->AddConvolution2dLayer(conv2dDesc, weights, optionalBiases);
425 input->GetOutputSlot(0).Connect(conv2d->
GetInputSlot(0));
429 input->GetOutputSlot(0).SetTensorInfo(inputInfo);
434 std::vector<armnn::BackendId> backends = { backendId };
437 ProfilingGuid optNetGuid = optNet->GetGuid();
447 CHECK(readableBuffer !=
nullptr);
448 unsigned int size = readableBuffer->GetSize();
450 const unsigned char* readableData = readableBuffer->GetReadableData();
451 CHECK(readableData !=
nullptr);
453 unsigned int offset = 0;
466 LabelsAndEventClasses::NETWORK_GUID,
467 LabelsAndEventClasses::TYPE_GUID,
483 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
489 std::stringstream ss;
491 std::string processIdLabel = ss.str();
499 LabelsAndEventClasses::PROCESS_ID_GUID,
515 LabelsAndEventClasses::NAME_GUID,
523 LabelsAndEventClasses::LAYER_GUID,
524 LabelsAndEventClasses::TYPE_GUID,
533 LabelsAndEventClasses::CHILD_GUID,
550 LabelsAndEventClasses::NAME_GUID,
558 LabelsAndEventClasses::LAYER_GUID,
559 LabelsAndEventClasses::TYPE_GUID,
568 LabelsAndEventClasses::CHILD_GUID,
577 LabelsAndEventClasses::CONNECTION_GUID,
589 LabelsAndEventClasses::WORKLOAD_GUID,
590 LabelsAndEventClasses::TYPE_GUID,
603 LabelsAndEventClasses::BACKENDID_GUID,
613 LabelsAndEventClasses::CHILD_GUID,
630 LabelsAndEventClasses::NAME_GUID,
638 LabelsAndEventClasses::LAYER_GUID,
639 LabelsAndEventClasses::TYPE_GUID,
648 LabelsAndEventClasses::CHILD_GUID,
657 LabelsAndEventClasses::CONNECTION_GUID,
669 LabelsAndEventClasses::WORKLOAD_GUID,
670 LabelsAndEventClasses::TYPE_GUID,
682 LabelsAndEventClasses::BACKENDID_GUID,
691 LabelsAndEventClasses::CHILD_GUID,
708 LabelsAndEventClasses::NAME_GUID,
716 LabelsAndEventClasses::LAYER_GUID,
717 LabelsAndEventClasses::TYPE_GUID,
726 LabelsAndEventClasses::CHILD_GUID,
735 LabelsAndEventClasses::CONNECTION_GUID,
739 bufferManager.MarkRead(readableBuffer);
742 std::vector<float> inputData(inputInfo.GetNumElements());
743 std::vector<float> outputData(outputInfo.GetNumElements());
758 auto inputReadableBuffer = bufferManager.GetReadableBuffer();
759 CHECK(inputReadableBuffer !=
nullptr);
762 auto outputReadableBuffer = bufferManager.GetReadableBuffer();
763 CHECK(outputReadableBuffer !=
nullptr);
766 auto inferenceReadableBuffer = bufferManager.GetReadableBuffer();
767 CHECK(inferenceReadableBuffer !=
nullptr);
770 size = inputReadableBuffer->GetSize();
773 readableData = inputReadableBuffer->GetReadableData();
774 CHECK(readableData !=
nullptr);
789 LabelsAndEventClasses::WORKLOAD_GUID,
790 LabelsAndEventClasses::TYPE_GUID,
802 LabelsAndEventClasses::BACKENDID_GUID,
811 LabelsAndEventClasses::CHILD_GUID,
815 bufferManager.MarkRead(inputReadableBuffer);
818 size = outputReadableBuffer->GetSize();
821 readableData = outputReadableBuffer->GetReadableData();
822 CHECK(readableData !=
nullptr);
837 LabelsAndEventClasses::WORKLOAD_GUID,
838 LabelsAndEventClasses::TYPE_GUID,
850 LabelsAndEventClasses::BACKENDID_GUID,
859 LabelsAndEventClasses::CHILD_GUID,
863 bufferManager.MarkRead(outputReadableBuffer);
866 size = inferenceReadableBuffer->GetSize();
870 readableData = inferenceReadableBuffer->GetReadableData();
871 CHECK(readableData !=
nullptr);
886 LabelsAndEventClasses::INFERENCE_GUID,
887 LabelsAndEventClasses::TYPE_GUID,
896 LabelsAndEventClasses::EXECUTION_OF_GUID,
910 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
923 inputWorkloadExecutionGuid,
924 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
925 LabelsAndEventClasses::TYPE_GUID,
933 inputWorkloadExecutionGuid,
934 LabelsAndEventClasses::CHILD_GUID,
942 inputWorkloadExecutionGuid,
943 LabelsAndEventClasses::EXECUTION_OF_GUID,
955 inputWorkloadExecutionGuid,
956 inputWorkloadExecutionSOLEventId,
957 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
969 inputWorkloadExecutionGuid,
970 inputWorkloadExecutionEOLEventId,
971 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
983 conv2DWorkloadExecutionGuid,
984 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
985 LabelsAndEventClasses::TYPE_GUID,
993 conv2DWorkloadExecutionGuid,
994 LabelsAndEventClasses::CHILD_GUID,
1002 conv2DWorkloadExecutionGuid,
1003 LabelsAndEventClasses::EXECUTION_OF_GUID,
1015 conv2DWorkloadExecutionGuid,
1016 conv2DWorkloadExecutionSOLEventGuid,
1017 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1029 conv2DWorkloadExecutionGuid,
1030 conv2DWorkloadExecutionEOLEventGuid,
1031 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1043 absWorkloadExecutionGuid,
1044 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
1045 LabelsAndEventClasses::TYPE_GUID,
1053 absWorkloadExecutionGuid,
1054 LabelsAndEventClasses::CHILD_GUID,
1062 absWorkloadExecutionGuid,
1063 LabelsAndEventClasses::EXECUTION_OF_GUID,
1075 absWorkloadExecutionGuid,
1076 absWorkloadExecutionSOLEventGuid,
1077 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1089 absWorkloadExecutionGuid,
1090 absWorkloadExecutionEOLEventGuid,
1091 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1103 outputWorkloadExecutionGuid,
1104 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
1105 LabelsAndEventClasses::TYPE_GUID,
1113 outputWorkloadExecutionGuid,
1114 LabelsAndEventClasses::CHILD_GUID,
1122 outputWorkloadExecutionGuid,
1123 LabelsAndEventClasses::EXECUTION_OF_GUID,
1135 outputWorkloadExecutionGuid,
1136 outputWorkloadExecutionSOLEventGuid,
1137 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1149 outputWorkloadExecutionGuid,
1150 outputWorkloadExecutionEOLEventGuid,
1151 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1164 inferenceEOLEventGuid,
1165 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1169 bufferManager.MarkRead(inferenceReadableBuffer);
1172 bool CompareOutput(std::vector<std::string> output, std::vector<std::string> expectedOutput)
1174 if (output.size() != expectedOutput.size())
1176 std::cerr <<
"output has [" << output.size() <<
"] lines, expected was [" 1177 << expectedOutput.size() <<
"] lines" << std::endl;
1178 std::cerr << std::endl <<
"actual" << std::endl << std::endl;
1179 for (
auto line : output)
1181 std::cerr << line << std::endl;
1183 std::cerr << std::endl <<
"expected" << std::endl << std::endl;
1184 for (
auto line : expectedOutput)
1186 std::cerr << line << std::endl;
1191 for (
unsigned long i = 0; i < output.size(); ++i)
1193 if (output[i] != expectedOutput[i])
1196 std::cerr << i <<
": actual [" << output[i] <<
"] expected [" << expectedOutput[i] <<
"]" << std::endl;
profiling::ProfilingService & GetProfilingService(armnn::RuntimeImpl *runtime)
uint32_t m_PadBottom
Padding bottom value in the height dimension.
bool m_BiasEnabled
Enable/disable bias.
TensorInfo GetInputTensorInfo(NetworkId networkId, LayerBindingId layerId) const
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
void VerifyTimelineEventClassBinaryPacketData(ProfilingGuid guid, ProfilingGuid nameGuid, const unsigned char *readableData, unsigned int &offset)
ProfilingGuid VerifyTimelineEntityBinaryPacketData(Optional< ProfilingGuid > guid, const unsigned char *readableData, unsigned int &offset)
void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId)
CPU Execution: Reference C++ kernels.
std::string GetHardwareVersion()
void ReadBytes(const IPacketBufferPtr &packetBuffer, unsigned int offset, unsigned int valueSize, uint8_t outValue[])
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
void ForceTransitionToState(ProfilingState newState)
A Convolution2dDescriptor for the Convolution2dLayer.
uint32_t GetStreamMetaDataPacketSize()
std::string GetProcessName()
BackendRegistry & BackendRegistryInstance()
Status LoadNetwork(NetworkId &networkIdOut, IOptimizedNetworkPtr network)
Loads a complete network into the Runtime.
std::vector< std::pair< LayerBindingId, class ConstTensor > > InputTensors
uint32_t m_PadRight
Padding right value in the width dimension.
TensorInfo GetOutputTensorInfo(NetworkId networkId, LayerBindingId layerId) const
Copyright (c) 2021 ARM Limited and Contributors.
Status EnqueueWorkload(NetworkId networkId, const InputTensors &inputTensors, const OutputTensors &outputTensors)
std::vector< BackendId > GetSuitableBackendRegistered()
Returns a vector of CpuRef, CpuAcc or GpuAcc backends if they where registered.
std::string GetSoftwareInfo()
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
unsigned int OffsetToNextWord(unsigned int numberOfBytes)
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 ProfilingStaticGuid GetStaticId(const std::string &str)
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.
void VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType relationshipType, Optional< ProfilingGuid > relationshipGuid, Optional< ProfilingGuid > headGuid, Optional< ProfilingGuid > tailGuid, Optional< ProfilingGuid > attributeGuid, const unsigned char *readableData, unsigned int &offset)
bool CompareOutput(std::vector< std::string > output, std::vector< std::string > expectedOutput)
bool has_value() const noexcept
const IDeviceSpec & GetDeviceSpec() const
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.
std::vector< std::pair< LayerBindingId, class Tensor > > OutputTensors
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
void ResetExternalProfilingOptions(const ExternalProfilingOptions &options, bool resetProfilingService=false)
ProfilingRelationshipType
#define ARMNN_ASSERT(COND)
constexpr char const * GetComputeDeviceAsCString(Compute compute)
Deprecated function that will be removed together with the Compute enum.
GPU Execution: OpenCL: ArmCompute.
IPacketBufferPtr GetReadableBuffer() override
constexpr unsigned int ThreadIdSize
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)
void VerifyTimelineHeaderBinary(const unsigned char *readableData, unsigned int &offset, uint32_t packetDataLength)
std::string GetSoftwareVersion()
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
A ElementwiseUnaryDescriptor for the ElementwiseUnaryLayer.
CPU Execution: NEON: ArmCompute.
const std::string & Get() const
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
BufferManager & GetProfilingBufferManager()
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
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)
ExternalProfilingOptions m_ProfilingOptions
static INetworkPtr Create(NetworkOptions networkOptions={})
uint32_t m_PadLeft
Padding left value in the width dimension.