blob: 526f3f95fda38146e7e13456d0aad80a7f79bd89 [file] [log] [blame]
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +00001//
Jim Flynn6398a982020-05-27 17:05:21 +01002// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +00003// SPDX-License-Identifier: MIT
4//
5
6#include "ProfilingTestUtils.hpp"
7#include "ProfilingUtils.hpp"
8
9#include <armnn/Descriptors.hpp>
10#include <LabelsAndEventClasses.hpp>
Jim Flynn1fdeb992020-07-09 07:28:37 +010011#include <Threads.hpp>
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +000012#include <ProfilingService.hpp>
Sadik Armaganea41b572020-03-19 18:16:46 +000013
14#include <test/TestUtils.hpp>
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +000015
16#include <boost/test/unit_test.hpp>
17
Finn Williamsa0de0562020-04-22 12:27:37 +010018uint32_t GetStreamMetaDataPacketSize()
19{
20 uint32_t sizeUint32 = sizeof(uint32_t);
21 uint32_t payloadSize = 0;
22 payloadSize += boost::numeric_cast<uint32_t>(GetSoftwareInfo().size()) + 1;
23 payloadSize += boost::numeric_cast<uint32_t>(GetHardwareVersion().size()) + 1;
24 payloadSize += boost::numeric_cast<uint32_t>(GetSoftwareVersion().size()) + 1;
25 payloadSize += boost::numeric_cast<uint32_t>(GetProcessName().size()) + 1;
26
27 // Add packetVersionEntries
28 payloadSize += 6 * 2 * sizeUint32;
29 // Add packetVersionCountSize
30 payloadSize += sizeUint32;
31
32 uint32_t headerSize = 2 * sizeUint32;
33 uint32_t bodySize = 10 * sizeUint32;
34
35 return headerSize + bodySize + payloadSize;
36}
37
Jan Eilersf78c7672020-07-01 18:09:39 +010038std::vector<BackendId> GetSuitableBackendRegistered()
39{
40 std::vector<BackendId> suitableBackends;
41 if (BackendRegistryInstance().IsBackendRegistered(GetComputeDeviceAsCString(armnn::Compute::CpuRef)))
42 {
43 suitableBackends.push_back(armnn::Compute::CpuRef);
44 }
45 if (BackendRegistryInstance().IsBackendRegistered(GetComputeDeviceAsCString(armnn::Compute::CpuAcc)))
46 {
47 suitableBackends.push_back(armnn::Compute::CpuAcc);
48 }
49 if (BackendRegistryInstance().IsBackendRegistered(GetComputeDeviceAsCString(armnn::Compute::GpuAcc)))
50 {
51 suitableBackends.push_back(armnn::Compute::GpuAcc);
52 }
53 return suitableBackends;
54}
55
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +000056inline unsigned int OffsetToNextWord(unsigned int numberOfBytes)
57{
58 unsigned int uint32_t_size = sizeof(uint32_t);
59
60 unsigned int remainder = numberOfBytes % uint32_t_size;
61 if (remainder == 0)
62 {
63 return numberOfBytes;
64 }
65
66 return numberOfBytes + uint32_t_size - remainder;
67}
68
Keith Davis97da5e22020-03-05 16:25:28 +000069void VerifyTimelineHeaderBinary(const unsigned char* readableData,
70 unsigned int& offset,
71 uint32_t packetDataLength)
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +000072{
Narumol Prangnawaratac2770a2020-04-01 16:51:23 +010073 ARMNN_ASSERT(readableData);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +000074
75 // Utils
76 unsigned int uint32_t_size = sizeof(uint32_t);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +000077
Keith Davis97da5e22020-03-05 16:25:28 +000078 // Check the TimelineEventClassBinaryPacket header
Finn Williams0a336dc2020-05-11 15:39:58 +010079 uint32_t timelineBinaryPacketHeaderWord0 = ReadUint32(readableData, offset);
80 uint32_t timelineBinaryPacketFamily = (timelineBinaryPacketHeaderWord0 >> 26) & 0x0000003F;
81 uint32_t timelineBinaryPacketClass = (timelineBinaryPacketHeaderWord0 >> 19) & 0x0000007F;
82 uint32_t timelineBinaryPacketType = (timelineBinaryPacketHeaderWord0 >> 16) & 0x00000007;
83 uint32_t timelineBinaryPacketStreamId = (timelineBinaryPacketHeaderWord0 >> 0) & 0x00000007;
84 BOOST_CHECK(timelineBinaryPacketFamily == 1);
85 BOOST_CHECK(timelineBinaryPacketClass == 0);
86 BOOST_CHECK(timelineBinaryPacketType == 1);
87 BOOST_CHECK(timelineBinaryPacketStreamId == 0);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +000088 offset += uint32_t_size;
Finn Williams0a336dc2020-05-11 15:39:58 +010089 uint32_t timelineBinaryPacketHeaderWord1 = ReadUint32(readableData, offset);
90 uint32_t timelineBinaryPacketSequenceNumber = (timelineBinaryPacketHeaderWord1 >> 24) & 0x00000001;
91 uint32_t timelineBinaryPacketDataLength = (timelineBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF;
92 BOOST_CHECK(timelineBinaryPacketSequenceNumber == 0);
93 BOOST_CHECK(timelineBinaryPacketDataLength == packetDataLength);
Keith Davis97da5e22020-03-05 16:25:28 +000094 offset += uint32_t_size;
95}
96
Jim Flynn6398a982020-05-27 17:05:21 +010097ProfilingGuid VerifyTimelineLabelBinaryPacketData(Optional<ProfilingGuid> guid,
98 const std::string& label,
99 const unsigned char* readableData,
100 unsigned int& offset)
Keith Davis97da5e22020-03-05 16:25:28 +0000101{
Narumol Prangnawaratac2770a2020-04-01 16:51:23 +0100102 ARMNN_ASSERT(readableData);
Keith Davis97da5e22020-03-05 16:25:28 +0000103
104 // Utils
105 unsigned int uint32_t_size = sizeof(uint32_t);
106 unsigned int uint64_t_size = sizeof(uint64_t);
107 unsigned int label_size = boost::numeric_cast<unsigned int>(label.size());
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000108
109 // Check the decl id
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000110 uint32_t eventClassDeclId = ReadUint32(readableData, offset);
111 BOOST_CHECK(eventClassDeclId == 0);
112
113 // Check the profiling GUID
114 offset += uint32_t_size;
115 uint64_t readProfilingGuid = ReadUint64(readableData, offset);
116 if (guid.has_value())
117 {
118 BOOST_CHECK(readProfilingGuid == guid.value());
119 }
120 else
121 {
Sadik Armagan3184c902020-03-18 10:57:30 +0000122 armnn::profiling::ProfilingService profilingService;
123 BOOST_CHECK(readProfilingGuid == profilingService.GetStaticId(label));
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000124 }
125
126 // Check the SWTrace label
127 offset += uint64_t_size;
128 uint32_t swTraceLabelLength = ReadUint32(readableData, offset);
Keith Davis97da5e22020-03-05 16:25:28 +0000129 BOOST_CHECK(swTraceLabelLength == label_size + 1); // Label length including the null-terminator
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000130 offset += uint32_t_size;
131 BOOST_CHECK(std::memcmp(readableData + offset, // Offset to the label in the buffer
Keith Davis97da5e22020-03-05 16:25:28 +0000132 label.data(), // The original label
133 swTraceLabelLength - 1) == 0); // The length of the label
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000134
135 // SWTrace strings are written in blocks of words, so the offset has to be updated to the next whole word
136 offset += OffsetToNextWord(swTraceLabelLength);
Jim Flynn6398a982020-05-27 17:05:21 +0100137
138 ProfilingGuid labelGuid(readProfilingGuid);
139 return labelGuid;
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000140}
141
Keith Davis97da5e22020-03-05 16:25:28 +0000142void VerifyTimelineEventClassBinaryPacketData(ProfilingGuid guid,
Jim Flynn1892d212020-05-26 21:10:49 +0100143 ProfilingGuid nameGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000144 const unsigned char* readableData,
145 unsigned int& offset)
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000146{
Narumol Prangnawaratac2770a2020-04-01 16:51:23 +0100147 ARMNN_ASSERT(readableData);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000148
149 // Utils
150 unsigned int uint32_t_size = sizeof(uint32_t);
151 unsigned int uint64_t_size = sizeof(uint64_t);
152
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000153 // Check the decl id
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000154 uint32_t eventClassDeclId = ReadUint32(readableData, offset);
155 BOOST_CHECK(eventClassDeclId == 2);
156
157 // Check the profiling GUID
158 offset += uint32_t_size;
159 uint64_t readProfilingGuid = ReadUint64(readableData, offset);
160 BOOST_CHECK(readProfilingGuid == guid);
161
Jim Flynn1892d212020-05-26 21:10:49 +0100162 offset += uint64_t_size;
163 uint64_t readProfiilngNameGuid = ReadUint64(readableData, offset);
164 BOOST_CHECK(readProfiilngNameGuid == nameGuid);
165
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000166 // Update the offset to allow parsing to be continued after this function returns
167 offset += uint64_t_size;
168}
169
Keith Davis97da5e22020-03-05 16:25:28 +0000170void VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType relationshipType,
Jim Flynn6398a982020-05-27 17:05:21 +0100171 Optional<ProfilingGuid> relationshipGuid,
172 Optional<ProfilingGuid> headGuid,
173 Optional<ProfilingGuid> tailGuid,
174 Optional<ProfilingGuid> attributeGuid,
175 const unsigned char* readableData,
176 unsigned int& offset)
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000177{
Narumol Prangnawaratac2770a2020-04-01 16:51:23 +0100178 ARMNN_ASSERT(readableData);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000179
180 uint32_t relationshipTypeUint = 0;
181 switch (relationshipType)
182 {
183 case ProfilingRelationshipType::RetentionLink:
184 relationshipTypeUint = 0;
185 break;
186 case ProfilingRelationshipType::ExecutionLink:
187 relationshipTypeUint = 1;
188 break;
189 case ProfilingRelationshipType::DataLink:
190 relationshipTypeUint = 2;
191 break;
192 case ProfilingRelationshipType::LabelLink:
193 relationshipTypeUint = 3;
194 break;
195 default:
196 BOOST_ERROR("Unknown relationship type");
197 }
198
199 // Utils
200 unsigned int uint32_t_size = sizeof(uint32_t);
201 unsigned int uint64_t_size = sizeof(uint64_t);
202
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000203 // Check the decl id
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000204 uint32_t eventClassDeclId = ReadUint32(readableData, offset);
205 BOOST_CHECK(eventClassDeclId == 3);
206
207 // Check the relationship type
208 offset += uint32_t_size;
209 uint32_t readRelationshipTypeUint = ReadUint32(readableData, offset);
210 BOOST_CHECK(readRelationshipTypeUint == relationshipTypeUint);
211
212 // Check the relationship GUID
213 offset += uint32_t_size;
214 uint64_t readRelationshipGuid = ReadUint64(readableData, offset);
215 if (relationshipGuid.has_value())
216 {
217 BOOST_CHECK(readRelationshipGuid == relationshipGuid.value());
218 }
219 else
220 {
221 BOOST_CHECK(readRelationshipGuid != ProfilingGuid(0));
222 }
223
Jim Flynn6398a982020-05-27 17:05:21 +0100224 // Check the head GUID of the relationship
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000225 offset += uint64_t_size;
226 uint64_t readHeadRelationshipGuid = ReadUint64(readableData, offset);
227 if (headGuid.has_value())
228 {
229 BOOST_CHECK(readHeadRelationshipGuid == headGuid.value());
230 }
231 else
232 {
233 BOOST_CHECK(readHeadRelationshipGuid != ProfilingGuid(0));
234 }
235
Jim Flynn6398a982020-05-27 17:05:21 +0100236 // Check the tail GUID of the relationship
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000237 offset += uint64_t_size;
238 uint64_t readTailRelationshipGuid = ReadUint64(readableData, offset);
239 if (tailGuid.has_value())
240 {
241 BOOST_CHECK(readTailRelationshipGuid == tailGuid.value());
242 }
243 else
244 {
245 BOOST_CHECK(readTailRelationshipGuid != ProfilingGuid(0));
246 }
247
Jim Flynn6398a982020-05-27 17:05:21 +0100248 // Check the attribute GUID of the relationship
Finn Williams0a336dc2020-05-11 15:39:58 +0100249 offset += uint64_t_size;
250 uint64_t readAttributeRelationshipGuid = ReadUint64(readableData, offset);
251 if (attributeGuid.has_value())
252 {
253 BOOST_CHECK(readAttributeRelationshipGuid == attributeGuid.value());
254 }
255 else
256 {
257 BOOST_CHECK(readAttributeRelationshipGuid == ProfilingGuid(0));
258 }
259
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000260 // Update the offset to allow parsing to be continued after this function returns
261 offset += uint64_t_size;
262}
263
Jim Flynn6398a982020-05-27 17:05:21 +0100264ProfilingGuid VerifyTimelineEntityBinaryPacketData(Optional<ProfilingGuid> guid,
265 const unsigned char* readableData,
266 unsigned int& offset)
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000267{
Narumol Prangnawaratac2770a2020-04-01 16:51:23 +0100268 ARMNN_ASSERT(readableData);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000269
270 // Utils
271 unsigned int uint32_t_size = sizeof(uint32_t);
272 unsigned int uint64_t_size = sizeof(uint64_t);
273
274 // Reading TimelineEntityClassBinaryPacket
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000275 // Check the decl_id
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000276 uint32_t entityDeclId = ReadUint32(readableData, offset);
277 BOOST_CHECK(entityDeclId == 1);
278
279 // Check the profiling GUID
280 offset += uint32_t_size;
281 uint64_t readProfilingGuid = ReadUint64(readableData, offset);
282
283 if (guid.has_value())
284 {
285 BOOST_CHECK(readProfilingGuid == guid.value());
286 }
287 else
288 {
289 BOOST_CHECK(readProfilingGuid != ProfilingGuid(0));
290 }
291
292 offset += uint64_t_size;
Jim Flynn6398a982020-05-27 17:05:21 +0100293
294 ProfilingGuid entityGuid(readProfilingGuid);
295 return entityGuid;
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000296}
297
Jim Flynn6398a982020-05-27 17:05:21 +0100298ProfilingGuid VerifyTimelineEventBinaryPacket(Optional<uint64_t> timestamp,
Jim Flynn1fdeb992020-07-09 07:28:37 +0100299 Optional<int> threadId,
Jim Flynn6398a982020-05-27 17:05:21 +0100300 Optional<ProfilingGuid> eventGuid,
301 const unsigned char* readableData,
302 unsigned int& offset)
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000303{
Narumol Prangnawaratac2770a2020-04-01 16:51:23 +0100304 ARMNN_ASSERT(readableData);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000305
306 // Utils
307 unsigned int uint32_t_size = sizeof(uint32_t);
308 unsigned int uint64_t_size = sizeof(uint64_t);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000309
310 // Reading TimelineEventBinaryPacket
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000311 // Check the decl_id
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000312 uint32_t entityDeclId = ReadUint32(readableData, offset);
313 BOOST_CHECK(entityDeclId == 4);
314
315 // Check the timestamp
316 offset += uint32_t_size;
317 uint64_t readTimestamp = ReadUint64(readableData, offset);
318 if (timestamp.has_value())
319 {
320 BOOST_CHECK(readTimestamp == timestamp.value());
321 }
322 else
323 {
324 BOOST_CHECK(readTimestamp != 0);
325 }
326
327 // Check the thread id
328 offset += uint64_t_size;
Colm Donelan5bb3d8a2020-05-12 16:36:46 +0100329 std::vector<uint8_t> readThreadId(ThreadIdSize, 0);
330 ReadBytes(readableData, offset, ThreadIdSize, readThreadId.data());
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000331 if (threadId.has_value())
332 {
333 BOOST_CHECK(readThreadId == threadId.value());
334 }
335 else
336 {
Jim Flynn1fdeb992020-07-09 07:28:37 +0100337 BOOST_CHECK(readThreadId == armnnUtils::Threads::GetCurrentThreadId());
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000338 }
339
340 // Check the event GUID
Colm Donelan5bb3d8a2020-05-12 16:36:46 +0100341 offset += ThreadIdSize;
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000342 uint64_t readEventGuid = ReadUint64(readableData, offset);
343 if (eventGuid.has_value())
344 {
345 BOOST_CHECK(readEventGuid == eventGuid.value());
346 }
347 else
348 {
349 BOOST_CHECK(readEventGuid != ProfilingGuid(0));
350 }
351
352 offset += uint64_t_size;
Jim Flynn6398a982020-05-27 17:05:21 +0100353
354 ProfilingGuid eventid(readEventGuid);
355 return eventid;
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000356}
357
358void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId)
359{
360 using namespace armnn;
361
362 // Create runtime in which test will run
363 armnn::IRuntime::CreationOptions options;
364 options.m_ProfilingOptions.m_EnableProfiling = true;
Keith Davis33ed2212020-03-30 10:43:41 +0100365 options.m_ProfilingOptions.m_TimelineEnabled = true;
Sadik Armagan3184c902020-03-18 10:57:30 +0000366 armnn::Runtime runtime(options);
Keith Davis33ed2212020-03-30 10:43:41 +0100367 GetProfilingService(&runtime).ResetExternalProfilingOptions(options.m_ProfilingOptions, false);
368
369 profiling::ProfilingServiceRuntimeHelper profilingServiceHelper(GetProfilingService(&runtime));
370 profilingServiceHelper.ForceTransitionToState(ProfilingState::NotConnected);
371 profilingServiceHelper.ForceTransitionToState(ProfilingState::WaitingForAck);
372 profilingServiceHelper.ForceTransitionToState(ProfilingState::Active);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000373
374 // build up the structure of the network
375 INetworkPtr net(INetwork::Create());
376
377 // Convolution details
378 TensorInfo inputInfo({ 1, 2, 5, 1 }, DataType::Float32);
Keith Davis97da5e22020-03-05 16:25:28 +0000379 TensorInfo weightInfo({ 3, 2, 3, 1 }, DataType::Float32);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000380 TensorInfo biasInfo({ 3 }, DataType::Float32);
Keith Davis97da5e22020-03-05 16:25:28 +0000381 TensorInfo outputInfo({ 1, 3, 7, 1 }, DataType::Float32);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000382 std::vector<float> weightsData{
Keith Davis97da5e22020-03-05 16:25:28 +0000383 1.0f, 0.0f, 0.0f,
384 0.0f, 2.0f, -1.5f,
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000385
Keith Davis97da5e22020-03-05 16:25:28 +0000386 0.0f, 0.0f, 0.0f,
387 0.2f, 0.2f, 0.2f,
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000388
Keith Davis97da5e22020-03-05 16:25:28 +0000389 0.5f, 0.0f, 0.5f,
390 0.0f, -1.0f, 0.0f
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000391 };
392 ConstTensor weights(weightInfo, weightsData);
393
394 Optional<ConstTensor> optionalBiases;
395 std::vector<float> biasesData{ 1.0f, 0.0f, 0.0f };
396 ConstTensor biases(biasInfo, biasesData);
397 optionalBiases = Optional<ConstTensor>(biases);
398
399 // Input layer
400 IConnectableLayer* input = net->AddInputLayer(0, "input");
401
402 // Convolution2d layer
403 Convolution2dDescriptor conv2dDesc;
Keith Davis97da5e22020-03-05 16:25:28 +0000404 conv2dDesc.m_StrideX = 1;
405 conv2dDesc.m_StrideY = 1;
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000406 conv2dDesc.m_PadLeft = 0;
407 conv2dDesc.m_PadRight = 0;
408 conv2dDesc.m_PadTop = 2;
409 conv2dDesc.m_PadBottom = 2;
410 conv2dDesc.m_BiasEnabled = true;
411 IConnectableLayer* conv2d = net->AddConvolution2dLayer(conv2dDesc, weights, optionalBiases);
412
413 // Activation layer
414 armnn::ActivationDescriptor activationDesc;
415 armnn::IConnectableLayer* const activation = net->AddActivationLayer(activationDesc, "activation");
416
417 // Output layer
418 IConnectableLayer* output = net->AddOutputLayer(0, "output");
419
420 input->GetOutputSlot(0).Connect(conv2d->GetInputSlot(0));
421 conv2d->GetOutputSlot(0).Connect(activation->GetInputSlot(0));
422 activation->GetOutputSlot(0).Connect(output->GetInputSlot(0));
423
424 input->GetOutputSlot(0).SetTensorInfo(inputInfo);
425 conv2d->GetOutputSlot(0).SetTensorInfo(outputInfo);
426 activation->GetOutputSlot(0).SetTensorInfo(outputInfo);
427
428 // optimize the network
429 std::vector<armnn::BackendId> backends = { backendId };
Sadik Armagan3184c902020-03-18 10:57:30 +0000430 IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime.GetDeviceSpec());
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000431
432 ProfilingGuid optNetGuid = optNet->GetGuid();
433
434 // Load it into the runtime. It should success.
435 armnn::NetworkId netId;
Sadik Armagan3184c902020-03-18 10:57:30 +0000436 BOOST_TEST(runtime.LoadNetwork(netId, std::move(optNet)) == Status::Success);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000437
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000438 profiling::BufferManager& bufferManager = profilingServiceHelper.GetProfilingBufferManager();
439 auto readableBuffer = bufferManager.GetReadableBuffer();
440
441 // Profiling is enable, the post-optimisation structure should be created
442 BOOST_CHECK(readableBuffer != nullptr);
443
444 unsigned int size = readableBuffer->GetSize();
Jim Flynn6398a982020-05-27 17:05:21 +0100445 BOOST_CHECK(size == 1124);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000446
447 const unsigned char* readableData = readableBuffer->GetReadableData();
448 BOOST_CHECK(readableData != nullptr);
449
450 unsigned int offset = 0;
451
Keith Davis97da5e22020-03-05 16:25:28 +0000452 // Verify Header
Jim Flynn6398a982020-05-27 17:05:21 +0100453 VerifyTimelineHeaderBinary(readableData, offset, 1116);
454 BOOST_TEST_MESSAGE("HEADER OK");
Keith Davis97da5e22020-03-05 16:25:28 +0000455
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000456 // Post-optimisation network
457 // Network entity
Keith Davis97da5e22020-03-05 16:25:28 +0000458 VerifyTimelineEntityBinaryPacketData(optNetGuid, readableData, offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100459 BOOST_TEST_MESSAGE("NETWORK ENTITY OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000460
461 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000462 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
463 EmptyOptional(),
464 optNetGuid,
Jim Flynn6398a982020-05-27 17:05:21 +0100465 LabelsAndEventClasses::NETWORK_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000466 LabelsAndEventClasses::TYPE_GUID,
467 readableData,
468 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100469 BOOST_TEST_MESSAGE("NETWORK TYPE RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000470
471 // Input layer
472 // Input layer entity
Keith Davis97da5e22020-03-05 16:25:28 +0000473 VerifyTimelineEntityBinaryPacketData(input->GetGuid(), readableData, offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100474 BOOST_TEST_MESSAGE("INPUT ENTITY OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000475
476 // Name Entity
Jim Flynn6398a982020-05-27 17:05:21 +0100477 ProfilingGuid inputLabelGuid = VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "input", readableData, offset);
478 BOOST_TEST_MESSAGE("INPUT NAME LABEL OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000479
480 // Entity - Name relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000481 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
482 EmptyOptional(),
483 input->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100484 inputLabelGuid,
Finn Williams0a336dc2020-05-11 15:39:58 +0100485 LabelsAndEventClasses::NAME_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000486 readableData,
487 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100488 BOOST_TEST_MESSAGE("INPUT NAME RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000489
490 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000491 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
492 EmptyOptional(),
493 input->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100494 LabelsAndEventClasses::LAYER_GUID,
Finn Williams0a336dc2020-05-11 15:39:58 +0100495 LabelsAndEventClasses::TYPE_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000496 readableData,
497 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100498 BOOST_TEST_MESSAGE("INPUT TYPE RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000499
500 // Network - Input layer relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000501 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
502 EmptyOptional(),
503 optNetGuid,
504 input->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100505 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000506 readableData,
507 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100508 BOOST_TEST_MESSAGE("NETWORK - INPUT CHILD RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000509
510 // Conv2d layer
511 // Conv2d layer entity
Keith Davis97da5e22020-03-05 16:25:28 +0000512 VerifyTimelineEntityBinaryPacketData(conv2d->GetGuid(), readableData, offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000513
514 // Name entity
Jim Flynn6398a982020-05-27 17:05:21 +0100515 ProfilingGuid conv2dNameLabelGuid = VerifyTimelineLabelBinaryPacketData(
516 EmptyOptional(), "<Unnamed>", readableData, offset);
517 BOOST_TEST_MESSAGE("CONV2D NAME LABEL OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000518
519 // Entity - Name relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000520 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
521 EmptyOptional(),
522 conv2d->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100523 conv2dNameLabelGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000524 LabelsAndEventClasses::NAME_GUID,
525 readableData,
526 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100527 BOOST_TEST_MESSAGE("CONV2D NAME RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000528
529 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000530 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
531 EmptyOptional(),
532 conv2d->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100533 LabelsAndEventClasses::LAYER_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000534 LabelsAndEventClasses::TYPE_GUID,
535 readableData,
536 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100537 BOOST_TEST_MESSAGE("CONV2D TYPE RELATIONSHIP OK");
Finn Williams0a336dc2020-05-11 15:39:58 +0100538
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000539 // Network - Conv2d layer relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000540 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
541 EmptyOptional(),
542 optNetGuid,
543 conv2d->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100544 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000545 readableData,
546 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100547 BOOST_TEST_MESSAGE("NETWORK - CONV2D CHILD RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000548
549 // Input layer - Conv2d layer relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000550 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
551 EmptyOptional(),
552 input->GetGuid(),
553 conv2d->GetGuid(),
Keith Davis97da5e22020-03-05 16:25:28 +0000554 LabelsAndEventClasses::CONNECTION_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000555 readableData,
556 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100557 BOOST_TEST_MESSAGE("INPUT - CONV2D LAYER CONNECTION OK");
Finn Williams0a336dc2020-05-11 15:39:58 +0100558
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000559 // Conv2d workload
560 // Conv2d workload entity
Jim Flynn6398a982020-05-27 17:05:21 +0100561 ProfilingGuid conv2DWorkloadGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
562 BOOST_TEST_MESSAGE("CONV2D WORKLOAD ENTITY OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000563
564 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000565 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
566 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100567 conv2DWorkloadGuid,
568 LabelsAndEventClasses::WORKLOAD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000569 LabelsAndEventClasses::TYPE_GUID,
570 readableData,
571 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100572 BOOST_TEST_MESSAGE("CONV2D WORKLOAD TYPE RELATIONSHIP OK");
Finn Williams0a336dc2020-05-11 15:39:58 +0100573
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000574 // BackendId entity
Jim Flynn6398a982020-05-27 17:05:21 +0100575 ProfilingGuid backendIdLabelGuid = VerifyTimelineLabelBinaryPacketData(
576 EmptyOptional(), backendId.Get(), readableData, offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000577
578 // Entity - BackendId relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000579 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
580 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100581 conv2DWorkloadGuid,
582 backendIdLabelGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000583 LabelsAndEventClasses::BACKENDID_GUID,
584 readableData,
585 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100586 BOOST_TEST_MESSAGE("CONV2D WORKLOAD BACKEND ID RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000587
Finn Williams0a336dc2020-05-11 15:39:58 +0100588
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000589 // Conv2d layer - Conv2d workload relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000590 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
591 EmptyOptional(),
592 conv2d->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100593 conv2DWorkloadGuid,
594 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000595 readableData,
596 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100597 BOOST_TEST_MESSAGE("CONV2D LAYER - WORKLOAD CHILD RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000598
599 // Activation layer
600 // Activation layer entity
Keith Davis97da5e22020-03-05 16:25:28 +0000601 VerifyTimelineEntityBinaryPacketData(activation->GetGuid(), readableData, offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100602 BOOST_TEST_MESSAGE("ACTIVATION ENTITY OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000603
604 // Name entity
Jim Flynn6398a982020-05-27 17:05:21 +0100605 ProfilingGuid activationLabelGuid = VerifyTimelineLabelBinaryPacketData(
606 EmptyOptional(), "activation", readableData, offset);
607 BOOST_TEST_MESSAGE("ACTIVATION NAME LABEL OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000608
609 // Entity - Name relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000610 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
611 EmptyOptional(),
612 activation->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100613 activationLabelGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000614 LabelsAndEventClasses::NAME_GUID,
615 readableData,
616 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100617 BOOST_TEST_MESSAGE("ACTIVATION LAYER - NAME RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000618
619 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000620 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
621 EmptyOptional(),
622 activation->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100623 LabelsAndEventClasses::LAYER_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000624 LabelsAndEventClasses::TYPE_GUID,
625 readableData,
626 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100627 BOOST_TEST_MESSAGE("ACTIVATION LAYER TYPE RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000628
629 // Network - Activation layer relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000630 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
631 EmptyOptional(),
632 optNetGuid,
633 activation->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100634 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000635 readableData,
636 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100637 BOOST_TEST_MESSAGE("NETWORK - ACTIVATION LAYER CHILD RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000638
639 // Conv2d layer - Activation layer relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000640 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
641 EmptyOptional(),
642 conv2d->GetGuid(),
643 activation->GetGuid(),
Keith Davis97da5e22020-03-05 16:25:28 +0000644 LabelsAndEventClasses::CONNECTION_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000645 readableData,
646 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100647 BOOST_TEST_MESSAGE("CONV2D LAYER - ACTIVATION LAYER CONNECTION OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000648
649 // Activation workload
650 // Activation workload entity
Jim Flynn6398a982020-05-27 17:05:21 +0100651 ProfilingGuid activationWorkloadGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
652 BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD ENTITY OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000653
654 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000655 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
656 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100657 activationWorkloadGuid,
658 LabelsAndEventClasses::WORKLOAD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000659 LabelsAndEventClasses::TYPE_GUID,
660 readableData,
661 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100662 BOOST_TEST_MESSAGE("ACTIVATION WORKLAD TYPE RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000663
664 // BackendId entity
Keith Davis97da5e22020-03-05 16:25:28 +0000665 VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100666 BOOST_TEST_MESSAGE("BACKEND ID LABEL OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000667
668 // Entity - BackendId relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000669 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
670 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100671 activationWorkloadGuid,
672 backendIdLabelGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000673 LabelsAndEventClasses::BACKENDID_GUID,
674 readableData,
675 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100676 BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD BACKEND ID RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000677
678 // Activation layer - Activation workload relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000679 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
680 EmptyOptional(),
681 activation->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100682 activationWorkloadGuid,
683 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000684 readableData,
685 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100686 BOOST_TEST_MESSAGE("ACTIVATION LAYER - WORKLOAD CHILD RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000687
688 // Output layer
689 // Output layer entity
Keith Davis97da5e22020-03-05 16:25:28 +0000690 VerifyTimelineEntityBinaryPacketData(output->GetGuid(), readableData, offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100691 BOOST_TEST_MESSAGE("OUTPUT LAYER ENTITY OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000692
693 // Name entity
Jim Flynn6398a982020-05-27 17:05:21 +0100694 ProfilingGuid outputLabelGuid = VerifyTimelineLabelBinaryPacketData(
695 EmptyOptional(), "output", readableData, offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000696
697 // Entity - Name relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000698 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
699 EmptyOptional(),
700 output->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100701 outputLabelGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000702 LabelsAndEventClasses::NAME_GUID,
703 readableData,
704 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100705 BOOST_TEST_MESSAGE("OUTPUT LAYER NAME RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000706
707 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000708 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
709 EmptyOptional(),
710 output->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100711 LabelsAndEventClasses::LAYER_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000712 LabelsAndEventClasses::TYPE_GUID,
713 readableData,
714 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100715 BOOST_TEST_MESSAGE("OUTPUT LAYER TYPE RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000716
717 // Network - Output layer relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000718 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
719 EmptyOptional(),
720 optNetGuid,
721 output->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100722 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000723 readableData,
724 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100725 BOOST_TEST_MESSAGE("NETWORK - OUTPUT LAYER CHILD RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000726
727 // Activation layer - Output layer relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000728 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
729 EmptyOptional(),
730 activation->GetGuid(),
731 output->GetGuid(),
Keith Davis97da5e22020-03-05 16:25:28 +0000732 LabelsAndEventClasses::CONNECTION_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000733 readableData,
734 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100735 BOOST_TEST_MESSAGE("ACTIVATION LAYER - OUTPUT LAYER CONNECTION OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000736
737 bufferManager.MarkRead(readableBuffer);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000738
739 // Creates structures for input & output.
740 std::vector<float> inputData(inputInfo.GetNumElements());
741 std::vector<float> outputData(outputInfo.GetNumElements());
742
743 InputTensors inputTensors
Keith Davis97da5e22020-03-05 16:25:28 +0000744 {
Sadik Armagan3184c902020-03-18 10:57:30 +0000745 {0, ConstTensor(runtime.GetInputTensorInfo(netId, 0), inputData.data())}
Keith Davis97da5e22020-03-05 16:25:28 +0000746 };
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000747 OutputTensors outputTensors
Keith Davis97da5e22020-03-05 16:25:28 +0000748 {
Sadik Armagan3184c902020-03-18 10:57:30 +0000749 {0, Tensor(runtime.GetOutputTensorInfo(netId, 0), outputData.data())}
Keith Davis97da5e22020-03-05 16:25:28 +0000750 };
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000751
752 // Does the inference.
Sadik Armagan3184c902020-03-18 10:57:30 +0000753 runtime.EnqueueWorkload(netId, inputTensors, outputTensors);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000754
Finn Williamsb6a402f2020-03-24 13:46:22 +0000755 // Get readable buffer for input workload
756 auto inputReadableBuffer = bufferManager.GetReadableBuffer();
757 BOOST_CHECK(inputReadableBuffer != nullptr);
David Monahan6198fe02019-12-02 08:35:43 +0000758
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000759 // Get readable buffer for output workload
760 auto outputReadableBuffer = bufferManager.GetReadableBuffer();
761 BOOST_CHECK(outputReadableBuffer != nullptr);
762
Finn Williamsb6a402f2020-03-24 13:46:22 +0000763 // Get readable buffer for inference timeline
764 auto inferenceReadableBuffer = bufferManager.GetReadableBuffer();
765 BOOST_CHECK(inferenceReadableBuffer != nullptr);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000766
767 // Validate input workload data
768 size = inputReadableBuffer->GetSize();
Finn Williams0a336dc2020-05-11 15:39:58 +0100769 BOOST_CHECK(size == 164);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000770
771 readableData = inputReadableBuffer->GetReadableData();
772 BOOST_CHECK(readableData != nullptr);
773
774 offset = 0;
775
Keith Davis97da5e22020-03-05 16:25:28 +0000776 // Verify Header
Finn Williams0a336dc2020-05-11 15:39:58 +0100777 VerifyTimelineHeaderBinary(readableData, offset, 156);
Jim Flynn6398a982020-05-27 17:05:21 +0100778 BOOST_TEST_MESSAGE("INPUT WORKLOAD HEADER OK");
Keith Davis97da5e22020-03-05 16:25:28 +0000779
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000780 // Input workload
781 // Input workload entity
Jim Flynn6398a982020-05-27 17:05:21 +0100782 ProfilingGuid inputWorkloadGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
783 BOOST_TEST_MESSAGE("INPUT WORKLOAD TYPE RELATIONSHIP OK");
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000784
785 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000786 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
787 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100788 inputWorkloadGuid,
789 LabelsAndEventClasses::WORKLOAD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000790 LabelsAndEventClasses::TYPE_GUID,
791 readableData,
792 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100793 BOOST_TEST_MESSAGE("INPUT WORKLOAD TYPE RELATIONSHIP OK");
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000794
795 // BackendId entity
Keith Davis97da5e22020-03-05 16:25:28 +0000796 VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000797
798 // Entity - BackendId relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000799 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
800 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100801 inputWorkloadGuid,
802 backendIdLabelGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000803 LabelsAndEventClasses::BACKENDID_GUID,
804 readableData,
805 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100806 BOOST_TEST_MESSAGE("INPUT WORKLOAD BACKEND ID RELATIONSHIP OK");
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000807
808 // Input layer - Input workload relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000809 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
810 EmptyOptional(),
811 input->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100812 inputWorkloadGuid,
813 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000814 readableData,
815 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100816 BOOST_TEST_MESSAGE("INPUT LAYER - INPUT WORKLOAD CHILD RELATIONSHIP OK");
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000817
818 bufferManager.MarkRead(inputReadableBuffer);
819
820 // Validate output workload data
821 size = outputReadableBuffer->GetSize();
Finn Williams0a336dc2020-05-11 15:39:58 +0100822 BOOST_CHECK(size == 164);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000823
824 readableData = outputReadableBuffer->GetReadableData();
825 BOOST_CHECK(readableData != nullptr);
826
827 offset = 0;
828
Keith Davis97da5e22020-03-05 16:25:28 +0000829 // Verify Header
Finn Williams0a336dc2020-05-11 15:39:58 +0100830 VerifyTimelineHeaderBinary(readableData, offset, 156);
Jim Flynn6398a982020-05-27 17:05:21 +0100831 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD HEADER OK");
Keith Davis97da5e22020-03-05 16:25:28 +0000832
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000833 // Output workload
834 // Output workload entity
Jim Flynn6398a982020-05-27 17:05:21 +0100835 ProfilingGuid outputWorkloadGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
836 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD ENTITY OK");
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000837
838 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000839 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
840 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100841 outputWorkloadGuid,
842 LabelsAndEventClasses::WORKLOAD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000843 LabelsAndEventClasses::TYPE_GUID,
844 readableData,
845 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100846 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD TYPE RELATIONSHIP OK");
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000847
848 // BackendId entity
Keith Davis97da5e22020-03-05 16:25:28 +0000849 VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100850 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD LABEL OK");
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000851
852 // Entity - BackendId relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000853 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
854 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100855 outputWorkloadGuid,
856 backendIdLabelGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000857 LabelsAndEventClasses::BACKENDID_GUID,
858 readableData,
859 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100860 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD BACKEND ID RELATIONSHIP OK");
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000861
862 // Output layer - Output workload relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000863 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
864 EmptyOptional(),
865 output->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100866 outputWorkloadGuid,
867 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000868 readableData,
869 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100870 BOOST_TEST_MESSAGE("OUTPUT LAYER - OUTPUT WORKLOAD CHILD RELATIONSHIP OK");
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000871
872 bufferManager.MarkRead(outputReadableBuffer);
David Monahan6198fe02019-12-02 08:35:43 +0000873
874 // Validate inference data
875 size = inferenceReadableBuffer->GetSize();
Jan Eilersa10e2a22020-03-26 12:04:54 +0000876
Finn Williams0a336dc2020-05-11 15:39:58 +0100877 BOOST_CHECK(size == 1228 + 10 * ThreadIdSize);
David Monahan6198fe02019-12-02 08:35:43 +0000878
879 readableData = inferenceReadableBuffer->GetReadableData();
880 BOOST_CHECK(readableData != nullptr);
881
882 offset = 0;
883
Keith Davis97da5e22020-03-05 16:25:28 +0000884 // Verify Header
Finn Williams0a336dc2020-05-11 15:39:58 +0100885 VerifyTimelineHeaderBinary(readableData, offset, 1220 + 10 * ThreadIdSize);
Jim Flynn6398a982020-05-27 17:05:21 +0100886 BOOST_TEST_MESSAGE("INFERENCE HEADER OK");
Keith Davis97da5e22020-03-05 16:25:28 +0000887
David Monahan6198fe02019-12-02 08:35:43 +0000888 // Inference timeline trace
889 // Inference entity
Jim Flynn6398a982020-05-27 17:05:21 +0100890 ProfilingGuid inferenceGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
891 BOOST_TEST_MESSAGE("INFERENCE ENTITY OK");
David Monahan6198fe02019-12-02 08:35:43 +0000892
893 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000894 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
895 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100896 inferenceGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000897 LabelsAndEventClasses::INFERENCE_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000898 LabelsAndEventClasses::TYPE_GUID,
899 readableData,
900 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100901 BOOST_TEST_MESSAGE("INFERENCE TYPE RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +0000902
903 // Network - Inference relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000904 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
905 EmptyOptional(),
906 optNetGuid,
Jim Flynn6398a982020-05-27 17:05:21 +0100907 inferenceGuid,
908 LabelsAndEventClasses::EXECUTION_OF_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000909 readableData,
910 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100911 BOOST_TEST_MESSAGE("NETWORK - INFERENCE EXECUTION_OF RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +0000912
913 // Start Inference life
914 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +0100915 ProfilingGuid inferenceEventGuid = VerifyTimelineEventBinaryPacket(
916 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
917 BOOST_TEST_MESSAGE("INFERENCE START OF LIFE EVENT OK");
David Monahan6198fe02019-12-02 08:35:43 +0000918
919 // Inference - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000920 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
921 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100922 inferenceGuid,
923 inferenceEventGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000924 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
925 readableData,
926 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100927 BOOST_TEST_MESSAGE("INFERENCE START OF LIFE RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +0000928
929 // Execution
930 // Input workload execution
931 // Input workload execution entity
Jim Flynn6398a982020-05-27 17:05:21 +0100932 ProfilingGuid inputWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
933 EmptyOptional(), readableData, offset);
934 BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION ENTITY OK");
David Monahan6198fe02019-12-02 08:35:43 +0000935
936 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000937 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
938 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100939 inputWorkloadExecutionGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000940 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000941 LabelsAndEventClasses::TYPE_GUID,
942 readableData,
943 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100944 BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION TYPE RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +0000945
946 // Inference - Workload execution relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000947 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
948 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100949 inferenceGuid,
950 inputWorkloadExecutionGuid,
951 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000952 readableData,
953 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100954 BOOST_TEST_MESSAGE("INPUT WORKLOAD - INPUT WORKLOAD EXECUTION RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +0000955
956 // Workload - Workload execution relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000957 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
958 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100959 inputWorkloadGuid,
960 inputWorkloadExecutionGuid,
961 LabelsAndEventClasses::EXECUTION_OF_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000962 readableData,
963 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100964 BOOST_TEST_MESSAGE("INPUT WORKLOAD - INPUT WORKLOAD EXECUTION RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +0000965
966 // Start Input workload execution life
967 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +0100968 ProfilingGuid inputWorkloadExecutionSOLEventId = VerifyTimelineEventBinaryPacket(
969 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
970 BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION - START OF LIFE EVENT OK");
David Monahan6198fe02019-12-02 08:35:43 +0000971
972 // Input workload execution - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000973 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
974 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100975 inputWorkloadExecutionGuid,
976 inputWorkloadExecutionSOLEventId,
Keith Davis97da5e22020-03-05 16:25:28 +0000977 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
978 readableData,
979 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100980 BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION - START OF LIFE EVENT RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +0000981
982 // End of Input workload execution life
983 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +0100984 ProfilingGuid inputWorkloadExecutionEOLEventId = VerifyTimelineEventBinaryPacket(
985 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
986 BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION - END OF LIFE EVENT OK");
David Monahan6198fe02019-12-02 08:35:43 +0000987
988 // Input workload execution - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000989 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
990 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100991 inputWorkloadExecutionGuid,
992 inputWorkloadExecutionEOLEventId,
Keith Davis97da5e22020-03-05 16:25:28 +0000993 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
994 readableData,
995 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100996 BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION - END OF LIFE EVENT RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +0000997
998 // Conv2d workload execution
999 // Conv2d workload execution entity
Jim Flynn6398a982020-05-27 17:05:21 +01001000 ProfilingGuid conv2DWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
1001 EmptyOptional(), readableData, offset);
1002 BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION ENTITY OK");
David Monahan6198fe02019-12-02 08:35:43 +00001003
1004 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001005 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1006 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001007 conv2DWorkloadExecutionGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001008 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +00001009 LabelsAndEventClasses::TYPE_GUID,
1010 readableData,
1011 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001012 BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION TYPE RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001013
1014 // Inference - Workload execution relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001015 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1016 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001017 inferenceGuid,
1018 conv2DWorkloadExecutionGuid,
1019 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +00001020 readableData,
1021 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001022 BOOST_TEST_MESSAGE("INFERENCE - CONV2D WORKLOAD EXECUTION CHILD RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001023
1024 // Workload - Workload execution relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001025 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1026 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001027 conv2DWorkloadGuid,
1028 conv2DWorkloadExecutionGuid,
1029 LabelsAndEventClasses::EXECUTION_OF_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +00001030 readableData,
1031 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001032 BOOST_TEST_MESSAGE("CONV2D WORKLOAD - CONV2D WORKLOAD EXECUTION RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001033
1034 // Start Conv2d workload execution life
1035 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +01001036 ProfilingGuid conv2DWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket(
1037 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1038 BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION START OF LIFE EVENT OK");
David Monahan6198fe02019-12-02 08:35:43 +00001039
1040 // Conv2d workload execution - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001041 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1042 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001043 conv2DWorkloadExecutionGuid,
1044 conv2DWorkloadExecutionSOLEventGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001045 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1046 readableData,
1047 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001048 BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION START OF LIFE RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001049
1050 // End of Conv2d workload execution life
1051 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +01001052 ProfilingGuid conv2DWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket(
1053 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1054 BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION END OF LIFE EVENT OK");
David Monahan6198fe02019-12-02 08:35:43 +00001055
1056 // Conv2d workload execution - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001057 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1058 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001059 conv2DWorkloadExecutionGuid,
1060 conv2DWorkloadExecutionEOLEventGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001061 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1062 readableData,
1063 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001064 BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION END OF LIFE RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001065
1066 // Activation workload execution
1067 // Activation workload execution entity
Jim Flynn6398a982020-05-27 17:05:21 +01001068 ProfilingGuid activationWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
1069 EmptyOptional(), readableData, offset);
1070 BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION ENTITY OK");
David Monahan6198fe02019-12-02 08:35:43 +00001071
1072 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001073 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1074 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001075 activationWorkloadExecutionGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001076 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +00001077 LabelsAndEventClasses::TYPE_GUID,
1078 readableData,
1079 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001080 BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION TYPE RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001081
1082 // Inference - Workload execution relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001083 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1084 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001085 inferenceGuid,
1086 activationWorkloadExecutionGuid,
1087 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +00001088 readableData,
1089 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001090 BOOST_TEST_MESSAGE("INFERENCE - ACTIVATION WORKLOAD EXECUTION CHILD RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001091
1092 // Workload - Workload execution relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001093 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1094 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001095 activationWorkloadGuid,
1096 activationWorkloadExecutionGuid,
1097 LabelsAndEventClasses::EXECUTION_OF_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +00001098 readableData,
1099 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001100 BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD - ACTIVATION WORKLOAD EXECUTION RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001101
1102 // Start Activation workload execution life
1103 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +01001104 ProfilingGuid activationWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket(
1105 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1106 BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION START OF LIFE EVENT OK");
David Monahan6198fe02019-12-02 08:35:43 +00001107
1108 // Activation workload execution - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001109 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1110 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001111 activationWorkloadExecutionGuid,
1112 activationWorkloadExecutionSOLEventGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001113 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1114 readableData,
1115 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001116 BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION START OF LIFE RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001117
1118 // End of Activation workload execution life
1119 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +01001120 ProfilingGuid activationWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket(
1121 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1122 BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION END OF LIFE EVENT OK");
David Monahan6198fe02019-12-02 08:35:43 +00001123
1124 // Activation workload execution - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001125 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1126 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001127 activationWorkloadExecutionGuid,
1128 activationWorkloadExecutionEOLEventGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001129 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1130 readableData,
1131 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001132 BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION END OF LIFE RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001133
1134 // Output workload execution
1135 // Output workload execution entity
Jim Flynn6398a982020-05-27 17:05:21 +01001136 ProfilingGuid outputWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
1137 EmptyOptional(), readableData, offset);
1138 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION ENTITY OK");
David Monahan6198fe02019-12-02 08:35:43 +00001139
1140 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001141 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1142 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001143 outputWorkloadExecutionGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001144 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +00001145 LabelsAndEventClasses::TYPE_GUID,
1146 readableData,
1147 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001148 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION TYPE RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001149
1150 // Inference - Workload execution relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001151 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1152 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001153 inferenceGuid,
1154 outputWorkloadExecutionGuid,
1155 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +00001156 readableData,
1157 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001158 BOOST_TEST_MESSAGE("INFERENCE - OUTPUT WORKLOAD EXECUTION CHILD RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001159
1160 // Workload - Workload execution relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001161 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1162 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001163 outputWorkloadGuid,
1164 outputWorkloadExecutionGuid,
1165 LabelsAndEventClasses::EXECUTION_OF_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +00001166 readableData,
1167 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001168 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD - OUTPUT WORKLOAD EXECUTION EXECUTION_OF RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001169
1170 // Start Output workload execution life
1171 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +01001172 ProfilingGuid outputWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket(
1173 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1174 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION START OF LIFE EVENT OK");
David Monahan6198fe02019-12-02 08:35:43 +00001175
1176 // Output workload execution - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001177 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1178 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001179 outputWorkloadExecutionGuid,
1180 outputWorkloadExecutionSOLEventGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001181 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1182 readableData,
1183 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001184 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION - START OF LIFE EVENT RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001185
1186 // End of Normalize workload execution life
1187 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +01001188 ProfilingGuid outputWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket(
1189 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1190 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION END OF LIFE EVENT OK");
David Monahan6198fe02019-12-02 08:35:43 +00001191
1192 // Output workload execution - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001193 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1194 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001195 outputWorkloadExecutionGuid,
1196 outputWorkloadExecutionEOLEventGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001197 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1198 readableData,
1199 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001200 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION - END OF LIFE EVENT RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001201
1202 // End of Inference life
1203 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +01001204 ProfilingGuid inferenceEOLEventGuid = VerifyTimelineEventBinaryPacket(
1205 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1206 BOOST_TEST_MESSAGE("INFERENCE END OF LIFE EVENT OK");
David Monahan6198fe02019-12-02 08:35:43 +00001207
1208 // Inference - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001209 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1210 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001211 inferenceGuid,
1212 inferenceEOLEventGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001213 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1214 readableData,
1215 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001216 BOOST_TEST_MESSAGE("INFERENCE - END OF LIFE EVENT RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001217
1218 bufferManager.MarkRead(inferenceReadableBuffer);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +00001219}
Jim Flynn6398a982020-05-27 17:05:21 +01001220
Jim Flynn6398a982020-05-27 17:05:21 +01001221bool CompareOutput(std::vector<std::string> output, std::vector<std::string> expectedOutput)
1222{
1223 if (output.size() != expectedOutput.size())
1224 {
1225 std::cerr << "output has [" << output.size() << "] lines, expected was ["
1226 << expectedOutput.size() << "] lines" << std::endl;
1227 std::cerr << std::endl << "actual" << std::endl << std::endl;
1228 for (auto line : output)
1229 {
1230 std::cerr << line << std::endl;
1231 }
1232 std::cerr << std::endl << "expected" << std::endl << std::endl;
1233 for (auto line : expectedOutput)
1234 {
1235 std::cerr << line << std::endl;
1236 }
1237 return false;
1238 }
1239 bool bRet = true;
1240 for (unsigned long i = 0; i < output.size(); ++i)
1241 {
1242 if (output[i] != expectedOutput[i])
1243 {
1244 bRet = false;
1245 std::cerr << i << ": actual [" << output[i] << "] expected [" << expectedOutput[i] << "]" << std::endl;
1246 }
1247 }
1248 return bRet;
1249}