Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 1 | // |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 2 | // Copyright © 2019 Arm Ltd and Contributors. All rights reserved. |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "ProfilingTestUtils.hpp" |
| 7 | #include "ProfilingUtils.hpp" |
| 8 | |
| 9 | #include <armnn/Descriptors.hpp> |
| 10 | #include <LabelsAndEventClasses.hpp> |
| 11 | #include <ProfilingService.hpp> |
Sadik Armagan | ea41b57 | 2020-03-19 18:16:46 +0000 | [diff] [blame] | 12 | |
| 13 | #include <test/TestUtils.hpp> |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 14 | |
| 15 | #include <boost/test/unit_test.hpp> |
| 16 | |
Finn Williams | a0de056 | 2020-04-22 12:27:37 +0100 | [diff] [blame] | 17 | uint32_t GetStreamMetaDataPacketSize() |
| 18 | { |
| 19 | uint32_t sizeUint32 = sizeof(uint32_t); |
| 20 | uint32_t payloadSize = 0; |
| 21 | payloadSize += boost::numeric_cast<uint32_t>(GetSoftwareInfo().size()) + 1; |
| 22 | payloadSize += boost::numeric_cast<uint32_t>(GetHardwareVersion().size()) + 1; |
| 23 | payloadSize += boost::numeric_cast<uint32_t>(GetSoftwareVersion().size()) + 1; |
| 24 | payloadSize += boost::numeric_cast<uint32_t>(GetProcessName().size()) + 1; |
| 25 | |
| 26 | // Add packetVersionEntries |
| 27 | payloadSize += 6 * 2 * sizeUint32; |
| 28 | // Add packetVersionCountSize |
| 29 | payloadSize += sizeUint32; |
| 30 | |
| 31 | uint32_t headerSize = 2 * sizeUint32; |
| 32 | uint32_t bodySize = 10 * sizeUint32; |
| 33 | |
| 34 | return headerSize + bodySize + payloadSize; |
| 35 | } |
| 36 | |
Jan Eilers | f78c767 | 2020-07-01 18:09:39 +0100 | [diff] [blame] | 37 | std::vector<BackendId> GetSuitableBackendRegistered() |
| 38 | { |
| 39 | std::vector<BackendId> suitableBackends; |
| 40 | if (BackendRegistryInstance().IsBackendRegistered(GetComputeDeviceAsCString(armnn::Compute::CpuRef))) |
| 41 | { |
| 42 | suitableBackends.push_back(armnn::Compute::CpuRef); |
| 43 | } |
| 44 | if (BackendRegistryInstance().IsBackendRegistered(GetComputeDeviceAsCString(armnn::Compute::CpuAcc))) |
| 45 | { |
| 46 | suitableBackends.push_back(armnn::Compute::CpuAcc); |
| 47 | } |
| 48 | if (BackendRegistryInstance().IsBackendRegistered(GetComputeDeviceAsCString(armnn::Compute::GpuAcc))) |
| 49 | { |
| 50 | suitableBackends.push_back(armnn::Compute::GpuAcc); |
| 51 | } |
| 52 | return suitableBackends; |
| 53 | } |
| 54 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 55 | inline unsigned int OffsetToNextWord(unsigned int numberOfBytes) |
| 56 | { |
| 57 | unsigned int uint32_t_size = sizeof(uint32_t); |
| 58 | |
| 59 | unsigned int remainder = numberOfBytes % uint32_t_size; |
| 60 | if (remainder == 0) |
| 61 | { |
| 62 | return numberOfBytes; |
| 63 | } |
| 64 | |
| 65 | return numberOfBytes + uint32_t_size - remainder; |
| 66 | } |
| 67 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 68 | void VerifyTimelineHeaderBinary(const unsigned char* readableData, |
| 69 | unsigned int& offset, |
| 70 | uint32_t packetDataLength) |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 71 | { |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 72 | ARMNN_ASSERT(readableData); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 73 | |
| 74 | // Utils |
| 75 | unsigned int uint32_t_size = sizeof(uint32_t); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 76 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 77 | // Check the TimelineEventClassBinaryPacket header |
Finn Williams | 0a336dc | 2020-05-11 15:39:58 +0100 | [diff] [blame] | 78 | uint32_t timelineBinaryPacketHeaderWord0 = ReadUint32(readableData, offset); |
| 79 | uint32_t timelineBinaryPacketFamily = (timelineBinaryPacketHeaderWord0 >> 26) & 0x0000003F; |
| 80 | uint32_t timelineBinaryPacketClass = (timelineBinaryPacketHeaderWord0 >> 19) & 0x0000007F; |
| 81 | uint32_t timelineBinaryPacketType = (timelineBinaryPacketHeaderWord0 >> 16) & 0x00000007; |
| 82 | uint32_t timelineBinaryPacketStreamId = (timelineBinaryPacketHeaderWord0 >> 0) & 0x00000007; |
| 83 | BOOST_CHECK(timelineBinaryPacketFamily == 1); |
| 84 | BOOST_CHECK(timelineBinaryPacketClass == 0); |
| 85 | BOOST_CHECK(timelineBinaryPacketType == 1); |
| 86 | BOOST_CHECK(timelineBinaryPacketStreamId == 0); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 87 | offset += uint32_t_size; |
Finn Williams | 0a336dc | 2020-05-11 15:39:58 +0100 | [diff] [blame] | 88 | uint32_t timelineBinaryPacketHeaderWord1 = ReadUint32(readableData, offset); |
| 89 | uint32_t timelineBinaryPacketSequenceNumber = (timelineBinaryPacketHeaderWord1 >> 24) & 0x00000001; |
| 90 | uint32_t timelineBinaryPacketDataLength = (timelineBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF; |
| 91 | BOOST_CHECK(timelineBinaryPacketSequenceNumber == 0); |
| 92 | BOOST_CHECK(timelineBinaryPacketDataLength == packetDataLength); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 93 | offset += uint32_t_size; |
| 94 | } |
| 95 | |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 96 | ProfilingGuid VerifyTimelineLabelBinaryPacketData(Optional<ProfilingGuid> guid, |
| 97 | const std::string& label, |
| 98 | const unsigned char* readableData, |
| 99 | unsigned int& offset) |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 100 | { |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 101 | ARMNN_ASSERT(readableData); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 102 | |
| 103 | // Utils |
| 104 | unsigned int uint32_t_size = sizeof(uint32_t); |
| 105 | unsigned int uint64_t_size = sizeof(uint64_t); |
| 106 | unsigned int label_size = boost::numeric_cast<unsigned int>(label.size()); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 107 | |
| 108 | // Check the decl id |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 109 | uint32_t eventClassDeclId = ReadUint32(readableData, offset); |
| 110 | BOOST_CHECK(eventClassDeclId == 0); |
| 111 | |
| 112 | // Check the profiling GUID |
| 113 | offset += uint32_t_size; |
| 114 | uint64_t readProfilingGuid = ReadUint64(readableData, offset); |
| 115 | if (guid.has_value()) |
| 116 | { |
| 117 | BOOST_CHECK(readProfilingGuid == guid.value()); |
| 118 | } |
| 119 | else |
| 120 | { |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 121 | armnn::profiling::ProfilingService profilingService; |
| 122 | BOOST_CHECK(readProfilingGuid == profilingService.GetStaticId(label)); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | // Check the SWTrace label |
| 126 | offset += uint64_t_size; |
| 127 | uint32_t swTraceLabelLength = ReadUint32(readableData, offset); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 128 | BOOST_CHECK(swTraceLabelLength == label_size + 1); // Label length including the null-terminator |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 129 | offset += uint32_t_size; |
| 130 | BOOST_CHECK(std::memcmp(readableData + offset, // Offset to the label in the buffer |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 131 | label.data(), // The original label |
| 132 | swTraceLabelLength - 1) == 0); // The length of the label |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 133 | |
| 134 | // SWTrace strings are written in blocks of words, so the offset has to be updated to the next whole word |
| 135 | offset += OffsetToNextWord(swTraceLabelLength); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 136 | |
| 137 | ProfilingGuid labelGuid(readProfilingGuid); |
| 138 | return labelGuid; |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 139 | } |
| 140 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 141 | void VerifyTimelineEventClassBinaryPacketData(ProfilingGuid guid, |
Jim Flynn | 1892d21 | 2020-05-26 21:10:49 +0100 | [diff] [blame] | 142 | ProfilingGuid nameGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 143 | const unsigned char* readableData, |
| 144 | unsigned int& offset) |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 145 | { |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 146 | ARMNN_ASSERT(readableData); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 147 | |
| 148 | // Utils |
| 149 | unsigned int uint32_t_size = sizeof(uint32_t); |
| 150 | unsigned int uint64_t_size = sizeof(uint64_t); |
| 151 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 152 | // Check the decl id |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 153 | uint32_t eventClassDeclId = ReadUint32(readableData, offset); |
| 154 | BOOST_CHECK(eventClassDeclId == 2); |
| 155 | |
| 156 | // Check the profiling GUID |
| 157 | offset += uint32_t_size; |
| 158 | uint64_t readProfilingGuid = ReadUint64(readableData, offset); |
| 159 | BOOST_CHECK(readProfilingGuid == guid); |
| 160 | |
Jim Flynn | 1892d21 | 2020-05-26 21:10:49 +0100 | [diff] [blame] | 161 | offset += uint64_t_size; |
| 162 | uint64_t readProfiilngNameGuid = ReadUint64(readableData, offset); |
| 163 | BOOST_CHECK(readProfiilngNameGuid == nameGuid); |
| 164 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 165 | // Update the offset to allow parsing to be continued after this function returns |
| 166 | offset += uint64_t_size; |
| 167 | } |
| 168 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 169 | void VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType relationshipType, |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 170 | Optional<ProfilingGuid> relationshipGuid, |
| 171 | Optional<ProfilingGuid> headGuid, |
| 172 | Optional<ProfilingGuid> tailGuid, |
| 173 | Optional<ProfilingGuid> attributeGuid, |
| 174 | const unsigned char* readableData, |
| 175 | unsigned int& offset) |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 176 | { |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 177 | ARMNN_ASSERT(readableData); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 178 | |
| 179 | uint32_t relationshipTypeUint = 0; |
| 180 | switch (relationshipType) |
| 181 | { |
| 182 | case ProfilingRelationshipType::RetentionLink: |
| 183 | relationshipTypeUint = 0; |
| 184 | break; |
| 185 | case ProfilingRelationshipType::ExecutionLink: |
| 186 | relationshipTypeUint = 1; |
| 187 | break; |
| 188 | case ProfilingRelationshipType::DataLink: |
| 189 | relationshipTypeUint = 2; |
| 190 | break; |
| 191 | case ProfilingRelationshipType::LabelLink: |
| 192 | relationshipTypeUint = 3; |
| 193 | break; |
| 194 | default: |
| 195 | BOOST_ERROR("Unknown relationship type"); |
| 196 | } |
| 197 | |
| 198 | // Utils |
| 199 | unsigned int uint32_t_size = sizeof(uint32_t); |
| 200 | unsigned int uint64_t_size = sizeof(uint64_t); |
| 201 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 202 | // Check the decl id |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 203 | uint32_t eventClassDeclId = ReadUint32(readableData, offset); |
| 204 | BOOST_CHECK(eventClassDeclId == 3); |
| 205 | |
| 206 | // Check the relationship type |
| 207 | offset += uint32_t_size; |
| 208 | uint32_t readRelationshipTypeUint = ReadUint32(readableData, offset); |
| 209 | BOOST_CHECK(readRelationshipTypeUint == relationshipTypeUint); |
| 210 | |
| 211 | // Check the relationship GUID |
| 212 | offset += uint32_t_size; |
| 213 | uint64_t readRelationshipGuid = ReadUint64(readableData, offset); |
| 214 | if (relationshipGuid.has_value()) |
| 215 | { |
| 216 | BOOST_CHECK(readRelationshipGuid == relationshipGuid.value()); |
| 217 | } |
| 218 | else |
| 219 | { |
| 220 | BOOST_CHECK(readRelationshipGuid != ProfilingGuid(0)); |
| 221 | } |
| 222 | |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 223 | // Check the head GUID of the relationship |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 224 | offset += uint64_t_size; |
| 225 | uint64_t readHeadRelationshipGuid = ReadUint64(readableData, offset); |
| 226 | if (headGuid.has_value()) |
| 227 | { |
| 228 | BOOST_CHECK(readHeadRelationshipGuid == headGuid.value()); |
| 229 | } |
| 230 | else |
| 231 | { |
| 232 | BOOST_CHECK(readHeadRelationshipGuid != ProfilingGuid(0)); |
| 233 | } |
| 234 | |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 235 | // Check the tail GUID of the relationship |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 236 | offset += uint64_t_size; |
| 237 | uint64_t readTailRelationshipGuid = ReadUint64(readableData, offset); |
| 238 | if (tailGuid.has_value()) |
| 239 | { |
| 240 | BOOST_CHECK(readTailRelationshipGuid == tailGuid.value()); |
| 241 | } |
| 242 | else |
| 243 | { |
| 244 | BOOST_CHECK(readTailRelationshipGuid != ProfilingGuid(0)); |
| 245 | } |
| 246 | |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 247 | // Check the attribute GUID of the relationship |
Finn Williams | 0a336dc | 2020-05-11 15:39:58 +0100 | [diff] [blame] | 248 | offset += uint64_t_size; |
| 249 | uint64_t readAttributeRelationshipGuid = ReadUint64(readableData, offset); |
| 250 | if (attributeGuid.has_value()) |
| 251 | { |
| 252 | BOOST_CHECK(readAttributeRelationshipGuid == attributeGuid.value()); |
| 253 | } |
| 254 | else |
| 255 | { |
| 256 | BOOST_CHECK(readAttributeRelationshipGuid == ProfilingGuid(0)); |
| 257 | } |
| 258 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 259 | // Update the offset to allow parsing to be continued after this function returns |
| 260 | offset += uint64_t_size; |
| 261 | } |
| 262 | |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 263 | ProfilingGuid VerifyTimelineEntityBinaryPacketData(Optional<ProfilingGuid> guid, |
| 264 | const unsigned char* readableData, |
| 265 | unsigned int& offset) |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 266 | { |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 267 | ARMNN_ASSERT(readableData); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 268 | |
| 269 | // Utils |
| 270 | unsigned int uint32_t_size = sizeof(uint32_t); |
| 271 | unsigned int uint64_t_size = sizeof(uint64_t); |
| 272 | |
| 273 | // Reading TimelineEntityClassBinaryPacket |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 274 | // Check the decl_id |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 275 | uint32_t entityDeclId = ReadUint32(readableData, offset); |
| 276 | BOOST_CHECK(entityDeclId == 1); |
| 277 | |
| 278 | // Check the profiling GUID |
| 279 | offset += uint32_t_size; |
| 280 | uint64_t readProfilingGuid = ReadUint64(readableData, offset); |
| 281 | |
| 282 | if (guid.has_value()) |
| 283 | { |
| 284 | BOOST_CHECK(readProfilingGuid == guid.value()); |
| 285 | } |
| 286 | else |
| 287 | { |
| 288 | BOOST_CHECK(readProfilingGuid != ProfilingGuid(0)); |
| 289 | } |
| 290 | |
| 291 | offset += uint64_t_size; |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 292 | |
| 293 | ProfilingGuid entityGuid(readProfilingGuid); |
| 294 | return entityGuid; |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 295 | } |
| 296 | |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 297 | ProfilingGuid VerifyTimelineEventBinaryPacket(Optional<uint64_t> timestamp, |
| 298 | Optional<std::thread::id> threadId, |
| 299 | Optional<ProfilingGuid> eventGuid, |
| 300 | const unsigned char* readableData, |
| 301 | unsigned int& offset) |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 302 | { |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 303 | ARMNN_ASSERT(readableData); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 304 | |
| 305 | // Utils |
| 306 | unsigned int uint32_t_size = sizeof(uint32_t); |
| 307 | unsigned int uint64_t_size = sizeof(uint64_t); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 308 | |
| 309 | // Reading TimelineEventBinaryPacket |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 310 | // Check the decl_id |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 311 | uint32_t entityDeclId = ReadUint32(readableData, offset); |
| 312 | BOOST_CHECK(entityDeclId == 4); |
| 313 | |
| 314 | // Check the timestamp |
| 315 | offset += uint32_t_size; |
| 316 | uint64_t readTimestamp = ReadUint64(readableData, offset); |
| 317 | if (timestamp.has_value()) |
| 318 | { |
| 319 | BOOST_CHECK(readTimestamp == timestamp.value()); |
| 320 | } |
| 321 | else |
| 322 | { |
| 323 | BOOST_CHECK(readTimestamp != 0); |
| 324 | } |
| 325 | |
| 326 | // Check the thread id |
| 327 | offset += uint64_t_size; |
Colm Donelan | 5bb3d8a | 2020-05-12 16:36:46 +0100 | [diff] [blame] | 328 | std::vector<uint8_t> readThreadId(ThreadIdSize, 0); |
| 329 | ReadBytes(readableData, offset, ThreadIdSize, readThreadId.data()); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 330 | if (threadId.has_value()) |
| 331 | { |
| 332 | BOOST_CHECK(readThreadId == threadId.value()); |
| 333 | } |
| 334 | else |
| 335 | { |
| 336 | BOOST_CHECK(readThreadId == std::this_thread::get_id()); |
| 337 | } |
| 338 | |
| 339 | // Check the event GUID |
Colm Donelan | 5bb3d8a | 2020-05-12 16:36:46 +0100 | [diff] [blame] | 340 | offset += ThreadIdSize; |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 341 | uint64_t readEventGuid = ReadUint64(readableData, offset); |
| 342 | if (eventGuid.has_value()) |
| 343 | { |
| 344 | BOOST_CHECK(readEventGuid == eventGuid.value()); |
| 345 | } |
| 346 | else |
| 347 | { |
| 348 | BOOST_CHECK(readEventGuid != ProfilingGuid(0)); |
| 349 | } |
| 350 | |
| 351 | offset += uint64_t_size; |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 352 | |
| 353 | ProfilingGuid eventid(readEventGuid); |
| 354 | return eventid; |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId) |
| 358 | { |
| 359 | using namespace armnn; |
| 360 | |
| 361 | // Create runtime in which test will run |
| 362 | armnn::IRuntime::CreationOptions options; |
| 363 | options.m_ProfilingOptions.m_EnableProfiling = true; |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 364 | options.m_ProfilingOptions.m_TimelineEnabled = true; |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 365 | armnn::Runtime runtime(options); |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 366 | GetProfilingService(&runtime).ResetExternalProfilingOptions(options.m_ProfilingOptions, false); |
| 367 | |
| 368 | profiling::ProfilingServiceRuntimeHelper profilingServiceHelper(GetProfilingService(&runtime)); |
| 369 | profilingServiceHelper.ForceTransitionToState(ProfilingState::NotConnected); |
| 370 | profilingServiceHelper.ForceTransitionToState(ProfilingState::WaitingForAck); |
| 371 | profilingServiceHelper.ForceTransitionToState(ProfilingState::Active); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 372 | |
| 373 | // build up the structure of the network |
| 374 | INetworkPtr net(INetwork::Create()); |
| 375 | |
| 376 | // Convolution details |
| 377 | TensorInfo inputInfo({ 1, 2, 5, 1 }, DataType::Float32); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 378 | TensorInfo weightInfo({ 3, 2, 3, 1 }, DataType::Float32); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 379 | TensorInfo biasInfo({ 3 }, DataType::Float32); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 380 | TensorInfo outputInfo({ 1, 3, 7, 1 }, DataType::Float32); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 381 | std::vector<float> weightsData{ |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 382 | 1.0f, 0.0f, 0.0f, |
| 383 | 0.0f, 2.0f, -1.5f, |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 384 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 385 | 0.0f, 0.0f, 0.0f, |
| 386 | 0.2f, 0.2f, 0.2f, |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 387 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 388 | 0.5f, 0.0f, 0.5f, |
| 389 | 0.0f, -1.0f, 0.0f |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 390 | }; |
| 391 | ConstTensor weights(weightInfo, weightsData); |
| 392 | |
| 393 | Optional<ConstTensor> optionalBiases; |
| 394 | std::vector<float> biasesData{ 1.0f, 0.0f, 0.0f }; |
| 395 | ConstTensor biases(biasInfo, biasesData); |
| 396 | optionalBiases = Optional<ConstTensor>(biases); |
| 397 | |
| 398 | // Input layer |
| 399 | IConnectableLayer* input = net->AddInputLayer(0, "input"); |
| 400 | |
| 401 | // Convolution2d layer |
| 402 | Convolution2dDescriptor conv2dDesc; |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 403 | conv2dDesc.m_StrideX = 1; |
| 404 | conv2dDesc.m_StrideY = 1; |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 405 | conv2dDesc.m_PadLeft = 0; |
| 406 | conv2dDesc.m_PadRight = 0; |
| 407 | conv2dDesc.m_PadTop = 2; |
| 408 | conv2dDesc.m_PadBottom = 2; |
| 409 | conv2dDesc.m_BiasEnabled = true; |
| 410 | IConnectableLayer* conv2d = net->AddConvolution2dLayer(conv2dDesc, weights, optionalBiases); |
| 411 | |
| 412 | // Activation layer |
| 413 | armnn::ActivationDescriptor activationDesc; |
| 414 | armnn::IConnectableLayer* const activation = net->AddActivationLayer(activationDesc, "activation"); |
| 415 | |
| 416 | // Output layer |
| 417 | IConnectableLayer* output = net->AddOutputLayer(0, "output"); |
| 418 | |
| 419 | input->GetOutputSlot(0).Connect(conv2d->GetInputSlot(0)); |
| 420 | conv2d->GetOutputSlot(0).Connect(activation->GetInputSlot(0)); |
| 421 | activation->GetOutputSlot(0).Connect(output->GetInputSlot(0)); |
| 422 | |
| 423 | input->GetOutputSlot(0).SetTensorInfo(inputInfo); |
| 424 | conv2d->GetOutputSlot(0).SetTensorInfo(outputInfo); |
| 425 | activation->GetOutputSlot(0).SetTensorInfo(outputInfo); |
| 426 | |
| 427 | // optimize the network |
| 428 | std::vector<armnn::BackendId> backends = { backendId }; |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 429 | IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime.GetDeviceSpec()); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 430 | |
| 431 | ProfilingGuid optNetGuid = optNet->GetGuid(); |
| 432 | |
| 433 | // Load it into the runtime. It should success. |
| 434 | armnn::NetworkId netId; |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 435 | BOOST_TEST(runtime.LoadNetwork(netId, std::move(optNet)) == Status::Success); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 436 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 437 | profiling::BufferManager& bufferManager = profilingServiceHelper.GetProfilingBufferManager(); |
| 438 | auto readableBuffer = bufferManager.GetReadableBuffer(); |
| 439 | |
| 440 | // Profiling is enable, the post-optimisation structure should be created |
| 441 | BOOST_CHECK(readableBuffer != nullptr); |
| 442 | |
| 443 | unsigned int size = readableBuffer->GetSize(); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 444 | BOOST_CHECK(size == 1124); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 445 | |
| 446 | const unsigned char* readableData = readableBuffer->GetReadableData(); |
| 447 | BOOST_CHECK(readableData != nullptr); |
| 448 | |
| 449 | unsigned int offset = 0; |
| 450 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 451 | // Verify Header |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 452 | VerifyTimelineHeaderBinary(readableData, offset, 1116); |
| 453 | BOOST_TEST_MESSAGE("HEADER OK"); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 454 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 455 | // Post-optimisation network |
| 456 | // Network entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 457 | VerifyTimelineEntityBinaryPacketData(optNetGuid, readableData, offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 458 | BOOST_TEST_MESSAGE("NETWORK ENTITY OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 459 | |
| 460 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 461 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 462 | EmptyOptional(), |
| 463 | optNetGuid, |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 464 | LabelsAndEventClasses::NETWORK_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 465 | LabelsAndEventClasses::TYPE_GUID, |
| 466 | readableData, |
| 467 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 468 | BOOST_TEST_MESSAGE("NETWORK TYPE RELATIONSHIP OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 469 | |
| 470 | // Input layer |
| 471 | // Input layer entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 472 | VerifyTimelineEntityBinaryPacketData(input->GetGuid(), readableData, offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 473 | BOOST_TEST_MESSAGE("INPUT ENTITY OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 474 | |
| 475 | // Name Entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 476 | ProfilingGuid inputLabelGuid = VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "input", readableData, offset); |
| 477 | BOOST_TEST_MESSAGE("INPUT NAME LABEL OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 478 | |
| 479 | // Entity - Name relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 480 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 481 | EmptyOptional(), |
| 482 | input->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 483 | inputLabelGuid, |
Finn Williams | 0a336dc | 2020-05-11 15:39:58 +0100 | [diff] [blame] | 484 | LabelsAndEventClasses::NAME_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 485 | readableData, |
| 486 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 487 | BOOST_TEST_MESSAGE("INPUT NAME RELATIONSHIP OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 488 | |
| 489 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 490 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 491 | EmptyOptional(), |
| 492 | input->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 493 | LabelsAndEventClasses::LAYER_GUID, |
Finn Williams | 0a336dc | 2020-05-11 15:39:58 +0100 | [diff] [blame] | 494 | LabelsAndEventClasses::TYPE_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 495 | readableData, |
| 496 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 497 | BOOST_TEST_MESSAGE("INPUT TYPE RELATIONSHIP OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 498 | |
| 499 | // Network - Input layer relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 500 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 501 | EmptyOptional(), |
| 502 | optNetGuid, |
| 503 | input->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 504 | LabelsAndEventClasses::CHILD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 505 | readableData, |
| 506 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 507 | BOOST_TEST_MESSAGE("NETWORK - INPUT CHILD RELATIONSHIP OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 508 | |
| 509 | // Conv2d layer |
| 510 | // Conv2d layer entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 511 | VerifyTimelineEntityBinaryPacketData(conv2d->GetGuid(), readableData, offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 512 | |
| 513 | // Name entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 514 | ProfilingGuid conv2dNameLabelGuid = VerifyTimelineLabelBinaryPacketData( |
| 515 | EmptyOptional(), "<Unnamed>", readableData, offset); |
| 516 | BOOST_TEST_MESSAGE("CONV2D NAME LABEL OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 517 | |
| 518 | // Entity - Name relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 519 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 520 | EmptyOptional(), |
| 521 | conv2d->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 522 | conv2dNameLabelGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 523 | LabelsAndEventClasses::NAME_GUID, |
| 524 | readableData, |
| 525 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 526 | BOOST_TEST_MESSAGE("CONV2D NAME RELATIONSHIP OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 527 | |
| 528 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 529 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 530 | EmptyOptional(), |
| 531 | conv2d->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 532 | LabelsAndEventClasses::LAYER_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 533 | LabelsAndEventClasses::TYPE_GUID, |
| 534 | readableData, |
| 535 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 536 | BOOST_TEST_MESSAGE("CONV2D TYPE RELATIONSHIP OK"); |
Finn Williams | 0a336dc | 2020-05-11 15:39:58 +0100 | [diff] [blame] | 537 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 538 | // Network - Conv2d layer relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 539 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 540 | EmptyOptional(), |
| 541 | optNetGuid, |
| 542 | conv2d->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 543 | LabelsAndEventClasses::CHILD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 544 | readableData, |
| 545 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 546 | BOOST_TEST_MESSAGE("NETWORK - CONV2D CHILD RELATIONSHIP OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 547 | |
| 548 | // Input layer - Conv2d layer relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 549 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 550 | EmptyOptional(), |
| 551 | input->GetGuid(), |
| 552 | conv2d->GetGuid(), |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 553 | LabelsAndEventClasses::CONNECTION_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 554 | readableData, |
| 555 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 556 | BOOST_TEST_MESSAGE("INPUT - CONV2D LAYER CONNECTION OK"); |
Finn Williams | 0a336dc | 2020-05-11 15:39:58 +0100 | [diff] [blame] | 557 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 558 | // Conv2d workload |
| 559 | // Conv2d workload entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 560 | ProfilingGuid conv2DWorkloadGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset); |
| 561 | BOOST_TEST_MESSAGE("CONV2D WORKLOAD ENTITY OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 562 | |
| 563 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 564 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 565 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 566 | conv2DWorkloadGuid, |
| 567 | LabelsAndEventClasses::WORKLOAD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 568 | LabelsAndEventClasses::TYPE_GUID, |
| 569 | readableData, |
| 570 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 571 | BOOST_TEST_MESSAGE("CONV2D WORKLOAD TYPE RELATIONSHIP OK"); |
Finn Williams | 0a336dc | 2020-05-11 15:39:58 +0100 | [diff] [blame] | 572 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 573 | // BackendId entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 574 | ProfilingGuid backendIdLabelGuid = VerifyTimelineLabelBinaryPacketData( |
| 575 | EmptyOptional(), backendId.Get(), readableData, offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 576 | |
| 577 | // Entity - BackendId relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 578 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 579 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 580 | conv2DWorkloadGuid, |
| 581 | backendIdLabelGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 582 | LabelsAndEventClasses::BACKENDID_GUID, |
| 583 | readableData, |
| 584 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 585 | BOOST_TEST_MESSAGE("CONV2D WORKLOAD BACKEND ID RELATIONSHIP OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 586 | |
Finn Williams | 0a336dc | 2020-05-11 15:39:58 +0100 | [diff] [blame] | 587 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 588 | // Conv2d layer - Conv2d workload relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 589 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 590 | EmptyOptional(), |
| 591 | conv2d->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 592 | conv2DWorkloadGuid, |
| 593 | LabelsAndEventClasses::CHILD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 594 | readableData, |
| 595 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 596 | BOOST_TEST_MESSAGE("CONV2D LAYER - WORKLOAD CHILD RELATIONSHIP OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 597 | |
| 598 | // Activation layer |
| 599 | // Activation layer entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 600 | VerifyTimelineEntityBinaryPacketData(activation->GetGuid(), readableData, offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 601 | BOOST_TEST_MESSAGE("ACTIVATION ENTITY OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 602 | |
| 603 | // Name entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 604 | ProfilingGuid activationLabelGuid = VerifyTimelineLabelBinaryPacketData( |
| 605 | EmptyOptional(), "activation", readableData, offset); |
| 606 | BOOST_TEST_MESSAGE("ACTIVATION NAME LABEL OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 607 | |
| 608 | // Entity - Name relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 609 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 610 | EmptyOptional(), |
| 611 | activation->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 612 | activationLabelGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 613 | LabelsAndEventClasses::NAME_GUID, |
| 614 | readableData, |
| 615 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 616 | BOOST_TEST_MESSAGE("ACTIVATION LAYER - NAME RELATIONSHIP OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 617 | |
| 618 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 619 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 620 | EmptyOptional(), |
| 621 | activation->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 622 | LabelsAndEventClasses::LAYER_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 623 | LabelsAndEventClasses::TYPE_GUID, |
| 624 | readableData, |
| 625 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 626 | BOOST_TEST_MESSAGE("ACTIVATION LAYER TYPE RELATIONSHIP OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 627 | |
| 628 | // Network - Activation layer relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 629 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 630 | EmptyOptional(), |
| 631 | optNetGuid, |
| 632 | activation->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 633 | LabelsAndEventClasses::CHILD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 634 | readableData, |
| 635 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 636 | BOOST_TEST_MESSAGE("NETWORK - ACTIVATION LAYER CHILD RELATIONSHIP OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 637 | |
| 638 | // Conv2d layer - Activation layer relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 639 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 640 | EmptyOptional(), |
| 641 | conv2d->GetGuid(), |
| 642 | activation->GetGuid(), |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 643 | LabelsAndEventClasses::CONNECTION_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 644 | readableData, |
| 645 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 646 | BOOST_TEST_MESSAGE("CONV2D LAYER - ACTIVATION LAYER CONNECTION OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 647 | |
| 648 | // Activation workload |
| 649 | // Activation workload entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 650 | ProfilingGuid activationWorkloadGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset); |
| 651 | BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD ENTITY OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 652 | |
| 653 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 654 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 655 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 656 | activationWorkloadGuid, |
| 657 | LabelsAndEventClasses::WORKLOAD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 658 | LabelsAndEventClasses::TYPE_GUID, |
| 659 | readableData, |
| 660 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 661 | BOOST_TEST_MESSAGE("ACTIVATION WORKLAD TYPE RELATIONSHIP OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 662 | |
| 663 | // BackendId entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 664 | VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 665 | BOOST_TEST_MESSAGE("BACKEND ID LABEL OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 666 | |
| 667 | // Entity - BackendId relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 668 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 669 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 670 | activationWorkloadGuid, |
| 671 | backendIdLabelGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 672 | LabelsAndEventClasses::BACKENDID_GUID, |
| 673 | readableData, |
| 674 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 675 | BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD BACKEND ID RELATIONSHIP OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 676 | |
| 677 | // Activation layer - Activation workload relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 678 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 679 | EmptyOptional(), |
| 680 | activation->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 681 | activationWorkloadGuid, |
| 682 | LabelsAndEventClasses::CHILD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 683 | readableData, |
| 684 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 685 | BOOST_TEST_MESSAGE("ACTIVATION LAYER - WORKLOAD CHILD RELATIONSHIP OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 686 | |
| 687 | // Output layer |
| 688 | // Output layer entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 689 | VerifyTimelineEntityBinaryPacketData(output->GetGuid(), readableData, offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 690 | BOOST_TEST_MESSAGE("OUTPUT LAYER ENTITY OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 691 | |
| 692 | // Name entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 693 | ProfilingGuid outputLabelGuid = VerifyTimelineLabelBinaryPacketData( |
| 694 | EmptyOptional(), "output", readableData, offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 695 | |
| 696 | // Entity - Name relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 697 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 698 | EmptyOptional(), |
| 699 | output->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 700 | outputLabelGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 701 | LabelsAndEventClasses::NAME_GUID, |
| 702 | readableData, |
| 703 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 704 | BOOST_TEST_MESSAGE("OUTPUT LAYER NAME RELATIONSHIP OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 705 | |
| 706 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 707 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 708 | EmptyOptional(), |
| 709 | output->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 710 | LabelsAndEventClasses::LAYER_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 711 | LabelsAndEventClasses::TYPE_GUID, |
| 712 | readableData, |
| 713 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 714 | BOOST_TEST_MESSAGE("OUTPUT LAYER TYPE RELATIONSHIP OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 715 | |
| 716 | // Network - Output layer relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 717 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 718 | EmptyOptional(), |
| 719 | optNetGuid, |
| 720 | output->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 721 | LabelsAndEventClasses::CHILD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 722 | readableData, |
| 723 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 724 | BOOST_TEST_MESSAGE("NETWORK - OUTPUT LAYER CHILD RELATIONSHIP OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 725 | |
| 726 | // Activation layer - Output layer relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 727 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 728 | EmptyOptional(), |
| 729 | activation->GetGuid(), |
| 730 | output->GetGuid(), |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 731 | LabelsAndEventClasses::CONNECTION_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 732 | readableData, |
| 733 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 734 | BOOST_TEST_MESSAGE("ACTIVATION LAYER - OUTPUT LAYER CONNECTION OK"); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 735 | |
| 736 | bufferManager.MarkRead(readableBuffer); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 737 | |
| 738 | // Creates structures for input & output. |
| 739 | std::vector<float> inputData(inputInfo.GetNumElements()); |
| 740 | std::vector<float> outputData(outputInfo.GetNumElements()); |
| 741 | |
| 742 | InputTensors inputTensors |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 743 | { |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 744 | {0, ConstTensor(runtime.GetInputTensorInfo(netId, 0), inputData.data())} |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 745 | }; |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 746 | OutputTensors outputTensors |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 747 | { |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 748 | {0, Tensor(runtime.GetOutputTensorInfo(netId, 0), outputData.data())} |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 749 | }; |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 750 | |
| 751 | // Does the inference. |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 752 | runtime.EnqueueWorkload(netId, inputTensors, outputTensors); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 753 | |
Finn Williams | b6a402f | 2020-03-24 13:46:22 +0000 | [diff] [blame] | 754 | // Get readable buffer for input workload |
| 755 | auto inputReadableBuffer = bufferManager.GetReadableBuffer(); |
| 756 | BOOST_CHECK(inputReadableBuffer != nullptr); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 757 | |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 758 | // Get readable buffer for output workload |
| 759 | auto outputReadableBuffer = bufferManager.GetReadableBuffer(); |
| 760 | BOOST_CHECK(outputReadableBuffer != nullptr); |
| 761 | |
Finn Williams | b6a402f | 2020-03-24 13:46:22 +0000 | [diff] [blame] | 762 | // Get readable buffer for inference timeline |
| 763 | auto inferenceReadableBuffer = bufferManager.GetReadableBuffer(); |
| 764 | BOOST_CHECK(inferenceReadableBuffer != nullptr); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 765 | |
| 766 | // Validate input workload data |
| 767 | size = inputReadableBuffer->GetSize(); |
Finn Williams | 0a336dc | 2020-05-11 15:39:58 +0100 | [diff] [blame] | 768 | BOOST_CHECK(size == 164); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 769 | |
| 770 | readableData = inputReadableBuffer->GetReadableData(); |
| 771 | BOOST_CHECK(readableData != nullptr); |
| 772 | |
| 773 | offset = 0; |
| 774 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 775 | // Verify Header |
Finn Williams | 0a336dc | 2020-05-11 15:39:58 +0100 | [diff] [blame] | 776 | VerifyTimelineHeaderBinary(readableData, offset, 156); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 777 | BOOST_TEST_MESSAGE("INPUT WORKLOAD HEADER OK"); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 778 | |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 779 | // Input workload |
| 780 | // Input workload entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 781 | ProfilingGuid inputWorkloadGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset); |
| 782 | BOOST_TEST_MESSAGE("INPUT WORKLOAD TYPE RELATIONSHIP OK"); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 783 | |
| 784 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 785 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 786 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 787 | inputWorkloadGuid, |
| 788 | LabelsAndEventClasses::WORKLOAD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 789 | LabelsAndEventClasses::TYPE_GUID, |
| 790 | readableData, |
| 791 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 792 | BOOST_TEST_MESSAGE("INPUT WORKLOAD TYPE RELATIONSHIP OK"); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 793 | |
| 794 | // BackendId entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 795 | VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 796 | |
| 797 | // Entity - BackendId relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 798 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 799 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 800 | inputWorkloadGuid, |
| 801 | backendIdLabelGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 802 | LabelsAndEventClasses::BACKENDID_GUID, |
| 803 | readableData, |
| 804 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 805 | BOOST_TEST_MESSAGE("INPUT WORKLOAD BACKEND ID RELATIONSHIP OK"); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 806 | |
| 807 | // Input layer - Input workload relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 808 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 809 | EmptyOptional(), |
| 810 | input->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 811 | inputWorkloadGuid, |
| 812 | LabelsAndEventClasses::CHILD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 813 | readableData, |
| 814 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 815 | BOOST_TEST_MESSAGE("INPUT LAYER - INPUT WORKLOAD CHILD RELATIONSHIP OK"); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 816 | |
| 817 | bufferManager.MarkRead(inputReadableBuffer); |
| 818 | |
| 819 | // Validate output workload data |
| 820 | size = outputReadableBuffer->GetSize(); |
Finn Williams | 0a336dc | 2020-05-11 15:39:58 +0100 | [diff] [blame] | 821 | BOOST_CHECK(size == 164); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 822 | |
| 823 | readableData = outputReadableBuffer->GetReadableData(); |
| 824 | BOOST_CHECK(readableData != nullptr); |
| 825 | |
| 826 | offset = 0; |
| 827 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 828 | // Verify Header |
Finn Williams | 0a336dc | 2020-05-11 15:39:58 +0100 | [diff] [blame] | 829 | VerifyTimelineHeaderBinary(readableData, offset, 156); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 830 | BOOST_TEST_MESSAGE("OUTPUT WORKLOAD HEADER OK"); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 831 | |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 832 | // Output workload |
| 833 | // Output workload entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 834 | ProfilingGuid outputWorkloadGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset); |
| 835 | BOOST_TEST_MESSAGE("OUTPUT WORKLOAD ENTITY OK"); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 836 | |
| 837 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 838 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 839 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 840 | outputWorkloadGuid, |
| 841 | LabelsAndEventClasses::WORKLOAD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 842 | LabelsAndEventClasses::TYPE_GUID, |
| 843 | readableData, |
| 844 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 845 | BOOST_TEST_MESSAGE("OUTPUT WORKLOAD TYPE RELATIONSHIP OK"); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 846 | |
| 847 | // BackendId entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 848 | VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 849 | BOOST_TEST_MESSAGE("OUTPUT WORKLOAD LABEL OK"); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 850 | |
| 851 | // Entity - BackendId relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 852 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 853 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 854 | outputWorkloadGuid, |
| 855 | backendIdLabelGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 856 | LabelsAndEventClasses::BACKENDID_GUID, |
| 857 | readableData, |
| 858 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 859 | BOOST_TEST_MESSAGE("OUTPUT WORKLOAD BACKEND ID RELATIONSHIP OK"); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 860 | |
| 861 | // Output layer - Output workload relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 862 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 863 | EmptyOptional(), |
| 864 | output->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 865 | outputWorkloadGuid, |
| 866 | LabelsAndEventClasses::CHILD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 867 | readableData, |
| 868 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 869 | BOOST_TEST_MESSAGE("OUTPUT LAYER - OUTPUT WORKLOAD CHILD RELATIONSHIP OK"); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 870 | |
| 871 | bufferManager.MarkRead(outputReadableBuffer); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 872 | |
| 873 | // Validate inference data |
| 874 | size = inferenceReadableBuffer->GetSize(); |
Jan Eilers | a10e2a2 | 2020-03-26 12:04:54 +0000 | [diff] [blame] | 875 | |
Finn Williams | 0a336dc | 2020-05-11 15:39:58 +0100 | [diff] [blame] | 876 | BOOST_CHECK(size == 1228 + 10 * ThreadIdSize); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 877 | |
| 878 | readableData = inferenceReadableBuffer->GetReadableData(); |
| 879 | BOOST_CHECK(readableData != nullptr); |
| 880 | |
| 881 | offset = 0; |
| 882 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 883 | // Verify Header |
Finn Williams | 0a336dc | 2020-05-11 15:39:58 +0100 | [diff] [blame] | 884 | VerifyTimelineHeaderBinary(readableData, offset, 1220 + 10 * ThreadIdSize); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 885 | BOOST_TEST_MESSAGE("INFERENCE HEADER OK"); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 886 | |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 887 | // Inference timeline trace |
| 888 | // Inference entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 889 | ProfilingGuid inferenceGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset); |
| 890 | BOOST_TEST_MESSAGE("INFERENCE ENTITY OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 891 | |
| 892 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 893 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 894 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 895 | inferenceGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 896 | LabelsAndEventClasses::INFERENCE_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 897 | LabelsAndEventClasses::TYPE_GUID, |
| 898 | readableData, |
| 899 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 900 | BOOST_TEST_MESSAGE("INFERENCE TYPE RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 901 | |
| 902 | // Network - Inference relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 903 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 904 | EmptyOptional(), |
| 905 | optNetGuid, |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 906 | inferenceGuid, |
| 907 | LabelsAndEventClasses::EXECUTION_OF_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 908 | readableData, |
| 909 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 910 | BOOST_TEST_MESSAGE("NETWORK - INFERENCE EXECUTION_OF RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 911 | |
| 912 | // Start Inference life |
| 913 | // Event packet - timeline, threadId, eventGuid |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 914 | ProfilingGuid inferenceEventGuid = VerifyTimelineEventBinaryPacket( |
| 915 | EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 916 | BOOST_TEST_MESSAGE("INFERENCE START OF LIFE EVENT OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 917 | |
| 918 | // Inference - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 919 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
| 920 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 921 | inferenceGuid, |
| 922 | inferenceEventGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 923 | LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, |
| 924 | readableData, |
| 925 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 926 | BOOST_TEST_MESSAGE("INFERENCE START OF LIFE RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 927 | |
| 928 | // Execution |
| 929 | // Input workload execution |
| 930 | // Input workload execution entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 931 | ProfilingGuid inputWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData( |
| 932 | EmptyOptional(), readableData, offset); |
| 933 | BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION ENTITY OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 934 | |
| 935 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 936 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 937 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 938 | inputWorkloadExecutionGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 939 | LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 940 | LabelsAndEventClasses::TYPE_GUID, |
| 941 | readableData, |
| 942 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 943 | BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION TYPE RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 944 | |
| 945 | // Inference - Workload execution relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 946 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 947 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 948 | inferenceGuid, |
| 949 | inputWorkloadExecutionGuid, |
| 950 | LabelsAndEventClasses::CHILD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 951 | readableData, |
| 952 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 953 | BOOST_TEST_MESSAGE("INPUT WORKLOAD - INPUT WORKLOAD EXECUTION RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 954 | |
| 955 | // Workload - Workload execution relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 956 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 957 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 958 | inputWorkloadGuid, |
| 959 | inputWorkloadExecutionGuid, |
| 960 | LabelsAndEventClasses::EXECUTION_OF_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 961 | readableData, |
| 962 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 963 | BOOST_TEST_MESSAGE("INPUT WORKLOAD - INPUT WORKLOAD EXECUTION RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 964 | |
| 965 | // Start Input workload execution life |
| 966 | // Event packet - timeline, threadId, eventGuid |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 967 | ProfilingGuid inputWorkloadExecutionSOLEventId = VerifyTimelineEventBinaryPacket( |
| 968 | EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 969 | BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION - START OF LIFE EVENT OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 970 | |
| 971 | // Input workload execution - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 972 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
| 973 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 974 | inputWorkloadExecutionGuid, |
| 975 | inputWorkloadExecutionSOLEventId, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 976 | LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, |
| 977 | readableData, |
| 978 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 979 | BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION - START OF LIFE EVENT RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 980 | |
| 981 | // End of Input workload execution life |
| 982 | // Event packet - timeline, threadId, eventGuid |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 983 | ProfilingGuid inputWorkloadExecutionEOLEventId = VerifyTimelineEventBinaryPacket( |
| 984 | EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 985 | BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION - END OF LIFE EVENT OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 986 | |
| 987 | // Input workload execution - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 988 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
| 989 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 990 | inputWorkloadExecutionGuid, |
| 991 | inputWorkloadExecutionEOLEventId, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 992 | LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, |
| 993 | readableData, |
| 994 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 995 | BOOST_TEST_MESSAGE("INPUT WORKLOAD EXECUTION - END OF LIFE EVENT RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 996 | |
| 997 | // Conv2d workload execution |
| 998 | // Conv2d workload execution entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 999 | ProfilingGuid conv2DWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData( |
| 1000 | EmptyOptional(), readableData, offset); |
| 1001 | BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION ENTITY OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1002 | |
| 1003 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1004 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 1005 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1006 | conv2DWorkloadExecutionGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1007 | LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1008 | LabelsAndEventClasses::TYPE_GUID, |
| 1009 | readableData, |
| 1010 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1011 | BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION TYPE RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1012 | |
| 1013 | // Inference - Workload execution relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1014 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 1015 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1016 | inferenceGuid, |
| 1017 | conv2DWorkloadExecutionGuid, |
| 1018 | LabelsAndEventClasses::CHILD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1019 | readableData, |
| 1020 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1021 | BOOST_TEST_MESSAGE("INFERENCE - CONV2D WORKLOAD EXECUTION CHILD RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1022 | |
| 1023 | // Workload - Workload execution relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1024 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 1025 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1026 | conv2DWorkloadGuid, |
| 1027 | conv2DWorkloadExecutionGuid, |
| 1028 | LabelsAndEventClasses::EXECUTION_OF_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1029 | readableData, |
| 1030 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1031 | BOOST_TEST_MESSAGE("CONV2D WORKLOAD - CONV2D WORKLOAD EXECUTION RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1032 | |
| 1033 | // Start Conv2d workload execution life |
| 1034 | // Event packet - timeline, threadId, eventGuid |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1035 | ProfilingGuid conv2DWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket( |
| 1036 | EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 1037 | BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION START OF LIFE EVENT OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1038 | |
| 1039 | // Conv2d workload execution - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1040 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
| 1041 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1042 | conv2DWorkloadExecutionGuid, |
| 1043 | conv2DWorkloadExecutionSOLEventGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1044 | LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, |
| 1045 | readableData, |
| 1046 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1047 | BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION START OF LIFE RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1048 | |
| 1049 | // End of Conv2d workload execution life |
| 1050 | // Event packet - timeline, threadId, eventGuid |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1051 | ProfilingGuid conv2DWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket( |
| 1052 | EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 1053 | BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION END OF LIFE EVENT OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1054 | |
| 1055 | // Conv2d workload execution - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1056 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
| 1057 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1058 | conv2DWorkloadExecutionGuid, |
| 1059 | conv2DWorkloadExecutionEOLEventGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1060 | LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, |
| 1061 | readableData, |
| 1062 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1063 | BOOST_TEST_MESSAGE("CONV2D WORKLOAD EXECUTION END OF LIFE RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1064 | |
| 1065 | // Activation workload execution |
| 1066 | // Activation workload execution entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1067 | ProfilingGuid activationWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData( |
| 1068 | EmptyOptional(), readableData, offset); |
| 1069 | BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION ENTITY OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1070 | |
| 1071 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1072 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 1073 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1074 | activationWorkloadExecutionGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1075 | LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1076 | LabelsAndEventClasses::TYPE_GUID, |
| 1077 | readableData, |
| 1078 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1079 | BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION TYPE RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1080 | |
| 1081 | // Inference - Workload execution relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1082 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 1083 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1084 | inferenceGuid, |
| 1085 | activationWorkloadExecutionGuid, |
| 1086 | LabelsAndEventClasses::CHILD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1087 | readableData, |
| 1088 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1089 | BOOST_TEST_MESSAGE("INFERENCE - ACTIVATION WORKLOAD EXECUTION CHILD RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1090 | |
| 1091 | // Workload - Workload execution relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1092 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 1093 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1094 | activationWorkloadGuid, |
| 1095 | activationWorkloadExecutionGuid, |
| 1096 | LabelsAndEventClasses::EXECUTION_OF_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1097 | readableData, |
| 1098 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1099 | BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD - ACTIVATION WORKLOAD EXECUTION RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1100 | |
| 1101 | // Start Activation workload execution life |
| 1102 | // Event packet - timeline, threadId, eventGuid |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1103 | ProfilingGuid activationWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket( |
| 1104 | EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 1105 | BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION START OF LIFE EVENT OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1106 | |
| 1107 | // Activation workload execution - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1108 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
| 1109 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1110 | activationWorkloadExecutionGuid, |
| 1111 | activationWorkloadExecutionSOLEventGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1112 | LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, |
| 1113 | readableData, |
| 1114 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1115 | BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION START OF LIFE RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1116 | |
| 1117 | // End of Activation workload execution life |
| 1118 | // Event packet - timeline, threadId, eventGuid |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1119 | ProfilingGuid activationWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket( |
| 1120 | EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 1121 | BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION END OF LIFE EVENT OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1122 | |
| 1123 | // Activation workload execution - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1124 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
| 1125 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1126 | activationWorkloadExecutionGuid, |
| 1127 | activationWorkloadExecutionEOLEventGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1128 | LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, |
| 1129 | readableData, |
| 1130 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1131 | BOOST_TEST_MESSAGE("ACTIVATION WORKLOAD EXECUTION END OF LIFE RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1132 | |
| 1133 | // Output workload execution |
| 1134 | // Output workload execution entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1135 | ProfilingGuid outputWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData( |
| 1136 | EmptyOptional(), readableData, offset); |
| 1137 | BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION ENTITY OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1138 | |
| 1139 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1140 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 1141 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1142 | outputWorkloadExecutionGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1143 | LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1144 | LabelsAndEventClasses::TYPE_GUID, |
| 1145 | readableData, |
| 1146 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1147 | BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION TYPE RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1148 | |
| 1149 | // Inference - Workload execution relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1150 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 1151 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1152 | inferenceGuid, |
| 1153 | outputWorkloadExecutionGuid, |
| 1154 | LabelsAndEventClasses::CHILD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1155 | readableData, |
| 1156 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1157 | BOOST_TEST_MESSAGE("INFERENCE - OUTPUT WORKLOAD EXECUTION CHILD RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1158 | |
| 1159 | // Workload - Workload execution relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1160 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 1161 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1162 | outputWorkloadGuid, |
| 1163 | outputWorkloadExecutionGuid, |
| 1164 | LabelsAndEventClasses::EXECUTION_OF_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1165 | readableData, |
| 1166 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1167 | BOOST_TEST_MESSAGE("OUTPUT WORKLOAD - OUTPUT WORKLOAD EXECUTION EXECUTION_OF RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1168 | |
| 1169 | // Start Output workload execution life |
| 1170 | // Event packet - timeline, threadId, eventGuid |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1171 | ProfilingGuid outputWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket( |
| 1172 | EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 1173 | BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION START OF LIFE EVENT OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1174 | |
| 1175 | // Output workload execution - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1176 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
| 1177 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1178 | outputWorkloadExecutionGuid, |
| 1179 | outputWorkloadExecutionSOLEventGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1180 | LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, |
| 1181 | readableData, |
| 1182 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1183 | BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION - START OF LIFE EVENT RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1184 | |
| 1185 | // End of Normalize workload execution life |
| 1186 | // Event packet - timeline, threadId, eventGuid |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1187 | ProfilingGuid outputWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket( |
| 1188 | EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 1189 | BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION END OF LIFE EVENT OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1190 | |
| 1191 | // Output workload execution - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1192 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
| 1193 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1194 | outputWorkloadExecutionGuid, |
| 1195 | outputWorkloadExecutionEOLEventGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1196 | LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, |
| 1197 | readableData, |
| 1198 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1199 | BOOST_TEST_MESSAGE("OUTPUT WORKLOAD EXECUTION - END OF LIFE EVENT RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1200 | |
| 1201 | // End of Inference life |
| 1202 | // Event packet - timeline, threadId, eventGuid |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1203 | ProfilingGuid inferenceEOLEventGuid = VerifyTimelineEventBinaryPacket( |
| 1204 | EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 1205 | BOOST_TEST_MESSAGE("INFERENCE END OF LIFE EVENT OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1206 | |
| 1207 | // Inference - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1208 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
| 1209 | EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1210 | inferenceGuid, |
| 1211 | inferenceEOLEventGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1212 | LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, |
| 1213 | readableData, |
| 1214 | offset); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1215 | BOOST_TEST_MESSAGE("INFERENCE - END OF LIFE EVENT RELATIONSHIP OK"); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1216 | |
| 1217 | bufferManager.MarkRead(inferenceReadableBuffer); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 1218 | } |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1219 | |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1220 | bool CompareOutput(std::vector<std::string> output, std::vector<std::string> expectedOutput) |
| 1221 | { |
| 1222 | if (output.size() != expectedOutput.size()) |
| 1223 | { |
| 1224 | std::cerr << "output has [" << output.size() << "] lines, expected was [" |
| 1225 | << expectedOutput.size() << "] lines" << std::endl; |
| 1226 | std::cerr << std::endl << "actual" << std::endl << std::endl; |
| 1227 | for (auto line : output) |
| 1228 | { |
| 1229 | std::cerr << line << std::endl; |
| 1230 | } |
| 1231 | std::cerr << std::endl << "expected" << std::endl << std::endl; |
| 1232 | for (auto line : expectedOutput) |
| 1233 | { |
| 1234 | std::cerr << line << std::endl; |
| 1235 | } |
| 1236 | return false; |
| 1237 | } |
| 1238 | bool bRet = true; |
| 1239 | for (unsigned long i = 0; i < output.size(); ++i) |
| 1240 | { |
| 1241 | if (output[i] != expectedOutput[i]) |
| 1242 | { |
| 1243 | bRet = false; |
| 1244 | std::cerr << i << ": actual [" << output[i] << "] expected [" << expectedOutput[i] << "]" << std::endl; |
| 1245 | } |
| 1246 | } |
| 1247 | return bRet; |
| 1248 | } |