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; |
| 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. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 44 | armnn::NetworkId networkIdentifier1 = 1; |
| 45 | armnn::INetworkPtr mockNetwork1(armnn::INetwork::Create()); |
| 46 | mockNetwork1->AddInputLayer(0, "test layer"); |
David Beck | f0b4845 | 2018-10-19 15:20:56 +0100 | [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. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 51 | armnn::NetworkId networkIdentifier2 = 2; |
| 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; |
| 113 | unsigned long leakedAfter = 0; |
| 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; |
| 119 | unsigned long reachableAfter = 0; |
| 120 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 121 | // Needed as out params but we don't test them. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 122 | unsigned long dubious = 0; |
| 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; |
| 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 | { |
Matteo Martincigh | 9326aab | 2018-11-15 10:54:54 +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. |
Aron Virginas-Tar | c26ba75 | 2018-10-22 13:32:01 +0100 | [diff] [blame] | 156 | BOOST_TEST(leakedBefore == leakedAfter); |
| 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; |
| 172 | armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); |
| 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 }; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 193 | IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec()); |
| 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; |
| 206 | armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); |
| 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 |
| 228 | IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec()); |
| 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; |
| 242 | armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); |
| 243 | |
| 244 | // build up the structure of the network |
| 245 | INetworkPtr net(INetwork::Create()); |
| 246 | armnn::IConnectableLayer* input = net->AddInputLayer( |
| 247 | 0, |
| 248 | "input" |
| 249 | ); |
| 250 | armnn::IConnectableLayer* softmax = net->AddSoftmaxLayer( |
| 251 | armnn::SoftmaxDescriptor(), |
| 252 | "softmax" |
| 253 | ); |
| 254 | armnn::IConnectableLayer* output = net->AddOutputLayer( |
| 255 | 0, |
| 256 | "output" |
| 257 | ); |
| 258 | |
| 259 | input->GetOutputSlot(0).Connect(softmax->GetInputSlot(0)); |
| 260 | softmax->GetOutputSlot(0).Connect(output->GetInputSlot(0)); |
| 261 | |
| 262 | input->GetOutputSlot(0).SetTensorInfo(armnn::TensorInfo( |
| 263 | armnn::TensorShape({ 1, 5 }), |
| 264 | armnn::DataType::QuantisedAsymm8, |
| 265 | 1.0f/255, |
| 266 | 0 |
| 267 | )); |
| 268 | |
| 269 | softmax->GetOutputSlot(0).SetTensorInfo(armnn::TensorInfo( |
| 270 | armnn::TensorShape({ 1, 5 }), |
| 271 | armnn::DataType::QuantisedAsymm8 |
| 272 | )); |
| 273 | |
David Beck | f0b4845 | 2018-10-19 15:20:56 +0100 | [diff] [blame] | 274 | std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef}; |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 275 | std::vector<std::string> errMessages; |
| 276 | armnn::IOptimizedNetworkPtr optNet = Optimize( |
| 277 | *net, |
| 278 | backends, |
| 279 | runtime->GetDeviceSpec(), |
| 280 | OptimizerOptions(), |
| 281 | errMessages |
| 282 | ); |
David Beck | f0b4845 | 2018-10-19 15:20:56 +0100 | [diff] [blame] | 283 | |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 284 | BOOST_TEST(errMessages.size() == 1); |
| 285 | BOOST_TEST(errMessages[0] == |
| 286 | "ERROR: output 0 of layer Softmax (softmax) is of type " |
| 287 | "Quantized 8 bit but its scale parameter has not been set"); |
| 288 | BOOST_TEST(!optNet); |
| 289 | } |
| 290 | |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame^] | 291 | BOOST_AUTO_TEST_CASE(RuntimeBackendOptions) |
| 292 | { |
| 293 | using namespace armnn; |
| 294 | |
| 295 | IRuntime::CreationOptions creationOptions; |
| 296 | auto& backendOptions = creationOptions.m_BackendOptions; |
| 297 | |
| 298 | |
| 299 | // Define Options on explicit construction |
| 300 | BackendOptions options1("FakeBackend1", |
| 301 | { |
| 302 | {"Option1", 1.3f}, |
| 303 | {"Option2", true} |
| 304 | }); |
| 305 | |
| 306 | // Add an option after construction |
| 307 | options1.AddOption({"Option3", "some_value"}); |
| 308 | |
| 309 | // Add the options to CreationOptions struct |
| 310 | backendOptions.push_back(options1); |
| 311 | |
| 312 | // Add more Options via inplace explicit construction |
| 313 | backendOptions.emplace_back( |
| 314 | BackendOptions{"FakeBackend1", |
| 315 | {{"Option4", 42}} |
| 316 | }); |
| 317 | |
| 318 | |
| 319 | // First group |
| 320 | BOOST_TEST(backendOptions[0].GetBackendId().Get() == "FakeBackend1"); |
| 321 | BOOST_TEST(backendOptions[0].GetOption(0).GetName() == "Option1"); |
| 322 | BOOST_TEST(backendOptions[0].GetOption(0).GetValue().IsFloat() == true); |
| 323 | BOOST_TEST(backendOptions[0].GetOption(0).GetValue().AsFloat() == 1.3f); |
| 324 | |
| 325 | BOOST_TEST(backendOptions[0].GetOption(1).GetName() == "Option2"); |
| 326 | BOOST_TEST(backendOptions[0].GetOption(1).GetValue().IsBool() == true); |
| 327 | BOOST_TEST(backendOptions[0].GetOption(1).GetValue().AsBool() == true); |
| 328 | |
| 329 | BOOST_TEST(backendOptions[0].GetOption(2).GetName() == "Option3"); |
| 330 | BOOST_TEST(backendOptions[0].GetOption(2).GetValue().IsString() == true); |
| 331 | BOOST_TEST(backendOptions[0].GetOption(2).GetValue().AsString() == "some_value"); |
| 332 | |
| 333 | // Second group |
| 334 | BOOST_TEST(backendOptions[1].GetBackendId().Get() == "FakeBackend1"); |
| 335 | BOOST_TEST(backendOptions[1].GetOption(0).GetName() == "Option4"); |
| 336 | BOOST_TEST(backendOptions[1].GetOption(0).GetValue().IsInt() == true); |
| 337 | BOOST_TEST(backendOptions[1].GetOption(0).GetValue().AsInt() == 42); |
| 338 | } |
| 339 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 340 | BOOST_AUTO_TEST_CASE(ProfilingDisable) |
| 341 | { |
| 342 | using namespace armnn; |
| 343 | |
| 344 | // Create runtime in which the test will run |
| 345 | armnn::IRuntime::CreationOptions options; |
| 346 | armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); |
| 347 | |
| 348 | // build up the structure of the network |
| 349 | INetworkPtr net(INetwork::Create()); |
| 350 | |
| 351 | IConnectableLayer* input = net->AddInputLayer(0); |
| 352 | |
| 353 | // This layer configuration isn't supported by CpuAcc, should fall back to CpuRef. |
| 354 | NormalizationDescriptor descriptor; |
| 355 | IConnectableLayer* normalize = net->AddNormalizationLayer(descriptor); |
| 356 | |
| 357 | IConnectableLayer* output = net->AddOutputLayer(0); |
| 358 | |
| 359 | input->GetOutputSlot(0).Connect(normalize->GetInputSlot(0)); |
| 360 | normalize->GetOutputSlot(0).Connect(output->GetInputSlot(0)); |
| 361 | |
| 362 | input->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32)); |
| 363 | normalize->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32)); |
| 364 | |
| 365 | // optimize the network |
| 366 | std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; |
| 367 | IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec()); |
| 368 | |
| 369 | // Load it into the runtime. It should succeed. |
| 370 | armnn::NetworkId netId; |
| 371 | BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet)) == Status::Success); |
| 372 | |
| 373 | profiling::ProfilingServiceRuntimeHelper profilingServiceHelper; |
| 374 | profiling::BufferManager& bufferManager = profilingServiceHelper.GetProfilingBufferManager(); |
| 375 | auto readableBuffer = bufferManager.GetReadableBuffer(); |
| 376 | |
| 377 | // Profiling is not enabled, the post-optimisation structure should not be created |
| 378 | BOOST_TEST(!readableBuffer); |
| 379 | } |
| 380 | |
| 381 | BOOST_AUTO_TEST_CASE(ProfilingEnableCpuRef) |
| 382 | { |
| 383 | using namespace armnn; |
| 384 | using namespace armnn::profiling; |
| 385 | |
| 386 | // Create runtime in which the test will run |
| 387 | armnn::IRuntime::CreationOptions options; |
| 388 | options.m_ProfilingOptions.m_EnableProfiling = true; |
| 389 | armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); |
| 390 | |
| 391 | // build up the structure of the network |
| 392 | INetworkPtr net(INetwork::Create()); |
| 393 | |
| 394 | IConnectableLayer* input = net->AddInputLayer(0, "input"); |
| 395 | |
| 396 | NormalizationDescriptor descriptor; |
| 397 | IConnectableLayer* normalize = net->AddNormalizationLayer(descriptor, "normalization"); |
| 398 | |
| 399 | IConnectableLayer* output = net->AddOutputLayer(0, "output"); |
| 400 | |
| 401 | input->GetOutputSlot(0).Connect(normalize->GetInputSlot(0)); |
| 402 | normalize->GetOutputSlot(0).Connect(output->GetInputSlot(0)); |
| 403 | |
| 404 | input->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32)); |
| 405 | normalize->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32)); |
| 406 | |
| 407 | // optimize the network |
| 408 | std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; |
| 409 | IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec()); |
| 410 | |
| 411 | ProfilingGuid optNetGuid = optNet->GetGuid(); |
| 412 | |
| 413 | // Load it into the runtime. It should succeed. |
| 414 | armnn::NetworkId netId; |
| 415 | BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet)) == Status::Success); |
| 416 | |
| 417 | profiling::ProfilingServiceRuntimeHelper profilingServiceHelper; |
| 418 | profiling::BufferManager& bufferManager = profilingServiceHelper.GetProfilingBufferManager(); |
| 419 | auto readableBuffer = bufferManager.GetReadableBuffer(); |
| 420 | |
| 421 | // Profiling is enabled, the post-optimisation structure should be created |
| 422 | BOOST_CHECK(readableBuffer != nullptr); |
| 423 | |
| 424 | unsigned int size = readableBuffer->GetSize(); |
| 425 | BOOST_CHECK(size == 1356); |
| 426 | |
| 427 | const unsigned char* readableData = readableBuffer->GetReadableData(); |
| 428 | BOOST_CHECK(readableData != nullptr); |
| 429 | |
| 430 | unsigned int offset = 0; |
| 431 | |
| 432 | // Post-optimisation network |
| 433 | // Network entity |
| 434 | VerifyTimelineEntityBinaryPacket(optNetGuid, readableData, offset); |
| 435 | |
| 436 | // Entity - Type relationship |
| 437 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 438 | EmptyOptional(), |
| 439 | optNetGuid, |
| 440 | LabelsAndEventClasses::NETWORK_GUID, |
| 441 | readableData, |
| 442 | offset); |
| 443 | |
| 444 | // Type label relationship |
| 445 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 446 | EmptyOptional(), |
| 447 | EmptyOptional(), |
| 448 | LabelsAndEventClasses::TYPE_GUID, |
| 449 | readableData, |
| 450 | offset); |
| 451 | |
| 452 | // Input layer |
| 453 | // Input layer entity |
| 454 | VerifyTimelineEntityBinaryPacket(input->GetGuid(), readableData, offset); |
| 455 | |
| 456 | // Name Entity |
| 457 | VerifyTimelineLabelBinaryPacket(EmptyOptional(), "input", readableData, offset); |
| 458 | |
| 459 | // Entity - Name relationship |
| 460 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 461 | EmptyOptional(), |
| 462 | input->GetGuid(), |
| 463 | EmptyOptional(), |
| 464 | readableData, |
| 465 | offset); |
| 466 | |
| 467 | // Name label relationship |
| 468 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 469 | EmptyOptional(), |
| 470 | EmptyOptional(), |
| 471 | LabelsAndEventClasses::NAME_GUID, |
| 472 | readableData, |
| 473 | offset); |
| 474 | |
| 475 | // Entity - Type relationship |
| 476 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 477 | EmptyOptional(), |
| 478 | input->GetGuid(), |
| 479 | EmptyOptional(), |
| 480 | readableData, |
| 481 | offset); |
| 482 | |
| 483 | // Type label relationship |
| 484 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 485 | EmptyOptional(), |
| 486 | EmptyOptional(), |
| 487 | LabelsAndEventClasses::TYPE_GUID, |
| 488 | readableData, |
| 489 | offset); |
| 490 | |
| 491 | // Network - Input layer relationship |
| 492 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, |
| 493 | EmptyOptional(), |
| 494 | optNetGuid, |
| 495 | input->GetGuid(), |
| 496 | readableData, |
| 497 | offset); |
| 498 | |
| 499 | // Normalization layer |
| 500 | // Normalization layer entity |
| 501 | VerifyTimelineEntityBinaryPacket(normalize->GetGuid(), readableData, offset); |
| 502 | |
| 503 | // Name entity |
| 504 | VerifyTimelineLabelBinaryPacket(EmptyOptional(), "normalization", readableData, offset); |
| 505 | |
| 506 | // Entity - Name relationship |
| 507 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 508 | EmptyOptional(), |
| 509 | normalize->GetGuid(), |
| 510 | EmptyOptional(), |
| 511 | readableData, |
| 512 | offset); |
| 513 | |
| 514 | // Name label relationship |
| 515 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 516 | EmptyOptional(), |
| 517 | EmptyOptional(), |
| 518 | LabelsAndEventClasses::NAME_GUID, |
| 519 | readableData, |
| 520 | offset); |
| 521 | |
| 522 | // Entity - Type relationship |
| 523 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 524 | EmptyOptional(), |
| 525 | normalize->GetGuid(), |
| 526 | EmptyOptional(), |
| 527 | readableData, |
| 528 | offset); |
| 529 | |
| 530 | // Type label relationship |
| 531 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 532 | EmptyOptional(), |
| 533 | EmptyOptional(), |
| 534 | LabelsAndEventClasses::TYPE_GUID, |
| 535 | readableData, |
| 536 | offset); |
| 537 | |
| 538 | // Network - Normalize layer relationship |
| 539 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, |
| 540 | EmptyOptional(), |
| 541 | optNetGuid, |
| 542 | normalize->GetGuid(), |
| 543 | readableData, |
| 544 | offset); |
| 545 | |
| 546 | // Input layer - Normalize layer relationship |
| 547 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, |
| 548 | EmptyOptional(), |
| 549 | input->GetGuid(), |
| 550 | normalize->GetGuid(), |
| 551 | readableData, |
| 552 | offset); |
| 553 | |
| 554 | // Entity - Type relationship |
| 555 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 556 | EmptyOptional(), |
| 557 | EmptyOptional(), |
| 558 | LabelsAndEventClasses::CONNECTION_GUID, |
| 559 | readableData, |
| 560 | offset); |
| 561 | |
| 562 | // Type label relationship |
| 563 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 564 | EmptyOptional(), |
| 565 | EmptyOptional(), |
| 566 | LabelsAndEventClasses::TYPE_GUID, |
| 567 | readableData, |
| 568 | offset); |
| 569 | |
| 570 | // Normalization workload |
| 571 | // Normalization workload entity |
| 572 | VerifyTimelineEntityBinaryPacket(EmptyOptional(), readableData, offset); |
| 573 | |
| 574 | // Entity - Type relationship |
| 575 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 576 | EmptyOptional(), |
| 577 | EmptyOptional(), |
| 578 | EmptyOptional(), |
| 579 | readableData, |
| 580 | offset); |
| 581 | |
| 582 | // Type label relationship |
| 583 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 584 | EmptyOptional(), |
| 585 | EmptyOptional(), |
| 586 | LabelsAndEventClasses::TYPE_GUID, |
| 587 | readableData, |
| 588 | offset); |
| 589 | |
| 590 | // BackendId entity |
| 591 | VerifyTimelineLabelBinaryPacket(EmptyOptional(), "CpuRef", readableData, offset); |
| 592 | |
| 593 | // Entity - BackendId relationship |
| 594 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 595 | EmptyOptional(), |
| 596 | EmptyOptional(), |
| 597 | EmptyOptional(), |
| 598 | readableData, |
| 599 | offset); |
| 600 | |
| 601 | // BackendId label relationship |
| 602 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 603 | EmptyOptional(), |
| 604 | EmptyOptional(), |
| 605 | LabelsAndEventClasses::BACKENDID_GUID, |
| 606 | readableData, |
| 607 | offset); |
| 608 | |
| 609 | // Normalize layer - Normalize workload relationship |
| 610 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, |
| 611 | EmptyOptional(), |
| 612 | normalize->GetGuid(), |
| 613 | EmptyOptional(), |
| 614 | readableData, |
| 615 | offset); |
| 616 | |
| 617 | // Output layer |
| 618 | // Output layer entity |
| 619 | VerifyTimelineEntityBinaryPacket(output->GetGuid(), readableData, offset); |
| 620 | |
| 621 | // Name entity |
| 622 | VerifyTimelineLabelBinaryPacket(EmptyOptional(), "output", readableData, offset); |
| 623 | |
| 624 | // Entity - Name relationship |
| 625 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 626 | EmptyOptional(), |
| 627 | output->GetGuid(), |
| 628 | EmptyOptional(), |
| 629 | readableData, |
| 630 | offset); |
| 631 | |
| 632 | // Name label relationship |
| 633 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 634 | EmptyOptional(), |
| 635 | EmptyOptional(), |
| 636 | LabelsAndEventClasses::NAME_GUID, |
| 637 | readableData, |
| 638 | offset); |
| 639 | |
| 640 | // Entity - Type relationship |
| 641 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 642 | EmptyOptional(), |
| 643 | output->GetGuid(), |
| 644 | EmptyOptional(), |
| 645 | readableData, |
| 646 | offset); |
| 647 | |
| 648 | // Type label relationship |
| 649 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 650 | EmptyOptional(), |
| 651 | EmptyOptional(), |
| 652 | LabelsAndEventClasses::TYPE_GUID, |
| 653 | readableData, |
| 654 | offset); |
| 655 | |
| 656 | // Network - Output layer relationship |
| 657 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, |
| 658 | EmptyOptional(), |
| 659 | optNetGuid, |
| 660 | output->GetGuid(), |
| 661 | readableData, |
| 662 | offset); |
| 663 | |
| 664 | // Normalize layer - Output layer relationship |
| 665 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, |
| 666 | EmptyOptional(), |
| 667 | normalize->GetGuid(), |
| 668 | output->GetGuid(), |
| 669 | readableData, |
| 670 | offset); |
| 671 | |
| 672 | // Entity - Type relationship |
| 673 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 674 | EmptyOptional(), |
| 675 | EmptyOptional(), |
| 676 | LabelsAndEventClasses::CONNECTION_GUID, |
| 677 | readableData, |
| 678 | offset); |
| 679 | |
| 680 | // Type label relationship |
| 681 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 682 | EmptyOptional(), |
| 683 | EmptyOptional(), |
| 684 | LabelsAndEventClasses::TYPE_GUID, |
| 685 | readableData, |
| 686 | offset); |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame^] | 687 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 688 | bufferManager.MarkRead(readableBuffer); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 689 | |
| 690 | // Creates structures for input & output. |
| 691 | std::vector<float> inputData(16); |
| 692 | std::vector<float> outputData(16); |
| 693 | |
| 694 | InputTensors inputTensors |
| 695 | { |
| 696 | {0, ConstTensor(runtime->GetInputTensorInfo(netId, 0), inputData.data())} |
| 697 | }; |
| 698 | OutputTensors outputTensors |
| 699 | { |
| 700 | {0, Tensor(runtime->GetOutputTensorInfo(netId, 0), outputData.data())} |
| 701 | }; |
| 702 | |
| 703 | // Does the inference. |
| 704 | runtime->EnqueueWorkload(netId, inputTensors, outputTensors); |
| 705 | |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 706 | // Get readable buffer for inference timeline |
| 707 | auto inferenceReadableBuffer = bufferManager.GetReadableBuffer(); |
| 708 | BOOST_CHECK(inferenceReadableBuffer != nullptr); |
| 709 | |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 710 | // Get readable buffer for output workload |
| 711 | auto outputReadableBuffer = bufferManager.GetReadableBuffer(); |
| 712 | BOOST_CHECK(outputReadableBuffer != nullptr); |
| 713 | |
| 714 | // Get readable buffer for input workload |
| 715 | auto inputReadableBuffer = bufferManager.GetReadableBuffer(); |
| 716 | BOOST_CHECK(inputReadableBuffer != nullptr); |
| 717 | |
| 718 | // Validate input workload data |
| 719 | size = inputReadableBuffer->GetSize(); |
| 720 | BOOST_CHECK(size == 252); |
| 721 | |
| 722 | readableData = inputReadableBuffer->GetReadableData(); |
| 723 | BOOST_CHECK(readableData != nullptr); |
| 724 | |
| 725 | offset = 0; |
| 726 | |
| 727 | // Input workload |
| 728 | // Input workload entity |
| 729 | VerifyTimelineEntityBinaryPacket(EmptyOptional(), readableData, offset); |
| 730 | |
| 731 | // Entity - Type relationship |
| 732 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 733 | EmptyOptional(), |
| 734 | EmptyOptional(), |
| 735 | EmptyOptional(), |
| 736 | readableData, |
| 737 | offset); |
| 738 | |
| 739 | // Type label relationship |
| 740 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 741 | EmptyOptional(), |
| 742 | EmptyOptional(), |
| 743 | LabelsAndEventClasses::TYPE_GUID, |
| 744 | readableData, |
| 745 | offset); |
| 746 | |
| 747 | // BackendId entity |
| 748 | VerifyTimelineLabelBinaryPacket(EmptyOptional(), "CpuRef", readableData, offset); |
| 749 | |
| 750 | // Entity - BackendId relationship |
| 751 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 752 | EmptyOptional(), |
| 753 | EmptyOptional(), |
| 754 | EmptyOptional(), |
| 755 | readableData, |
| 756 | offset); |
| 757 | |
| 758 | // BackendId label relationship |
| 759 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 760 | EmptyOptional(), |
| 761 | EmptyOptional(), |
| 762 | LabelsAndEventClasses::BACKENDID_GUID, |
| 763 | readableData, |
| 764 | offset); |
| 765 | |
| 766 | // Input layer - Input workload relationship |
| 767 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, |
| 768 | EmptyOptional(), |
| 769 | input->GetGuid(), |
| 770 | EmptyOptional(), |
| 771 | readableData, |
| 772 | offset); |
| 773 | |
| 774 | bufferManager.MarkRead(inputReadableBuffer); |
| 775 | |
| 776 | // Validate output workload data |
| 777 | size = outputReadableBuffer->GetSize(); |
| 778 | BOOST_CHECK(size == 252); |
| 779 | |
| 780 | readableData = outputReadableBuffer->GetReadableData(); |
| 781 | BOOST_CHECK(readableData != nullptr); |
| 782 | |
| 783 | offset = 0; |
| 784 | |
| 785 | // Output workload |
| 786 | // Output workload entity |
| 787 | VerifyTimelineEntityBinaryPacket(EmptyOptional(), readableData, offset); |
| 788 | |
| 789 | // Entity - Type relationship |
| 790 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 791 | EmptyOptional(), |
| 792 | EmptyOptional(), |
| 793 | EmptyOptional(), |
| 794 | readableData, |
| 795 | offset); |
| 796 | |
| 797 | // Type label relationship |
| 798 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 799 | EmptyOptional(), |
| 800 | EmptyOptional(), |
| 801 | LabelsAndEventClasses::TYPE_GUID, |
| 802 | readableData, |
| 803 | offset); |
| 804 | |
| 805 | // BackendId entity |
| 806 | VerifyTimelineLabelBinaryPacket(EmptyOptional(), "CpuRef", readableData, offset); |
| 807 | |
| 808 | // Entity - BackendId relationship |
| 809 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 810 | EmptyOptional(), |
| 811 | EmptyOptional(), |
| 812 | EmptyOptional(), |
| 813 | readableData, |
| 814 | offset); |
| 815 | |
| 816 | // BackendId label relationship |
| 817 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 818 | EmptyOptional(), |
| 819 | EmptyOptional(), |
| 820 | LabelsAndEventClasses::BACKENDID_GUID, |
| 821 | readableData, |
| 822 | offset); |
| 823 | |
| 824 | // Output layer - Output workload relationship |
| 825 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, |
| 826 | EmptyOptional(), |
| 827 | output->GetGuid(), |
| 828 | EmptyOptional(), |
| 829 | readableData, |
| 830 | offset); |
| 831 | |
| 832 | bufferManager.MarkRead(outputReadableBuffer); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 833 | |
| 834 | // Validate inference data |
| 835 | size = inferenceReadableBuffer->GetSize(); |
| 836 | BOOST_CHECK(size == 1608); |
| 837 | |
| 838 | readableData = inferenceReadableBuffer->GetReadableData(); |
| 839 | BOOST_CHECK(readableData != nullptr); |
| 840 | |
| 841 | offset = 0; |
| 842 | |
| 843 | // Inference timeline trace |
| 844 | // Inference entity |
| 845 | VerifyTimelineEntityBinaryPacket(EmptyOptional(), readableData, offset); |
| 846 | |
| 847 | // Entity - Type relationship |
| 848 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 849 | EmptyOptional(), |
| 850 | EmptyOptional(), |
| 851 | LabelsAndEventClasses::INFERENCE_GUID, |
| 852 | readableData, |
| 853 | offset); |
| 854 | |
| 855 | // Type label relationship |
| 856 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 857 | EmptyOptional(), |
| 858 | EmptyOptional(), |
| 859 | LabelsAndEventClasses::TYPE_GUID, |
| 860 | readableData, |
| 861 | offset); |
| 862 | |
| 863 | // Network - Inference relationship |
| 864 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, |
| 865 | EmptyOptional(), |
| 866 | optNetGuid, |
| 867 | EmptyOptional(), |
| 868 | readableData, |
| 869 | offset); |
| 870 | |
| 871 | // Start Inference life |
| 872 | // Event packet - timeline, threadId, eventGuid |
| 873 | VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 874 | |
| 875 | // Inference - event relationship |
| 876 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::ExecutionLink, |
| 877 | EmptyOptional(), |
| 878 | EmptyOptional(), |
| 879 | EmptyOptional(), |
| 880 | readableData, |
| 881 | offset); |
| 882 | |
| 883 | // Event - event class relationship |
| 884 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::DataLink, |
| 885 | EmptyOptional(), |
| 886 | EmptyOptional(), |
| 887 | LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, |
| 888 | readableData, |
| 889 | offset); |
| 890 | |
| 891 | // Execution |
| 892 | // Input workload execution |
| 893 | // Input workload execution entity |
| 894 | VerifyTimelineEntityBinaryPacket(EmptyOptional(), readableData, offset); |
| 895 | |
| 896 | // Entity - Type relationship |
| 897 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 898 | EmptyOptional(), |
| 899 | EmptyOptional(), |
| 900 | LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, |
| 901 | readableData, |
| 902 | offset); |
| 903 | |
| 904 | // Type label relationship |
| 905 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 906 | EmptyOptional(), |
| 907 | EmptyOptional(), |
| 908 | LabelsAndEventClasses::TYPE_GUID, |
| 909 | readableData, |
| 910 | offset); |
| 911 | |
| 912 | // Inference - Workload execution relationship |
| 913 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, |
| 914 | EmptyOptional(), |
| 915 | EmptyOptional(), |
| 916 | EmptyOptional(), |
| 917 | readableData, |
| 918 | offset); |
| 919 | |
| 920 | // Workload - Workload execution relationship |
| 921 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, |
| 922 | EmptyOptional(), |
| 923 | EmptyOptional(), |
| 924 | EmptyOptional(), |
| 925 | readableData, |
| 926 | offset); |
| 927 | |
| 928 | // Start Input workload execution life |
| 929 | // Event packet - timeline, threadId, eventGuid |
| 930 | VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 931 | |
| 932 | // Input workload execution - event relationship |
| 933 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::ExecutionLink, |
| 934 | EmptyOptional(), |
| 935 | EmptyOptional(), |
| 936 | EmptyOptional(), |
| 937 | readableData, |
| 938 | offset); |
| 939 | |
| 940 | // Event - event class relationship |
| 941 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::DataLink, |
| 942 | EmptyOptional(), |
| 943 | EmptyOptional(), |
| 944 | LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, |
| 945 | readableData, |
| 946 | offset); |
| 947 | |
| 948 | // End of Input workload execution life |
| 949 | // Event packet - timeline, threadId, eventGuid |
| 950 | VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 951 | |
| 952 | // Input workload execution - event relationship |
| 953 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::ExecutionLink, |
| 954 | EmptyOptional(), |
| 955 | EmptyOptional(), |
| 956 | EmptyOptional(), |
| 957 | readableData, |
| 958 | offset); |
| 959 | |
| 960 | // Event - event class relationship |
| 961 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::DataLink, |
| 962 | EmptyOptional(), |
| 963 | EmptyOptional(), |
| 964 | LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, |
| 965 | readableData, |
| 966 | offset); |
| 967 | |
| 968 | // Normalize workload execution |
| 969 | // Normalize workload execution entity |
| 970 | VerifyTimelineEntityBinaryPacket(EmptyOptional(), readableData, offset); |
| 971 | |
| 972 | // Entity - Type relationship |
| 973 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 974 | EmptyOptional(), |
| 975 | EmptyOptional(), |
| 976 | LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, |
| 977 | readableData, |
| 978 | offset); |
| 979 | |
| 980 | // Type label relationship |
| 981 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 982 | EmptyOptional(), |
| 983 | EmptyOptional(), |
| 984 | LabelsAndEventClasses::TYPE_GUID, |
| 985 | readableData, |
| 986 | offset); |
| 987 | |
| 988 | // Inference - Workload execution relationship |
| 989 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, |
| 990 | EmptyOptional(), |
| 991 | EmptyOptional(), |
| 992 | EmptyOptional(), |
| 993 | readableData, |
| 994 | offset); |
| 995 | |
| 996 | // Workload - Workload execution relationship |
| 997 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, |
| 998 | EmptyOptional(), |
| 999 | EmptyOptional(), |
| 1000 | EmptyOptional(), |
| 1001 | readableData, |
| 1002 | offset); |
| 1003 | |
| 1004 | // Start Normalize workload execution life |
| 1005 | // Event packet - timeline, threadId, eventGuid |
| 1006 | VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 1007 | |
| 1008 | // Normalize workload execution - event relationship |
| 1009 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::ExecutionLink, |
| 1010 | EmptyOptional(), |
| 1011 | EmptyOptional(), |
| 1012 | EmptyOptional(), |
| 1013 | readableData, |
| 1014 | offset); |
| 1015 | |
| 1016 | // Event - event class relationship |
| 1017 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::DataLink, |
| 1018 | EmptyOptional(), |
| 1019 | EmptyOptional(), |
| 1020 | LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, |
| 1021 | readableData, |
| 1022 | offset); |
| 1023 | |
| 1024 | // End of Normalize workload execution life |
| 1025 | // Event packet - timeline, threadId, eventGuid |
| 1026 | VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 1027 | |
| 1028 | // Normalize workload execution - event relationship |
| 1029 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::ExecutionLink, |
| 1030 | EmptyOptional(), |
| 1031 | EmptyOptional(), |
| 1032 | EmptyOptional(), |
| 1033 | readableData, |
| 1034 | offset); |
| 1035 | |
| 1036 | // Event - event class relationship |
| 1037 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::DataLink, |
| 1038 | EmptyOptional(), |
| 1039 | EmptyOptional(), |
| 1040 | LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, |
| 1041 | readableData, |
| 1042 | offset); |
| 1043 | |
| 1044 | // Output workload execution |
| 1045 | // Output workload execution entity |
| 1046 | VerifyTimelineEntityBinaryPacket(EmptyOptional(), readableData, offset); |
| 1047 | |
| 1048 | // Entity - Type relationship |
| 1049 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 1050 | EmptyOptional(), |
| 1051 | EmptyOptional(), |
| 1052 | LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, |
| 1053 | readableData, |
| 1054 | offset); |
| 1055 | |
| 1056 | // Type label relationship |
| 1057 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, |
| 1058 | EmptyOptional(), |
| 1059 | EmptyOptional(), |
| 1060 | LabelsAndEventClasses::TYPE_GUID, |
| 1061 | readableData, |
| 1062 | offset); |
| 1063 | |
| 1064 | // Inference - Workload execution relationship |
| 1065 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, |
| 1066 | EmptyOptional(), |
| 1067 | EmptyOptional(), |
| 1068 | EmptyOptional(), |
| 1069 | readableData, |
| 1070 | offset); |
| 1071 | |
| 1072 | // Workload - Workload execution relationship |
| 1073 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, |
| 1074 | EmptyOptional(), |
| 1075 | EmptyOptional(), |
| 1076 | EmptyOptional(), |
| 1077 | readableData, |
| 1078 | offset); |
| 1079 | |
| 1080 | // Start Output workload execution life |
| 1081 | // Event packet - timeline, threadId, eventGuid |
| 1082 | VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 1083 | |
| 1084 | // Output workload execution - event relationship |
| 1085 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::ExecutionLink, |
| 1086 | EmptyOptional(), |
| 1087 | EmptyOptional(), |
| 1088 | EmptyOptional(), |
| 1089 | readableData, |
| 1090 | offset); |
| 1091 | |
| 1092 | // Event - event class relationship |
| 1093 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::DataLink, |
| 1094 | EmptyOptional(), |
| 1095 | EmptyOptional(), |
| 1096 | LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, |
| 1097 | readableData, |
| 1098 | offset); |
| 1099 | |
| 1100 | // End of Normalize workload execution life |
| 1101 | // Event packet - timeline, threadId, eventGuid |
| 1102 | VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 1103 | |
| 1104 | // Output workload execution - event relationship |
| 1105 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::ExecutionLink, |
| 1106 | EmptyOptional(), |
| 1107 | EmptyOptional(), |
| 1108 | EmptyOptional(), |
| 1109 | readableData, |
| 1110 | offset); |
| 1111 | |
| 1112 | // Event - event class relationship |
| 1113 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::DataLink, |
| 1114 | EmptyOptional(), |
| 1115 | EmptyOptional(), |
| 1116 | LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, |
| 1117 | readableData, |
| 1118 | offset); |
| 1119 | |
| 1120 | // End of Inference life |
| 1121 | // Event packet - timeline, threadId, eventGuid |
| 1122 | VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); |
| 1123 | |
| 1124 | // Inference - event relationship |
| 1125 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::ExecutionLink, |
| 1126 | EmptyOptional(), |
| 1127 | EmptyOptional(), |
| 1128 | EmptyOptional(), |
| 1129 | readableData, |
| 1130 | offset); |
| 1131 | |
| 1132 | // Event - event class relationship |
| 1133 | VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::DataLink, |
| 1134 | EmptyOptional(), |
| 1135 | EmptyOptional(), |
| 1136 | LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, |
| 1137 | readableData, |
| 1138 | offset); |
| 1139 | |
| 1140 | bufferManager.MarkRead(inferenceReadableBuffer); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 1141 | } |
| 1142 | |
| 1143 | BOOST_AUTO_TEST_CASE(ProfilingPostOptimisationStructureCpuRef) |
| 1144 | { |
| 1145 | VerifyPostOptimisationStructureTestImpl(armnn::Compute::CpuRef); |
| 1146 | } |
| 1147 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1148 | BOOST_AUTO_TEST_SUITE_END() |