13 #include <boost/test/unit_test.hpp> 25 return numberOfBytes + uint32_t_size - remainder;
29 const std::string& label,
30 const unsigned char* readableData,
33 BOOST_ASSERT(readableData);
37 unsigned int uint64_t_size =
sizeof(uint64_t);
38 unsigned int label_size = boost::numeric_cast<
unsigned int>(label.size());
41 uint32_t entityBinaryPacketHeaderWord0 =
ReadUint32(readableData, offset);
42 uint32_t entityBinaryPacketFamily = (entityBinaryPacketHeaderWord0 >> 26) & 0x0000003F;
43 uint32_t entityBinaryPacketClass = (entityBinaryPacketHeaderWord0 >> 19) & 0x0000007F;
44 uint32_t entityBinaryPacketType = (entityBinaryPacketHeaderWord0 >> 16) & 0x00000007;
45 uint32_t entityBinaryPacketStreamId = (entityBinaryPacketHeaderWord0 >> 0) & 0x00000007;
51 uint32_t entityBinaryPacketHeaderWord1 =
ReadUint32(readableData, offset);
52 uint32_t eventBinaryPacketSequenceNumber = (entityBinaryPacketHeaderWord1 >> 24) & 0x00000001;
53 uint32_t eventBinaryPacketDataLength = (entityBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF;
59 uint32_t eventClassDeclId =
ReadUint32(readableData, offset);
64 uint64_t readProfilingGuid =
ReadUint64(readableData, offset);
71 BOOST_CHECK(readProfilingGuid == ProfilingService::Instance().GenerateStaticId(label));
75 offset += uint64_t_size;
76 uint32_t swTraceLabelLength =
ReadUint32(readableData, offset);
81 swTraceLabelLength - 1) == 0);
82 BOOST_CHECK(readableData[offset + swTraceLabelLength] ==
'\0');
89 const unsigned char* readableData,
92 BOOST_ASSERT(readableData);
96 unsigned int uint64_t_size =
sizeof(uint64_t);
99 uint32_t entityBinaryPacketHeaderWord0 =
ReadUint32(readableData, offset);
100 uint32_t entityBinaryPacketFamily = (entityBinaryPacketHeaderWord0 >> 26) & 0x0000003F;
101 uint32_t entityBinaryPacketClass = (entityBinaryPacketHeaderWord0 >> 19) & 0x0000007F;
102 uint32_t entityBinaryPacketType = (entityBinaryPacketHeaderWord0 >> 16) & 0x00000007;
103 uint32_t entityBinaryPacketStreamId = (entityBinaryPacketHeaderWord0 >> 0) & 0x00000007;
109 uint32_t entityBinaryPacketHeaderWord1 =
ReadUint32(readableData, offset);
110 uint32_t eventBinaryPacketSequenceNumber = (entityBinaryPacketHeaderWord1 >> 24) & 0x00000001;
111 uint32_t eventBinaryPacketDataLength = (entityBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF;
117 uint32_t eventClassDeclId =
ReadUint32(readableData, offset);
122 uint64_t readProfilingGuid =
ReadUint64(readableData, offset);
126 offset += uint64_t_size;
133 const unsigned char* readableData,
134 unsigned int& offset)
136 BOOST_ASSERT(readableData);
138 uint32_t relationshipTypeUint = 0;
139 switch (relationshipType)
142 relationshipTypeUint = 0;
145 relationshipTypeUint = 1;
148 relationshipTypeUint = 2;
151 relationshipTypeUint = 3;
154 BOOST_ERROR(
"Unknown relationship type");
159 unsigned int uint64_t_size =
sizeof(uint64_t);
162 uint32_t entityBinaryPacketHeaderWord0 =
ReadUint32(readableData, offset);
163 uint32_t entityBinaryPacketFamily = (entityBinaryPacketHeaderWord0 >> 26) & 0x0000003F;
164 uint32_t entityBinaryPacketClass = (entityBinaryPacketHeaderWord0 >> 19) & 0x0000007F;
165 uint32_t entityBinaryPacketType = (entityBinaryPacketHeaderWord0 >> 16) & 0x00000007;
166 uint32_t entityBinaryPacketStreamId = (entityBinaryPacketHeaderWord0 >> 0) & 0x00000007;
172 uint32_t entityBinaryPacketHeaderWord1 =
ReadUint32(readableData, offset);
173 uint32_t eventBinaryPacketSequenceNumber = (entityBinaryPacketHeaderWord1 >> 24) & 0x00000001;
174 uint32_t eventBinaryPacketDataLength = (entityBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF;
180 uint32_t eventClassDeclId =
ReadUint32(readableData, offset);
185 uint32_t readRelationshipTypeUint =
ReadUint32(readableData, offset);
186 BOOST_CHECK(readRelationshipTypeUint == relationshipTypeUint);
190 uint64_t readRelationshipGuid =
ReadUint64(readableData, offset);
201 offset += uint64_t_size;
202 uint64_t readHeadRelationshipGuid =
ReadUint64(readableData, offset);
213 offset += uint64_t_size;
214 uint64_t readTailRelationshipGuid =
ReadUint64(readableData, offset);
225 offset += uint64_t_size;
229 const unsigned char* readableData,
230 unsigned int& offset)
232 BOOST_ASSERT(readableData);
236 unsigned int uint64_t_size =
sizeof(uint64_t);
239 uint32_t entityBinaryPacketHeaderWord0 =
ReadUint32(readableData, offset);
240 uint32_t entityBinaryPacketFamily = (entityBinaryPacketHeaderWord0 >> 26) & 0x0000003F;
241 uint32_t entityBinaryPacketClass = (entityBinaryPacketHeaderWord0 >> 19) & 0x0000007F;
242 uint32_t entityBinaryPacketType = (entityBinaryPacketHeaderWord0 >> 16) & 0x00000007;
243 uint32_t entityBinaryPacketStreamId = (entityBinaryPacketHeaderWord0 >> 0) & 0x00000007;
251 uint32_t entityBinaryPacketHeaderWord1 =
ReadUint32(readableData, offset);
252 uint32_t entityBinaryPacketSequenceNumbered = (entityBinaryPacketHeaderWord1 >> 24) & 0x00000001;
253 uint32_t entityBinaryPacketDataLength = (entityBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF;
254 BOOST_CHECK(entityBinaryPacketSequenceNumbered == 0);
259 uint32_t entityDeclId =
ReadUint32(readableData, offset);
264 uint64_t readProfilingGuid =
ReadUint64(readableData, offset);
275 offset += uint64_t_size;
281 const unsigned char* readableData,
282 unsigned int& offset)
284 BOOST_ASSERT(readableData);
288 unsigned int uint64_t_size =
sizeof(uint64_t);
289 unsigned int threadId_size =
sizeof(std::thread::id);
292 uint32_t entityBinaryPacketHeaderWord0 =
ReadUint32(readableData, offset);
293 uint32_t entityBinaryPacketFamily = (entityBinaryPacketHeaderWord0 >> 26) & 0x0000003F;
294 uint32_t entityBinaryPacketClass = (entityBinaryPacketHeaderWord0 >> 19) & 0x0000007F;
295 uint32_t entityBinaryPacketType = (entityBinaryPacketHeaderWord0 >> 16) & 0x00000007;
296 uint32_t entityBinaryPacketStreamId = (entityBinaryPacketHeaderWord0 >> 0) & 0x00000007;
304 uint32_t entityBinaryPacketHeaderWord1 =
ReadUint32(readableData, offset);
305 uint32_t entityBinaryPacketSequenceNumbered = (entityBinaryPacketHeaderWord1 >> 24) & 0x00000001;
306 uint32_t entityBinaryPacketDataLength = (entityBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF;
307 BOOST_CHECK(entityBinaryPacketSequenceNumbered == 0);
308 BOOST_CHECK(entityBinaryPacketDataLength == 20 + threadId_size);
312 uint32_t entityDeclId =
ReadUint32(readableData, offset);
317 uint64_t readTimestamp =
ReadUint64(readableData, offset);
328 offset += uint64_t_size;
329 std::vector<uint8_t> readThreadId(threadId_size, 0);
330 ReadBytes(readableData, offset, threadId_size, readThreadId.data());
337 BOOST_CHECK(readThreadId == std::this_thread::get_id());
341 offset += threadId_size;
342 uint64_t readEventGuid =
ReadUint64(readableData, offset);
352 offset += uint64_t_size;
357 using namespace armnn;
374 std::vector<float> weightsData{
387 std::vector<float> biasesData{ 1.0f, 0.0f, 0.0f };
403 IConnectableLayer* conv2d = net->AddConvolution2dLayer(conv2dDesc, weights, optionalBiases);
412 input->GetOutputSlot(0).Connect(conv2d->
GetInputSlot(0));
416 input->GetOutputSlot(0).SetTensorInfo(inputInfo);
421 std::vector<armnn::BackendId> backends = { backendId };
428 BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet)) ==
Status::Success);
437 unsigned int size = readableBuffer->GetSize();
440 const unsigned char* readableData = readableBuffer->GetReadableData();
443 unsigned int offset = 0;
819 bufferManager.
MarkRead(readableBuffer);
822 std::vector<float> inputData(inputInfo.GetNumElements());
823 std::vector<float> outputData(outputInfo.GetNumElements());
827 {0,
ConstTensor(runtime->GetInputTensorInfo(netId, 0), inputData.data())}
831 {0,
Tensor(runtime->GetOutputTensorInfo(netId, 0), outputData.data())}
835 runtime->EnqueueWorkload(netId, inputTensors, outputTensors);
850 size = inputReadableBuffer->GetSize();
853 readableData = inputReadableBuffer->GetReadableData();
905 bufferManager.
MarkRead(inputReadableBuffer);
908 size = outputReadableBuffer->GetSize();
911 readableData = outputReadableBuffer->GetReadableData();
963 bufferManager.
MarkRead(outputReadableBuffer);
966 size = inferenceReadableBuffer->GetSize();
969 readableData = inferenceReadableBuffer->GetReadableData();
1347 bufferManager.
MarkRead(inferenceReadableBuffer);
virtual LayerGuid GetGuid() const =0
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
Head retains(parents) Tail.
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
uint32_t m_PadRight
Padding right value in the width dimension.
ProfilingRelationshipType
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
static ARMNN_DLLEXPORT ProfilingStaticGuid WORKLOAD_EXECUTION_GUID
std::vector< std::pair< LayerBindingId, class Tensor > > OutputTensors
void VerifyTimelineLabelBinaryPacket(Optional< ProfilingGuid > guid, const std::string &label, const unsigned char *readableData, unsigned int &offset)
static ARMNN_DLLEXPORT ProfilingStaticGuid ARMNN_PROFILING_EOL_EVENT_CLASS
IOptimizedNetworkPtr Optimize(const INetwork &network, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptions &options=OptimizerOptions(), Optional< std::vector< std::string > &> messages=EmptyOptional())
An ActivationDescriptor for the ActivationLayer.
void VerifyTimelineEventClassBinaryPacket(ProfilingGuid guid, const unsigned char *readableData, unsigned int &offset)
static ARMNN_DLLEXPORT ProfilingStaticGuid CONNECTION_GUID
uint32_t m_PadBottom
Padding bottom value in the height dimension.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
ExternalProfilingOptions m_ProfilingOptions
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
static ARMNN_DLLEXPORT ProfilingStaticGuid INFERENCE_GUID
static ARMNN_DLLEXPORT ProfilingStaticGuid TYPE_GUID
uint32_t m_PadTop
Padding top value in the height dimension.
uint32_t m_PadLeft
Padding left value in the width dimension.
void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId)
IPacketBufferPtr GetReadableBuffer() override
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
void VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType relationshipType, Optional< ProfilingGuid > relationshipGuid, Optional< ProfilingGuid > headGuid, Optional< ProfilingGuid > tailGuid, 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)
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
static ARMNN_DLLEXPORT ProfilingStaticGuid BACKENDID_GUID
Head execution start depends on Tail execution completion.
std::vector< std::pair< LayerBindingId, class ConstTensor > > InputTensors
static INetworkPtr Create()
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
unsigned int OffsetToNextWord(unsigned int numberOfBytes)
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
bool m_BiasEnabled
Enable/disable bias.
static ProfilingService & Instance()
static IRuntimePtr Create(const CreationOptions &options)
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)
void ReadBytes(const IPacketBufferPtr &packetBuffer, unsigned int offset, unsigned int valueSize, uint8_t outValue[])
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
void MarkRead(IPacketBufferPtr &packetBuffer) override
static ARMNN_DLLEXPORT ProfilingStaticGuid ARMNN_PROFILING_SOL_EVENT_CLASS
ProfilingService & profilingService
A Convolution2dDescriptor for the Convolution2dLayer.
ProfilingState ConfigureProfilingService(const ExternalProfilingOptions &options, bool resetProfilingService=false)
virtual int Connect(IInputSlot &destination)=0
armnn::Runtime::CreationOptions::ExternalProfilingOptions options
static ARMNN_DLLEXPORT ProfilingStaticGuid NAME_GUID
std::unique_ptr< IRuntime, void(*)(IRuntime *runtime)> IRuntimePtr
bool has_value() const noexcept
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
const std::string & Get() const
void VerifyTimelineEntityBinaryPacket(Optional< ProfilingGuid > guid, const unsigned char *readableData, unsigned int &offset)