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());
749 {0,
ConstTensor(inputTensorInfo, inputData.data())}
760 auto inputReadableBuffer = bufferManager.GetReadableBuffer();
761 CHECK(inputReadableBuffer !=
nullptr);
764 auto outputReadableBuffer = bufferManager.GetReadableBuffer();
765 CHECK(outputReadableBuffer !=
nullptr);
768 auto inferenceReadableBuffer = bufferManager.GetReadableBuffer();
769 CHECK(inferenceReadableBuffer !=
nullptr);
772 size = inputReadableBuffer->GetSize();
775 readableData = inputReadableBuffer->GetReadableData();
776 CHECK(readableData !=
nullptr);
791 LabelsAndEventClasses::WORKLOAD_GUID,
792 LabelsAndEventClasses::TYPE_GUID,
804 LabelsAndEventClasses::BACKENDID_GUID,
813 LabelsAndEventClasses::CHILD_GUID,
817 bufferManager.MarkRead(inputReadableBuffer);
820 size = outputReadableBuffer->GetSize();
823 readableData = outputReadableBuffer->GetReadableData();
824 CHECK(readableData !=
nullptr);
839 LabelsAndEventClasses::WORKLOAD_GUID,
840 LabelsAndEventClasses::TYPE_GUID,
852 LabelsAndEventClasses::BACKENDID_GUID,
861 LabelsAndEventClasses::CHILD_GUID,
865 bufferManager.MarkRead(outputReadableBuffer);
868 size = inferenceReadableBuffer->GetSize();
872 readableData = inferenceReadableBuffer->GetReadableData();
873 CHECK(readableData !=
nullptr);
888 LabelsAndEventClasses::INFERENCE_GUID,
889 LabelsAndEventClasses::TYPE_GUID,
898 LabelsAndEventClasses::EXECUTION_OF_GUID,
912 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
925 inputWorkloadExecutionGuid,
926 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
927 LabelsAndEventClasses::TYPE_GUID,
935 inputWorkloadExecutionGuid,
936 LabelsAndEventClasses::CHILD_GUID,
944 inputWorkloadExecutionGuid,
945 LabelsAndEventClasses::EXECUTION_OF_GUID,
957 inputWorkloadExecutionGuid,
958 inputWorkloadExecutionSOLEventId,
959 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
971 inputWorkloadExecutionGuid,
972 inputWorkloadExecutionEOLEventId,
973 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
985 conv2DWorkloadExecutionGuid,
986 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
987 LabelsAndEventClasses::TYPE_GUID,
995 conv2DWorkloadExecutionGuid,
996 LabelsAndEventClasses::CHILD_GUID,
1004 conv2DWorkloadExecutionGuid,
1005 LabelsAndEventClasses::EXECUTION_OF_GUID,
1017 conv2DWorkloadExecutionGuid,
1018 conv2DWorkloadExecutionSOLEventGuid,
1019 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1031 conv2DWorkloadExecutionGuid,
1032 conv2DWorkloadExecutionEOLEventGuid,
1033 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1045 absWorkloadExecutionGuid,
1046 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
1047 LabelsAndEventClasses::TYPE_GUID,
1055 absWorkloadExecutionGuid,
1056 LabelsAndEventClasses::CHILD_GUID,
1064 absWorkloadExecutionGuid,
1065 LabelsAndEventClasses::EXECUTION_OF_GUID,
1077 absWorkloadExecutionGuid,
1078 absWorkloadExecutionSOLEventGuid,
1079 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1091 absWorkloadExecutionGuid,
1092 absWorkloadExecutionEOLEventGuid,
1093 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1105 outputWorkloadExecutionGuid,
1106 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
1107 LabelsAndEventClasses::TYPE_GUID,
1115 outputWorkloadExecutionGuid,
1116 LabelsAndEventClasses::CHILD_GUID,
1124 outputWorkloadExecutionGuid,
1125 LabelsAndEventClasses::EXECUTION_OF_GUID,
1137 outputWorkloadExecutionGuid,
1138 outputWorkloadExecutionSOLEventGuid,
1139 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1151 outputWorkloadExecutionGuid,
1152 outputWorkloadExecutionEOLEventGuid,
1153 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1166 inferenceEOLEventGuid,
1167 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1171 bufferManager.MarkRead(inferenceReadableBuffer);
1174 bool CompareOutput(std::vector<std::string> output, std::vector<std::string> expectedOutput)
1176 if (output.size() != expectedOutput.size())
1178 std::cerr <<
"output has [" << output.size() <<
"] lines, expected was [" 1179 << expectedOutput.size() <<
"] lines" << std::endl;
1180 std::cerr << std::endl <<
"actual" << std::endl << std::endl;
1181 for (
auto line : output)
1183 std::cerr << line << std::endl;
1185 std::cerr << std::endl <<
"expected" << std::endl << std::endl;
1186 for (
auto line : expectedOutput)
1188 std::cerr << line << std::endl;
1193 for (
unsigned long i = 0; i < output.size(); ++i)
1195 if (output[i] != expectedOutput[i])
1198 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.
armnn::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.
armnn::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()
bool m_EnableProfiling
Indicates whether external profiling is enabled or not.
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.
void SetConstant(const bool IsConstant=true)
Marks the data corresponding to this tensor info as constant.
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
bool m_TimelineEnabled
Indicates whether external timeline profiling is enabled or not.
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.