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