blob: abf13f5dc6033b1c0c86f267442ccc8a400f6684 [file] [log] [blame]
Laurent Carlier749294b2020-06-01 09:03:17 +01001//
Jim Flynn6398a982020-05-27 17:05:21 +01002// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa014fcda012018-03-09 14:13:49 +00004//
telsoa014fcda012018-03-09 14:13:49 +00005
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +01006#include <armnn/Descriptors.hpp>
7#include <armnn/IRuntime.hpp>
8#include <armnn/INetwork.hpp>
Jim Flynnf7713212020-07-14 09:50:59 +01009#include <Processes.hpp>
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +000010#include <Runtime.hpp>
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +010011#include <armnn/TypesUtils.hpp>
telsoa014fcda012018-03-09 14:13:49 +000012
Nikhil Raj77fe76b2021-06-09 14:55:32 +010013#include <common/include/LabelsAndEventClasses.hpp>
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +000014#include <test/ProfilingTestUtils.hpp>
15
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +000016#include <HeapProfiling.hpp>
17#include <LeakChecking.hpp>
telsoa014fcda012018-03-09 14:13:49 +000018
19#ifdef WITH_VALGRIND
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +010020#include <valgrind/memcheck.h>
telsoa014fcda012018-03-09 14:13:49 +000021#endif
22
Sadik Armagan1625efc2021-06-10 18:24:34 +010023#include <doctest/doctest.h>
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +000024#include "RuntimeTests.hpp"
Sadik Armaganea41b572020-03-19 18:16:46 +000025#include "TestUtils.hpp"
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +010026
telsoa014fcda012018-03-09 14:13:49 +000027namespace armnn
28{
29
Kevin Mayd92a6e42021-02-04 10:27:41 +000030void RuntimeLoadedNetworksReserve(armnn::RuntimeImpl* runtime)
telsoa014fcda012018-03-09 14:13:49 +000031{
32 runtime->m_LoadedNetworks.reserve(1);
33}
34
35}
36
Sadik Armagan1625efc2021-06-10 18:24:34 +010037TEST_SUITE("Runtime")
38{
39TEST_CASE("RuntimeUnloadNetwork")
telsoa014fcda012018-03-09 14:13:49 +000040{
41 // build 2 mock-networks and load them into the runtime
telsoa01c577f2c2018-08-31 09:22:23 +010042 armnn::IRuntime::CreationOptions options;
Keith Davis97da5e22020-03-05 16:25:28 +000043 armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options));
telsoa014fcda012018-03-09 14:13:49 +000044
telsoa01c577f2c2018-08-31 09:22:23 +010045 // Mock network 1.
Keith Davis97da5e22020-03-05 16:25:28 +000046 armnn::NetworkId networkIdentifier1 = 1;
telsoa014fcda012018-03-09 14:13:49 +000047 armnn::INetworkPtr mockNetwork1(armnn::INetwork::Create());
48 mockNetwork1->AddInputLayer(0, "test layer");
Keith Davis97da5e22020-03-05 16:25:28 +000049 std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef };
telsoa01c577f2c2018-08-31 09:22:23 +010050 runtime->LoadNetwork(networkIdentifier1, Optimize(*mockNetwork1, backends, runtime->GetDeviceSpec()));
telsoa014fcda012018-03-09 14:13:49 +000051
telsoa01c577f2c2018-08-31 09:22:23 +010052 // Mock network 2.
Keith Davis97da5e22020-03-05 16:25:28 +000053 armnn::NetworkId networkIdentifier2 = 2;
telsoa014fcda012018-03-09 14:13:49 +000054 armnn::INetworkPtr mockNetwork2(armnn::INetwork::Create());
55 mockNetwork2->AddInputLayer(0, "test layer");
telsoa01c577f2c2018-08-31 09:22:23 +010056 runtime->LoadNetwork(networkIdentifier2, Optimize(*mockNetwork2, backends, runtime->GetDeviceSpec()));
telsoa014fcda012018-03-09 14:13:49 +000057
telsoa01c577f2c2018-08-31 09:22:23 +010058 // Unloads one by its networkID.
Sadik Armagan1625efc2021-06-10 18:24:34 +010059 CHECK(runtime->UnloadNetwork(networkIdentifier1) == armnn::Status::Success);
telsoa014fcda012018-03-09 14:13:49 +000060
Sadik Armagan1625efc2021-06-10 18:24:34 +010061 CHECK(runtime->UnloadNetwork(networkIdentifier1) == armnn::Status::Failure);
telsoa014fcda012018-03-09 14:13:49 +000062}
63
Finn Williamsf37b9702021-09-01 18:06:04 +010064TEST_CASE("RuntimePreImportInputs")
65{
66 armnn::IRuntime::CreationOptions options;
67 armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options));
68
69 armnn::NetworkId networkIdentifier1 = 1;
70
71 armnn::INetworkPtr testNetwork(armnn::INetwork::Create());
72 auto inputLayer1 = testNetwork->AddInputLayer(0, "input 1 layer");
73 auto inputLayer2 = testNetwork->AddInputLayer(1, "input 2 layer");
74 auto addLayer = testNetwork->AddAdditionLayer("add layer");
75 auto outputLayer = testNetwork->AddOutputLayer(2, "output layer");
76
77 TensorInfo tensorInfo{{4}, armnn::DataType::Signed32};
78
79 inputLayer1->GetOutputSlot(0).Connect(addLayer->GetInputSlot(0));
80 inputLayer1->GetOutputSlot(0).SetTensorInfo(tensorInfo);
81 inputLayer2->GetOutputSlot(0).Connect(addLayer->GetInputSlot(1));
82 inputLayer2->GetOutputSlot(0).SetTensorInfo(tensorInfo);
83
84 addLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
85 addLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo);
86
87 std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef };
88
89 std::string er;
90 armnn::INetworkProperties networkProperties(true, MemorySource::Malloc, MemorySource::Undefined);
91 runtime->LoadNetwork(networkIdentifier1,
92 Optimize(*testNetwork, backends, runtime->GetDeviceSpec()),
93 er,
94 networkProperties);
95
96 std::vector<int> inputData1(4, 10);
97 std::vector<int> inputData2(4, 20);
98 std::vector<int> output(4);
99
100 ConstTensor inputTensor1({{4}, armnn::DataType::Signed32}, inputData1.data());
101 ConstTensor inputTensor2({{4}, armnn::DataType::Signed32}, inputData2.data());
102
103 Tensor outputTensor({{4}, armnn::DataType::Signed32}, output.data());
104
105 auto importedInputVec1 = runtime->ImportInputs(networkIdentifier1, {{0, inputTensor1}});
106 CHECK(importedInputVec1.size() == 1);
107 CHECK(importedInputVec1[0] == 0);
108
109 auto memHandle = runtime->CreateWorkingMemHandle(networkIdentifier1);
110
111 runtime->Execute(*memHandle.get(), {{1, inputTensor2}}, {{2, outputTensor}}, {0 /* pre-imported id */});
112 for (auto val : output)
113 {
114 CHECK(val == 30);
115 }
116
117 auto importedInputVec2 = runtime->ImportInputs(networkIdentifier1, {{1, inputTensor2}});
118 CHECK(importedInputVec2.size() == 1);
119 CHECK(importedInputVec2[0] == 1);
120
121 runtime->Execute(*memHandle.get(), {{0, inputTensor1}}, {{2, outputTensor}}, {1 /* pre-imported id */});
122 for (auto val : output)
123 {
124 CHECK(val == 30);
125 }
126
127 runtime->Execute(*memHandle.get(), {}, {{2, outputTensor}}, {0, 1});
128 for (auto val : output)
129 {
130 CHECK(val == 30);
131 }
132
133 // Duplicate ImportedInputId and LayerBindingId
134 CHECK_THROWS_AS(runtime->Execute(*memHandle.get(),{},{{2, outputTensor}},{0, 0});
135 , armnn::InvalidArgumentException);
136
137 // Duplicate LayerBindingId
138 CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), {{1, inputTensor2}}, {{2, outputTensor}},{1});
139 , armnn::InvalidArgumentException);
140
141 // Incorrect ImportedInputId
142 CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), {{1, inputTensor2}}, {{2, outputTensor}},{10});
143 , armnn::InvalidArgumentException);
144
145 // Incorrect LayerBindingId
146 CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), {{-2, inputTensor2}}, {{2, outputTensor}},{1});
147 , armnn::InvalidArgumentException);
148
149 // Incorrect layer binding id and ImportedInputId
150 CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), {{-2, inputTensor2}}, {{2, outputTensor}},{10});
151 , armnn::InvalidArgumentException);
152
153
154 auto importedInputVec3 = runtime->ImportInputs(networkIdentifier1, {{1, inputTensor2}});
155 CHECK(importedInputVec3[0] == 2);
156 // Too many ImportedInputIds
157 CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), {}, {{2, outputTensor}},{0, 1, 2});
158 , armnn::InvalidArgumentException);
159
160 // Too many InputTensors
161 CHECK_THROWS_AS(runtime->Execute(*memHandle.get(),
162 {{0, inputTensor2}, {1, inputTensor2}, {2, inputTensor2}},
163 {{2, outputTensor}});
164 , armnn::InvalidArgumentException);
165
166 // Too few ImportedInputIds
167 CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), {}, {{2, outputTensor}},{0});
168 , armnn::InvalidArgumentException);
169}
170
surmeh013537c2c2018-05-18 16:31:43 +0100171// Note: the current builds we don't do valgrind and gperftools based leak checking at the same
telsoa01c577f2c2018-08-31 09:22:23 +0100172// time, so in practice WITH_VALGRIND and ARMNN_LEAK_CHECKING_ENABLED are exclusive. The
173// valgrind tests can stay for x86 builds, but on hikey Valgrind is just way too slow
174// to be integrated into the CI system.
surmeh013537c2c2018-05-18 16:31:43 +0100175
telsoa01c577f2c2018-08-31 09:22:23 +0100176#ifdef ARMNN_LEAK_CHECKING_ENABLED
177
178struct DisableGlobalLeakChecking
179{
180 DisableGlobalLeakChecking()
181 {
182 ARMNN_LOCAL_LEAK_CHECKING_ONLY();
183 }
184};
185
Sadik Armagan1625efc2021-06-10 18:24:34 +0100186TEST_CASE_FIXTURE(DisableGlobalLeakChecking, "RuntimeHeapMemoryUsageSanityChecks")
surmeh013537c2c2018-05-18 16:31:43 +0100187{
Sadik Armagan1625efc2021-06-10 18:24:34 +0100188 CHECK(ARMNN_LEAK_CHECKER_IS_ACTIVE());
surmeh013537c2c2018-05-18 16:31:43 +0100189 {
190 ARMNN_SCOPED_LEAK_CHECKER("Sanity_Check_Outer");
191 {
192 ARMNN_SCOPED_LEAK_CHECKER("Sanity_Check_Inner");
Sadik Armagan1625efc2021-06-10 18:24:34 +0100193 CHECK(ARMNN_NO_LEAKS_IN_SCOPE() == true);
surmeh013537c2c2018-05-18 16:31:43 +0100194 std::unique_ptr<char[]> dummyAllocation(new char[1000]);
Sadik Armagan1625efc2021-06-10 18:24:34 +0100195 // "A leak of 1000 bytes is expected here. "
196 // "Please make sure environment variable: HEAPCHECK=draconian is set!"
197 CHECK((ARMNN_NO_LEAKS_IN_SCOPE() == false));
198 CHECK(ARMNN_BYTES_LEAKED_IN_SCOPE() == 1000);
199 CHECK(ARMNN_OBJECTS_LEAKED_IN_SCOPE() == 1);
surmeh013537c2c2018-05-18 16:31:43 +0100200 }
Sadik Armagan1625efc2021-06-10 18:24:34 +0100201 CHECK(ARMNN_NO_LEAKS_IN_SCOPE());
202 CHECK(ARMNN_BYTES_LEAKED_IN_SCOPE() == 0);
203 CHECK(ARMNN_OBJECTS_LEAKED_IN_SCOPE() == 0);
surmeh013537c2c2018-05-18 16:31:43 +0100204 }
205}
206
surmeh013537c2c2018-05-18 16:31:43 +0100207#endif // ARMNN_LEAK_CHECKING_ENABLED
208
209// Note: this part of the code is due to be removed when we fully trust the gperftools based results.
telsoa014fcda012018-03-09 14:13:49 +0000210#ifdef WITH_VALGRIND
telsoa01c577f2c2018-08-31 09:22:23 +0100211// Run with the following command to get all the amazing output (in the devenv/build folder) :)
telsoa014fcda012018-03-09 14:13:49 +0000212// valgrind --leak-check=full --show-leak-kinds=all --log-file=Valgrind_Memcheck_Leak_Report.txt armnn/test/UnitTests
Sadik Armagan1625efc2021-06-10 18:24:34 +0100213TEST_CASE("RuntimeMemoryLeak")
telsoa014fcda012018-03-09 14:13:49 +0000214{
215 // From documentation:
216
217 // This means that no pointer to the block can be found. The block is classified as "lost",
218 // because the programmer could not possibly have freed it at program exit, since no pointer to it exists.
219 unsigned long leakedBefore = 0;
Keith Davis97da5e22020-03-05 16:25:28 +0000220 unsigned long leakedAfter = 0;
telsoa014fcda012018-03-09 14:13:49 +0000221
222 // A start-pointer or chain of start-pointers to the block is found. Since the block is still pointed at,
223 // the programmer could, at least in principle, have freed it before program exit.
telsoa01c577f2c2018-08-31 09:22:23 +0100224 // We want to test this in case memory is not freed as early as it could have been.
telsoa014fcda012018-03-09 14:13:49 +0000225 unsigned long reachableBefore = 0;
Keith Davis97da5e22020-03-05 16:25:28 +0000226 unsigned long reachableAfter = 0;
telsoa014fcda012018-03-09 14:13:49 +0000227
telsoa01c577f2c2018-08-31 09:22:23 +0100228 // Needed as out params but we don't test them.
Keith Davis97da5e22020-03-05 16:25:28 +0000229 unsigned long dubious = 0;
telsoa014fcda012018-03-09 14:13:49 +0000230 unsigned long suppressed = 0;
231
232 armnn::NetworkId networkIdentifier1 = 1;
233
234 // ensure that runtime is large enough before checking for memory leaks
235 // otherwise when loading the network it will automatically reserve memory that won't be released until destruction
telsoa01c577f2c2018-08-31 09:22:23 +0100236 armnn::IRuntime::CreationOptions options;
Kevin Mayd92a6e42021-02-04 10:27:41 +0000237 armnn::RuntimeImpl runtime(options);
telsoa014fcda012018-03-09 14:13:49 +0000238 armnn::RuntimeLoadedNetworksReserve(&runtime);
239
telsoa014fcda012018-03-09 14:13:49 +0000240 {
Keith Davis97da5e22020-03-05 16:25:28 +0000241 std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef };
telsoa014fcda012018-03-09 14:13:49 +0000242
Francis Murtagh3d2b4b22021-02-15 18:23:17 +0000243 armnn::INetworkPtr mockNetwork1(armnn::INetwork::Create());
telsoa014fcda012018-03-09 14:13:49 +0000244 mockNetwork1->AddInputLayer(0, "test layer");
245
Matteo Martincigh9326aab2018-11-15 10:54:54 +0000246 // Warm-up load/unload pair to put the runtime in a stable state (memory-wise).
telsoa01c577f2c2018-08-31 09:22:23 +0100247 runtime.LoadNetwork(networkIdentifier1, Optimize(*mockNetwork1, backends, runtime.GetDeviceSpec()));
Matteo Martincigh9326aab2018-11-15 10:54:54 +0000248 runtime.UnloadNetwork(networkIdentifier1);
249
250 // Checks for leaks before we load the network and record them so that we can see the delta after unloading.
251 VALGRIND_DO_QUICK_LEAK_CHECK;
252 VALGRIND_COUNT_LEAKS(leakedBefore, dubious, reachableBefore, suppressed);
253
254 // The actual test.
255 runtime.LoadNetwork(networkIdentifier1, Optimize(*mockNetwork1, backends, runtime.GetDeviceSpec()));
256 runtime.UnloadNetwork(networkIdentifier1);
257
258 VALGRIND_DO_ADDED_LEAK_CHECK;
259 VALGRIND_COUNT_LEAKS(leakedAfter, dubious, reachableAfter, suppressed);
telsoa014fcda012018-03-09 14:13:49 +0000260 }
261
telsoa01c577f2c2018-08-31 09:22:23 +0100262 // If we're not running under Valgrind, these vars will have been initialised to 0, so this will always pass.
Sadik Armagan1625efc2021-06-10 18:24:34 +0100263 CHECK(leakedBefore == leakedAfter);
264 CHECK(reachableBefore == reachableAfter);
telsoa014fcda012018-03-09 14:13:49 +0000265
telsoa01c577f2c2018-08-31 09:22:23 +0100266 // These are needed because VALGRIND_COUNT_LEAKS is a macro that assigns to the parameters
267 // so they are assigned to, but still considered unused, causing a warning.
Jan Eilers8eb25602020-03-09 12:13:48 +0000268 IgnoreUnused(dubious);
269 IgnoreUnused(suppressed);
telsoa014fcda012018-03-09 14:13:49 +0000270}
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +0100271#endif // WITH_VALGRIND
telsoa01c577f2c2018-08-31 09:22:23 +0100272
Sadik Armagan1625efc2021-06-10 18:24:34 +0100273TEST_CASE("RuntimeCpuRef")
telsoa01c577f2c2018-08-31 09:22:23 +0100274{
275 using namespace armnn;
276
277 // Create runtime in which test will run
278 armnn::IRuntime::CreationOptions options;
Keith Davis97da5e22020-03-05 16:25:28 +0000279 armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options));
telsoa01c577f2c2018-08-31 09:22:23 +0100280
281 // build up the structure of the network
282 INetworkPtr net(INetwork::Create());
283
284 IConnectableLayer* input = net->AddInputLayer(0);
285
286 // This layer configuration isn't supported by CpuAcc, should be fall back to CpuRef.
287 NormalizationDescriptor descriptor;
288 IConnectableLayer* normalize = net->AddNormalizationLayer(descriptor);
289
290 IConnectableLayer* output = net->AddOutputLayer(0);
291
292 input->GetOutputSlot(0).Connect(normalize->GetInputSlot(0));
293 normalize->GetOutputSlot(0).Connect(output->GetInputSlot(0));
294
295 input->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32));
296 normalize->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32));
297
298 // optimize the network
David Beckf0b48452018-10-19 15:20:56 +0100299 std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef };
Keith Davis97da5e22020-03-05 16:25:28 +0000300 IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec());
telsoa01c577f2c2018-08-31 09:22:23 +0100301
302 // Load it into the runtime. It should success.
303 armnn::NetworkId netId;
Sadik Armagan1625efc2021-06-10 18:24:34 +0100304 CHECK(runtime->LoadNetwork(netId, std::move(optNet)) == Status::Success);
telsoa01c577f2c2018-08-31 09:22:23 +0100305}
306
Sadik Armagan1625efc2021-06-10 18:24:34 +0100307TEST_CASE("RuntimeFallbackToCpuRef")
telsoa01c577f2c2018-08-31 09:22:23 +0100308{
309 using namespace armnn;
310
311 // Create runtime in which test will run
312 armnn::IRuntime::CreationOptions options;
Keith Davis97da5e22020-03-05 16:25:28 +0000313 armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options));
telsoa01c577f2c2018-08-31 09:22:23 +0100314
315 // build up the structure of the network
316 INetworkPtr net(INetwork::Create());
317
318 IConnectableLayer* input = net->AddInputLayer(0);
319
320 // This layer configuration isn't supported by CpuAcc, should be fall back to CpuRef.
321 NormalizationDescriptor descriptor;
322 IConnectableLayer* normalize = net->AddNormalizationLayer(descriptor);
323
324 IConnectableLayer* output = net->AddOutputLayer(0);
325
326 input->GetOutputSlot(0).Connect(normalize->GetInputSlot(0));
327 normalize->GetOutputSlot(0).Connect(output->GetInputSlot(0));
328
329 input->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32));
330 normalize->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32));
331
332 // Allow fallback to CpuRef.
David Beckf0b48452018-10-19 15:20:56 +0100333 std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc, armnn::Compute::CpuRef };
telsoa01c577f2c2018-08-31 09:22:23 +0100334 // optimize the network
Keith Davis97da5e22020-03-05 16:25:28 +0000335 IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec());
telsoa01c577f2c2018-08-31 09:22:23 +0100336
337 // Load it into the runtime. It should succeed.
338 armnn::NetworkId netId;
Sadik Armagan1625efc2021-06-10 18:24:34 +0100339 CHECK(runtime->LoadNetwork(netId, std::move(optNet)) == Status::Success);
telsoa01c577f2c2018-08-31 09:22:23 +0100340}
341
Sadik Armagan1625efc2021-06-10 18:24:34 +0100342TEST_CASE("IVGCVSW_1929_QuantizedSoftmaxIssue")
jimfly016b0b53d2018-10-08 14:43:01 +0100343{
344 // Test for issue reported by Chris Nix in https://jira.arm.com/browse/IVGCVSW-1929
345 using namespace armnn;
346
347 // Create runtime in which test will run
348 armnn::IRuntime::CreationOptions options;
Keith Davis97da5e22020-03-05 16:25:28 +0000349 armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options));
jimfly016b0b53d2018-10-08 14:43:01 +0100350
351 // build up the structure of the network
352 INetworkPtr net(INetwork::Create());
Keith Davis97da5e22020-03-05 16:25:28 +0000353 armnn::IConnectableLayer* input = net->AddInputLayer(0,"input");
354 armnn::IConnectableLayer* softmax = net->AddSoftmaxLayer(armnn::SoftmaxDescriptor(), "softmax");
355 armnn::IConnectableLayer* output = net->AddOutputLayer(0, "output");
jimfly016b0b53d2018-10-08 14:43:01 +0100356
357 input->GetOutputSlot(0).Connect(softmax->GetInputSlot(0));
358 softmax->GetOutputSlot(0).Connect(output->GetInputSlot(0));
359
Keith Davis97da5e22020-03-05 16:25:28 +0000360 input->GetOutputSlot(0).SetTensorInfo(armnn::TensorInfo(armnn::TensorShape({ 1, 5 }),
361 armnn::DataType::QAsymmU8,
362 1.0f / 255,
363 0));
jimfly016b0b53d2018-10-08 14:43:01 +0100364
Keith Davis97da5e22020-03-05 16:25:28 +0000365 softmax->GetOutputSlot(0).SetTensorInfo(armnn::TensorInfo(armnn::TensorShape({ 1, 5 }),
366 armnn::DataType::QAsymmU8));
jimfly016b0b53d2018-10-08 14:43:01 +0100367
Keith Davis97da5e22020-03-05 16:25:28 +0000368 std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef };
369 std::vector<std::string> errMessages;
Mike Kelly3a613cc2020-09-29 20:50:35 +0100370
371 try
372 {
373 armnn::IOptimizedNetworkPtr optNet = Optimize(*net,
Keith Davis97da5e22020-03-05 16:25:28 +0000374 backends,
375 runtime->GetDeviceSpec(),
376 OptimizerOptions(),
377 errMessages);
Sadik Armagan1625efc2021-06-10 18:24:34 +0100378 FAIL("An exception should have been thrown");
Mike Kelly3a613cc2020-09-29 20:50:35 +0100379 }
Rob Hughesc013bc82021-07-14 09:31:31 +0100380 catch (const InvalidArgumentException&)
Mike Kelly3a613cc2020-09-29 20:50:35 +0100381 {
382 // Different exceptions are thrown on different backends
383 }
Sadik Armagan1625efc2021-06-10 18:24:34 +0100384 CHECK(errMessages.size() > 0);
jimfly016b0b53d2018-10-08 14:43:01 +0100385}
386
Sadik Armagan1625efc2021-06-10 18:24:34 +0100387TEST_CASE("RuntimeBackendOptions")
Derek Lamberti836b27b2019-11-20 10:51:57 +0000388{
389 using namespace armnn;
390
391 IRuntime::CreationOptions creationOptions;
392 auto& backendOptions = creationOptions.m_BackendOptions;
393
394
395 // Define Options on explicit construction
396 BackendOptions options1("FakeBackend1",
Keith Davis97da5e22020-03-05 16:25:28 +0000397 {
398 { "Option1", 1.3f },
399 { "Option2", true }
400 });
Derek Lamberti836b27b2019-11-20 10:51:57 +0000401
402 // Add an option after construction
Keith Davis97da5e22020-03-05 16:25:28 +0000403 options1.AddOption({ "Option3", "some_value" });
Derek Lamberti836b27b2019-11-20 10:51:57 +0000404
405 // Add the options to CreationOptions struct
406 backendOptions.push_back(options1);
407
408 // Add more Options via inplace explicit construction
Keith Davis97da5e22020-03-05 16:25:28 +0000409 backendOptions.emplace_back(BackendOptions{ "FakeBackend1",
410 {{ "Option4", 42 }}
411 });
Derek Lamberti836b27b2019-11-20 10:51:57 +0000412
413
414 // First group
Sadik Armagan1625efc2021-06-10 18:24:34 +0100415 CHECK(backendOptions[0].GetBackendId().Get() == "FakeBackend1");
416 CHECK(backendOptions[0].GetOption(0).GetName() == "Option1");
417 CHECK(backendOptions[0].GetOption(0).GetValue().IsFloat() == true);
418 CHECK(backendOptions[0].GetOption(0).GetValue().AsFloat() == 1.3f);
Derek Lamberti836b27b2019-11-20 10:51:57 +0000419
Sadik Armagan1625efc2021-06-10 18:24:34 +0100420 CHECK(backendOptions[0].GetOption(1).GetName() == "Option2");
421 CHECK(backendOptions[0].GetOption(1).GetValue().IsBool() == true);
422 CHECK(backendOptions[0].GetOption(1).GetValue().AsBool() == true);
Derek Lamberti836b27b2019-11-20 10:51:57 +0000423
Sadik Armagan1625efc2021-06-10 18:24:34 +0100424 CHECK(backendOptions[0].GetOption(2).GetName() == "Option3");
425 CHECK(backendOptions[0].GetOption(2).GetValue().IsString() == true);
426 CHECK(backendOptions[0].GetOption(2).GetValue().AsString() == "some_value");
Derek Lamberti836b27b2019-11-20 10:51:57 +0000427
428 // Second group
Sadik Armagan1625efc2021-06-10 18:24:34 +0100429 CHECK(backendOptions[1].GetBackendId().Get() == "FakeBackend1");
430 CHECK(backendOptions[1].GetOption(0).GetName() == "Option4");
431 CHECK(backendOptions[1].GetOption(0).GetValue().IsInt() == true);
432 CHECK(backendOptions[1].GetOption(0).GetValue().AsInt() == 42);
Derek Lamberti836b27b2019-11-20 10:51:57 +0000433}
434
Sadik Armagan1625efc2021-06-10 18:24:34 +0100435TEST_CASE("ProfilingDisable")
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000436{
437 using namespace armnn;
438
439 // Create runtime in which the test will run
440 armnn::IRuntime::CreationOptions options;
Kevin Mayd92a6e42021-02-04 10:27:41 +0000441 armnn::RuntimeImpl runtime(options);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000442
443 // build up the structure of the network
444 INetworkPtr net(INetwork::Create());
445
446 IConnectableLayer* input = net->AddInputLayer(0);
447
448 // This layer configuration isn't supported by CpuAcc, should fall back to CpuRef.
449 NormalizationDescriptor descriptor;
450 IConnectableLayer* normalize = net->AddNormalizationLayer(descriptor);
451
452 IConnectableLayer* output = net->AddOutputLayer(0);
453
454 input->GetOutputSlot(0).Connect(normalize->GetInputSlot(0));
455 normalize->GetOutputSlot(0).Connect(output->GetInputSlot(0));
456
457 input->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32));
458 normalize->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32));
459
460 // optimize the network
461 std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef };
Sadik Armagan3184c902020-03-18 10:57:30 +0000462 IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime.GetDeviceSpec());
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000463
464 // Load it into the runtime. It should succeed.
465 armnn::NetworkId netId;
Sadik Armagan1625efc2021-06-10 18:24:34 +0100466 CHECK(runtime.LoadNetwork(netId, std::move(optNet)) == Status::Success);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000467
Sadik Armagan3184c902020-03-18 10:57:30 +0000468 profiling::ProfilingServiceRuntimeHelper profilingServiceHelper(GetProfilingService(&runtime));
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000469 profiling::BufferManager& bufferManager = profilingServiceHelper.GetProfilingBufferManager();
470 auto readableBuffer = bufferManager.GetReadableBuffer();
471
472 // Profiling is not enabled, the post-optimisation structure should not be created
Sadik Armagan1625efc2021-06-10 18:24:34 +0100473 CHECK(!readableBuffer);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000474}
475
Sadik Armagan1625efc2021-06-10 18:24:34 +0100476TEST_CASE("ProfilingEnableCpuRef")
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000477{
478 using namespace armnn;
479 using namespace armnn::profiling;
480
481 // Create runtime in which the test will run
482 armnn::IRuntime::CreationOptions options;
483 options.m_ProfilingOptions.m_EnableProfiling = true;
Keith Davis33ed2212020-03-30 10:43:41 +0100484 options.m_ProfilingOptions.m_TimelineEnabled = true;
485
Kevin Mayd92a6e42021-02-04 10:27:41 +0000486 armnn::RuntimeImpl runtime(options);
Keith Davis33ed2212020-03-30 10:43:41 +0100487 GetProfilingService(&runtime).ResetExternalProfilingOptions(options.m_ProfilingOptions, false);
488
489 profiling::ProfilingServiceRuntimeHelper profilingServiceHelper(GetProfilingService(&runtime));
490 profilingServiceHelper.ForceTransitionToState(ProfilingState::NotConnected);
491 profilingServiceHelper.ForceTransitionToState(ProfilingState::WaitingForAck);
492 profilingServiceHelper.ForceTransitionToState(ProfilingState::Active);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000493
494 // build up the structure of the network
495 INetworkPtr net(INetwork::Create());
496
497 IConnectableLayer* input = net->AddInputLayer(0, "input");
498
499 NormalizationDescriptor descriptor;
500 IConnectableLayer* normalize = net->AddNormalizationLayer(descriptor, "normalization");
501
502 IConnectableLayer* output = net->AddOutputLayer(0, "output");
503
504 input->GetOutputSlot(0).Connect(normalize->GetInputSlot(0));
505 normalize->GetOutputSlot(0).Connect(output->GetInputSlot(0));
506
507 input->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32));
508 normalize->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32));
509
510 // optimize the network
511 std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef };
Sadik Armagan3184c902020-03-18 10:57:30 +0000512 IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime.GetDeviceSpec());
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000513
514 ProfilingGuid optNetGuid = optNet->GetGuid();
515
516 // Load it into the runtime. It should succeed.
517 armnn::NetworkId netId;
Sadik Armagan1625efc2021-06-10 18:24:34 +0100518 CHECK(runtime.LoadNetwork(netId, std::move(optNet)) == Status::Success);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000519
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000520 profiling::BufferManager& bufferManager = profilingServiceHelper.GetProfilingBufferManager();
521 auto readableBuffer = bufferManager.GetReadableBuffer();
522
523 // Profiling is enabled, the post-optimisation structure should be created
Sadik Armagan1625efc2021-06-10 18:24:34 +0100524 CHECK(readableBuffer != nullptr);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000525
526 unsigned int size = readableBuffer->GetSize();
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000527
528 const unsigned char* readableData = readableBuffer->GetReadableData();
Sadik Armagan1625efc2021-06-10 18:24:34 +0100529 CHECK(readableData != nullptr);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000530
531 unsigned int offset = 0;
532
Keith Davis97da5e22020-03-05 16:25:28 +0000533 // Verify Header
Jim Flynnf7713212020-07-14 09:50:59 +0100534 VerifyTimelineHeaderBinary(readableData, offset, size - 8);
Keith Davis97da5e22020-03-05 16:25:28 +0000535
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000536 // Post-optimisation network
537 // Network entity
Jim Flynn6398a982020-05-27 17:05:21 +0100538 VerifyTimelineEntityBinaryPacketData(optNetGuid, readableData, offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000539
540 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000541 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
542 EmptyOptional(),
543 optNetGuid,
544 LabelsAndEventClasses::NETWORK_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000545 LabelsAndEventClasses::TYPE_GUID,
546 readableData,
547 offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000548
Jim Flynnf7713212020-07-14 09:50:59 +0100549 // Network - START OF LIFE
550 ProfilingGuid networkSolEventGuid = VerifyTimelineEventBinaryPacket(EmptyOptional(),
551 EmptyOptional(),
552 EmptyOptional(),
553 readableData,
554 offset);
Jim Flynnf7713212020-07-14 09:50:59 +0100555
556 // Network - START OF LIFE event relationship
557 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
558 EmptyOptional(),
559 optNetGuid,
560 networkSolEventGuid,
561 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
562 readableData,
563 offset);
Jim Flynnf7713212020-07-14 09:50:59 +0100564
565 // Process ID Label
566 int processID = armnnUtils::Processes::GetCurrentId();
567 std::stringstream ss;
568 ss << processID;
569 std::string processIdLabel = ss.str();
570 VerifyTimelineLabelBinaryPacketData(EmptyOptional(), processIdLabel, readableData, offset);
Jim Flynnf7713212020-07-14 09:50:59 +0100571
572 // Entity - Process ID relationship
573 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
574 EmptyOptional(),
575 optNetGuid,
576 EmptyOptional(),
577 LabelsAndEventClasses::PROCESS_ID_GUID,
578 readableData,
579 offset);
Jim Flynnf7713212020-07-14 09:50:59 +0100580
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000581 // Input layer
582 // Input layer entity
Keith Davis97da5e22020-03-05 16:25:28 +0000583 VerifyTimelineEntityBinaryPacketData(input->GetGuid(), readableData, offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000584
585 // Name Entity
Jim Flynn6398a982020-05-27 17:05:21 +0100586 ProfilingGuid inputLabelGuid = VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "input", readableData, offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000587
588 // Entity - Name relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000589 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
590 EmptyOptional(),
591 input->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100592 inputLabelGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000593 LabelsAndEventClasses::NAME_GUID,
594 readableData,
595 offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000596
597 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000598 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
599 EmptyOptional(),
600 input->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100601 LabelsAndEventClasses::LAYER_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000602 LabelsAndEventClasses::TYPE_GUID,
603 readableData,
604 offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000605
606 // Network - Input layer relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000607 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
608 EmptyOptional(),
609 optNetGuid,
610 input->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100611 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000612 readableData,
613 offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000614
615 // Normalization layer
616 // Normalization layer entity
Keith Davis97da5e22020-03-05 16:25:28 +0000617 VerifyTimelineEntityBinaryPacketData(normalize->GetGuid(), readableData, offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000618
619 // Name entity
Jim Flynn6398a982020-05-27 17:05:21 +0100620 ProfilingGuid normalizationLayerNameGuid = VerifyTimelineLabelBinaryPacketData(
621 EmptyOptional(), "normalization", readableData, offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000622
623 // Entity - Name relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000624 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
625 EmptyOptional(),
626 normalize->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100627 normalizationLayerNameGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000628 LabelsAndEventClasses::NAME_GUID,
629 readableData,
630 offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000631
632 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000633 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
634 EmptyOptional(),
635 normalize->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100636 LabelsAndEventClasses::LAYER_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000637 LabelsAndEventClasses::TYPE_GUID,
638 readableData,
639 offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000640
641 // Network - Normalize layer relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000642 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
643 EmptyOptional(),
644 optNetGuid,
645 normalize->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100646 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000647 readableData,
648 offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000649
650 // Input layer - Normalize layer relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000651 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
652 EmptyOptional(),
653 input->GetGuid(),
654 normalize->GetGuid(),
Keith Davis97da5e22020-03-05 16:25:28 +0000655 LabelsAndEventClasses::CONNECTION_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000656 readableData,
657 offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000658
659 // Normalization workload
660 // Normalization workload entity
Jim Flynn6398a982020-05-27 17:05:21 +0100661 ProfilingGuid normalizationWorkloadGuid = VerifyTimelineEntityBinaryPacketData(
662 EmptyOptional(), readableData, offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000663
664 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000665 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
666 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100667 normalizationWorkloadGuid,
668 LabelsAndEventClasses::WORKLOAD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000669 LabelsAndEventClasses::TYPE_GUID,
670 readableData,
671 offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000672
673 // BackendId entity
Jim Flynn6398a982020-05-27 17:05:21 +0100674 ProfilingGuid cpuRefLabelGuid = VerifyTimelineLabelBinaryPacketData(
675 EmptyOptional(), "CpuRef", readableData, offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000676
677 // Entity - BackendId relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000678 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
679 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100680 normalizationWorkloadGuid,
681 cpuRefLabelGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000682 LabelsAndEventClasses::BACKENDID_GUID,
683 readableData,
684 offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000685
686 // Normalize layer - Normalize workload relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000687 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
688 EmptyOptional(),
689 normalize->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100690 normalizationWorkloadGuid,
691 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000692 readableData,
693 offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000694
695 // Output layer
696 // Output layer entity
Keith Davis97da5e22020-03-05 16:25:28 +0000697 VerifyTimelineEntityBinaryPacketData(output->GetGuid(), readableData, offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000698
699 // Name entity
Jim Flynn6398a982020-05-27 17:05:21 +0100700 ProfilingGuid outputLabelGuid = VerifyTimelineLabelBinaryPacketData(
701 EmptyOptional(), "output", readableData, offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000702
703 // Entity - Name relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000704 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
705 EmptyOptional(),
706 output->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100707 outputLabelGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000708 LabelsAndEventClasses::NAME_GUID,
709 readableData,
710 offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000711
712 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000713 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
714 EmptyOptional(),
715 output->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100716 LabelsAndEventClasses::LAYER_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000717 LabelsAndEventClasses::TYPE_GUID,
718 readableData,
719 offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000720
721 // Network - Output layer relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000722 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
723 EmptyOptional(),
724 optNetGuid,
725 output->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100726 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000727 readableData,
728 offset);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000729
730 // Normalize layer - Output layer relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000731 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
732 EmptyOptional(),
733 normalize->GetGuid(),
734 output->GetGuid(),
Keith Davis97da5e22020-03-05 16:25:28 +0000735 LabelsAndEventClasses::CONNECTION_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000736 readableData,
737 offset);
Derek Lamberti836b27b2019-11-20 10:51:57 +0000738
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +0000739 bufferManager.MarkRead(readableBuffer);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000740
741 // Creates structures for input & output.
742 std::vector<float> inputData(16);
743 std::vector<float> outputData(16);
744
Keith Davis97da5e22020-03-05 16:25:28 +0000745 InputTensors inputTensors
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000746 {
Sadik Armagan3184c902020-03-18 10:57:30 +0000747 {0, ConstTensor(runtime.GetInputTensorInfo(netId, 0), inputData.data())}
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000748 };
749 OutputTensors outputTensors
750 {
Sadik Armagan3184c902020-03-18 10:57:30 +0000751 {0, Tensor(runtime.GetOutputTensorInfo(netId, 0), outputData.data())}
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000752 };
753
754 // Does the inference.
Sadik Armagan3184c902020-03-18 10:57:30 +0000755 runtime.EnqueueWorkload(netId, inputTensors, outputTensors);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000756
Finn Williamsb6a402f2020-03-24 13:46:22 +0000757 // Get readable buffer for input workload
758 auto inputReadableBuffer = bufferManager.GetReadableBuffer();
Sadik Armagan1625efc2021-06-10 18:24:34 +0100759 CHECK(inputReadableBuffer != nullptr);
David Monahan6198fe02019-12-02 08:35:43 +0000760
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000761 // Get readable buffer for output workload
762 auto outputReadableBuffer = bufferManager.GetReadableBuffer();
Sadik Armagan1625efc2021-06-10 18:24:34 +0100763 CHECK(outputReadableBuffer != nullptr);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000764
Finn Williamsb6a402f2020-03-24 13:46:22 +0000765 // Get readable buffer for inference timeline
766 auto inferenceReadableBuffer = bufferManager.GetReadableBuffer();
Sadik Armagan1625efc2021-06-10 18:24:34 +0100767 CHECK(inferenceReadableBuffer != nullptr);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000768
769 // Validate input workload data
770 size = inputReadableBuffer->GetSize();
Sadik Armagan1625efc2021-06-10 18:24:34 +0100771 CHECK(size == 164);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000772
773 readableData = inputReadableBuffer->GetReadableData();
Sadik Armagan1625efc2021-06-10 18:24:34 +0100774 CHECK(readableData != nullptr);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000775
776 offset = 0;
777
Keith Davis97da5e22020-03-05 16:25:28 +0000778 // Verify Header
Finn Williams0a336dc2020-05-11 15:39:58 +0100779 VerifyTimelineHeaderBinary(readableData, offset, 156);
Keith Davis97da5e22020-03-05 16:25:28 +0000780
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000781 // Input workload
782 // Input workload entity
Jim Flynn6398a982020-05-27 17:05:21 +0100783 ProfilingGuid inputWorkloadGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000784
785 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000786 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
787 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100788 inputWorkloadGuid,
789 LabelsAndEventClasses::WORKLOAD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000790 LabelsAndEventClasses::TYPE_GUID,
791 readableData,
792 offset);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000793
794 // BackendId entity
Jim Flynn6398a982020-05-27 17:05:21 +0100795 ProfilingGuid CpuRefLabelGuid = VerifyTimelineLabelBinaryPacketData(
796 EmptyOptional(), "CpuRef", readableData, offset);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000797
798 // Entity - BackendId relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000799 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
800 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100801 inputWorkloadGuid,
802 CpuRefLabelGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000803 LabelsAndEventClasses::BACKENDID_GUID,
804 readableData,
805 offset);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000806
807 // Input layer - Input workload relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000808 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
809 EmptyOptional(),
810 input->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100811 inputWorkloadGuid,
812 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000813 readableData,
814 offset);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000815
816 bufferManager.MarkRead(inputReadableBuffer);
817
818 // Validate output workload data
819 size = outputReadableBuffer->GetSize();
Sadik Armagan1625efc2021-06-10 18:24:34 +0100820 CHECK(size == 164);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000821
822 readableData = outputReadableBuffer->GetReadableData();
Sadik Armagan1625efc2021-06-10 18:24:34 +0100823 CHECK(readableData != nullptr);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000824
825 offset = 0;
826
Keith Davis97da5e22020-03-05 16:25:28 +0000827 // Verify Header
Finn Williams0a336dc2020-05-11 15:39:58 +0100828 VerifyTimelineHeaderBinary(readableData, offset, 156);
Keith Davis97da5e22020-03-05 16:25:28 +0000829
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000830 // Output workload
831 // Output workload entity
Jim Flynn6398a982020-05-27 17:05:21 +0100832 ProfilingGuid outputWorkloadGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000833
834 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000835 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
836 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100837 outputWorkloadGuid,
838 LabelsAndEventClasses::WORKLOAD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000839 LabelsAndEventClasses::TYPE_GUID,
840 readableData,
841 offset);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000842
843 // BackendId entity
Keith Davis97da5e22020-03-05 16:25:28 +0000844 VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "CpuRef", readableData, offset);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000845
846 // Entity - BackendId relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000847 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
848 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100849 outputWorkloadGuid,
850 CpuRefLabelGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000851 LabelsAndEventClasses::BACKENDID_GUID,
852 readableData,
853 offset);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000854
855 // Output layer - Output workload relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000856 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
857 EmptyOptional(),
858 output->GetGuid(),
Jim Flynn6398a982020-05-27 17:05:21 +0100859 outputWorkloadGuid,
860 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000861 readableData,
862 offset);
Narumol Prangnawarataa68e012019-11-29 17:17:43 +0000863
864 bufferManager.MarkRead(outputReadableBuffer);
David Monahan6198fe02019-12-02 08:35:43 +0000865
866 // Validate inference data
867 size = inferenceReadableBuffer->GetSize();
Sadik Armagan1625efc2021-06-10 18:24:34 +0100868 CHECK(size == 976 + 8 * ThreadIdSize);
David Monahan6198fe02019-12-02 08:35:43 +0000869
870 readableData = inferenceReadableBuffer->GetReadableData();
Sadik Armagan1625efc2021-06-10 18:24:34 +0100871 CHECK(readableData != nullptr);
David Monahan6198fe02019-12-02 08:35:43 +0000872
873 offset = 0;
874
Keith Davis97da5e22020-03-05 16:25:28 +0000875 // Verify Header
Finn Williams0a336dc2020-05-11 15:39:58 +0100876 VerifyTimelineHeaderBinary(readableData, offset, 968 + 8 * ThreadIdSize);
Keith Davis97da5e22020-03-05 16:25:28 +0000877
David Monahan6198fe02019-12-02 08:35:43 +0000878 // Inference timeline trace
879 // Inference entity
Jim Flynn6398a982020-05-27 17:05:21 +0100880 ProfilingGuid inferenceGuid = VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
David Monahan6198fe02019-12-02 08:35:43 +0000881
882 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000883 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
884 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100885 inferenceGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000886 LabelsAndEventClasses::INFERENCE_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000887 LabelsAndEventClasses::TYPE_GUID,
888 readableData,
889 offset);
David Monahan6198fe02019-12-02 08:35:43 +0000890
891 // Network - Inference relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000892 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
893 EmptyOptional(),
894 optNetGuid,
Jim Flynn6398a982020-05-27 17:05:21 +0100895 inferenceGuid,
896 LabelsAndEventClasses::EXECUTION_OF_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000897 readableData,
898 offset);
David Monahan6198fe02019-12-02 08:35:43 +0000899
900 // Start Inference life
901 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +0100902 ProfilingGuid inferenceEventGuid = VerifyTimelineEventBinaryPacket(
903 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
David Monahan6198fe02019-12-02 08:35:43 +0000904
905 // Inference - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000906 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
907 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100908 inferenceGuid,
909 inferenceEventGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000910 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
911 readableData,
912 offset);
David Monahan6198fe02019-12-02 08:35:43 +0000913
914 // Execution
915 // Input workload execution
916 // Input workload execution entity
Jim Flynn6398a982020-05-27 17:05:21 +0100917 ProfilingGuid inputWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
918 EmptyOptional(), readableData, offset);
David Monahan6198fe02019-12-02 08:35:43 +0000919
920 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000921 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
922 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100923 inputWorkloadExecutionGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000924 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000925 LabelsAndEventClasses::TYPE_GUID,
926 readableData,
927 offset);
David Monahan6198fe02019-12-02 08:35:43 +0000928
929 // Inference - Workload execution relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000930 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
931 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100932 inferenceGuid,
933 inputWorkloadExecutionGuid,
934 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000935 readableData,
936 offset);
David Monahan6198fe02019-12-02 08:35:43 +0000937
938 // Workload - Workload execution relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000939 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
940 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100941 inputWorkloadGuid,
942 inputWorkloadExecutionGuid,
943 LabelsAndEventClasses::EXECUTION_OF_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000944 readableData,
945 offset);
David Monahan6198fe02019-12-02 08:35:43 +0000946
947 // Start Input workload execution life
948 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +0100949 ProfilingGuid inputWorkloadExecutionSOLEventId = VerifyTimelineEventBinaryPacket(
950 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
David Monahan6198fe02019-12-02 08:35:43 +0000951
952 // Input workload execution - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000953 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
954 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100955 inputWorkloadExecutionGuid,
956 inputWorkloadExecutionSOLEventId,
Keith Davis97da5e22020-03-05 16:25:28 +0000957 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
958 readableData,
959 offset);
David Monahan6198fe02019-12-02 08:35:43 +0000960
961 // End of Input workload execution life
962 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +0100963 ProfilingGuid inputWorkloadExecutionEOLEventId = VerifyTimelineEventBinaryPacket(
964 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
David Monahan6198fe02019-12-02 08:35:43 +0000965
966 // Input workload execution - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000967 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
968 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100969 inputWorkloadExecutionGuid,
970 inputWorkloadExecutionEOLEventId,
Keith Davis97da5e22020-03-05 16:25:28 +0000971 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
972 readableData,
973 offset);
David Monahan6198fe02019-12-02 08:35:43 +0000974
975 // Normalize workload execution
976 // Normalize workload execution entity
Jim Flynn6398a982020-05-27 17:05:21 +0100977 ProfilingGuid normalizeWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
978 EmptyOptional(), readableData, offset);
David Monahan6198fe02019-12-02 08:35:43 +0000979
980 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000981 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
982 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100983 normalizeWorkloadExecutionGuid,
Keith Davis97da5e22020-03-05 16:25:28 +0000984 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000985 LabelsAndEventClasses::TYPE_GUID,
986 readableData,
987 offset);
David Monahan6198fe02019-12-02 08:35:43 +0000988
989 // Inference - Workload execution relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000990 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
991 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +0100992 inferenceGuid,
993 normalizeWorkloadExecutionGuid,
994 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +0000995 readableData,
996 offset);
David Monahan6198fe02019-12-02 08:35:43 +0000997
998 // Workload - Workload execution relationship
Keith Davis97da5e22020-03-05 16:25:28 +0000999 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1000 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001001 normalizationWorkloadGuid,
1002 normalizeWorkloadExecutionGuid,
1003 LabelsAndEventClasses::EXECUTION_OF_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +00001004 readableData,
1005 offset);
David Monahan6198fe02019-12-02 08:35:43 +00001006
1007 // Start Normalize workload execution life
1008 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +01001009 ProfilingGuid normalizationWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket(
1010 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
David Monahan6198fe02019-12-02 08:35:43 +00001011
1012 // Normalize workload execution - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001013 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1014 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001015 normalizeWorkloadExecutionGuid,
1016 normalizationWorkloadExecutionSOLEventGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001017 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1018 readableData,
1019 offset);
David Monahan6198fe02019-12-02 08:35:43 +00001020
1021 // End of Normalize workload execution life
1022 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +01001023 ProfilingGuid normalizationWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket(
1024 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
David Monahan6198fe02019-12-02 08:35:43 +00001025
1026 // Normalize workload execution - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001027 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1028 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001029 normalizeWorkloadExecutionGuid,
1030 normalizationWorkloadExecutionEOLEventGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001031 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1032 readableData,
1033 offset);
David Monahan6198fe02019-12-02 08:35:43 +00001034
1035 // Output workload execution
1036 // Output workload execution entity
Jim Flynn6398a982020-05-27 17:05:21 +01001037 ProfilingGuid outputWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData(
1038 EmptyOptional(), readableData, offset);
David Monahan6198fe02019-12-02 08:35:43 +00001039
1040 // Entity - Type relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001041 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
1042 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001043 outputWorkloadExecutionGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001044 LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +00001045 LabelsAndEventClasses::TYPE_GUID,
1046 readableData,
1047 offset);
David Monahan6198fe02019-12-02 08:35:43 +00001048
1049 // Inference - Workload execution relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001050 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1051 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001052 inferenceGuid,
1053 outputWorkloadExecutionGuid,
1054 LabelsAndEventClasses::CHILD_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +00001055 readableData,
1056 offset);
David Monahan6198fe02019-12-02 08:35:43 +00001057
1058 // Workload - Workload execution relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001059 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
1060 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001061 outputWorkloadGuid,
1062 outputWorkloadExecutionGuid,
1063 LabelsAndEventClasses::EXECUTION_OF_GUID,
Keith Davis97da5e22020-03-05 16:25:28 +00001064 readableData,
1065 offset);
David Monahan6198fe02019-12-02 08:35:43 +00001066
1067 // Start Output workload execution life
1068 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +01001069 ProfilingGuid outputWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket(
1070 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
David Monahan6198fe02019-12-02 08:35:43 +00001071
1072 // Output workload execution - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001073 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1074 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001075 outputWorkloadExecutionGuid,
1076 outputWorkloadExecutionSOLEventGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001077 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
1078 readableData,
1079 offset);
Finn Williams0a336dc2020-05-11 15:39:58 +01001080
David Monahan6198fe02019-12-02 08:35:43 +00001081 // End of Normalize workload execution life
1082 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +01001083 ProfilingGuid outputWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket(
1084 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
David Monahan6198fe02019-12-02 08:35:43 +00001085
1086 // Output workload execution - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001087 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1088 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001089 outputWorkloadExecutionGuid,
1090 outputWorkloadExecutionEOLEventGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001091 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1092 readableData,
1093 offset);
David Monahan6198fe02019-12-02 08:35:43 +00001094
1095 // End of Inference life
1096 // Event packet - timeline, threadId, eventGuid
Jim Flynn6398a982020-05-27 17:05:21 +01001097 ProfilingGuid inferenceEOLEventGuid = VerifyTimelineEventBinaryPacket(
1098 EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset);
David Monahan6198fe02019-12-02 08:35:43 +00001099
1100 // Inference - event relationship
Keith Davis97da5e22020-03-05 16:25:28 +00001101 VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
1102 EmptyOptional(),
Jim Flynn6398a982020-05-27 17:05:21 +01001103 inferenceGuid,
1104 inferenceEOLEventGuid,
Keith Davis97da5e22020-03-05 16:25:28 +00001105 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
1106 readableData,
1107 offset);
David Monahan6198fe02019-12-02 08:35:43 +00001108
1109 bufferManager.MarkRead(inferenceReadableBuffer);
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +00001110}
1111
Sadik Armagan1625efc2021-06-10 18:24:34 +01001112TEST_CASE("ProfilingPostOptimisationStructureCpuRef")
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +00001113{
1114 VerifyPostOptimisationStructureTestImpl(armnn::Compute::CpuRef);
1115}
1116
Sadik Armagan1625efc2021-06-10 18:24:34 +01001117}