blob: 8050eaa508817094ce60c78aff7ccb87afd27fd0 [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 Flynnf7713212020-07-14 09:50:59 +010011#include <Processes.hpp>
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +000012#include <ProfilingService.hpp>
Jim Flynnf7713212020-07-14 09:50:59 +010013#include <Threads.hpp>
Sadik Armaganea41b572020-03-19 18:16:46 +000014
15#include <test/TestUtils.hpp>
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +000016
17#include <boost/test/unit_test.hpp>
18
Finn Williamsa0de0562020-04-22 12:27:37 +010019uint32_t GetStreamMetaDataPacketSize()
20{
21 uint32_t sizeUint32 = sizeof(uint32_t);
22 uint32_t payloadSize = 0;
23 payloadSize += boost::numeric_cast<uint32_t>(GetSoftwareInfo().size()) + 1;
24 payloadSize += boost::numeric_cast<uint32_t>(GetHardwareVersion().size()) + 1;
25 payloadSize += boost::numeric_cast<uint32_t>(GetSoftwareVersion().size()) + 1;
26 payloadSize += boost::numeric_cast<uint32_t>(GetProcessName().size()) + 1;
27
28 // Add packetVersionEntries
Jim Flynn83d08a92020-07-09 13:48:16 +010029 payloadSize += 13 * 2 * sizeUint32;
Finn Williamsa0de0562020-04-22 12:27:37 +010030 // Add packetVersionCountSize
31 payloadSize += sizeUint32;
32
33 uint32_t headerSize = 2 * sizeUint32;
34 uint32_t bodySize = 10 * sizeUint32;
35
36 return headerSize + bodySize + payloadSize;
37}
38
Jan Eilersf78c7672020-07-01 18:09:39 +010039std::vector<BackendId> GetSuitableBackendRegistered()
40{
41 std::vector<BackendId> suitableBackends;
42 if (BackendRegistryInstance().IsBackendRegistered(GetComputeDeviceAsCString(armnn::Compute::CpuRef)))
43 {
44 suitableBackends.push_back(armnn::Compute::CpuRef);
45 }
46 if (BackendRegistryInstance().IsBackendRegistered(GetComputeDeviceAsCString(armnn::Compute::CpuAcc)))
47 {
48 suitableBackends.push_back(armnn::Compute::CpuAcc);
49 }
50 if (BackendRegistryInstance().IsBackendRegistered(GetComputeDeviceAsCString(armnn::Compute::GpuAcc)))
51 {
52 suitableBackends.push_back(armnn::Compute::GpuAcc);
53 }
54 return suitableBackends;
55}
56
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +000057inline unsigned int OffsetToNextWord(unsigned int numberOfBytes)
58{
59 unsigned int uint32_t_size = sizeof(uint32_t);
60
61 unsigned int remainder = numberOfBytes % uint32_t_size;
62 if (remainder == 0)
63 {
64 return numberOfBytes;
65 }
66
67 return numberOfBytes + uint32_t_size - remainder;
68}
69
Keith Davis97da5e22020-03-05 16:25:28 +000070void VerifyTimelineHeaderBinary(const unsigned char* readableData,
71 unsigned int& offset,
72 uint32_t packetDataLength)
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +000073{
Narumol Prangnawaratac2770a2020-04-01 16:51:23 +010074 ARMNN_ASSERT(readableData);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +000075
76 // Utils
77 unsigned int uint32_t_size = sizeof(uint32_t);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +000078
Keith Davis97da5e22020-03-05 16:25:28 +000079 // Check the TimelineEventClassBinaryPacket header
Finn Williams0a336dc2020-05-11 15:39:58 +010080 uint32_t timelineBinaryPacketHeaderWord0 = ReadUint32(readableData, offset);
81 uint32_t timelineBinaryPacketFamily = (timelineBinaryPacketHeaderWord0 >> 26) & 0x0000003F;
82 uint32_t timelineBinaryPacketClass = (timelineBinaryPacketHeaderWord0 >> 19) & 0x0000007F;
83 uint32_t timelineBinaryPacketType = (timelineBinaryPacketHeaderWord0 >> 16) & 0x00000007;
84 uint32_t timelineBinaryPacketStreamId = (timelineBinaryPacketHeaderWord0 >> 0) & 0x00000007;
85 BOOST_CHECK(timelineBinaryPacketFamily == 1);
86 BOOST_CHECK(timelineBinaryPacketClass == 0);
87 BOOST_CHECK(timelineBinaryPacketType == 1);
88 BOOST_CHECK(timelineBinaryPacketStreamId == 0);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +000089 offset += uint32_t_size;
Finn Williams0a336dc2020-05-11 15:39:58 +010090 uint32_t timelineBinaryPacketHeaderWord1 = ReadUint32(readableData, offset);
91 uint32_t timelineBinaryPacketSequenceNumber = (timelineBinaryPacketHeaderWord1 >> 24) & 0x00000001;
92 uint32_t timelineBinaryPacketDataLength = (timelineBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF;
93 BOOST_CHECK(timelineBinaryPacketSequenceNumber == 0);
94 BOOST_CHECK(timelineBinaryPacketDataLength == packetDataLength);
Keith Davis97da5e22020-03-05 16:25:28 +000095 offset += uint32_t_size;
96}
97
Jim Flynn6398a982020-05-27 17:05:21 +010098ProfilingGuid VerifyTimelineLabelBinaryPacketData(Optional<ProfilingGuid> guid,
99 const std::string& label,
100 const unsigned char* readableData,
101 unsigned int& offset)
Keith Davis97da5e22020-03-05 16:25:28 +0000102{
Narumol Prangnawaratac2770a2020-04-01 16:51:23 +0100103 ARMNN_ASSERT(readableData);
Keith Davis97da5e22020-03-05 16:25:28 +0000104
105 // Utils
106 unsigned int uint32_t_size = sizeof(uint32_t);
107 unsigned int uint64_t_size = sizeof(uint64_t);
108 unsigned int label_size = boost::numeric_cast<unsigned int>(label.size());
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000109
110 // Check the decl id
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000111 uint32_t eventClassDeclId = ReadUint32(readableData, offset);
112 BOOST_CHECK(eventClassDeclId == 0);
113
114 // Check the profiling GUID
115 offset += uint32_t_size;
116 uint64_t readProfilingGuid = ReadUint64(readableData, offset);
117 if (guid.has_value())
118 {
119 BOOST_CHECK(readProfilingGuid == guid.value());
120 }
121 else
122 {
Sadik Armagan3184c902020-03-18 10:57:30 +0000123 armnn::profiling::ProfilingService profilingService;
124 BOOST_CHECK(readProfilingGuid == profilingService.GetStaticId(label));
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000125 }
126
127 // Check the SWTrace label
128 offset += uint64_t_size;
129 uint32_t swTraceLabelLength = ReadUint32(readableData, offset);
Keith Davis97da5e22020-03-05 16:25:28 +0000130 BOOST_CHECK(swTraceLabelLength == label_size + 1); // Label length including the null-terminator
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000131 offset += uint32_t_size;
132 BOOST_CHECK(std::memcmp(readableData + offset, // Offset to the label in the buffer
Keith Davis97da5e22020-03-05 16:25:28 +0000133 label.data(), // The original label
134 swTraceLabelLength - 1) == 0); // The length of the label
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000135
136 // SWTrace strings are written in blocks of words, so the offset has to be updated to the next whole word
137 offset += OffsetToNextWord(swTraceLabelLength);
Jim Flynn6398a982020-05-27 17:05:21 +0100138
139 ProfilingGuid labelGuid(readProfilingGuid);
140 return labelGuid;
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000141}
142
Keith Davis97da5e22020-03-05 16:25:28 +0000143void VerifyTimelineEventClassBinaryPacketData(ProfilingGuid guid,
Jim Flynn1892d212020-05-26 21:10:49 +0100144 ProfilingGuid nameGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000145 const unsigned char* readableData,
146 unsigned int& offset)
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000147{
Narumol Prangnawaratac2770a2020-04-01 16:51:23 +0100148 ARMNN_ASSERT(readableData);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000149
150 // Utils
151 unsigned int uint32_t_size = sizeof(uint32_t);
152 unsigned int uint64_t_size = sizeof(uint64_t);
153
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000154 // Check the decl id
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000155 uint32_t eventClassDeclId = ReadUint32(readableData, offset);
156 BOOST_CHECK(eventClassDeclId == 2);
157
158 // Check the profiling GUID
159 offset += uint32_t_size;
160 uint64_t readProfilingGuid = ReadUint64(readableData, offset);
161 BOOST_CHECK(readProfilingGuid == guid);
162
Jim Flynn1892d212020-05-26 21:10:49 +0100163 offset += uint64_t_size;
164 uint64_t readProfiilngNameGuid = ReadUint64(readableData, offset);
165 BOOST_CHECK(readProfiilngNameGuid == nameGuid);
166
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000167 // Update the offset to allow parsing to be continued after this function returns
168 offset += uint64_t_size;
169}
170
Keith Davis97da5e22020-03-05 16:25:28 +0000171void VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType relationshipType,
Jim Flynn6398a982020-05-27 17:05:21 +0100172 Optional<ProfilingGuid> relationshipGuid,
173 Optional<ProfilingGuid> headGuid,
174 Optional<ProfilingGuid> tailGuid,
175 Optional<ProfilingGuid> attributeGuid,
176 const unsigned char* readableData,
177 unsigned int& offset)
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000178{
Narumol Prangnawaratac2770a2020-04-01 16:51:23 +0100179 ARMNN_ASSERT(readableData);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000180
181 uint32_t relationshipTypeUint = 0;
182 switch (relationshipType)
183 {
184 case ProfilingRelationshipType::RetentionLink:
185 relationshipTypeUint = 0;
186 break;
187 case ProfilingRelationshipType::ExecutionLink:
188 relationshipTypeUint = 1;
189 break;
190 case ProfilingRelationshipType::DataLink:
191 relationshipTypeUint = 2;
192 break;
193 case ProfilingRelationshipType::LabelLink:
194 relationshipTypeUint = 3;
195 break;
196 default:
197 BOOST_ERROR("Unknown relationship type");
198 }
199
200 // Utils
201 unsigned int uint32_t_size = sizeof(uint32_t);
202 unsigned int uint64_t_size = sizeof(uint64_t);
203
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000204 // Check the decl id
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000205 uint32_t eventClassDeclId = ReadUint32(readableData, offset);
206 BOOST_CHECK(eventClassDeclId == 3);
207
208 // Check the relationship type
209 offset += uint32_t_size;
210 uint32_t readRelationshipTypeUint = ReadUint32(readableData, offset);
211 BOOST_CHECK(readRelationshipTypeUint == relationshipTypeUint);
212
213 // Check the relationship GUID
214 offset += uint32_t_size;
215 uint64_t readRelationshipGuid = ReadUint64(readableData, offset);
216 if (relationshipGuid.has_value())
217 {
218 BOOST_CHECK(readRelationshipGuid == relationshipGuid.value());
219 }
220 else
221 {
222 BOOST_CHECK(readRelationshipGuid != ProfilingGuid(0));
223 }
224
Jim Flynn6398a982020-05-27 17:05:21 +0100225 // Check the head GUID of the relationship
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000226 offset += uint64_t_size;
227 uint64_t readHeadRelationshipGuid = ReadUint64(readableData, offset);
228 if (headGuid.has_value())
229 {
230 BOOST_CHECK(readHeadRelationshipGuid == headGuid.value());
231 }
232 else
233 {
234 BOOST_CHECK(readHeadRelationshipGuid != ProfilingGuid(0));
235 }
236
Jim Flynn6398a982020-05-27 17:05:21 +0100237 // Check the tail GUID of the relationship
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000238 offset += uint64_t_size;
239 uint64_t readTailRelationshipGuid = ReadUint64(readableData, offset);
240 if (tailGuid.has_value())
241 {
242 BOOST_CHECK(readTailRelationshipGuid == tailGuid.value());
243 }
244 else
245 {
246 BOOST_CHECK(readTailRelationshipGuid != ProfilingGuid(0));
247 }
248
Jim Flynn6398a982020-05-27 17:05:21 +0100249 // Check the attribute GUID of the relationship
Finn Williams0a336dc2020-05-11 15:39:58 +0100250 offset += uint64_t_size;
251 uint64_t readAttributeRelationshipGuid = ReadUint64(readableData, offset);
252 if (attributeGuid.has_value())
253 {
254 BOOST_CHECK(readAttributeRelationshipGuid == attributeGuid.value());
255 }
256 else
257 {
258 BOOST_CHECK(readAttributeRelationshipGuid == ProfilingGuid(0));
259 }
260
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000261 // Update the offset to allow parsing to be continued after this function returns
262 offset += uint64_t_size;
263}
264
Jim Flynn6398a982020-05-27 17:05:21 +0100265ProfilingGuid VerifyTimelineEntityBinaryPacketData(Optional<ProfilingGuid> guid,
266 const unsigned char* readableData,
267 unsigned int& offset)
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000268{
Narumol Prangnawaratac2770a2020-04-01 16:51:23 +0100269 ARMNN_ASSERT(readableData);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000270
271 // Utils
272 unsigned int uint32_t_size = sizeof(uint32_t);
273 unsigned int uint64_t_size = sizeof(uint64_t);
274
275 // Reading TimelineEntityClassBinaryPacket
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000276 // Check the decl_id
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000277 uint32_t entityDeclId = ReadUint32(readableData, offset);
278 BOOST_CHECK(entityDeclId == 1);
279
280 // Check the profiling GUID
281 offset += uint32_t_size;
282 uint64_t readProfilingGuid = ReadUint64(readableData, offset);
283
284 if (guid.has_value())
285 {
286 BOOST_CHECK(readProfilingGuid == guid.value());
287 }
288 else
289 {
290 BOOST_CHECK(readProfilingGuid != ProfilingGuid(0));
291 }
292
293 offset += uint64_t_size;
Jim Flynn6398a982020-05-27 17:05:21 +0100294
295 ProfilingGuid entityGuid(readProfilingGuid);
296 return entityGuid;
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000297}
298
Jim Flynn6398a982020-05-27 17:05:21 +0100299ProfilingGuid VerifyTimelineEventBinaryPacket(Optional<uint64_t> timestamp,
Jim Flynn1fdeb992020-07-09 07:28:37 +0100300 Optional<int> threadId,
Jim Flynn6398a982020-05-27 17:05:21 +0100301 Optional<ProfilingGuid> eventGuid,
302 const unsigned char* readableData,
303 unsigned int& offset)
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000304{
Narumol Prangnawaratac2770a2020-04-01 16:51:23 +0100305 ARMNN_ASSERT(readableData);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000306
307 // Utils
308 unsigned int uint32_t_size = sizeof(uint32_t);
309 unsigned int uint64_t_size = sizeof(uint64_t);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000310
311 // Reading TimelineEventBinaryPacket
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000312 // Check the decl_id
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000313 uint32_t entityDeclId = ReadUint32(readableData, offset);
314 BOOST_CHECK(entityDeclId == 4);
315
316 // Check the timestamp
317 offset += uint32_t_size;
318 uint64_t readTimestamp = ReadUint64(readableData, offset);
319 if (timestamp.has_value())
320 {
321 BOOST_CHECK(readTimestamp == timestamp.value());
322 }
323 else
324 {
325 BOOST_CHECK(readTimestamp != 0);
326 }
327
328 // Check the thread id
329 offset += uint64_t_size;
Colm Donelan5bb3d8a2020-05-12 16:36:46 +0100330 std::vector<uint8_t> readThreadId(ThreadIdSize, 0);
331 ReadBytes(readableData, offset, ThreadIdSize, readThreadId.data());
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000332 if (threadId.has_value())
333 {
334 BOOST_CHECK(readThreadId == threadId.value());
335 }
336 else
337 {
Jim Flynn1fdeb992020-07-09 07:28:37 +0100338 BOOST_CHECK(readThreadId == armnnUtils::Threads::GetCurrentThreadId());
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000339 }
340
341 // Check the event GUID
Colm Donelan5bb3d8a2020-05-12 16:36:46 +0100342 offset += ThreadIdSize;
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000343 uint64_t readEventGuid = ReadUint64(readableData, offset);
344 if (eventGuid.has_value())
345 {
346 BOOST_CHECK(readEventGuid == eventGuid.value());
347 }
348 else
349 {
350 BOOST_CHECK(readEventGuid != ProfilingGuid(0));
351 }
352
353 offset += uint64_t_size;
Jim Flynn6398a982020-05-27 17:05:21 +0100354
355 ProfilingGuid eventid(readEventGuid);
356 return eventid;
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000357}
358
359void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId)
360{
361 using namespace armnn;
362
363 // Create runtime in which test will run
364 armnn::IRuntime::CreationOptions options;
365 options.m_ProfilingOptions.m_EnableProfiling = true;
Keith Davis33ed2212020-03-30 10:43:41 +0100366 options.m_ProfilingOptions.m_TimelineEnabled = true;
Sadik Armagan3184c902020-03-18 10:57:30 +0000367 armnn::Runtime runtime(options);
Keith Davis33ed2212020-03-30 10:43:41 +0100368 GetProfilingService(&runtime).ResetExternalProfilingOptions(options.m_ProfilingOptions, false);
369
370 profiling::ProfilingServiceRuntimeHelper profilingServiceHelper(GetProfilingService(&runtime));
371 profilingServiceHelper.ForceTransitionToState(ProfilingState::NotConnected);
372 profilingServiceHelper.ForceTransitionToState(ProfilingState::WaitingForAck);
373 profilingServiceHelper.ForceTransitionToState(ProfilingState::Active);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000374
375 // build up the structure of the network
376 INetworkPtr net(INetwork::Create());
377
378 // Convolution details
379 TensorInfo inputInfo({ 1, 2, 5, 1 }, DataType::Float32);
Keith Davis97da5e22020-03-05 16:25:28 +0000380 TensorInfo weightInfo({ 3, 2, 3, 1 }, DataType::Float32);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000381 TensorInfo biasInfo({ 3 }, DataType::Float32);
Keith Davis97da5e22020-03-05 16:25:28 +0000382 TensorInfo outputInfo({ 1, 3, 7, 1 }, DataType::Float32);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000383 std::vector<float> weightsData{
Keith Davis97da5e22020-03-05 16:25:28 +0000384 1.0f, 0.0f, 0.0f,
385 0.0f, 2.0f, -1.5f,
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000386
Keith Davis97da5e22020-03-05 16:25:28 +0000387 0.0f, 0.0f, 0.0f,
388 0.2f, 0.2f, 0.2f,
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000389
Keith Davis97da5e22020-03-05 16:25:28 +0000390 0.5f, 0.0f, 0.5f,
391 0.0f, -1.0f, 0.0f
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000392 };
393 ConstTensor weights(weightInfo, weightsData);
394
395 Optional<ConstTensor> optionalBiases;
396 std::vector<float> biasesData{ 1.0f, 0.0f, 0.0f };
397 ConstTensor biases(biasInfo, biasesData);
398 optionalBiases = Optional<ConstTensor>(biases);
399
400 // Input layer
401 IConnectableLayer* input = net->AddInputLayer(0, "input");
402
403 // Convolution2d layer
404 Convolution2dDescriptor conv2dDesc;
Keith Davis97da5e22020-03-05 16:25:28 +0000405 conv2dDesc.m_StrideX = 1;
406 conv2dDesc.m_StrideY = 1;
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000407 conv2dDesc.m_PadLeft = 0;
408 conv2dDesc.m_PadRight = 0;
409 conv2dDesc.m_PadTop = 2;
410 conv2dDesc.m_PadBottom = 2;
411 conv2dDesc.m_BiasEnabled = true;
412 IConnectableLayer* conv2d = net->AddConvolution2dLayer(conv2dDesc, weights, optionalBiases);
413
414 // Activation layer
415 armnn::ActivationDescriptor activationDesc;
416 armnn::IConnectableLayer* const activation = net->AddActivationLayer(activationDesc, "activation");
417
418 // Output layer
419 IConnectableLayer* output = net->AddOutputLayer(0, "output");
420
421 input->GetOutputSlot(0).Connect(conv2d->GetInputSlot(0));
422 conv2d->GetOutputSlot(0).Connect(activation->GetInputSlot(0));
423 activation->GetOutputSlot(0).Connect(output->GetInputSlot(0));
424
425 input->GetOutputSlot(0).SetTensorInfo(inputInfo);
426 conv2d->GetOutputSlot(0).SetTensorInfo(outputInfo);
427 activation->GetOutputSlot(0).SetTensorInfo(outputInfo);
428
429 // optimize the network
430 std::vector<armnn::BackendId> backends = { backendId };
Sadik Armagan3184c902020-03-18 10:57:30 +0000431 IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime.GetDeviceSpec());
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000432
433 ProfilingGuid optNetGuid = optNet->GetGuid();
434
435 // Load it into the runtime. It should success.
436 armnn::NetworkId netId;
Sadik Armagan3184c902020-03-18 10:57:30 +0000437 BOOST_TEST(runtime.LoadNetwork(netId, std::move(optNet)) == Status::Success);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000438
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000439 profiling::BufferManager& bufferManager = profilingServiceHelper.GetProfilingBufferManager();
440 auto readableBuffer = bufferManager.GetReadableBuffer();
441
Jim Flynnf7713212020-07-14 09:50:59 +0100442 // Profiling is enabled, the post-optimisation structure should be created
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000443 BOOST_CHECK(readableBuffer != nullptr);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000444 unsigned int size = readableBuffer->GetSize();
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000445
446 const unsigned char* readableData = readableBuffer->GetReadableData();
447 BOOST_CHECK(readableData != nullptr);
448
449 unsigned int offset = 0;
450
Keith Davis97da5e22020-03-05 16:25:28 +0000451 // Verify Header
Jim Flynnf7713212020-07-14 09:50:59 +0100452 VerifyTimelineHeaderBinary(readableData, offset, size - 8);
Jim Flynn6398a982020-05-27 17:05:21 +0100453 BOOST_TEST_MESSAGE("HEADER OK");
Keith Davis97da5e22020-03-05 16:25:28 +0000454
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000455 // Post-optimisation network
456 // Network entity
Keith Davis97da5e22020-03-05 16:25:28 +0000457 VerifyTimelineEntityBinaryPacketData(optNetGuid, readableData, offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100458 BOOST_TEST_MESSAGE("NETWORK ENTITY OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000459
460 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000461 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
462 EmptyOptional(),
463 optNetGuid,
Jim Flynn6398a982020-05-27 17:05:21 +0100464 LabelsAndEventClasses::NETWORK_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000465 LabelsAndEventClasses::TYPE_GUID,
466 readableData,
467 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100468 BOOST_TEST_MESSAGE("NETWORK TYPE RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000469
Jim Flynnf7713212020-07-14 09:50:59 +0100470 // Network - START OF LIFE
471 ProfilingGuid networkSolEventGuid = VerifyTimelineEventBinaryPacket(EmptyOptional(),
472 EmptyOptional(),
473 EmptyOptional(),
474 readableData,
475 offset);
476 BOOST_TEST_MESSAGE("NETWORK START OF LIFE EVENT OK");
477
478 // Network - START OF LIFE event relationship
479 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
480 EmptyOptional(),
481 optNetGuid,
482 networkSolEventGuid,
483 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
484 readableData,
485 offset);
486 BOOST_TEST_MESSAGE("NETWORK START OF LIFE RELATIONSHIP OK");
487
488 // Process ID Label
489 int processID = armnnUtils::Processes::GetCurrentId();
490 std::stringstream ss;
491 ss << processID;
492 std::string processIdLabel = ss.str();
493 VerifyTimelineLabelBinaryPacketData(EmptyOptional(), processIdLabel, readableData, offset);
494 BOOST_TEST_MESSAGE("PROCESS ID LABEL OK");
495
496 // Entity - Process ID relationship
497 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
498 EmptyOptional(),
499 optNetGuid,
500 EmptyOptional(),
501 LabelsAndEventClasses::PROCESS_ID_GUID,
502 readableData,
503 offset);
504 BOOST_TEST_MESSAGE("NETWORK PROCESS ID RELATIONSHIP OK");
505
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000506 // Input layer
507 // Input layer entity
Keith Davis97da5e22020-03-05 16:25:28 +0000508 VerifyTimelineEntityBinaryPacketData(input->GetGuid(), readableData, offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100509 BOOST_TEST_MESSAGE("INPUT ENTITY OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000510
511 // Name Entity
Jim Flynn6398a982020-05-27 17:05:21 +0100512 ProfilingGuid inputLabelGuid = VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "input", readableData, offset);
513 BOOST_TEST_MESSAGE("INPUT NAME LABEL OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000514
515 // Entity - Name relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000516 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
517 EmptyOptional(),
518 input->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100519 inputLabelGuid,
Finn Williams0a336dc2020-05-11 15:39:58 +0100520 LabelsAndEventClasses::NAME_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000521 readableData,
522 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100523 BOOST_TEST_MESSAGE("INPUT NAME RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000524
525 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000526 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
527 EmptyOptional(),
528 input->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100529 LabelsAndEventClasses::LAYER_GUID,
Finn Williams0a336dc2020-05-11 15:39:58 +0100530 LabelsAndEventClasses::TYPE_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000531 readableData,
532 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100533 BOOST_TEST_MESSAGE("INPUT TYPE RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000534
535 // Network - Input layer relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000536 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
537 EmptyOptional(),
538 optNetGuid,
539 input->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100540 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000541 readableData,
542 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100543 BOOST_TEST_MESSAGE("NETWORK - INPUT CHILD RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000544
545 // Conv2d layer
546 // Conv2d layer entity
Keith Davis97da5e22020-03-05 16:25:28 +0000547 VerifyTimelineEntityBinaryPacketData(conv2d->GetGuid(), readableData, offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000548
549 // Name entity
Jim Flynn6398a982020-05-27 17:05:21 +0100550 ProfilingGuid conv2dNameLabelGuid = VerifyTimelineLabelBinaryPacketData(
551 EmptyOptional(), "<Unnamed>", readableData, offset);
552 BOOST_TEST_MESSAGE("CONV2D NAME LABEL OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000553
554 // Entity - Name relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000555 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
556 EmptyOptional(),
557 conv2d->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100558 conv2dNameLabelGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000559 LabelsAndEventClasses::NAME_GUID,
560 readableData,
561 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100562 BOOST_TEST_MESSAGE("CONV2D NAME RELATIONSHIP 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(),
567 conv2d->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100568 LabelsAndEventClasses::LAYER_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 TYPE RELATIONSHIP OK");
Finn Williams0a336dc2020-05-11 15:39:58 +0100573
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000574 // Network - Conv2d layer relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000575 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
576 EmptyOptional(),
577 optNetGuid,
578 conv2d->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100579 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000580 readableData,
581 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100582 BOOST_TEST_MESSAGE("NETWORK - CONV2D CHILD RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000583
584 // Input layer - Conv2d layer relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000585 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
586 EmptyOptional(),
587 input->GetGuid(),
588 conv2d->GetGuid(),
Keith Davis97da5e22020-03-05 16:25:28 +0000589 LabelsAndEventClasses::CONNECTION_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000590 readableData,
591 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100592 BOOST_TEST_MESSAGE("INPUT - CONV2D LAYER CONNECTION OK");
Finn Williams0a336dc2020-05-11 15:39:58 +0100593
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000594 // Conv2d workload
595 // Conv2d workload entity
Jim Flynn6398a982020-05-27 17:05:21 +0100596 ProfilingGuid conv2DWorkloadGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
597 BOOST_TEST_MESSAGE("CONV2D WORKLOAD ENTITY OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000598
599 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000600 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
601 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100602 conv2DWorkloadGuid,
603 LabelsAndEventClasses::WORKLOAD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000604 LabelsAndEventClasses::TYPE_GUID,
605 readableData,
606 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100607 BOOST_TEST_MESSAGE("CONV2D WORKLOAD TYPE RELATIONSHIP OK");
Finn Williams0a336dc2020-05-11 15:39:58 +0100608
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000609 // BackendId entity
Jim Flynn6398a982020-05-27 17:05:21 +0100610 ProfilingGuid backendIdLabelGuid = VerifyTimelineLabelBinaryPacketData(
611 EmptyOptional(), backendId.Get(), readableData, offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000612
613 // Entity - BackendId relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000614 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
615 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100616 conv2DWorkloadGuid,
617 backendIdLabelGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000618 LabelsAndEventClasses::BACKENDID_GUID,
619 readableData,
620 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100621 BOOST_TEST_MESSAGE("CONV2D WORKLOAD BACKEND ID RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000622
Finn Williams0a336dc2020-05-11 15:39:58 +0100623
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000624 // Conv2d layer - Conv2d workload relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000625 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
626 EmptyOptional(),
627 conv2d->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100628 conv2DWorkloadGuid,
629 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000630 readableData,
631 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100632 BOOST_TEST_MESSAGE("CONV2D LAYER - WORKLOAD CHILD RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000633
634 // Activation layer
635 // Activation layer entity
Keith Davis97da5e22020-03-05 16:25:28 +0000636 VerifyTimelineEntityBinaryPacketData(activation->GetGuid(), readableData, offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100637 BOOST_TEST_MESSAGE("ACTIVATION ENTITY OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000638
639 // Name entity
Jim Flynn6398a982020-05-27 17:05:21 +0100640 ProfilingGuid activationLabelGuid = VerifyTimelineLabelBinaryPacketData(
641 EmptyOptional(), "activation", readableData, offset);
642 BOOST_TEST_MESSAGE("ACTIVATION NAME LABEL OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000643
644 // Entity - Name relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000645 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
646 EmptyOptional(),
647 activation->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100648 activationLabelGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000649 LabelsAndEventClasses::NAME_GUID,
650 readableData,
651 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100652 BOOST_TEST_MESSAGE("ACTIVATION LAYER - NAME RELATIONSHIP 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(),
657 activation->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100658 LabelsAndEventClasses::LAYER_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 LAYER TYPE RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000663
664 // Network - Activation layer relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000665 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
666 EmptyOptional(),
667 optNetGuid,
668 activation->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100669 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000670 readableData,
671 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100672 BOOST_TEST_MESSAGE("NETWORK - ACTIVATION LAYER CHILD RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000673
674 // Conv2d layer - Activation layer relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000675 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
676 EmptyOptional(),
677 conv2d->GetGuid(),
678 activation->GetGuid(),
Keith Davis97da5e22020-03-05 16:25:28 +0000679 LabelsAndEventClasses::CONNECTION_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000680 readableData,
681 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100682 BOOST_TEST_MESSAGE("CONV2D LAYER - ACTIVATION LAYER CONNECTION OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000683
684 // Activation workload
685 // Activation workload entity
Jim Flynn6398a982020-05-27 17:05:21 +0100686 ProfilingGuid activationWorkloadGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
687 BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD ENTITY OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000688
689 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000690 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
691 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100692 activationWorkloadGuid,
693 LabelsAndEventClasses::WORKLOAD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000694 LabelsAndEventClasses::TYPE_GUID,
695 readableData,
696 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100697 BOOST_TEST_MESSAGE("ACTIVATION WORKLAD TYPE RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000698
699 // BackendId entity
Keith Davis97da5e22020-03-05 16:25:28 +0000700 VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100701 BOOST_TEST_MESSAGE("BACKEND ID LABEL OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000702
703 // Entity - BackendId relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000704 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
705 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100706 activationWorkloadGuid,
707 backendIdLabelGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000708 LabelsAndEventClasses::BACKENDID_GUID,
709 readableData,
710 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100711 BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD BACKEND ID RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000712
713 // Activation layer - Activation workload relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000714 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
715 EmptyOptional(),
716 activation->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100717 activationWorkloadGuid,
718 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000719 readableData,
720 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100721 BOOST_TEST_MESSAGE("ACTIVATION LAYER - WORKLOAD CHILD RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000722
723 // Output layer
724 // Output layer entity
Keith Davis97da5e22020-03-05 16:25:28 +0000725 VerifyTimelineEntityBinaryPacketData(output->GetGuid(), readableData, offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100726 BOOST_TEST_MESSAGE("OUTPUT LAYER ENTITY OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000727
728 // Name entity
Jim Flynn6398a982020-05-27 17:05:21 +0100729 ProfilingGuid outputLabelGuid = VerifyTimelineLabelBinaryPacketData(
730 EmptyOptional(), "output", readableData, offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000731
732 // Entity - Name relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000733 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
734 EmptyOptional(),
735 output->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100736 outputLabelGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000737 LabelsAndEventClasses::NAME_GUID,
738 readableData,
739 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100740 BOOST_TEST_MESSAGE("OUTPUT LAYER NAME RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000741
742 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000743 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
744 EmptyOptional(),
745 output->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100746 LabelsAndEventClasses::LAYER_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000747 LabelsAndEventClasses::TYPE_GUID,
748 readableData,
749 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100750 BOOST_TEST_MESSAGE("OUTPUT LAYER TYPE RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000751
752 // Network - Output layer relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000753 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
754 EmptyOptional(),
755 optNetGuid,
756 output->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100757 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000758 readableData,
759 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100760 BOOST_TEST_MESSAGE("NETWORK - OUTPUT LAYER CHILD RELATIONSHIP OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000761
762 // Activation layer - Output layer relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000763 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
764 EmptyOptional(),
765 activation->GetGuid(),
766 output->GetGuid(),
Keith Davis97da5e22020-03-05 16:25:28 +0000767 LabelsAndEventClasses::CONNECTION_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000768 readableData,
769 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100770 BOOST_TEST_MESSAGE("ACTIVATION LAYER - OUTPUT LAYER CONNECTION OK");
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000771
772 bufferManager.MarkRead(readableBuffer);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000773
774 // Creates structures for input & output.
775 std::vector<float> inputData(inputInfo.GetNumElements());
776 std::vector<float> outputData(outputInfo.GetNumElements());
777
778 InputTensors inputTensors
Keith Davis97da5e22020-03-05 16:25:28 +0000779 {
Sadik Armagan3184c902020-03-18 10:57:30 +0000780 {0, ConstTensor(runtime.GetInputTensorInfo(netId, 0), inputData.data())}
Keith Davis97da5e22020-03-05 16:25:28 +0000781 };
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000782 OutputTensors outputTensors
Keith Davis97da5e22020-03-05 16:25:28 +0000783 {
Sadik Armagan3184c902020-03-18 10:57:30 +0000784 {0, Tensor(runtime.GetOutputTensorInfo(netId, 0), outputData.data())}
Keith Davis97da5e22020-03-05 16:25:28 +0000785 };
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000786
787 // Does the inference.
Sadik Armagan3184c902020-03-18 10:57:30 +0000788 runtime.EnqueueWorkload(netId, inputTensors, outputTensors);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000789
Finn Williamsb6a402f2020-03-24 13:46:22 +0000790 // Get readable buffer for input workload
791 auto inputReadableBuffer = bufferManager.GetReadableBuffer();
792 BOOST_CHECK(inputReadableBuffer != nullptr);
David Monahan6198fe02019-12-02 08:35:43 +0000793
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000794 // Get readable buffer for output workload
795 auto outputReadableBuffer = bufferManager.GetReadableBuffer();
796 BOOST_CHECK(outputReadableBuffer != nullptr);
797
Finn Williamsb6a402f2020-03-24 13:46:22 +0000798 // Get readable buffer for inference timeline
799 auto inferenceReadableBuffer = bufferManager.GetReadableBuffer();
800 BOOST_CHECK(inferenceReadableBuffer != nullptr);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000801
802 // Validate input workload data
803 size = inputReadableBuffer->GetSize();
Finn Williams0a336dc2020-05-11 15:39:58 +0100804 BOOST_CHECK(size == 164);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000805
806 readableData = inputReadableBuffer->GetReadableData();
807 BOOST_CHECK(readableData != nullptr);
808
809 offset = 0;
810
Keith Davis97da5e22020-03-05 16:25:28 +0000811 // Verify Header
Finn Williams0a336dc2020-05-11 15:39:58 +0100812 VerifyTimelineHeaderBinary(readableData, offset, 156);
Jim Flynn6398a982020-05-27 17:05:21 +0100813 BOOST_TEST_MESSAGE("INPUT WORKLOAD HEADER OK");
Keith Davis97da5e22020-03-05 16:25:28 +0000814
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000815 // Input workload
816 // Input workload entity
Jim Flynn6398a982020-05-27 17:05:21 +0100817 ProfilingGuid inputWorkloadGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
818 BOOST_TEST_MESSAGE("INPUT WORKLOAD TYPE RELATIONSHIP OK");
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000819
820 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000821 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
822 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100823 inputWorkloadGuid,
824 LabelsAndEventClasses::WORKLOAD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000825 LabelsAndEventClasses::TYPE_GUID,
826 readableData,
827 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100828 BOOST_TEST_MESSAGE("INPUT WORKLOAD TYPE RELATIONSHIP OK");
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000829
830 // BackendId entity
Keith Davis97da5e22020-03-05 16:25:28 +0000831 VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000832
833 // Entity - BackendId relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000834 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
835 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100836 inputWorkloadGuid,
837 backendIdLabelGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000838 LabelsAndEventClasses::BACKENDID_GUID,
839 readableData,
840 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100841 BOOST_TEST_MESSAGE("INPUT WORKLOAD BACKEND ID RELATIONSHIP OK");
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000842
843 // Input layer - Input workload relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000844 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
845 EmptyOptional(),
846 input->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100847 inputWorkloadGuid,
848 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000849 readableData,
850 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100851 BOOST_TEST_MESSAGE("INPUT LAYER - INPUT WORKLOAD CHILD RELATIONSHIP OK");
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000852
853 bufferManager.MarkRead(inputReadableBuffer);
854
855 // Validate output workload data
856 size = outputReadableBuffer->GetSize();
Finn Williams0a336dc2020-05-11 15:39:58 +0100857 BOOST_CHECK(size == 164);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000858
859 readableData = outputReadableBuffer->GetReadableData();
860 BOOST_CHECK(readableData != nullptr);
861
862 offset = 0;
863
Keith Davis97da5e22020-03-05 16:25:28 +0000864 // Verify Header
Finn Williams0a336dc2020-05-11 15:39:58 +0100865 VerifyTimelineHeaderBinary(readableData, offset, 156);
Jim Flynn6398a982020-05-27 17:05:21 +0100866 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD HEADER OK");
Keith Davis97da5e22020-03-05 16:25:28 +0000867
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000868 // Output workload
869 // Output workload entity
Jim Flynn6398a982020-05-27 17:05:21 +0100870 ProfilingGuid outputWorkloadGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
871 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD ENTITY OK");
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000872
873 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000874 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
875 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100876 outputWorkloadGuid,
877 LabelsAndEventClasses::WORKLOAD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000878 LabelsAndEventClasses::TYPE_GUID,
879 readableData,
880 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100881 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD TYPE RELATIONSHIP OK");
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000882
883 // BackendId entity
Keith Davis97da5e22020-03-05 16:25:28 +0000884 VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100885 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD LABEL OK");
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000886
887 // Entity - BackendId relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000888 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
889 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100890 outputWorkloadGuid,
891 backendIdLabelGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000892 LabelsAndEventClasses::BACKENDID_GUID,
893 readableData,
894 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100895 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD BACKEND ID RELATIONSHIP OK");
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000896
897 // Output layer - Output workload relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000898 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
899 EmptyOptional(),
900 output->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100901 outputWorkloadGuid,
902 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000903 readableData,
904 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100905 BOOST_TEST_MESSAGE("OUTPUT LAYER - OUTPUT WORKLOAD CHILD RELATIONSHIP OK");
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000906
907 bufferManager.MarkRead(outputReadableBuffer);
David Monahan6198fe02019-12-02 08:35:43 +0000908
909 // Validate inference data
910 size = inferenceReadableBuffer->GetSize();
Jan Eilersa10e2a22020-03-26 12:04:54 +0000911
Finn Williams0a336dc2020-05-11 15:39:58 +0100912 BOOST_CHECK(size == 1228 + 10 * ThreadIdSize);
David Monahan6198fe02019-12-02 08:35:43 +0000913
914 readableData = inferenceReadableBuffer->GetReadableData();
915 BOOST_CHECK(readableData != nullptr);
916
917 offset = 0;
918
Keith Davis97da5e22020-03-05 16:25:28 +0000919 // Verify Header
Finn Williams0a336dc2020-05-11 15:39:58 +0100920 VerifyTimelineHeaderBinary(readableData, offset, 1220 + 10 * ThreadIdSize);
Jim Flynn6398a982020-05-27 17:05:21 +0100921 BOOST_TEST_MESSAGE("INFERENCE HEADER OK");
Keith Davis97da5e22020-03-05 16:25:28 +0000922
David Monahan6198fe02019-12-02 08:35:43 +0000923 // Inference timeline trace
924 // Inference entity
Jim Flynn6398a982020-05-27 17:05:21 +0100925 ProfilingGuid inferenceGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
926 BOOST_TEST_MESSAGE("INFERENCE ENTITY OK");
David Monahan6198fe02019-12-02 08:35:43 +0000927
928 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000929 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
930 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100931 inferenceGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000932 LabelsAndEventClasses::INFERENCE_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000933 LabelsAndEventClasses::TYPE_GUID,
934 readableData,
935 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100936 BOOST_TEST_MESSAGE("INFERENCE TYPE RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +0000937
938 // Network - Inference relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000939 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
940 EmptyOptional(),
941 optNetGuid,
Jim Flynn6398a982020-05-27 17:05:21 +0100942 inferenceGuid,
943 LabelsAndEventClasses::EXECUTION_OF_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000944 readableData,
945 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100946 BOOST_TEST_MESSAGE("NETWORK - INFERENCE EXECUTION_OF RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +0000947
948 // Start Inference life
949 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +0100950 ProfilingGuid inferenceEventGuid = VerifyTimelineEventBinaryPacket(
951 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
952 BOOST_TEST_MESSAGE("INFERENCE START OF LIFE EVENT OK");
David Monahan6198fe02019-12-02 08:35:43 +0000953
954 // Inference - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000955 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
956 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100957 inferenceGuid,
958 inferenceEventGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000959 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
960 readableData,
961 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100962 BOOST_TEST_MESSAGE("INFERENCE START OF LIFE RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +0000963
964 // Execution
965 // Input workload execution
966 // Input workload execution entity
Jim Flynn6398a982020-05-27 17:05:21 +0100967 ProfilingGuid inputWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
968 EmptyOptional(), readableData, offset);
969 BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION ENTITY OK");
David Monahan6198fe02019-12-02 08:35:43 +0000970
971 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000972 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
973 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100974 inputWorkloadExecutionGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000975 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000976 LabelsAndEventClasses::TYPE_GUID,
977 readableData,
978 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100979 BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION TYPE RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +0000980
981 // Inference - Workload execution relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000982 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
983 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100984 inferenceGuid,
985 inputWorkloadExecutionGuid,
986 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000987 readableData,
988 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100989 BOOST_TEST_MESSAGE("INPUT WORKLOAD - INPUT WORKLOAD EXECUTION RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +0000990
991 // Workload - Workload execution relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000992 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
993 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100994 inputWorkloadGuid,
995 inputWorkloadExecutionGuid,
996 LabelsAndEventClasses::EXECUTION_OF_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000997 readableData,
998 offset);
Jim Flynn6398a982020-05-27 17:05:21 +0100999 BOOST_TEST_MESSAGE("INPUT WORKLOAD - INPUT WORKLOAD EXECUTION RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001000
1001 // Start Input workload execution life
1002 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +01001003 ProfilingGuid inputWorkloadExecutionSOLEventId = VerifyTimelineEventBinaryPacket(
1004 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1005 BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION - START OF LIFE EVENT OK");
David Monahan6198fe02019-12-02 08:35:43 +00001006
1007 // Input workload execution - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001008 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1009 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001010 inputWorkloadExecutionGuid,
1011 inputWorkloadExecutionSOLEventId,
Keith Davis97da5e22020-03-05 16:25:28 +00001012 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1013 readableData,
1014 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001015 BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION - START OF LIFE EVENT RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001016
1017 // End of Input workload execution life
1018 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +01001019 ProfilingGuid inputWorkloadExecutionEOLEventId = VerifyTimelineEventBinaryPacket(
1020 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1021 BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION - END OF LIFE EVENT OK");
David Monahan6198fe02019-12-02 08:35:43 +00001022
1023 // Input workload execution - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001024 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1025 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001026 inputWorkloadExecutionGuid,
1027 inputWorkloadExecutionEOLEventId,
Keith Davis97da5e22020-03-05 16:25:28 +00001028 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1029 readableData,
1030 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001031 BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION - END OF LIFE EVENT RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001032
1033 // Conv2d workload execution
1034 // Conv2d workload execution entity
Jim Flynn6398a982020-05-27 17:05:21 +01001035 ProfilingGuid conv2DWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
1036 EmptyOptional(), readableData, offset);
1037 BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION ENTITY OK");
David Monahan6198fe02019-12-02 08:35:43 +00001038
1039 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001040 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1041 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001042 conv2DWorkloadExecutionGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001043 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +00001044 LabelsAndEventClasses::TYPE_GUID,
1045 readableData,
1046 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001047 BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION TYPE RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001048
1049 // Inference - Workload execution relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001050 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1051 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001052 inferenceGuid,
1053 conv2DWorkloadExecutionGuid,
1054 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +00001055 readableData,
1056 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001057 BOOST_TEST_MESSAGE("INFERENCE - CONV2D WORKLOAD EXECUTION CHILD RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001058
1059 // Workload - Workload execution relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001060 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1061 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001062 conv2DWorkloadGuid,
1063 conv2DWorkloadExecutionGuid,
1064 LabelsAndEventClasses::EXECUTION_OF_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +00001065 readableData,
1066 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001067 BOOST_TEST_MESSAGE("CONV2D WORKLOAD - CONV2D WORKLOAD EXECUTION RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001068
1069 // Start Conv2d workload execution life
1070 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +01001071 ProfilingGuid conv2DWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket(
1072 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1073 BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION START OF LIFE EVENT OK");
David Monahan6198fe02019-12-02 08:35:43 +00001074
1075 // Conv2d workload execution - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001076 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1077 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001078 conv2DWorkloadExecutionGuid,
1079 conv2DWorkloadExecutionSOLEventGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001080 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1081 readableData,
1082 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001083 BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION START OF LIFE RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001084
1085 // End of Conv2d workload execution life
1086 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +01001087 ProfilingGuid conv2DWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket(
1088 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1089 BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION END OF LIFE EVENT OK");
David Monahan6198fe02019-12-02 08:35:43 +00001090
1091 // Conv2d workload execution - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001092 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1093 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001094 conv2DWorkloadExecutionGuid,
1095 conv2DWorkloadExecutionEOLEventGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001096 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1097 readableData,
1098 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001099 BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION END OF LIFE RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001100
1101 // Activation workload execution
1102 // Activation workload execution entity
Jim Flynn6398a982020-05-27 17:05:21 +01001103 ProfilingGuid activationWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
1104 EmptyOptional(), readableData, offset);
1105 BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION ENTITY OK");
David Monahan6198fe02019-12-02 08:35:43 +00001106
1107 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001108 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1109 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001110 activationWorkloadExecutionGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001111 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +00001112 LabelsAndEventClasses::TYPE_GUID,
1113 readableData,
1114 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001115 BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION TYPE RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001116
1117 // Inference - Workload execution relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001118 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1119 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001120 inferenceGuid,
1121 activationWorkloadExecutionGuid,
1122 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +00001123 readableData,
1124 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001125 BOOST_TEST_MESSAGE("INFERENCE - ACTIVATION WORKLOAD EXECUTION CHILD RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001126
1127 // Workload - Workload execution relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001128 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1129 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001130 activationWorkloadGuid,
1131 activationWorkloadExecutionGuid,
1132 LabelsAndEventClasses::EXECUTION_OF_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +00001133 readableData,
1134 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001135 BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD - ACTIVATION WORKLOAD EXECUTION RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001136
1137 // Start Activation workload execution life
1138 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +01001139 ProfilingGuid activationWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket(
1140 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1141 BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION START OF LIFE EVENT OK");
David Monahan6198fe02019-12-02 08:35:43 +00001142
1143 // Activation workload execution - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001144 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1145 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001146 activationWorkloadExecutionGuid,
1147 activationWorkloadExecutionSOLEventGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001148 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1149 readableData,
1150 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001151 BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION START OF LIFE RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001152
1153 // End of Activation workload execution life
1154 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +01001155 ProfilingGuid activationWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket(
1156 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1157 BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION END OF LIFE EVENT OK");
David Monahan6198fe02019-12-02 08:35:43 +00001158
1159 // Activation workload execution - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001160 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1161 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001162 activationWorkloadExecutionGuid,
1163 activationWorkloadExecutionEOLEventGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001164 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1165 readableData,
1166 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001167 BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION END OF LIFE RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001168
1169 // Output workload execution
1170 // Output workload execution entity
Jim Flynn6398a982020-05-27 17:05:21 +01001171 ProfilingGuid outputWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
1172 EmptyOptional(), readableData, offset);
1173 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION ENTITY OK");
David Monahan6198fe02019-12-02 08:35:43 +00001174
1175 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001176 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1177 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001178 outputWorkloadExecutionGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001179 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +00001180 LabelsAndEventClasses::TYPE_GUID,
1181 readableData,
1182 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001183 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION TYPE RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001184
1185 // Inference - Workload execution relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001186 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1187 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001188 inferenceGuid,
1189 outputWorkloadExecutionGuid,
1190 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +00001191 readableData,
1192 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001193 BOOST_TEST_MESSAGE("INFERENCE - OUTPUT WORKLOAD EXECUTION CHILD RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001194
1195 // Workload - Workload execution relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001196 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1197 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001198 outputWorkloadGuid,
1199 outputWorkloadExecutionGuid,
1200 LabelsAndEventClasses::EXECUTION_OF_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +00001201 readableData,
1202 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001203 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD - OUTPUT WORKLOAD EXECUTION EXECUTION_OF RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001204
1205 // Start Output workload execution life
1206 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +01001207 ProfilingGuid outputWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket(
1208 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1209 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION START OF LIFE EVENT OK");
David Monahan6198fe02019-12-02 08:35:43 +00001210
1211 // Output workload execution - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001212 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1213 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001214 outputWorkloadExecutionGuid,
1215 outputWorkloadExecutionSOLEventGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001216 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1217 readableData,
1218 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001219 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION - START OF LIFE EVENT RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001220
1221 // End of Normalize workload execution life
1222 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +01001223 ProfilingGuid outputWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket(
1224 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1225 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION END OF LIFE EVENT OK");
David Monahan6198fe02019-12-02 08:35:43 +00001226
1227 // Output workload execution - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001228 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1229 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001230 outputWorkloadExecutionGuid,
1231 outputWorkloadExecutionEOLEventGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001232 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1233 readableData,
1234 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001235 BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION - END OF LIFE EVENT RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001236
1237 // End of Inference life
1238 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +01001239 ProfilingGuid inferenceEOLEventGuid = VerifyTimelineEventBinaryPacket(
1240 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
1241 BOOST_TEST_MESSAGE("INFERENCE END OF LIFE EVENT OK");
David Monahan6198fe02019-12-02 08:35:43 +00001242
1243 // Inference - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001244 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1245 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001246 inferenceGuid,
1247 inferenceEOLEventGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001248 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1249 readableData,
1250 offset);
Jim Flynn6398a982020-05-27 17:05:21 +01001251 BOOST_TEST_MESSAGE("INFERENCE - END OF LIFE EVENT RELATIONSHIP OK");
David Monahan6198fe02019-12-02 08:35:43 +00001252
1253 bufferManager.MarkRead(inferenceReadableBuffer);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +00001254}
Jim Flynn6398a982020-05-27 17:05:21 +01001255
Jim Flynn6398a982020-05-27 17:05:21 +01001256bool CompareOutput(std::vector<std::string> output, std::vector<std::string> expectedOutput)
1257{
1258 if (output.size() != expectedOutput.size())
1259 {
1260 std::cerr << "output has [" << output.size() << "] lines, expected was ["
1261 << expectedOutput.size() << "] lines" << std::endl;
1262 std::cerr << std::endl << "actual" << std::endl << std::endl;
1263 for (auto line : output)
1264 {
1265 std::cerr << line << std::endl;
1266 }
1267 std::cerr << std::endl << "expected" << std::endl << std::endl;
1268 for (auto line : expectedOutput)
1269 {
1270 std::cerr << line << std::endl;
1271 }
1272 return false;
1273 }
1274 bool bRet = true;
1275 for (unsigned long i = 0; i < output.size(); ++i)
1276 {
1277 if (output[i] != expectedOutput[i])
1278 {
1279 bRet = false;
1280 std::cerr << i << ": actual [" << output[i] << "] expected [" << expectedOutput[i] << "]" << std::endl;
1281 }
1282 }
1283 return bRet;
1284}