13 #include <boost/test/unit_test.hpp> 25 return numberOfBytes + uint32_t_size - remainder;
30 uint32_t packetDataLength)
32 BOOST_ASSERT(readableData);
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;
48 uint32_t entityBinaryPacketHeaderWord1 =
ReadUint32(readableData, offset);
49 uint32_t eventBinaryPacketSequenceNumber = (entityBinaryPacketHeaderWord1 >> 24) & 0x00000001;
50 uint32_t eventBinaryPacketDataLength = (entityBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF;
52 BOOST_CHECK(eventBinaryPacketDataLength == packetDataLength);
57 const std::string& label,
58 const unsigned char* readableData,
61 BOOST_ASSERT(readableData);
65 unsigned int uint64_t_size =
sizeof(uint64_t);
69 uint32_t eventClassDeclId =
ReadUint32(readableData, offset);
74 uint64_t readProfilingGuid =
ReadUint64(readableData, offset);
81 BOOST_CHECK(readProfilingGuid == ProfilingService::Instance().GenerateStaticId(label));
85 offset += uint64_t_size;
86 uint32_t swTraceLabelLength =
ReadUint32(readableData, offset);
91 swTraceLabelLength - 1) == 0);
98 const unsigned char* readableData,
101 BOOST_ASSERT(readableData);
105 unsigned int uint64_t_size =
sizeof(uint64_t);
108 uint32_t eventClassDeclId =
ReadUint32(readableData, offset);
113 uint64_t readProfilingGuid =
ReadUint64(readableData, offset);
117 offset += uint64_t_size;
124 const unsigned char* readableData,
125 unsigned int& offset)
127 BOOST_ASSERT(readableData);
129 uint32_t relationshipTypeUint = 0;
130 switch (relationshipType)
132 case ProfilingRelationshipType::RetentionLink:
133 relationshipTypeUint = 0;
135 case ProfilingRelationshipType::ExecutionLink:
136 relationshipTypeUint = 1;
138 case ProfilingRelationshipType::DataLink:
139 relationshipTypeUint = 2;
141 case ProfilingRelationshipType::LabelLink:
142 relationshipTypeUint = 3;
145 BOOST_ERROR(
"Unknown relationship type");
150 unsigned int uint64_t_size =
sizeof(uint64_t);
153 uint32_t eventClassDeclId =
ReadUint32(readableData, offset);
158 uint32_t readRelationshipTypeUint =
ReadUint32(readableData, offset);
159 BOOST_CHECK(readRelationshipTypeUint == relationshipTypeUint);
163 uint64_t readRelationshipGuid =
ReadUint64(readableData, offset);
174 offset += uint64_t_size;
175 uint64_t readHeadRelationshipGuid =
ReadUint64(readableData, offset);
186 offset += uint64_t_size;
187 uint64_t readTailRelationshipGuid =
ReadUint64(readableData, offset);
198 offset += uint64_t_size;
202 const unsigned char* readableData,
203 unsigned int& offset)
205 BOOST_ASSERT(readableData);
209 unsigned int uint64_t_size =
sizeof(uint64_t);
213 uint32_t entityDeclId =
ReadUint32(readableData, offset);
218 uint64_t readProfilingGuid =
ReadUint64(readableData, offset);
229 offset += uint64_t_size;
235 const unsigned char* readableData,
236 unsigned int& offset)
238 BOOST_ASSERT(readableData);
242 unsigned int uint64_t_size =
sizeof(uint64_t);
243 unsigned int threadId_size =
sizeof(std::thread::id);
247 uint32_t entityDeclId =
ReadUint32(readableData, offset);
252 uint64_t readTimestamp =
ReadUint64(readableData, offset);
263 offset += uint64_t_size;
264 std::vector<uint8_t> readThreadId(threadId_size, 0);
265 ReadBytes(readableData, offset, threadId_size, readThreadId.data());
272 BOOST_CHECK(readThreadId == std::this_thread::get_id());
276 offset += threadId_size;
277 uint64_t readEventGuid =
ReadUint64(readableData, offset);
287 offset += uint64_t_size;
292 using namespace armnn;
309 std::vector<float> weightsData{
322 std::vector<float> biasesData{ 1.0f, 0.0f, 0.0f };
338 IConnectableLayer* conv2d = net->AddConvolution2dLayer(conv2dDesc, weights, optionalBiases);
347 input->GetOutputSlot(0).Connect(conv2d->
GetInputSlot(0));
351 input->GetOutputSlot(0).SetTensorInfo(inputInfo);
356 std::vector<armnn::BackendId> backends = { backendId };
363 BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet)) ==
Status::Success);
372 unsigned int size = readableBuffer->GetSize();
375 const unsigned char* readableData = readableBuffer->GetReadableData();
378 unsigned int offset = 0;
757 bufferManager.
MarkRead(readableBuffer);
760 std::vector<float> inputData(inputInfo.GetNumElements());
761 std::vector<float> outputData(outputInfo.GetNumElements());
765 { 0,
ConstTensor(runtime->GetInputTensorInfo(netId, 0), inputData.data()) }
769 { 0,
Tensor(runtime->GetOutputTensorInfo(netId, 0), outputData.data()) }
773 runtime->EnqueueWorkload(netId, inputTensors, outputTensors);
788 size = inputReadableBuffer->GetSize();
791 readableData = inputReadableBuffer->GetReadableData();
846 bufferManager.
MarkRead(inputReadableBuffer);
849 size = outputReadableBuffer->GetSize();
852 readableData = outputReadableBuffer->GetReadableData();
907 bufferManager.
MarkRead(outputReadableBuffer);
910 size = inferenceReadableBuffer->GetSize();
913 readableData = inferenceReadableBuffer->GetReadableData();
1294 bufferManager.
MarkRead(inferenceReadableBuffer);
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)
static ProfilingService & Instance()
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
void VerifyTimelineEntityBinaryPacketData(Optional< ProfilingGuid > guid, const unsigned char *readableData, unsigned int &offset)
void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId)
void ReadBytes(const IPacketBufferPtr &packetBuffer, unsigned int offset, unsigned int valueSize, uint8_t outValue[])
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
A Convolution2dDescriptor for the Convolution2dLayer.
std::unique_ptr< IRuntime, void(*)(IRuntime *runtime)> IRuntimePtr
Head retains(parents) Tail.
std::vector< std::pair< LayerBindingId, class ConstTensor > > InputTensors
uint32_t m_PadRight
Padding right value in the width dimension.
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.
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.
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.
bool has_value() const noexcept
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
ProfilingRelationshipType
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
IPacketBufferPtr GetReadableBuffer() override
An ActivationDescriptor for the ActivationLayer.
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)
void MarkRead(IPacketBufferPtr &packetBuffer) override
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
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)
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
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
virtual int Connect(IInputSlot &destination)=0
armnn::Runtime::CreationOptions::ExternalProfilingOptions options
ExternalProfilingOptions m_ProfilingOptions
ProfilingState ConfigureProfilingService(const ExternalProfilingOptions &options, bool resetProfilingService=false)
static ARMNN_DLLEXPORT ProfilingStaticGuid BACKENDID_GUID
static INetworkPtr Create()
uint32_t m_PadLeft
Padding left value in the width dimension.