telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5 | |
Aron Virginas-Tar | c26ba75 | 2018-10-22 13:32:01 +0100 | [diff] [blame] | 6 | #include <armnn/Descriptors.hpp> |
| 7 | #include <armnn/IRuntime.hpp> |
| 8 | #include <armnn/INetwork.hpp> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 9 | #include <Runtime.hpp> |
Aron Virginas-Tar | c26ba75 | 2018-10-22 13:32:01 +0100 | [diff] [blame] | 10 | #include <armnn/TypesUtils.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 11 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 12 | #include <LabelsAndEventClasses.hpp> |
| 13 | #include <test/ProfilingTestUtils.hpp> |
| 14 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 15 | #include <HeapProfiling.hpp> |
| 16 | #include <LeakChecking.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 17 | |
| 18 | #ifdef WITH_VALGRIND |
Aron Virginas-Tar | c26ba75 | 2018-10-22 13:32:01 +0100 | [diff] [blame] | 19 | #include <valgrind/memcheck.h> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 20 | #endif |
| 21 | |
Aron Virginas-Tar | c26ba75 | 2018-10-22 13:32:01 +0100 | [diff] [blame] | 22 | #include <boost/test/unit_test.hpp> |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 23 | #include "RuntimeTests.hpp" |
Aron Virginas-Tar | c26ba75 | 2018-10-22 13:32:01 +0100 | [diff] [blame] | 24 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 25 | namespace armnn |
| 26 | { |
| 27 | |
| 28 | void RuntimeLoadedNetworksReserve(armnn::Runtime* runtime) |
| 29 | { |
| 30 | runtime->m_LoadedNetworks.reserve(1); |
| 31 | } |
| 32 | |
| 33 | } |
| 34 | |
| 35 | BOOST_AUTO_TEST_SUITE(Runtime) |
| 36 | |
| 37 | BOOST_AUTO_TEST_CASE(RuntimeUnloadNetwork) |
| 38 | { |
| 39 | // build 2 mock-networks and load them into the runtime |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 40 | armnn::IRuntime::CreationOptions options; |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 41 | armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 42 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 43 | // Mock network 1. |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 44 | armnn::NetworkId networkIdentifier1 = 1; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 45 | armnn::INetworkPtr mockNetwork1(armnn::INetwork::Create()); |
| 46 | mockNetwork1->AddInputLayer(0, "test layer"); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 47 | std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 48 | runtime->LoadNetwork(networkIdentifier1, Optimize(*mockNetwork1, backends, runtime->GetDeviceSpec())); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 49 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 50 | // Mock network 2. |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 51 | armnn::NetworkId networkIdentifier2 = 2; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 52 | armnn::INetworkPtr mockNetwork2(armnn::INetwork::Create()); |
| 53 | mockNetwork2->AddInputLayer(0, "test layer"); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 54 | runtime->LoadNetwork(networkIdentifier2, Optimize(*mockNetwork2, backends, runtime->GetDeviceSpec())); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 55 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 56 | // Unloads one by its networkID. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 57 | BOOST_TEST(runtime->UnloadNetwork(networkIdentifier1) == armnn::Status::Success); |
| 58 | |
| 59 | BOOST_TEST(runtime->UnloadNetwork(networkIdentifier1) == armnn::Status::Failure); |
| 60 | } |
| 61 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 62 | // Note: the current builds we don't do valgrind and gperftools based leak checking at the same |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 63 | // time, so in practice WITH_VALGRIND and ARMNN_LEAK_CHECKING_ENABLED are exclusive. The |
| 64 | // valgrind tests can stay for x86 builds, but on hikey Valgrind is just way too slow |
| 65 | // to be integrated into the CI system. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 66 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 67 | #ifdef ARMNN_LEAK_CHECKING_ENABLED |
| 68 | |
| 69 | struct DisableGlobalLeakChecking |
| 70 | { |
| 71 | DisableGlobalLeakChecking() |
| 72 | { |
| 73 | ARMNN_LOCAL_LEAK_CHECKING_ONLY(); |
| 74 | } |
| 75 | }; |
| 76 | |
| 77 | BOOST_GLOBAL_FIXTURE(DisableGlobalLeakChecking); |
| 78 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 79 | BOOST_AUTO_TEST_CASE(RuntimeHeapMemoryUsageSanityChecks) |
| 80 | { |
| 81 | BOOST_TEST(ARMNN_LEAK_CHECKER_IS_ACTIVE()); |
| 82 | { |
| 83 | ARMNN_SCOPED_LEAK_CHECKER("Sanity_Check_Outer"); |
| 84 | { |
| 85 | ARMNN_SCOPED_LEAK_CHECKER("Sanity_Check_Inner"); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 86 | BOOST_TEST(ARMNN_NO_LEAKS_IN_SCOPE() == true); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 87 | std::unique_ptr<char[]> dummyAllocation(new char[1000]); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 88 | BOOST_CHECK_MESSAGE(ARMNN_NO_LEAKS_IN_SCOPE() == false, |
| 89 | "A leak of 1000 bytes is expected here. " |
| 90 | "Please make sure environment variable: HEAPCHECK=draconian is set!"); |
| 91 | BOOST_TEST(ARMNN_BYTES_LEAKED_IN_SCOPE() == 1000); |
| 92 | BOOST_TEST(ARMNN_OBJECTS_LEAKED_IN_SCOPE() == 1); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 93 | } |
| 94 | BOOST_TEST(ARMNN_NO_LEAKS_IN_SCOPE()); |
| 95 | BOOST_TEST(ARMNN_BYTES_LEAKED_IN_SCOPE() == 0); |
| 96 | BOOST_TEST(ARMNN_OBJECTS_LEAKED_IN_SCOPE() == 0); |
| 97 | } |
| 98 | } |
| 99 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 100 | #endif // ARMNN_LEAK_CHECKING_ENABLED |
| 101 | |
| 102 | // Note: this part of the code is due to be removed when we fully trust the gperftools based results. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 103 | #ifdef WITH_VALGRIND |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 104 | // Run with the following command to get all the amazing output (in the devenv/build folder) :) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 105 | // valgrind --leak-check=full --show-leak-kinds=all --log-file=Valgrind_Memcheck_Leak_Report.txt armnn/test/UnitTests |
| 106 | BOOST_AUTO_TEST_CASE(RuntimeMemoryLeak) |
| 107 | { |
| 108 | // From documentation: |
| 109 | |
| 110 | // This means that no pointer to the block can be found. The block is classified as "lost", |
| 111 | // because the programmer could not possibly have freed it at program exit, since no pointer to it exists. |
| 112 | unsigned long leakedBefore = 0; |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 113 | unsigned long leakedAfter = 0; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 114 | |
| 115 | // A start-pointer or chain of start-pointers to the block is found. Since the block is still pointed at, |
| 116 | // the programmer could, at least in principle, have freed it before program exit. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 117 | // We want to test this in case memory is not freed as early as it could have been. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 118 | unsigned long reachableBefore = 0; |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 119 | unsigned long reachableAfter = 0; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 120 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 121 | // Needed as out params but we don't test them. |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 122 | unsigned long dubious = 0; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 123 | unsigned long suppressed = 0; |
| 124 | |
| 125 | armnn::NetworkId networkIdentifier1 = 1; |
| 126 | |
| 127 | // ensure that runtime is large enough before checking for memory leaks |
| 128 | // otherwise when loading the network it will automatically reserve memory that won't be released until destruction |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 129 | armnn::IRuntime::CreationOptions options; |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 130 | armnn::Runtime runtime(options); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 131 | armnn::RuntimeLoadedNetworksReserve(&runtime); |
| 132 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 133 | { |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 134 | std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 135 | |
| 136 | std::unique_ptr<armnn::Network> mockNetwork1 = std::make_unique<armnn::Network>(); |
| 137 | mockNetwork1->AddInputLayer(0, "test layer"); |
| 138 | |
Matteo Martincigh | 9326aab | 2018-11-15 10:54:54 +0000 | [diff] [blame] | 139 | // Warm-up load/unload pair to put the runtime in a stable state (memory-wise). |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 140 | runtime.LoadNetwork(networkIdentifier1, Optimize(*mockNetwork1, backends, runtime.GetDeviceSpec())); |
Matteo Martincigh | 9326aab | 2018-11-15 10:54:54 +0000 | [diff] [blame] | 141 | runtime.UnloadNetwork(networkIdentifier1); |
| 142 | |
| 143 | // Checks for leaks before we load the network and record them so that we can see the delta after unloading. |
| 144 | VALGRIND_DO_QUICK_LEAK_CHECK; |
| 145 | VALGRIND_COUNT_LEAKS(leakedBefore, dubious, reachableBefore, suppressed); |
| 146 | |
| 147 | // The actual test. |
| 148 | runtime.LoadNetwork(networkIdentifier1, Optimize(*mockNetwork1, backends, runtime.GetDeviceSpec())); |
| 149 | runtime.UnloadNetwork(networkIdentifier1); |
| 150 | |
| 151 | VALGRIND_DO_ADDED_LEAK_CHECK; |
| 152 | VALGRIND_COUNT_LEAKS(leakedAfter, dubious, reachableAfter, suppressed); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 153 | } |
| 154 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 155 | // If we're not running under Valgrind, these vars will have been initialised to 0, so this will always pass. |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 156 | BOOST_TEST(leakedBefore == leakedAfter); |
Aron Virginas-Tar | c26ba75 | 2018-10-22 13:32:01 +0100 | [diff] [blame] | 157 | BOOST_TEST(reachableBefore == reachableAfter); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 158 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 159 | // These are needed because VALGRIND_COUNT_LEAKS is a macro that assigns to the parameters |
| 160 | // so they are assigned to, but still considered unused, causing a warning. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 161 | boost::ignore_unused(dubious); |
| 162 | boost::ignore_unused(suppressed); |
| 163 | } |
Aron Virginas-Tar | c26ba75 | 2018-10-22 13:32:01 +0100 | [diff] [blame] | 164 | #endif // WITH_VALGRIND |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 165 | |
| 166 | BOOST_AUTO_TEST_CASE(RuntimeCpuRef) |
| 167 | { |
| 168 | using namespace armnn; |
| 169 | |
| 170 | // Create runtime in which test will run |
| 171 | armnn::IRuntime::CreationOptions options; |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 172 | armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 173 | |
| 174 | // build up the structure of the network |
| 175 | INetworkPtr net(INetwork::Create()); |
| 176 | |
| 177 | IConnectableLayer* input = net->AddInputLayer(0); |
| 178 | |
| 179 | // This layer configuration isn't supported by CpuAcc, should be fall back to CpuRef. |
| 180 | NormalizationDescriptor descriptor; |
| 181 | IConnectableLayer* normalize = net->AddNormalizationLayer(descriptor); |
| 182 | |
| 183 | IConnectableLayer* output = net->AddOutputLayer(0); |
| 184 | |
| 185 | input->GetOutputSlot(0).Connect(normalize->GetInputSlot(0)); |
| 186 | normalize->GetOutputSlot(0).Connect(output->GetInputSlot(0)); |
| 187 | |
| 188 | input->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32)); |
| 189 | normalize->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32)); |
| 190 | |
| 191 | // optimize the network |
David Beck | f0b4845 | 2018-10-19 15:20:56 +0100 | [diff] [blame] | 192 | std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 193 | IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec()); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 194 | |
| 195 | // Load it into the runtime. It should success. |
| 196 | armnn::NetworkId netId; |
| 197 | BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet)) == Status::Success); |
| 198 | } |
| 199 | |
| 200 | BOOST_AUTO_TEST_CASE(RuntimeFallbackToCpuRef) |
| 201 | { |
| 202 | using namespace armnn; |
| 203 | |
| 204 | // Create runtime in which test will run |
| 205 | armnn::IRuntime::CreationOptions options; |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 206 | armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 207 | |
| 208 | // build up the structure of the network |
| 209 | INetworkPtr net(INetwork::Create()); |
| 210 | |
| 211 | IConnectableLayer* input = net->AddInputLayer(0); |
| 212 | |
| 213 | // This layer configuration isn't supported by CpuAcc, should be fall back to CpuRef. |
| 214 | NormalizationDescriptor descriptor; |
| 215 | IConnectableLayer* normalize = net->AddNormalizationLayer(descriptor); |
| 216 | |
| 217 | IConnectableLayer* output = net->AddOutputLayer(0); |
| 218 | |
| 219 | input->GetOutputSlot(0).Connect(normalize->GetInputSlot(0)); |
| 220 | normalize->GetOutputSlot(0).Connect(output->GetInputSlot(0)); |
| 221 | |
| 222 | input->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32)); |
| 223 | normalize->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32)); |
| 224 | |
| 225 | // Allow fallback to CpuRef. |
David Beck | f0b4845 | 2018-10-19 15:20:56 +0100 | [diff] [blame] | 226 | std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc, armnn::Compute::CpuRef }; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 227 | // optimize the network |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 228 | IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec()); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 229 | |
| 230 | // Load it into the runtime. It should succeed. |
| 231 | armnn::NetworkId netId; |
| 232 | BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet)) == Status::Success); |
| 233 | } |
| 234 | |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 235 | BOOST_AUTO_TEST_CASE(IVGCVSW_1929_QuantizedSoftmaxIssue) |
| 236 | { |
| 237 | // Test for issue reported by Chris Nix in https://jira.arm.com/browse/IVGCVSW-1929 |
| 238 | using namespace armnn; |
| 239 | |
| 240 | // Create runtime in which test will run |
| 241 | armnn::IRuntime::CreationOptions options; |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 242 | armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 243 | |
| 244 | // build up the structure of the network |
| 245 | INetworkPtr net(INetwork::Create()); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 246 | armnn::IConnectableLayer* input = net->AddInputLayer(0,"input"); |
| 247 | armnn::IConnectableLayer* softmax = net->AddSoftmaxLayer(armnn::SoftmaxDescriptor(), "softmax"); |
| 248 | armnn::IConnectableLayer* output = net->AddOutputLayer(0, "output"); |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 249 | |
| 250 | input->GetOutputSlot(0).Connect(softmax->GetInputSlot(0)); |
| 251 | softmax->GetOutputSlot(0).Connect(output->GetInputSlot(0)); |
| 252 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 253 | input->GetOutputSlot(0).SetTensorInfo(armnn::TensorInfo(armnn::TensorShape({ 1, 5 }), |
| 254 | armnn::DataType::QAsymmU8, |
| 255 | 1.0f / 255, |
| 256 | 0)); |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 257 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 258 | softmax->GetOutputSlot(0).SetTensorInfo(armnn::TensorInfo(armnn::TensorShape({ 1, 5 }), |
| 259 | armnn::DataType::QAsymmU8)); |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 260 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 261 | std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; |
| 262 | std::vector<std::string> errMessages; |
| 263 | armnn::IOptimizedNetworkPtr optNet = Optimize(*net, |
| 264 | backends, |
| 265 | runtime->GetDeviceSpec(), |
| 266 | OptimizerOptions(), |
| 267 | errMessages); |
David Beck | f0b4845 | 2018-10-19 15:20:56 +0100 | [diff] [blame] | 268 | |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 269 | BOOST_TEST(errMessages.size() == 1); |
| 270 | BOOST_TEST(errMessages[0] == |
| 271 | "ERROR: output 0 of layer Softmax (softmax) is of type " |
| 272 | "Quantized 8 bit but its scale parameter has not been set"); |
| 273 | BOOST_TEST(!optNet); |
| 274 | } |
| 275 | |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 276 | BOOST_AUTO_TEST_CASE(RuntimeBackendOptions) |
| 277 | { |
| 278 | using namespace armnn; |
| 279 | |
| 280 | IRuntime::CreationOptions creationOptions; |
| 281 | auto& backendOptions = creationOptions.m_BackendOptions; |
| 282 | |
| 283 | |
| 284 | // Define Options on explicit construction |
| 285 | BackendOptions options1("FakeBackend1", |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 286 | { |
| 287 | { "Option1", 1.3f }, |
| 288 | { "Option2", true } |
| 289 | }); |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 290 | |
| 291 | // Add an option after construction |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 292 | options1.AddOption({ "Option3", "some_value" }); |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 293 | |
| 294 | // Add the options to CreationOptions struct |
| 295 | backendOptions.push_back(options1); |
| 296 | |
| 297 | // Add more Options via inplace explicit construction |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 298 | backendOptions.emplace_back(BackendOptions{ "FakeBackend1", |
| 299 | {{ "Option4", 42 }} |
| 300 | }); |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 301 | |
| 302 | |
| 303 | // First group |
| 304 | BOOST_TEST(backendOptions[0].GetBackendId().Get() == "FakeBackend1"); |
| 305 | BOOST_TEST(backendOptions[0].GetOption(0).GetName() == "Option1"); |
| 306 | BOOST_TEST(backendOptions[0].GetOption(0).GetValue().IsFloat() == true); |
| 307 | BOOST_TEST(backendOptions[0].GetOption(0).GetValue().AsFloat() == 1.3f); |
| 308 | |
| 309 | BOOST_TEST(backendOptions[0].GetOption(1).GetName() == "Option2"); |
| 310 | BOOST_TEST(backendOptions[0].GetOption(1).GetValue().IsBool() == true); |
| 311 | BOOST_TEST(backendOptions[0].GetOption(1).GetValue().AsBool() == true); |
| 312 | |
| 313 | BOOST_TEST(backendOptions[0].GetOption(2).GetName() == "Option3"); |
| 314 | BOOST_TEST(backendOptions[0].GetOption(2).GetValue().IsString() == true); |
| 315 | BOOST_TEST(backendOptions[0].GetOption(2).GetValue().AsString() == "some_value"); |
| 316 | |
| 317 | // Second group |
| 318 | BOOST_TEST(backendOptions[1].GetBackendId().Get() == "FakeBackend1"); |
| 319 | BOOST_TEST(backendOptions[1].GetOption(0).GetName() == "Option4"); |
| 320 | BOOST_TEST(backendOptions[1].GetOption(0).GetValue().IsInt() == true); |
| 321 | BOOST_TEST(backendOptions[1].GetOption(0).GetValue().AsInt() == 42); |
| 322 | } |
| 323 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 324 | BOOST_AUTO_TEST_CASE(ProfilingDisable) |
| 325 | { |
| 326 | using namespace armnn; |
| 327 | |
| 328 | // Create runtime in which the test will run |
| 329 | armnn::IRuntime::CreationOptions options; |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 330 | armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 331 | |
| 332 | // build up the structure of the network |
| 333 | INetworkPtr net(INetwork::Create()); |
| 334 | |
| 335 | IConnectableLayer* input = net->AddInputLayer(0); |
| 336 | |
| 337 | // This layer configuration isn't supported by CpuAcc, should fall back to CpuRef. |
| 338 | NormalizationDescriptor descriptor; |
| 339 | IConnectableLayer* normalize = net->AddNormalizationLayer(descriptor); |
| 340 | |
| 341 | IConnectableLayer* output = net->AddOutputLayer(0); |
| 342 | |
| 343 | input->GetOutputSlot(0).Connect(normalize->GetInputSlot(0)); |
| 344 | normalize->GetOutputSlot(0).Connect(output->GetInputSlot(0)); |
| 345 | |
| 346 | input->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32)); |
| 347 | normalize->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32)); |
| 348 | |
| 349 | // optimize the network |
| 350 | std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 351 | IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec()); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 352 | |
| 353 | // Load it into the runtime. It should succeed. |
| 354 | armnn::NetworkId netId; |
| 355 | BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet)) == Status::Success); |
| 356 | |
| 357 | profiling::ProfilingServiceRuntimeHelper profilingServiceHelper; |
| 358 | profiling::BufferManager& bufferManager = profilingServiceHelper.GetProfilingBufferManager(); |
| 359 | auto readableBuffer = bufferManager.GetReadableBuffer(); |
| 360 | |
| 361 | // Profiling is not enabled, the post-optimisation structure should not be created |
| 362 | BOOST_TEST(!readableBuffer); |
| 363 | } |
| 364 | |
| 365 | BOOST_AUTO_TEST_CASE(ProfilingEnableCpuRef) |
| 366 | { |
| 367 | using namespace armnn; |
| 368 | using namespace armnn::profiling; |
| 369 | |
| 370 | // Create runtime in which the test will run |
| 371 | armnn::IRuntime::CreationOptions options; |
| 372 | options.m_ProfilingOptions.m_EnableProfiling = true; |
| 373 | armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); |
| 374 | |
| 375 | // build up the structure of the network |
| 376 | INetworkPtr net(INetwork::Create()); |
| 377 | |
| 378 | IConnectableLayer* input = net->AddInputLayer(0, "input"); |
| 379 | |
| 380 | NormalizationDescriptor descriptor; |
| 381 | IConnectableLayer* normalize = net->AddNormalizationLayer(descriptor, "normalization"); |
| 382 | |
| 383 | IConnectableLayer* output = net->AddOutputLayer(0, "output"); |
| 384 | |
| 385 | input->GetOutputSlot(0).Connect(normalize->GetInputSlot(0)); |
| 386 | normalize->GetOutputSlot(0).Connect(output->GetInputSlot(0)); |
| 387 | |
| 388 | input->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32)); |
| 389 | normalize->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32)); |
| 390 | |
| 391 | // optimize the network |
| 392 | std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 393 | IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec()); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 394 | |
| 395 | ProfilingGuid optNetGuid = optNet->GetGuid(); |
| 396 | |
| 397 | // Load it into the runtime. It should succeed. |
| 398 | armnn::NetworkId netId; |
| 399 | BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet)) == Status::Success); |
| 400 | |
| 401 | profiling::ProfilingServiceRuntimeHelper profilingServiceHelper; |
| 402 | profiling::BufferManager& bufferManager = profilingServiceHelper.GetProfilingBufferManager(); |
| 403 | auto readableBuffer = bufferManager.GetReadableBuffer(); |
| 404 | |
| 405 | // Profiling is enabled, the post-optimisation structure should be created |
| 406 | BOOST_CHECK(readableBuffer != nullptr); |
| 407 | |
| 408 | unsigned int size = readableBuffer->GetSize(); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 409 | BOOST_CHECK(size == 1068); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 410 | |
| 411 | const unsigned char* readableData = readableBuffer->GetReadableData(); |
| 412 | BOOST_CHECK(readableData != nullptr); |
| 413 | |
| 414 | unsigned int offset = 0; |
| 415 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 416 | // Verify Header |
| 417 | VerifyTimelineHeaderBinary(readableData, offset, 1060); |
| 418 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 419 | // Post-optimisation network |
| 420 | // Network entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 421 | VerifyTimelineEntityBinaryPacketData(optNetGuid, readableData, offset |
| 422 | ); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 423 | |
| 424 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 425 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 426 | EmptyOptional(), |
| 427 | optNetGuid, |
| 428 | LabelsAndEventClasses::NETWORK_GUID, |
| 429 | readableData, |
| 430 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 431 | |
| 432 | // Type label relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 433 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 434 | EmptyOptional(), |
| 435 | EmptyOptional(), |
| 436 | LabelsAndEventClasses::TYPE_GUID, |
| 437 | readableData, |
| 438 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 439 | |
| 440 | // Input layer |
| 441 | // Input layer entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 442 | VerifyTimelineEntityBinaryPacketData(input->GetGuid(), readableData, offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 443 | |
| 444 | // Name Entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 445 | VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "input", readableData, offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 446 | |
| 447 | // Entity - Name relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 448 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 449 | EmptyOptional(), |
| 450 | input->GetGuid(), |
| 451 | EmptyOptional(), |
| 452 | readableData, |
| 453 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 454 | |
| 455 | // Name label relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 456 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 457 | EmptyOptional(), |
| 458 | EmptyOptional(), |
| 459 | LabelsAndEventClasses::NAME_GUID, |
| 460 | readableData, |
| 461 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 462 | |
| 463 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 464 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 465 | EmptyOptional(), |
| 466 | input->GetGuid(), |
| 467 | EmptyOptional(), |
| 468 | readableData, |
| 469 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 470 | |
| 471 | // Type label relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 472 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 473 | EmptyOptional(), |
| 474 | EmptyOptional(), |
| 475 | LabelsAndEventClasses::TYPE_GUID, |
| 476 | readableData, |
| 477 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 478 | |
| 479 | // Network - Input layer relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 480 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 481 | EmptyOptional(), |
| 482 | optNetGuid, |
| 483 | input->GetGuid(), |
| 484 | readableData, |
| 485 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 486 | |
| 487 | // Normalization layer |
| 488 | // Normalization layer entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 489 | VerifyTimelineEntityBinaryPacketData(normalize->GetGuid(), readableData, offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 490 | |
| 491 | // Name entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 492 | VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "normalization", readableData, offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 493 | |
| 494 | // Entity - Name relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 495 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 496 | EmptyOptional(), |
| 497 | normalize->GetGuid(), |
| 498 | EmptyOptional(), |
| 499 | readableData, |
| 500 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 501 | |
| 502 | // Name label relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 503 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 504 | EmptyOptional(), |
| 505 | EmptyOptional(), |
| 506 | LabelsAndEventClasses::NAME_GUID, |
| 507 | readableData, |
| 508 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 509 | |
| 510 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 511 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 512 | EmptyOptional(), |
| 513 | normalize->GetGuid(), |
| 514 | EmptyOptional(), |
| 515 | readableData, |
| 516 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 517 | |
| 518 | // Type label relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 519 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 520 | EmptyOptional(), |
| 521 | EmptyOptional(), |
| 522 | LabelsAndEventClasses::TYPE_GUID, |
| 523 | readableData, |
| 524 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 525 | |
| 526 | // Network - Normalize layer relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 527 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 528 | EmptyOptional(), |
| 529 | optNetGuid, |
| 530 | normalize->GetGuid(), |
| 531 | readableData, |
| 532 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 533 | |
| 534 | // Input layer - Normalize layer relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 535 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 536 | EmptyOptional(), |
| 537 | input->GetGuid(), |
| 538 | normalize->GetGuid(), |
| 539 | readableData, |
| 540 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 541 | |
| 542 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 543 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 544 | EmptyOptional(), |
| 545 | EmptyOptional(), |
| 546 | LabelsAndEventClasses::CONNECTION_GUID, |
| 547 | readableData, |
| 548 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 549 | |
| 550 | // Type label relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 551 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 552 | EmptyOptional(), |
| 553 | EmptyOptional(), |
| 554 | LabelsAndEventClasses::TYPE_GUID, |
| 555 | readableData, |
| 556 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 557 | |
| 558 | // Normalization workload |
| 559 | // Normalization workload entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 560 | VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 561 | |
| 562 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 563 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 564 | EmptyOptional(), |
| 565 | EmptyOptional(), |
| 566 | EmptyOptional(), |
| 567 | readableData, |
| 568 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 569 | |
| 570 | // Type label relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 571 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 572 | EmptyOptional(), |
| 573 | EmptyOptional(), |
| 574 | LabelsAndEventClasses::TYPE_GUID, |
| 575 | readableData, |
| 576 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 577 | |
| 578 | // BackendId entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 579 | VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "CpuRef", readableData, offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 580 | |
| 581 | // Entity - BackendId relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 582 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 583 | EmptyOptional(), |
| 584 | EmptyOptional(), |
| 585 | EmptyOptional(), |
| 586 | readableData, |
| 587 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 588 | |
| 589 | // BackendId label relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 590 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 591 | EmptyOptional(), |
| 592 | EmptyOptional(), |
| 593 | LabelsAndEventClasses::BACKENDID_GUID, |
| 594 | readableData, |
| 595 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 596 | |
| 597 | // Normalize layer - Normalize workload relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 598 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 599 | EmptyOptional(), |
| 600 | normalize->GetGuid(), |
| 601 | EmptyOptional(), |
| 602 | readableData, |
| 603 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 604 | |
| 605 | // Output layer |
| 606 | // Output layer entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 607 | VerifyTimelineEntityBinaryPacketData(output->GetGuid(), readableData, offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 608 | |
| 609 | // Name entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 610 | VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "output", readableData, offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 611 | |
| 612 | // Entity - Name relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 613 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 614 | EmptyOptional(), |
| 615 | output->GetGuid(), |
| 616 | EmptyOptional(), |
| 617 | readableData, |
| 618 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 619 | |
| 620 | // Name label relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 621 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 622 | EmptyOptional(), |
| 623 | EmptyOptional(), |
| 624 | LabelsAndEventClasses::NAME_GUID, |
| 625 | readableData, |
| 626 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 627 | |
| 628 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 629 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 630 | EmptyOptional(), |
| 631 | output->GetGuid(), |
| 632 | EmptyOptional(), |
| 633 | readableData, |
| 634 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 635 | |
| 636 | // Type label relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 637 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 638 | EmptyOptional(), |
| 639 | EmptyOptional(), |
| 640 | LabelsAndEventClasses::TYPE_GUID, |
| 641 | readableData, |
| 642 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 643 | |
| 644 | // Network - Output layer relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 645 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 646 | EmptyOptional(), |
| 647 | optNetGuid, |
| 648 | output->GetGuid(), |
| 649 | readableData, |
| 650 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 651 | |
| 652 | // Normalize layer - Output layer relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 653 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 654 | EmptyOptional(), |
| 655 | normalize->GetGuid(), |
| 656 | output->GetGuid(), |
| 657 | readableData, |
| 658 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 659 | |
| 660 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 661 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 662 | EmptyOptional(), |
| 663 | EmptyOptional(), |
| 664 | LabelsAndEventClasses::CONNECTION_GUID, |
| 665 | readableData, |
| 666 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 667 | |
| 668 | // Type label relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 669 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 670 | EmptyOptional(), |
| 671 | EmptyOptional(), |
| 672 | LabelsAndEventClasses::TYPE_GUID, |
| 673 | readableData, |
| 674 | offset); |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 675 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 676 | bufferManager.MarkRead(readableBuffer); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 677 | |
| 678 | // Creates structures for input & output. |
| 679 | std::vector<float> inputData(16); |
| 680 | std::vector<float> outputData(16); |
| 681 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 682 | InputTensors inputTensors |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 683 | { |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 684 | { 0, ConstTensor(runtime->GetInputTensorInfo(netId, 0), inputData.data()) } |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 685 | }; |
| 686 | OutputTensors outputTensors |
| 687 | { |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 688 | { 0, Tensor(runtime->GetOutputTensorInfo(netId, 0), outputData.data()) } |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 689 | }; |
| 690 | |
| 691 | // Does the inference. |
| 692 | runtime->EnqueueWorkload(netId, inputTensors, outputTensors); |
| 693 | |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 694 | // Get readable buffer for inference timeline |
| 695 | auto inferenceReadableBuffer = bufferManager.GetReadableBuffer(); |
| 696 | BOOST_CHECK(inferenceReadableBuffer != nullptr); |
| 697 | |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 698 | // Get readable buffer for output workload |
| 699 | auto outputReadableBuffer = bufferManager.GetReadableBuffer(); |
| 700 | BOOST_CHECK(outputReadableBuffer != nullptr); |
| 701 | |
| 702 | // Get readable buffer for input workload |
| 703 | auto inputReadableBuffer = bufferManager.GetReadableBuffer(); |
| 704 | BOOST_CHECK(inputReadableBuffer != nullptr); |
| 705 | |
| 706 | // Validate input workload data |
| 707 | size = inputReadableBuffer->GetSize(); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 708 | BOOST_CHECK(size == 204); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 709 | |
| 710 | readableData = inputReadableBuffer->GetReadableData(); |
| 711 | BOOST_CHECK(readableData != nullptr); |
| 712 | |
| 713 | offset = 0; |
| 714 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 715 | // Verify Header |
| 716 | VerifyTimelineHeaderBinary(readableData, offset, 196); |
| 717 | |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 718 | // Input workload |
| 719 | // Input workload entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 720 | VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 721 | |
| 722 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 723 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 724 | EmptyOptional(), |
| 725 | EmptyOptional(), |
| 726 | EmptyOptional(), |
| 727 | readableData, |
| 728 | offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 729 | |
| 730 | // Type label relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 731 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 732 | EmptyOptional(), |
| 733 | EmptyOptional(), |
| 734 | LabelsAndEventClasses::TYPE_GUID, |
| 735 | readableData, |
| 736 | offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 737 | |
| 738 | // BackendId entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 739 | VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "CpuRef", readableData, offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 740 | |
| 741 | // Entity - BackendId relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 742 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 743 | EmptyOptional(), |
| 744 | EmptyOptional(), |
| 745 | EmptyOptional(), |
| 746 | readableData, |
| 747 | offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 748 | |
| 749 | // BackendId label relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 750 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 751 | EmptyOptional(), |
| 752 | EmptyOptional(), |
| 753 | LabelsAndEventClasses::BACKENDID_GUID, |
| 754 | readableData, |
| 755 | offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 756 | |
| 757 | // Input layer - Input workload relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 758 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 759 | EmptyOptional(), |
| 760 | input->GetGuid(), |
| 761 | EmptyOptional(), |
| 762 | readableData, |
| 763 | offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 764 | |
| 765 | bufferManager.MarkRead(inputReadableBuffer); |
| 766 | |
| 767 | // Validate output workload data |
| 768 | size = outputReadableBuffer->GetSize(); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 769 | BOOST_CHECK(size == 204); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 770 | |
| 771 | readableData = outputReadableBuffer->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 |
| 777 | VerifyTimelineHeaderBinary(readableData, offset, 196); |
| 778 | |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 779 | // Output workload |
| 780 | // Output workload entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 781 | VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 782 | |
| 783 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 784 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 785 | EmptyOptional(), |
| 786 | EmptyOptional(), |
| 787 | EmptyOptional(), |
| 788 | readableData, |
| 789 | offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 790 | |
| 791 | // Type label relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 792 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 793 | EmptyOptional(), |
| 794 | EmptyOptional(), |
| 795 | LabelsAndEventClasses::TYPE_GUID, |
| 796 | readableData, |
| 797 | offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 798 | |
| 799 | // BackendId entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 800 | VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "CpuRef", readableData, offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 801 | |
| 802 | // Entity - BackendId relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 803 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 804 | EmptyOptional(), |
| 805 | EmptyOptional(), |
| 806 | EmptyOptional(), |
| 807 | readableData, |
| 808 | offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 809 | |
| 810 | // BackendId label relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 811 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 812 | EmptyOptional(), |
| 813 | EmptyOptional(), |
| 814 | LabelsAndEventClasses::BACKENDID_GUID, |
| 815 | readableData, |
| 816 | offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 817 | |
| 818 | // Output layer - Output workload relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 819 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 820 | EmptyOptional(), |
| 821 | output->GetGuid(), |
| 822 | EmptyOptional(), |
| 823 | readableData, |
| 824 | offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 825 | |
| 826 | bufferManager.MarkRead(outputReadableBuffer); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 827 | |
| 828 | // Validate inference data |
| 829 | size = inferenceReadableBuffer->GetSize(); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 830 | BOOST_CHECK(size == 1272); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 831 | |
| 832 | readableData = inferenceReadableBuffer->GetReadableData(); |
| 833 | BOOST_CHECK(readableData != nullptr); |
| 834 | |
| 835 | offset = 0; |
| 836 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 837 | // Verify Header |
| 838 | VerifyTimelineHeaderBinary(readableData, offset, 1264); |
| 839 | |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 840 | // Inference timeline trace |
| 841 | // Inference entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 842 | VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 843 | |
| 844 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 845 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 846 | EmptyOptional(), |
| 847 | EmptyOptional(), |
| 848 | LabelsAndEventClasses::INFERENCE_GUID, |
| 849 | readableData, |
| 850 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 851 | |
| 852 | // Type label relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 853 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 854 | EmptyOptional(), |
| 855 | EmptyOptional(), |
| 856 | LabelsAndEventClasses::TYPE_GUID, |
| 857 | readableData, |
| 858 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 859 | |
| 860 | // Network - Inference relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 861 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 862 | EmptyOptional(), |
| 863 | optNetGuid, |
| 864 | EmptyOptional(), |
| 865 | readableData, |
| 866 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 867 | |
| 868 | // Start Inference life |
| 869 | // Event packet - timeline, threadId, eventGuid |
| 870 | VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 871 | |
| 872 | // Inference - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 873 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
| 874 | EmptyOptional(), |
| 875 | EmptyOptional(), |
| 876 | EmptyOptional(), |
| 877 | readableData, |
| 878 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 879 | |
| 880 | // Event - event class relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 881 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink, |
| 882 | EmptyOptional(), |
| 883 | EmptyOptional(), |
| 884 | LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, |
| 885 | readableData, |
| 886 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 887 | |
| 888 | // Execution |
| 889 | // Input workload execution |
| 890 | // Input workload execution entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 891 | VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset); |
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(), |
| 896 | EmptyOptional(), |
| 897 | LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, |
| 898 | readableData, |
| 899 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 900 | |
| 901 | // Type label relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 902 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 903 | EmptyOptional(), |
| 904 | EmptyOptional(), |
| 905 | LabelsAndEventClasses::TYPE_GUID, |
| 906 | readableData, |
| 907 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 908 | |
| 909 | // Inference - Workload execution relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 910 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 911 | EmptyOptional(), |
| 912 | EmptyOptional(), |
| 913 | EmptyOptional(), |
| 914 | readableData, |
| 915 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 916 | |
| 917 | // Workload - Workload execution relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 918 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 919 | EmptyOptional(), |
| 920 | EmptyOptional(), |
| 921 | EmptyOptional(), |
| 922 | readableData, |
| 923 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 924 | |
| 925 | // Start Input workload execution life |
| 926 | // Event packet - timeline, threadId, eventGuid |
| 927 | VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 928 | |
| 929 | // Input workload execution - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 930 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
| 931 | EmptyOptional(), |
| 932 | EmptyOptional(), |
| 933 | EmptyOptional(), |
| 934 | readableData, |
| 935 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 936 | |
| 937 | // Event - event class relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 938 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink, |
| 939 | EmptyOptional(), |
| 940 | EmptyOptional(), |
| 941 | LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, |
| 942 | readableData, |
| 943 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 944 | |
| 945 | // End of Input workload execution life |
| 946 | // Event packet - timeline, threadId, eventGuid |
| 947 | VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 948 | |
| 949 | // Input workload execution - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 950 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
| 951 | EmptyOptional(), |
| 952 | EmptyOptional(), |
| 953 | EmptyOptional(), |
| 954 | readableData, |
| 955 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 956 | |
| 957 | // Event - event class relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 958 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink, |
| 959 | EmptyOptional(), |
| 960 | EmptyOptional(), |
| 961 | LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, |
| 962 | readableData, |
| 963 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 964 | |
| 965 | // Normalize workload execution |
| 966 | // Normalize workload execution entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 967 | VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 968 | |
| 969 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 970 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 971 | EmptyOptional(), |
| 972 | EmptyOptional(), |
| 973 | LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, |
| 974 | readableData, |
| 975 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 976 | |
| 977 | // Type label relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 978 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 979 | EmptyOptional(), |
| 980 | EmptyOptional(), |
| 981 | LabelsAndEventClasses::TYPE_GUID, |
| 982 | readableData, |
| 983 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 984 | |
| 985 | // Inference - Workload execution relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 986 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 987 | EmptyOptional(), |
| 988 | EmptyOptional(), |
| 989 | EmptyOptional(), |
| 990 | readableData, |
| 991 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 992 | |
| 993 | // Workload - Workload execution relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 994 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 995 | EmptyOptional(), |
| 996 | EmptyOptional(), |
| 997 | EmptyOptional(), |
| 998 | readableData, |
| 999 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1000 | |
| 1001 | // Start Normalize workload execution life |
| 1002 | // Event packet - timeline, threadId, eventGuid |
| 1003 | VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 1004 | |
| 1005 | // Normalize workload execution - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 1006 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
| 1007 | EmptyOptional(), |
| 1008 | EmptyOptional(), |
| 1009 | EmptyOptional(), |
| 1010 | readableData, |
| 1011 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1012 | |
| 1013 | // Event - event class relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 1014 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink, |
| 1015 | EmptyOptional(), |
| 1016 | EmptyOptional(), |
| 1017 | LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, |
| 1018 | readableData, |
| 1019 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1020 | |
| 1021 | // End of Normalize workload execution life |
| 1022 | // Event packet - timeline, threadId, eventGuid |
| 1023 | VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 1024 | |
| 1025 | // Normalize workload execution - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 1026 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
| 1027 | EmptyOptional(), |
| 1028 | EmptyOptional(), |
| 1029 | EmptyOptional(), |
| 1030 | readableData, |
| 1031 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1032 | |
| 1033 | // Event - event class relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 1034 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink, |
| 1035 | EmptyOptional(), |
| 1036 | EmptyOptional(), |
| 1037 | LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, |
| 1038 | readableData, |
| 1039 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1040 | |
| 1041 | // Output workload execution |
| 1042 | // Output workload execution entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 1043 | VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1044 | |
| 1045 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 1046 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 1047 | EmptyOptional(), |
| 1048 | EmptyOptional(), |
| 1049 | LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, |
| 1050 | readableData, |
| 1051 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1052 | |
| 1053 | // Type label relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 1054 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
| 1055 | EmptyOptional(), |
| 1056 | EmptyOptional(), |
| 1057 | LabelsAndEventClasses::TYPE_GUID, |
| 1058 | readableData, |
| 1059 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1060 | |
| 1061 | // Inference - Workload execution relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 1062 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 1063 | EmptyOptional(), |
| 1064 | EmptyOptional(), |
| 1065 | EmptyOptional(), |
| 1066 | readableData, |
| 1067 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1068 | |
| 1069 | // Workload - Workload execution relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 1070 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
| 1071 | EmptyOptional(), |
| 1072 | EmptyOptional(), |
| 1073 | EmptyOptional(), |
| 1074 | readableData, |
| 1075 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1076 | |
| 1077 | // Start Output workload execution life |
| 1078 | // Event packet - timeline, threadId, eventGuid |
| 1079 | VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 1080 | |
| 1081 | // Output workload execution - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 1082 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
| 1083 | EmptyOptional(), |
| 1084 | EmptyOptional(), |
| 1085 | EmptyOptional(), |
| 1086 | readableData, |
| 1087 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1088 | |
| 1089 | // Event - event class relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 1090 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink, |
| 1091 | EmptyOptional(), |
| 1092 | EmptyOptional(), |
| 1093 | LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, |
| 1094 | readableData, |
| 1095 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1096 | |
| 1097 | // End of Normalize workload execution life |
| 1098 | // Event packet - timeline, threadId, eventGuid |
| 1099 | VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 1100 | |
| 1101 | // Output workload execution - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 1102 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
| 1103 | EmptyOptional(), |
| 1104 | EmptyOptional(), |
| 1105 | EmptyOptional(), |
| 1106 | readableData, |
| 1107 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1108 | |
| 1109 | // Event - event class relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 1110 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink, |
| 1111 | EmptyOptional(), |
| 1112 | EmptyOptional(), |
| 1113 | LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, |
| 1114 | readableData, |
| 1115 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1116 | |
| 1117 | // End of Inference life |
| 1118 | // Event packet - timeline, threadId, eventGuid |
| 1119 | VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 1120 | |
| 1121 | // Inference - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 1122 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
| 1123 | EmptyOptional(), |
| 1124 | EmptyOptional(), |
| 1125 | EmptyOptional(), |
| 1126 | readableData, |
| 1127 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1128 | |
| 1129 | // Event - event class relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame^] | 1130 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink, |
| 1131 | EmptyOptional(), |
| 1132 | EmptyOptional(), |
| 1133 | LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, |
| 1134 | readableData, |
| 1135 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1136 | |
| 1137 | bufferManager.MarkRead(inferenceReadableBuffer); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 1138 | } |
| 1139 | |
| 1140 | BOOST_AUTO_TEST_CASE(ProfilingPostOptimisationStructureCpuRef) |
| 1141 | { |
| 1142 | VerifyPostOptimisationStructureTestImpl(armnn::Compute::CpuRef); |
| 1143 | } |
| 1144 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1145 | BOOST_AUTO_TEST_SUITE_END() |