Laurent Carlier | 749294b | 2020-06-01 09:03:17 +0100 | [diff] [blame] | 1 | // |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd and Contributors. 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 | |
Jim Flynn | 77b284e | 2022-03-13 20:53:35 +0000 | [diff] [blame] | 6 | #include <ArmNNProfilingServiceInitialiser.hpp> |
| 7 | #include <ProfilingOptionsConverter.hpp> |
| 8 | #include <Runtime.hpp> |
| 9 | |
Aron Virginas-Tar | c26ba75 | 2018-10-22 13:32:01 +0100 | [diff] [blame] | 10 | #include <armnn/Descriptors.hpp> |
| 11 | #include <armnn/IRuntime.hpp> |
| 12 | #include <armnn/INetwork.hpp> |
Aron Virginas-Tar | c26ba75 | 2018-10-22 13:32:01 +0100 | [diff] [blame] | 13 | #include <armnn/TypesUtils.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 14 | |
Jim Flynn | 77b284e | 2022-03-13 20:53:35 +0000 | [diff] [blame] | 15 | #include <armnn/profiling/ArmNNProfiling.hpp> |
| 16 | |
Nikhil Raj | 77fe76b | 2021-06-09 14:55:32 +0100 | [diff] [blame] | 17 | #include <common/include/LabelsAndEventClasses.hpp> |
Jim Flynn | 77b284e | 2022-03-13 20:53:35 +0000 | [diff] [blame] | 18 | #include <common/include/Processes.hpp> |
| 19 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 20 | #include <test/ProfilingTestUtils.hpp> |
| 21 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 22 | #include <HeapProfiling.hpp> |
| 23 | #include <LeakChecking.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 24 | |
| 25 | #ifdef WITH_VALGRIND |
Aron Virginas-Tar | c26ba75 | 2018-10-22 13:32:01 +0100 | [diff] [blame] | 26 | #include <valgrind/memcheck.h> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 27 | #endif |
| 28 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 29 | #include <doctest/doctest.h> |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 30 | #include "RuntimeTests.hpp" |
Sadik Armagan | a097d2a | 2021-11-24 15:47:28 +0000 | [diff] [blame] | 31 | #include <TestUtils.hpp> |
Aron Virginas-Tar | c26ba75 | 2018-10-22 13:32:01 +0100 | [diff] [blame] | 32 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 33 | namespace armnn |
| 34 | { |
| 35 | |
Kevin May | d92a6e4 | 2021-02-04 10:27:41 +0000 | [diff] [blame] | 36 | void RuntimeLoadedNetworksReserve(armnn::RuntimeImpl* runtime) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 37 | { |
| 38 | runtime->m_LoadedNetworks.reserve(1); |
| 39 | } |
| 40 | |
Jim Flynn | 6c9f17d | 2022-03-10 23:13:01 +0000 | [diff] [blame] | 41 | } // namespace armnn |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 42 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 43 | TEST_SUITE("Runtime") |
| 44 | { |
| 45 | TEST_CASE("RuntimeUnloadNetwork") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 46 | { |
| 47 | // build 2 mock-networks and load them into the runtime |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 48 | armnn::IRuntime::CreationOptions options; |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 49 | armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 50 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 51 | // Mock network 1. |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 52 | armnn::NetworkId networkIdentifier1 = 1; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 53 | armnn::INetworkPtr mockNetwork1(armnn::INetwork::Create()); |
| 54 | mockNetwork1->AddInputLayer(0, "test layer"); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 55 | std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 56 | runtime->LoadNetwork(networkIdentifier1, Optimize(*mockNetwork1, backends, runtime->GetDeviceSpec())); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 57 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 58 | // Mock network 2. |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 59 | armnn::NetworkId networkIdentifier2 = 2; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 60 | armnn::INetworkPtr mockNetwork2(armnn::INetwork::Create()); |
| 61 | mockNetwork2->AddInputLayer(0, "test layer"); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 62 | runtime->LoadNetwork(networkIdentifier2, Optimize(*mockNetwork2, backends, runtime->GetDeviceSpec())); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 63 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 64 | // Unloads one by its networkID. |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 65 | CHECK(runtime->UnloadNetwork(networkIdentifier1) == armnn::Status::Success); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 66 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 67 | CHECK(runtime->UnloadNetwork(networkIdentifier1) == armnn::Status::Failure); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 68 | } |
| 69 | |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 70 | TEST_CASE("RuntimePreImportInputs") |
| 71 | { |
| 72 | armnn::IRuntime::CreationOptions options; |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 73 | armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); |
| 74 | armnn::NetworkId networkId = 1; |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 75 | armnn::INetworkPtr testNetwork(armnn::INetwork::Create()); |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 76 | |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 77 | auto inputLayer1 = testNetwork->AddInputLayer(0, "input 1 layer"); |
| 78 | auto inputLayer2 = testNetwork->AddInputLayer(1, "input 2 layer"); |
| 79 | auto addLayer = testNetwork->AddAdditionLayer("add layer"); |
| 80 | auto outputLayer = testNetwork->AddOutputLayer(2, "output layer"); |
| 81 | |
| 82 | TensorInfo tensorInfo{{4}, armnn::DataType::Signed32}; |
| 83 | |
| 84 | inputLayer1->GetOutputSlot(0).Connect(addLayer->GetInputSlot(0)); |
| 85 | inputLayer1->GetOutputSlot(0).SetTensorInfo(tensorInfo); |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 86 | |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 87 | inputLayer2->GetOutputSlot(0).Connect(addLayer->GetInputSlot(1)); |
| 88 | inputLayer2->GetOutputSlot(0).SetTensorInfo(tensorInfo); |
| 89 | |
| 90 | addLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0)); |
| 91 | addLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo); |
| 92 | |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 93 | std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef}; |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 94 | |
| 95 | std::string er; |
Colm Donelan | 03bf98a | 2022-05-30 15:20:36 +0100 | [diff] [blame^] | 96 | armnn::INetworkProperties networkProperties(true, MemorySource::Undefined, MemorySource::Undefined); |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 97 | runtime->LoadNetwork(networkId, |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 98 | Optimize(*testNetwork, backends, runtime->GetDeviceSpec()), |
| 99 | er, |
| 100 | networkProperties); |
| 101 | |
| 102 | std::vector<int> inputData1(4, 10); |
| 103 | std::vector<int> inputData2(4, 20); |
| 104 | std::vector<int> output(4); |
| 105 | |
Cathal Corbett | 5b8093c | 2021-10-22 11:12:07 +0100 | [diff] [blame] | 106 | ConstTensor inputTensor1({{4}, armnn::DataType::Signed32, 0.0f, 0, true}, inputData1.data()); |
| 107 | ConstTensor inputTensor2({{4}, armnn::DataType::Signed32, 0.0f, 0, true}, inputData2.data()); |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 108 | Tensor outputTensor({{4}, armnn::DataType::Signed32}, output.data()); |
| 109 | |
Colm Donelan | 03bf98a | 2022-05-30 15:20:36 +0100 | [diff] [blame^] | 110 | auto importedInputVec1 = runtime->ImportInputs(networkId, {{0, inputTensor1}}, MemorySource::Malloc); |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 111 | CHECK(importedInputVec1.size() == 1); |
| 112 | CHECK(importedInputVec1[0] == 0); |
| 113 | |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 114 | auto memHandle = runtime->CreateWorkingMemHandle(networkId); |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 115 | |
| 116 | runtime->Execute(*memHandle.get(), {{1, inputTensor2}}, {{2, outputTensor}}, {0 /* pre-imported id */}); |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 117 | for (auto val: output) { |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 118 | CHECK(val == 30); |
| 119 | } |
| 120 | |
Colm Donelan | 03bf98a | 2022-05-30 15:20:36 +0100 | [diff] [blame^] | 121 | auto importedInputVec2 = runtime->ImportInputs(networkId, {{1, inputTensor2}}, MemorySource::Malloc); |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 122 | CHECK(importedInputVec2.size() == 1); |
| 123 | CHECK(importedInputVec2[0] == 1); |
| 124 | |
| 125 | runtime->Execute(*memHandle.get(), {{0, inputTensor1}}, {{2, outputTensor}}, {1 /* pre-imported id */}); |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 126 | for (auto val: output) { |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 127 | CHECK(val == 30); |
| 128 | } |
| 129 | |
| 130 | runtime->Execute(*memHandle.get(), {}, {{2, outputTensor}}, {0, 1}); |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 131 | for (auto val: output) { |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 132 | CHECK(val == 30); |
| 133 | } |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 134 | // Duplicate ImportedInputId and LayerBindingId |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 135 | CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), {}, {{2, outputTensor}}, {0, 0});, |
| 136 | armnn::InvalidArgumentException); |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 137 | // Duplicate LayerBindingId |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 138 | CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), {{1, inputTensor2}}, {{2, outputTensor}}, {1});, |
| 139 | armnn::InvalidArgumentException); |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 140 | // Incorrect ImportedInputId |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 141 | CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), {{1, inputTensor2}}, {{2, outputTensor}}, {10});, |
| 142 | armnn::InvalidArgumentException); |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 143 | // Incorrect LayerBindingId |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 144 | CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), {{-2, inputTensor2}}, {{2, outputTensor}}, {1});, |
| 145 | armnn::InvalidArgumentException); |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 146 | // Incorrect layer binding id and ImportedInputId |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 147 | CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), {{-2, inputTensor2}}, {{2, outputTensor}}, {10});, |
| 148 | armnn::InvalidArgumentException); |
Colm Donelan | 03bf98a | 2022-05-30 15:20:36 +0100 | [diff] [blame^] | 149 | auto importedInputVec3 = runtime->ImportInputs(networkId, {{1, inputTensor2}}, MemorySource::Malloc); |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 150 | CHECK(importedInputVec3[0] == 2); |
| 151 | // Too many ImportedInputIds |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 152 | CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), {}, {{2, outputTensor}}, {0, 1, 2});, |
| 153 | armnn::InvalidArgumentException); |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 154 | // Too many InputTensors |
| 155 | CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 156 | {{0, inputTensor2}, |
| 157 | {1, inputTensor2}, |
| 158 | {2, inputTensor2}}, |
| 159 | {{2, outputTensor}});, armnn::InvalidArgumentException); |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 160 | // Too few ImportedInputIds |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 161 | CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), {}, {{2, outputTensor}}, {0});, |
| 162 | armnn::InvalidArgumentException); |
| 163 | runtime->ClearImportedInputs(networkId, {1}); |
| 164 | runtime->Execute(*memHandle.get(), {{1, inputTensor2}}, {{2, outputTensor}}, {0}, {}); |
| 165 | for (auto val: output) { |
| 166 | CHECK(val == 30); |
| 167 | } |
| 168 | // Using deleted pre-imported input |
| 169 | CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), {}, {{2, outputTensor}}, {0, 1}, {});, |
| 170 | armnn::InvalidArgumentException); |
| 171 | |
| 172 | // Trying to delete deleted pre-imported tensor |
| 173 | CHECK_THROWS_AS(runtime->ClearImportedInputs(networkId, {1});, armnn::InvalidArgumentException); |
| 174 | |
| 175 | // Trying to delete unknown pre-imported tensor |
| 176 | CHECK_THROWS_AS(runtime->ClearImportedInputs(networkId, {10});, armnn::InvalidArgumentException); |
| 177 | } |
Colm Donelan | 03bf98a | 2022-05-30 15:20:36 +0100 | [diff] [blame^] | 178 | |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 179 | TEST_CASE("RuntimePreImportOutputs") |
| 180 | { |
| 181 | armnn::IRuntime::CreationOptions options; |
| 182 | armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); |
| 183 | |
| 184 | armnn::NetworkId networkId = 1; |
| 185 | |
| 186 | armnn::INetworkPtr testNetwork(armnn::INetwork::Create()); |
Cathal Corbett | 5b8093c | 2021-10-22 11:12:07 +0100 | [diff] [blame] | 187 | TensorInfo tensorInfo{{4}, armnn::DataType::Float32, 0.0f, 0, true}; |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 188 | |
| 189 | auto inputLayer1 = testNetwork->AddInputLayer(0, "input 1 layer"); |
| 190 | inputLayer1->GetOutputSlot(0).SetTensorInfo(tensorInfo); |
| 191 | |
| 192 | ActivationDescriptor activationDescriptor; |
| 193 | activationDescriptor.m_Function = ActivationFunction::BoundedReLu; |
| 194 | activationDescriptor.m_A = 2.0f; |
| 195 | activationDescriptor.m_B = 0.0f; |
| 196 | auto activationLayer1 = testNetwork->AddActivationLayer(activationDescriptor, "add layer"); |
| 197 | auto outputLayer1 = testNetwork->AddOutputLayer(2, "output layer"); |
| 198 | |
| 199 | inputLayer1->GetOutputSlot(0).Connect(activationLayer1->GetInputSlot(0)); |
| 200 | |
| 201 | activationLayer1->GetOutputSlot(0).Connect(outputLayer1->GetInputSlot(0)); |
| 202 | activationLayer1->GetOutputSlot(0).SetTensorInfo(tensorInfo); |
| 203 | |
| 204 | auto inputLayer2 = testNetwork->AddInputLayer(1, "input 1 layer"); |
| 205 | |
| 206 | activationDescriptor.m_A = 4.0f; |
| 207 | activationDescriptor.m_B = 2.0f; |
| 208 | auto activationLayer2 = testNetwork->AddActivationLayer(activationDescriptor, "add layer"); |
| 209 | auto outputLayer2 = testNetwork->AddOutputLayer(3, "output layer"); |
| 210 | |
| 211 | inputLayer2->GetOutputSlot(0).Connect(activationLayer2->GetInputSlot(0)); |
| 212 | inputLayer2->GetOutputSlot(0).SetTensorInfo(tensorInfo); |
| 213 | |
| 214 | activationLayer2->GetOutputSlot(0).Connect(outputLayer2->GetInputSlot(0)); |
| 215 | activationLayer2->GetOutputSlot(0).SetTensorInfo(tensorInfo); |
| 216 | |
| 217 | std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; |
| 218 | |
| 219 | std::string er; |
Colm Donelan | 03bf98a | 2022-05-30 15:20:36 +0100 | [diff] [blame^] | 220 | armnn::INetworkProperties networkProperties(true, MemorySource::Undefined, MemorySource::Undefined); |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 221 | runtime->LoadNetwork(networkId, |
| 222 | Optimize(*testNetwork, backends, runtime->GetDeviceSpec()), |
| 223 | er, |
| 224 | networkProperties); |
| 225 | |
| 226 | std::vector<float> inputData1(4, 1.0f); |
| 227 | std::vector<float> inputData2(4, 3.0f); |
| 228 | |
| 229 | std::vector<float> outputData1(4); |
| 230 | std::vector<float> outputData2(4); |
| 231 | |
| 232 | ConstTensor inputTensor1(tensorInfo, inputData1.data()); |
| 233 | ConstTensor inputTensor2(tensorInfo, inputData2.data()); |
| 234 | |
| 235 | Tensor outputTensor1{tensorInfo, outputData1.data()}; |
| 236 | Tensor outputTensor2{tensorInfo, outputData2.data()}; |
| 237 | |
| 238 | InputTensors inputTensors = {{0, inputTensor1}, {1, inputTensor2}}; |
| 239 | |
| 240 | std::pair<LayerBindingId, class Tensor> output1{2, outputTensor1}; |
| 241 | std::pair<LayerBindingId, class Tensor> output2{3, outputTensor2}; |
| 242 | |
| 243 | auto testOutputs = [&]() |
| 244 | { |
| 245 | for (auto val : outputData1) |
| 246 | { |
| 247 | CHECK(val == 1.0f); |
| 248 | } |
| 249 | |
| 250 | for (auto val : outputData2) |
| 251 | { |
| 252 | CHECK(val == 3.0f); |
| 253 | } |
| 254 | }; |
| 255 | |
| 256 | auto memHandle = runtime->CreateWorkingMemHandle(networkId); |
| 257 | |
| 258 | runtime->Execute(*memHandle.get(),inputTensors, {output1, output2}); |
| 259 | testOutputs(); |
| 260 | |
Colm Donelan | 03bf98a | 2022-05-30 15:20:36 +0100 | [diff] [blame^] | 261 | auto importedOutputVec = runtime->ImportOutputs(networkId, {output1, output2 }, MemorySource::Malloc); |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 262 | CHECK(importedOutputVec.size() == 2); |
| 263 | CHECK(importedOutputVec[0] == 0); |
| 264 | CHECK(importedOutputVec[1] == 1); |
| 265 | |
| 266 | runtime->Execute(*memHandle.get(), inputTensors, {}, {}, importedOutputVec); |
| 267 | testOutputs(); |
| 268 | |
| 269 | runtime->Execute(*memHandle.get(), inputTensors, {output1}, {}, {1}); |
| 270 | testOutputs(); |
| 271 | |
| 272 | runtime->Execute(*memHandle.get(), inputTensors, {output2}, {}, {0}); |
| 273 | testOutputs(); |
| 274 | |
Colm Donelan | 03bf98a | 2022-05-30 15:20:36 +0100 | [diff] [blame^] | 275 | auto importedInputVec = runtime->ImportInputs(networkId, inputTensors, MemorySource::Malloc); |
Finn Williams | 8636bc7 | 2021-10-02 15:06:39 +0100 | [diff] [blame] | 276 | CHECK(importedInputVec.size() == 2); |
| 277 | CHECK(importedInputVec[0] == 0); |
| 278 | CHECK(importedInputVec[1] == 1); |
| 279 | |
| 280 | runtime->Execute(*memHandle.get(), {}, {}, importedInputVec, importedOutputVec); |
| 281 | testOutputs(); |
| 282 | |
| 283 | runtime->Execute(*memHandle.get(), {{0, inputTensor1}}, {output2}, {1}, {0}); |
| 284 | testOutputs(); |
| 285 | |
| 286 | // Too many ids |
| 287 | CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), inputTensors, {output1, output2}, {}, {0, 1});, |
| 288 | armnn::InvalidArgumentException); |
| 289 | |
| 290 | // Duplicate ids |
| 291 | CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), inputTensors, {output2}, {}, {1});, |
| 292 | armnn::InvalidArgumentException); |
| 293 | |
| 294 | // Duplicate ids |
| 295 | CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), inputTensors, {output1, output1}, {}, {});, |
| 296 | armnn::InvalidArgumentException); |
| 297 | |
| 298 | // Duplicate ids |
| 299 | CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), inputTensors, {}, {}, {0, 0}), |
| 300 | armnn::InvalidArgumentException); |
| 301 | |
| 302 | // Unknown id |
| 303 | CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), inputTensors, {output1}, {}, {3});, |
| 304 | armnn::InvalidArgumentException); |
| 305 | |
| 306 | // Unknown id |
| 307 | CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), inputTensors, {{4, outputTensor2}}, {}, {1});, |
| 308 | armnn::InvalidArgumentException); |
| 309 | |
| 310 | // Input id for output |
| 311 | CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), inputTensors, {{0, outputTensor2}}, {}, {1});, |
| 312 | armnn::InvalidArgumentException); |
| 313 | |
| 314 | // Input id for output |
| 315 | CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), inputTensors, {{0, outputTensor2}}, {}, {1});, |
| 316 | armnn::InvalidArgumentException); |
| 317 | |
| 318 | // Output id for input |
| 319 | CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), {{2, inputTensor1}}, {{0, outputTensor2}}, {1}, {1, 0});, |
| 320 | armnn::InvalidArgumentException); |
| 321 | |
| 322 | runtime->ClearImportedOutputs(networkId, {1}); |
| 323 | |
| 324 | runtime->Execute(*memHandle.get(), inputTensors, {output2}, {}, {0}); |
| 325 | testOutputs(); |
| 326 | |
| 327 | // Trying to use deleted pre-imported tensor |
| 328 | CHECK_THROWS_AS(runtime->Execute(*memHandle.get(), inputTensors, {}, {}, importedOutputVec), |
| 329 | armnn::InvalidArgumentException); |
| 330 | |
| 331 | // Trying to delete deleted pre-imported tensor |
| 332 | CHECK_THROWS_AS(runtime->ClearImportedOutputs(networkId, {1});, armnn::InvalidArgumentException); |
| 333 | |
| 334 | // Trying to delete unknown pre-imported tensor |
| 335 | CHECK_THROWS_AS(runtime->ClearImportedOutputs(networkId, {10});, armnn::InvalidArgumentException); |
Finn Williams | f37b970 | 2021-09-01 18:06:04 +0100 | [diff] [blame] | 336 | } |
| 337 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 338 | // 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] | 339 | // time, so in practice WITH_VALGRIND and ARMNN_LEAK_CHECKING_ENABLED are exclusive. The |
| 340 | // valgrind tests can stay for x86 builds, but on hikey Valgrind is just way too slow |
| 341 | // to be integrated into the CI system. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 342 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 343 | #ifdef ARMNN_LEAK_CHECKING_ENABLED |
| 344 | |
| 345 | struct DisableGlobalLeakChecking |
| 346 | { |
| 347 | DisableGlobalLeakChecking() |
| 348 | { |
| 349 | ARMNN_LOCAL_LEAK_CHECKING_ONLY(); |
| 350 | } |
| 351 | }; |
| 352 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 353 | TEST_CASE_FIXTURE(DisableGlobalLeakChecking, "RuntimeHeapMemoryUsageSanityChecks") |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 354 | { |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 355 | CHECK(ARMNN_LEAK_CHECKER_IS_ACTIVE()); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 356 | { |
| 357 | ARMNN_SCOPED_LEAK_CHECKER("Sanity_Check_Outer"); |
| 358 | { |
| 359 | ARMNN_SCOPED_LEAK_CHECKER("Sanity_Check_Inner"); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 360 | CHECK(ARMNN_NO_LEAKS_IN_SCOPE() == true); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 361 | std::unique_ptr<char[]> dummyAllocation(new char[1000]); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 362 | // "A leak of 1000 bytes is expected here. " |
| 363 | // "Please make sure environment variable: HEAPCHECK=draconian is set!" |
| 364 | CHECK((ARMNN_NO_LEAKS_IN_SCOPE() == false)); |
| 365 | CHECK(ARMNN_BYTES_LEAKED_IN_SCOPE() == 1000); |
| 366 | CHECK(ARMNN_OBJECTS_LEAKED_IN_SCOPE() == 1); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 367 | } |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 368 | CHECK(ARMNN_NO_LEAKS_IN_SCOPE()); |
| 369 | CHECK(ARMNN_BYTES_LEAKED_IN_SCOPE() == 0); |
| 370 | CHECK(ARMNN_OBJECTS_LEAKED_IN_SCOPE() == 0); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 371 | } |
| 372 | } |
| 373 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 374 | #endif // ARMNN_LEAK_CHECKING_ENABLED |
| 375 | |
| 376 | // 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] | 377 | #ifdef WITH_VALGRIND |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 378 | // 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] | 379 | // valgrind --leak-check=full --show-leak-kinds=all --log-file=Valgrind_Memcheck_Leak_Report.txt armnn/test/UnitTests |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 380 | TEST_CASE("RuntimeMemoryLeak") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 381 | { |
| 382 | // From documentation: |
| 383 | |
| 384 | // This means that no pointer to the block can be found. The block is classified as "lost", |
| 385 | // because the programmer could not possibly have freed it at program exit, since no pointer to it exists. |
| 386 | unsigned long leakedBefore = 0; |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 387 | unsigned long leakedAfter = 0; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 388 | |
| 389 | // A start-pointer or chain of start-pointers to the block is found. Since the block is still pointed at, |
| 390 | // the programmer could, at least in principle, have freed it before program exit. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 391 | // 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] | 392 | unsigned long reachableBefore = 0; |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 393 | unsigned long reachableAfter = 0; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 394 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 395 | // Needed as out params but we don't test them. |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 396 | unsigned long dubious = 0; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 397 | unsigned long suppressed = 0; |
| 398 | |
| 399 | armnn::NetworkId networkIdentifier1 = 1; |
| 400 | |
| 401 | // ensure that runtime is large enough before checking for memory leaks |
| 402 | // 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] | 403 | armnn::IRuntime::CreationOptions options; |
Kevin May | d92a6e4 | 2021-02-04 10:27:41 +0000 | [diff] [blame] | 404 | armnn::RuntimeImpl runtime(options); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 405 | armnn::RuntimeLoadedNetworksReserve(&runtime); |
| 406 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 407 | { |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 408 | std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 409 | |
Francis Murtagh | 3d2b4b2 | 2021-02-15 18:23:17 +0000 | [diff] [blame] | 410 | armnn::INetworkPtr mockNetwork1(armnn::INetwork::Create()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 411 | mockNetwork1->AddInputLayer(0, "test layer"); |
| 412 | |
Matteo Martincigh | 9326aab | 2018-11-15 10:54:54 +0000 | [diff] [blame] | 413 | // 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] | 414 | runtime.LoadNetwork(networkIdentifier1, Optimize(*mockNetwork1, backends, runtime.GetDeviceSpec())); |
Matteo Martincigh | 9326aab | 2018-11-15 10:54:54 +0000 | [diff] [blame] | 415 | runtime.UnloadNetwork(networkIdentifier1); |
| 416 | |
| 417 | // Checks for leaks before we load the network and record them so that we can see the delta after unloading. |
| 418 | VALGRIND_DO_QUICK_LEAK_CHECK; |
| 419 | VALGRIND_COUNT_LEAKS(leakedBefore, dubious, reachableBefore, suppressed); |
| 420 | |
| 421 | // The actual test. |
| 422 | runtime.LoadNetwork(networkIdentifier1, Optimize(*mockNetwork1, backends, runtime.GetDeviceSpec())); |
| 423 | runtime.UnloadNetwork(networkIdentifier1); |
| 424 | |
| 425 | VALGRIND_DO_ADDED_LEAK_CHECK; |
| 426 | VALGRIND_COUNT_LEAKS(leakedAfter, dubious, reachableAfter, suppressed); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 427 | } |
| 428 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 429 | // If we're not running under Valgrind, these vars will have been initialised to 0, so this will always pass. |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 430 | CHECK(leakedBefore == leakedAfter); |
| 431 | CHECK(reachableBefore == reachableAfter); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 432 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 433 | // These are needed because VALGRIND_COUNT_LEAKS is a macro that assigns to the parameters |
| 434 | // so they are assigned to, but still considered unused, causing a warning. |
Jim Flynn | 9265a88 | 2022-03-10 23:35:26 +0000 | [diff] [blame] | 435 | armnn::IgnoreUnused(dubious); |
| 436 | armnn::IgnoreUnused(suppressed); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 437 | } |
Aron Virginas-Tar | c26ba75 | 2018-10-22 13:32:01 +0100 | [diff] [blame] | 438 | #endif // WITH_VALGRIND |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 439 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 440 | TEST_CASE("RuntimeCpuRef") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 441 | { |
| 442 | using namespace armnn; |
| 443 | |
| 444 | // Create runtime in which test will run |
| 445 | armnn::IRuntime::CreationOptions options; |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 446 | armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 447 | |
| 448 | // build up the structure of the network |
| 449 | INetworkPtr net(INetwork::Create()); |
| 450 | |
| 451 | IConnectableLayer* input = net->AddInputLayer(0); |
| 452 | |
| 453 | // This layer configuration isn't supported by CpuAcc, should be fall back to CpuRef. |
| 454 | NormalizationDescriptor descriptor; |
| 455 | IConnectableLayer* normalize = net->AddNormalizationLayer(descriptor); |
| 456 | |
| 457 | IConnectableLayer* output = net->AddOutputLayer(0); |
| 458 | |
| 459 | input->GetOutputSlot(0).Connect(normalize->GetInputSlot(0)); |
| 460 | normalize->GetOutputSlot(0).Connect(output->GetInputSlot(0)); |
| 461 | |
| 462 | input->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32)); |
| 463 | normalize->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32)); |
| 464 | |
| 465 | // optimize the network |
David Beck | f0b4845 | 2018-10-19 15:20:56 +0100 | [diff] [blame] | 466 | std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 467 | IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec()); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 468 | |
| 469 | // Load it into the runtime. It should success. |
| 470 | armnn::NetworkId netId; |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 471 | CHECK(runtime->LoadNetwork(netId, std::move(optNet)) == Status::Success); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 472 | } |
| 473 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 474 | TEST_CASE("RuntimeFallbackToCpuRef") |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 475 | { |
| 476 | using namespace armnn; |
| 477 | |
| 478 | // Create runtime in which test will run |
| 479 | armnn::IRuntime::CreationOptions options; |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 480 | armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 481 | |
| 482 | // build up the structure of the network |
| 483 | INetworkPtr net(INetwork::Create()); |
| 484 | |
| 485 | IConnectableLayer* input = net->AddInputLayer(0); |
| 486 | |
| 487 | // This layer configuration isn't supported by CpuAcc, should be fall back to CpuRef. |
| 488 | NormalizationDescriptor descriptor; |
| 489 | IConnectableLayer* normalize = net->AddNormalizationLayer(descriptor); |
| 490 | |
| 491 | IConnectableLayer* output = net->AddOutputLayer(0); |
| 492 | |
| 493 | input->GetOutputSlot(0).Connect(normalize->GetInputSlot(0)); |
| 494 | normalize->GetOutputSlot(0).Connect(output->GetInputSlot(0)); |
| 495 | |
| 496 | input->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32)); |
| 497 | normalize->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32)); |
| 498 | |
| 499 | // Allow fallback to CpuRef. |
David Beck | f0b4845 | 2018-10-19 15:20:56 +0100 | [diff] [blame] | 500 | std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc, armnn::Compute::CpuRef }; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 501 | // optimize the network |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 502 | IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec()); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 503 | |
| 504 | // Load it into the runtime. It should succeed. |
| 505 | armnn::NetworkId netId; |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 506 | CHECK(runtime->LoadNetwork(netId, std::move(optNet)) == Status::Success); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 507 | } |
| 508 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 509 | TEST_CASE("IVGCVSW_1929_QuantizedSoftmaxIssue") |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 510 | { |
| 511 | // Test for issue reported by Chris Nix in https://jira.arm.com/browse/IVGCVSW-1929 |
| 512 | using namespace armnn; |
| 513 | |
| 514 | // Create runtime in which test will run |
| 515 | armnn::IRuntime::CreationOptions options; |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 516 | armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 517 | |
| 518 | // build up the structure of the network |
| 519 | INetworkPtr net(INetwork::Create()); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 520 | armnn::IConnectableLayer* input = net->AddInputLayer(0,"input"); |
| 521 | armnn::IConnectableLayer* softmax = net->AddSoftmaxLayer(armnn::SoftmaxDescriptor(), "softmax"); |
| 522 | armnn::IConnectableLayer* output = net->AddOutputLayer(0, "output"); |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 523 | |
| 524 | input->GetOutputSlot(0).Connect(softmax->GetInputSlot(0)); |
| 525 | softmax->GetOutputSlot(0).Connect(output->GetInputSlot(0)); |
| 526 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 527 | input->GetOutputSlot(0).SetTensorInfo(armnn::TensorInfo(armnn::TensorShape({ 1, 5 }), |
| 528 | armnn::DataType::QAsymmU8, |
| 529 | 1.0f / 255, |
| 530 | 0)); |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 531 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 532 | softmax->GetOutputSlot(0).SetTensorInfo(armnn::TensorInfo(armnn::TensorShape({ 1, 5 }), |
| 533 | armnn::DataType::QAsymmU8)); |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 534 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 535 | std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; |
| 536 | std::vector<std::string> errMessages; |
Mike Kelly | 3a613cc | 2020-09-29 20:50:35 +0100 | [diff] [blame] | 537 | |
| 538 | try |
| 539 | { |
| 540 | armnn::IOptimizedNetworkPtr optNet = Optimize(*net, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 541 | backends, |
| 542 | runtime->GetDeviceSpec(), |
| 543 | OptimizerOptions(), |
| 544 | errMessages); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 545 | FAIL("An exception should have been thrown"); |
Mike Kelly | 3a613cc | 2020-09-29 20:50:35 +0100 | [diff] [blame] | 546 | } |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 547 | catch (const armnn::InvalidArgumentException&) |
Mike Kelly | 3a613cc | 2020-09-29 20:50:35 +0100 | [diff] [blame] | 548 | { |
| 549 | // Different exceptions are thrown on different backends |
| 550 | } |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 551 | CHECK(errMessages.size() > 0); |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 552 | } |
| 553 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 554 | TEST_CASE("RuntimeBackendOptions") |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 555 | { |
| 556 | using namespace armnn; |
| 557 | |
| 558 | IRuntime::CreationOptions creationOptions; |
| 559 | auto& backendOptions = creationOptions.m_BackendOptions; |
| 560 | |
| 561 | |
| 562 | // Define Options on explicit construction |
| 563 | BackendOptions options1("FakeBackend1", |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 564 | { |
| 565 | { "Option1", 1.3f }, |
| 566 | { "Option2", true } |
| 567 | }); |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 568 | |
| 569 | // Add an option after construction |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 570 | options1.AddOption({ "Option3", "some_value" }); |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 571 | |
| 572 | // Add the options to CreationOptions struct |
| 573 | backendOptions.push_back(options1); |
| 574 | |
| 575 | // Add more Options via inplace explicit construction |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 576 | backendOptions.emplace_back(BackendOptions{ "FakeBackend1", |
| 577 | {{ "Option4", 42 }} |
| 578 | }); |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 579 | |
| 580 | |
| 581 | // First group |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 582 | CHECK(backendOptions[0].GetBackendId().Get() == "FakeBackend1"); |
| 583 | CHECK(backendOptions[0].GetOption(0).GetName() == "Option1"); |
| 584 | CHECK(backendOptions[0].GetOption(0).GetValue().IsFloat() == true); |
| 585 | CHECK(backendOptions[0].GetOption(0).GetValue().AsFloat() == 1.3f); |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 586 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 587 | CHECK(backendOptions[0].GetOption(1).GetName() == "Option2"); |
| 588 | CHECK(backendOptions[0].GetOption(1).GetValue().IsBool() == true); |
| 589 | CHECK(backendOptions[0].GetOption(1).GetValue().AsBool() == true); |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 590 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 591 | CHECK(backendOptions[0].GetOption(2).GetName() == "Option3"); |
| 592 | CHECK(backendOptions[0].GetOption(2).GetValue().IsString() == true); |
| 593 | CHECK(backendOptions[0].GetOption(2).GetValue().AsString() == "some_value"); |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 594 | |
| 595 | // Second group |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 596 | CHECK(backendOptions[1].GetBackendId().Get() == "FakeBackend1"); |
| 597 | CHECK(backendOptions[1].GetOption(0).GetName() == "Option4"); |
| 598 | CHECK(backendOptions[1].GetOption(0).GetValue().IsInt() == true); |
| 599 | CHECK(backendOptions[1].GetOption(0).GetValue().AsInt() == 42); |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 600 | } |
| 601 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 602 | TEST_CASE("ProfilingDisable") |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 603 | { |
| 604 | using namespace armnn; |
| 605 | |
Jim Flynn | 6c9f17d | 2022-03-10 23:13:01 +0000 | [diff] [blame] | 606 | LogLevelSwapper logLevelSwapper(arm::pipe::LogSeverity::Fatal); |
| 607 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 608 | // Create runtime in which the test will run |
| 609 | armnn::IRuntime::CreationOptions options; |
Kevin May | d92a6e4 | 2021-02-04 10:27:41 +0000 | [diff] [blame] | 610 | armnn::RuntimeImpl runtime(options); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 611 | |
| 612 | // build up the structure of the network |
| 613 | INetworkPtr net(INetwork::Create()); |
| 614 | |
| 615 | IConnectableLayer* input = net->AddInputLayer(0); |
| 616 | |
| 617 | // This layer configuration isn't supported by CpuAcc, should fall back to CpuRef. |
| 618 | NormalizationDescriptor descriptor; |
| 619 | IConnectableLayer* normalize = net->AddNormalizationLayer(descriptor); |
| 620 | |
| 621 | IConnectableLayer* output = net->AddOutputLayer(0); |
| 622 | |
| 623 | input->GetOutputSlot(0).Connect(normalize->GetInputSlot(0)); |
| 624 | normalize->GetOutputSlot(0).Connect(output->GetInputSlot(0)); |
| 625 | |
| 626 | input->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32)); |
| 627 | normalize->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32)); |
| 628 | |
| 629 | // optimize the network |
| 630 | std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 631 | IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime.GetDeviceSpec()); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 632 | |
| 633 | // Load it into the runtime. It should succeed. |
| 634 | armnn::NetworkId netId; |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 635 | CHECK(runtime.LoadNetwork(netId, std::move(optNet)) == Status::Success); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 636 | |
Jim Flynn | 3443025 | 2022-03-04 15:03:58 +0000 | [diff] [blame] | 637 | armnn::ArmNNProfilingServiceInitialiser initialiser; |
| 638 | ProfilingServiceRuntimeHelper profilingServiceHelper( |
| 639 | arm::pipe::MAX_ARMNN_COUNTER, initialiser, GetProfilingService(&runtime)); |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 640 | BufferManager& bufferManager = profilingServiceHelper.GetProfilingBufferManager(); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 641 | auto readableBuffer = bufferManager.GetReadableBuffer(); |
| 642 | |
| 643 | // Profiling is not enabled, the post-optimisation structure should not be created |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 644 | CHECK(!readableBuffer); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 645 | } |
| 646 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 647 | TEST_CASE("ProfilingEnableCpuRef") |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 648 | { |
| 649 | using namespace armnn; |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 650 | using namespace arm::pipe; |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 651 | |
| 652 | // Create runtime in which the test will run |
| 653 | armnn::IRuntime::CreationOptions options; |
| 654 | options.m_ProfilingOptions.m_EnableProfiling = true; |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 655 | options.m_ProfilingOptions.m_TimelineEnabled = true; |
| 656 | |
Kevin May | d92a6e4 | 2021-02-04 10:27:41 +0000 | [diff] [blame] | 657 | armnn::RuntimeImpl runtime(options); |
Jim Flynn | 4c9ed1d | 2022-01-23 23:57:20 +0000 | [diff] [blame] | 658 | GetProfilingService(&runtime).ResetExternalProfilingOptions( |
| 659 | ConvertExternalProfilingOptions(options.m_ProfilingOptions), false); |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 660 | |
Jim Flynn | 3443025 | 2022-03-04 15:03:58 +0000 | [diff] [blame] | 661 | armnn::ArmNNProfilingServiceInitialiser initialiser; |
| 662 | ProfilingServiceRuntimeHelper profilingServiceHelper( |
| 663 | arm::pipe::MAX_ARMNN_COUNTER, initialiser, GetProfilingService(&runtime)); |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 664 | profilingServiceHelper.ForceTransitionToState(ProfilingState::NotConnected); |
| 665 | profilingServiceHelper.ForceTransitionToState(ProfilingState::WaitingForAck); |
| 666 | profilingServiceHelper.ForceTransitionToState(ProfilingState::Active); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 667 | |
| 668 | // build up the structure of the network |
| 669 | INetworkPtr net(INetwork::Create()); |
| 670 | |
| 671 | IConnectableLayer* input = net->AddInputLayer(0, "input"); |
| 672 | |
| 673 | NormalizationDescriptor descriptor; |
| 674 | IConnectableLayer* normalize = net->AddNormalizationLayer(descriptor, "normalization"); |
| 675 | |
| 676 | IConnectableLayer* output = net->AddOutputLayer(0, "output"); |
| 677 | |
| 678 | input->GetOutputSlot(0).Connect(normalize->GetInputSlot(0)); |
| 679 | normalize->GetOutputSlot(0).Connect(output->GetInputSlot(0)); |
| 680 | |
| 681 | input->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32)); |
| 682 | normalize->GetOutputSlot(0).SetTensorInfo(TensorInfo({ 1, 1, 4, 4 }, DataType::Float32)); |
| 683 | |
| 684 | // optimize the network |
| 685 | std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 686 | IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime.GetDeviceSpec()); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 687 | |
| 688 | ProfilingGuid optNetGuid = optNet->GetGuid(); |
| 689 | |
| 690 | // Load it into the runtime. It should succeed. |
| 691 | armnn::NetworkId netId; |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 692 | CHECK(runtime.LoadNetwork(netId, std::move(optNet)) == Status::Success); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 693 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 694 | BufferManager& bufferManager = profilingServiceHelper.GetProfilingBufferManager(); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 695 | auto readableBuffer = bufferManager.GetReadableBuffer(); |
| 696 | |
| 697 | // Profiling is enabled, the post-optimisation structure should be created |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 698 | CHECK(readableBuffer != nullptr); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 699 | |
| 700 | unsigned int size = readableBuffer->GetSize(); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 701 | |
| 702 | const unsigned char* readableData = readableBuffer->GetReadableData(); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 703 | CHECK(readableData != nullptr); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 704 | |
| 705 | unsigned int offset = 0; |
| 706 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 707 | // Verify Header |
Jim Flynn | f771321 | 2020-07-14 09:50:59 +0100 | [diff] [blame] | 708 | VerifyTimelineHeaderBinary(readableData, offset, size - 8); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 709 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 710 | // Post-optimisation network |
| 711 | // Network entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 712 | VerifyTimelineEntityBinaryPacketData(optNetGuid, readableData, offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 713 | |
| 714 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 715 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 716 | arm::pipe::EmptyOptional(), |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 717 | optNetGuid, |
| 718 | LabelsAndEventClasses::NETWORK_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 719 | LabelsAndEventClasses::TYPE_GUID, |
| 720 | readableData, |
| 721 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 722 | |
Jim Flynn | f771321 | 2020-07-14 09:50:59 +0100 | [diff] [blame] | 723 | // Network - START OF LIFE |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 724 | ProfilingGuid networkSolEventGuid = VerifyTimelineEventBinaryPacket(arm::pipe::EmptyOptional(), |
| 725 | arm::pipe::EmptyOptional(), |
| 726 | arm::pipe::EmptyOptional(), |
Jim Flynn | f771321 | 2020-07-14 09:50:59 +0100 | [diff] [blame] | 727 | readableData, |
| 728 | offset); |
Jim Flynn | f771321 | 2020-07-14 09:50:59 +0100 | [diff] [blame] | 729 | |
| 730 | // Network - START OF LIFE event relationship |
| 731 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 732 | arm::pipe::EmptyOptional(), |
Jim Flynn | f771321 | 2020-07-14 09:50:59 +0100 | [diff] [blame] | 733 | optNetGuid, |
| 734 | networkSolEventGuid, |
| 735 | LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, |
| 736 | readableData, |
| 737 | offset); |
Jim Flynn | f771321 | 2020-07-14 09:50:59 +0100 | [diff] [blame] | 738 | |
| 739 | // Process ID Label |
Jim Flynn | 9c85b41 | 2022-03-16 00:27:43 +0000 | [diff] [blame] | 740 | int processID = arm::pipe::GetCurrentProcessId(); |
Jim Flynn | f771321 | 2020-07-14 09:50:59 +0100 | [diff] [blame] | 741 | std::stringstream ss; |
| 742 | ss << processID; |
| 743 | std::string processIdLabel = ss.str(); |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 744 | VerifyTimelineLabelBinaryPacketData(arm::pipe::EmptyOptional(), processIdLabel, readableData, offset); |
Jim Flynn | f771321 | 2020-07-14 09:50:59 +0100 | [diff] [blame] | 745 | |
| 746 | // Entity - Process ID relationship |
| 747 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 748 | arm::pipe::EmptyOptional(), |
Jim Flynn | f771321 | 2020-07-14 09:50:59 +0100 | [diff] [blame] | 749 | optNetGuid, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 750 | arm::pipe::EmptyOptional(), |
Jim Flynn | f771321 | 2020-07-14 09:50:59 +0100 | [diff] [blame] | 751 | LabelsAndEventClasses::PROCESS_ID_GUID, |
| 752 | readableData, |
| 753 | offset); |
Jim Flynn | f771321 | 2020-07-14 09:50:59 +0100 | [diff] [blame] | 754 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 755 | // Input layer |
| 756 | // Input layer entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 757 | VerifyTimelineEntityBinaryPacketData(input->GetGuid(), readableData, offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 758 | |
| 759 | // Name Entity |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 760 | ProfilingGuid inputLabelGuid = VerifyTimelineLabelBinaryPacketData( |
| 761 | arm::pipe::EmptyOptional(), "input", readableData, offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 762 | |
| 763 | // Entity - Name relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 764 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 765 | arm::pipe::EmptyOptional(), |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 766 | input->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 767 | inputLabelGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 768 | LabelsAndEventClasses::NAME_GUID, |
| 769 | readableData, |
| 770 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 771 | |
| 772 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 773 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 774 | arm::pipe::EmptyOptional(), |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 775 | input->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 776 | LabelsAndEventClasses::LAYER_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 777 | LabelsAndEventClasses::TYPE_GUID, |
| 778 | readableData, |
| 779 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 780 | |
| 781 | // Network - Input layer relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 782 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 783 | arm::pipe::EmptyOptional(), |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 784 | optNetGuid, |
| 785 | input->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 786 | LabelsAndEventClasses::CHILD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 787 | readableData, |
| 788 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 789 | |
| 790 | // Normalization layer |
| 791 | // Normalization layer entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 792 | VerifyTimelineEntityBinaryPacketData(normalize->GetGuid(), readableData, offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 793 | |
| 794 | // Name entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 795 | ProfilingGuid normalizationLayerNameGuid = VerifyTimelineLabelBinaryPacketData( |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 796 | arm::pipe::EmptyOptional(), "normalization", readableData, offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 797 | |
| 798 | // Entity - Name relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 799 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 800 | arm::pipe::EmptyOptional(), |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 801 | normalize->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 802 | normalizationLayerNameGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 803 | LabelsAndEventClasses::NAME_GUID, |
| 804 | readableData, |
| 805 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 806 | |
| 807 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 808 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 809 | arm::pipe::EmptyOptional(), |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 810 | normalize->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 811 | LabelsAndEventClasses::LAYER_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 812 | LabelsAndEventClasses::TYPE_GUID, |
| 813 | readableData, |
| 814 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 815 | |
| 816 | // Network - Normalize layer relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 817 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 818 | arm::pipe::EmptyOptional(), |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 819 | optNetGuid, |
| 820 | normalize->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 821 | LabelsAndEventClasses::CHILD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 822 | readableData, |
| 823 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 824 | |
| 825 | // Input layer - Normalize layer relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 826 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 827 | arm::pipe::EmptyOptional(), |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 828 | input->GetGuid(), |
| 829 | normalize->GetGuid(), |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 830 | LabelsAndEventClasses::CONNECTION_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 831 | readableData, |
| 832 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 833 | |
| 834 | // Normalization workload |
| 835 | // Normalization workload entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 836 | ProfilingGuid normalizationWorkloadGuid = VerifyTimelineEntityBinaryPacketData( |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 837 | arm::pipe::EmptyOptional(), readableData, offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 838 | |
| 839 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 840 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 841 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 842 | normalizationWorkloadGuid, |
| 843 | LabelsAndEventClasses::WORKLOAD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 844 | LabelsAndEventClasses::TYPE_GUID, |
| 845 | readableData, |
| 846 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 847 | |
| 848 | // BackendId entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 849 | ProfilingGuid cpuRefLabelGuid = VerifyTimelineLabelBinaryPacketData( |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 850 | arm::pipe::EmptyOptional(), "CpuRef", readableData, offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 851 | |
| 852 | // Entity - BackendId relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 853 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 854 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 855 | normalizationWorkloadGuid, |
| 856 | cpuRefLabelGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 857 | LabelsAndEventClasses::BACKENDID_GUID, |
| 858 | readableData, |
| 859 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 860 | |
| 861 | // Normalize layer - Normalize workload relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 862 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 863 | arm::pipe::EmptyOptional(), |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 864 | normalize->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 865 | normalizationWorkloadGuid, |
| 866 | LabelsAndEventClasses::CHILD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 867 | readableData, |
| 868 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 869 | |
| 870 | // Output layer |
| 871 | // Output layer entity |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 872 | VerifyTimelineEntityBinaryPacketData(output->GetGuid(), readableData, offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 873 | |
| 874 | // Name entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 875 | ProfilingGuid outputLabelGuid = VerifyTimelineLabelBinaryPacketData( |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 876 | arm::pipe::EmptyOptional(), "output", readableData, offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 877 | |
| 878 | // Entity - Name relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 879 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 880 | arm::pipe::EmptyOptional(), |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 881 | output->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 882 | outputLabelGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 883 | LabelsAndEventClasses::NAME_GUID, |
| 884 | readableData, |
| 885 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 886 | |
| 887 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 888 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 889 | arm::pipe::EmptyOptional(), |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 890 | output->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 891 | LabelsAndEventClasses::LAYER_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 892 | LabelsAndEventClasses::TYPE_GUID, |
| 893 | readableData, |
| 894 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 895 | |
| 896 | // Network - Output layer relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 897 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 898 | arm::pipe::EmptyOptional(), |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 899 | optNetGuid, |
| 900 | output->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 901 | LabelsAndEventClasses::CHILD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 902 | readableData, |
| 903 | offset); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 904 | |
| 905 | // Normalize layer - Output layer relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 906 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 907 | arm::pipe::EmptyOptional(), |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 908 | normalize->GetGuid(), |
| 909 | output->GetGuid(), |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 910 | LabelsAndEventClasses::CONNECTION_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 911 | readableData, |
| 912 | offset); |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 913 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 914 | bufferManager.MarkRead(readableBuffer); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 915 | |
| 916 | // Creates structures for input & output. |
| 917 | std::vector<float> inputData(16); |
| 918 | std::vector<float> outputData(16); |
| 919 | |
Cathal Corbett | 5b8093c | 2021-10-22 11:12:07 +0100 | [diff] [blame] | 920 | TensorInfo inputTensorInfo = runtime.GetInputTensorInfo(netId, 0); |
| 921 | inputTensorInfo.SetConstant(true); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 922 | InputTensors inputTensors |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 923 | { |
Cathal Corbett | 5b8093c | 2021-10-22 11:12:07 +0100 | [diff] [blame] | 924 | {0, ConstTensor(inputTensorInfo, inputData.data())} |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 925 | }; |
| 926 | OutputTensors outputTensors |
| 927 | { |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 928 | {0, Tensor(runtime.GetOutputTensorInfo(netId, 0), outputData.data())} |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 929 | }; |
| 930 | |
| 931 | // Does the inference. |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 932 | runtime.EnqueueWorkload(netId, inputTensors, outputTensors); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 933 | |
Finn Williams | b6a402f | 2020-03-24 13:46:22 +0000 | [diff] [blame] | 934 | // Get readable buffer for input workload |
| 935 | auto inputReadableBuffer = bufferManager.GetReadableBuffer(); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 936 | CHECK(inputReadableBuffer != nullptr); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 937 | |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 938 | // Get readable buffer for output workload |
| 939 | auto outputReadableBuffer = bufferManager.GetReadableBuffer(); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 940 | CHECK(outputReadableBuffer != nullptr); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 941 | |
Finn Williams | b6a402f | 2020-03-24 13:46:22 +0000 | [diff] [blame] | 942 | // Get readable buffer for inference timeline |
| 943 | auto inferenceReadableBuffer = bufferManager.GetReadableBuffer(); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 944 | CHECK(inferenceReadableBuffer != nullptr); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 945 | |
| 946 | // Validate input workload data |
| 947 | size = inputReadableBuffer->GetSize(); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 948 | CHECK(size == 164); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 949 | |
| 950 | readableData = inputReadableBuffer->GetReadableData(); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 951 | CHECK(readableData != nullptr); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 952 | |
| 953 | offset = 0; |
| 954 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 955 | // Verify Header |
Finn Williams | 0a336dc | 2020-05-11 15:39:58 +0100 | [diff] [blame] | 956 | VerifyTimelineHeaderBinary(readableData, offset, 156); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 957 | |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 958 | // Input workload |
| 959 | // Input workload entity |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 960 | ProfilingGuid inputWorkloadGuid = VerifyTimelineEntityBinaryPacketData( |
| 961 | arm::pipe::EmptyOptional(), readableData, offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 962 | |
| 963 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 964 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 965 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 966 | inputWorkloadGuid, |
| 967 | LabelsAndEventClasses::WORKLOAD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 968 | LabelsAndEventClasses::TYPE_GUID, |
| 969 | readableData, |
| 970 | offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 971 | |
| 972 | // BackendId entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 973 | ProfilingGuid CpuRefLabelGuid = VerifyTimelineLabelBinaryPacketData( |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 974 | arm::pipe::EmptyOptional(), "CpuRef", readableData, offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 975 | |
| 976 | // Entity - BackendId relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 977 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 978 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 979 | inputWorkloadGuid, |
| 980 | CpuRefLabelGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 981 | LabelsAndEventClasses::BACKENDID_GUID, |
| 982 | readableData, |
| 983 | offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 984 | |
| 985 | // Input layer - Input workload relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 986 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 987 | arm::pipe::EmptyOptional(), |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 988 | input->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 989 | inputWorkloadGuid, |
| 990 | LabelsAndEventClasses::CHILD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 991 | readableData, |
| 992 | offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 993 | |
| 994 | bufferManager.MarkRead(inputReadableBuffer); |
| 995 | |
| 996 | // Validate output workload data |
| 997 | size = outputReadableBuffer->GetSize(); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 998 | CHECK(size == 164); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 999 | |
| 1000 | readableData = outputReadableBuffer->GetReadableData(); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1001 | CHECK(readableData != nullptr); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 1002 | |
| 1003 | offset = 0; |
| 1004 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1005 | // Verify Header |
Finn Williams | 0a336dc | 2020-05-11 15:39:58 +0100 | [diff] [blame] | 1006 | VerifyTimelineHeaderBinary(readableData, offset, 156); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1007 | |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 1008 | // Output workload |
| 1009 | // Output workload entity |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1010 | ProfilingGuid outputWorkloadGuid = VerifyTimelineEntityBinaryPacketData( |
| 1011 | arm::pipe::EmptyOptional(), readableData, offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 1012 | |
| 1013 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1014 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1015 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1016 | outputWorkloadGuid, |
| 1017 | LabelsAndEventClasses::WORKLOAD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1018 | LabelsAndEventClasses::TYPE_GUID, |
| 1019 | readableData, |
| 1020 | offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 1021 | |
| 1022 | // BackendId entity |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1023 | VerifyTimelineLabelBinaryPacketData(arm::pipe::EmptyOptional(), "CpuRef", readableData, offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 1024 | |
| 1025 | // Entity - BackendId relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1026 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1027 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1028 | outputWorkloadGuid, |
| 1029 | CpuRefLabelGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1030 | LabelsAndEventClasses::BACKENDID_GUID, |
| 1031 | readableData, |
| 1032 | offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 1033 | |
| 1034 | // Output layer - Output workload relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1035 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1036 | arm::pipe::EmptyOptional(), |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1037 | output->GetGuid(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1038 | outputWorkloadGuid, |
| 1039 | LabelsAndEventClasses::CHILD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1040 | readableData, |
| 1041 | offset); |
Narumol Prangnawarat | aa68e01 | 2019-11-29 17:17:43 +0000 | [diff] [blame] | 1042 | |
| 1043 | bufferManager.MarkRead(outputReadableBuffer); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1044 | |
| 1045 | // Validate inference data |
| 1046 | size = inferenceReadableBuffer->GetSize(); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1047 | CHECK(size == 976 + 8 * ThreadIdSize); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1048 | |
| 1049 | readableData = inferenceReadableBuffer->GetReadableData(); |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1050 | CHECK(readableData != nullptr); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1051 | |
| 1052 | offset = 0; |
| 1053 | |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1054 | // Verify Header |
Finn Williams | 0a336dc | 2020-05-11 15:39:58 +0100 | [diff] [blame] | 1055 | VerifyTimelineHeaderBinary(readableData, offset, 968 + 8 * ThreadIdSize); |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1056 | |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1057 | // Inference timeline trace |
| 1058 | // Inference entity |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1059 | ProfilingGuid inferenceGuid = VerifyTimelineEntityBinaryPacketData( |
| 1060 | arm::pipe::EmptyOptional(), readableData, offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1061 | |
| 1062 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1063 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1064 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1065 | inferenceGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1066 | LabelsAndEventClasses::INFERENCE_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1067 | LabelsAndEventClasses::TYPE_GUID, |
| 1068 | readableData, |
| 1069 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1070 | |
| 1071 | // Network - Inference relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1072 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1073 | arm::pipe::EmptyOptional(), |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1074 | optNetGuid, |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1075 | inferenceGuid, |
| 1076 | LabelsAndEventClasses::EXECUTION_OF_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1077 | readableData, |
| 1078 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1079 | |
| 1080 | // Start Inference life |
| 1081 | // Event packet - timeline, threadId, eventGuid |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1082 | ProfilingGuid inferenceEventGuid = VerifyTimelineEventBinaryPacket( |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1083 | arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1084 | |
| 1085 | // Inference - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1086 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1087 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1088 | inferenceGuid, |
| 1089 | inferenceEventGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1090 | LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, |
| 1091 | readableData, |
| 1092 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1093 | |
| 1094 | // Execution |
| 1095 | // Input workload execution |
| 1096 | // Input workload execution entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1097 | ProfilingGuid inputWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData( |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1098 | arm::pipe::EmptyOptional(), readableData, offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1099 | |
| 1100 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1101 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1102 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1103 | inputWorkloadExecutionGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1104 | LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1105 | LabelsAndEventClasses::TYPE_GUID, |
| 1106 | readableData, |
| 1107 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1108 | |
| 1109 | // Inference - Workload execution relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1110 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1111 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1112 | inferenceGuid, |
| 1113 | inputWorkloadExecutionGuid, |
| 1114 | LabelsAndEventClasses::CHILD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1115 | readableData, |
| 1116 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1117 | |
| 1118 | // Workload - Workload execution relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1119 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1120 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1121 | inputWorkloadGuid, |
| 1122 | inputWorkloadExecutionGuid, |
| 1123 | LabelsAndEventClasses::EXECUTION_OF_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1124 | readableData, |
| 1125 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1126 | |
| 1127 | // Start Input workload execution life |
| 1128 | // Event packet - timeline, threadId, eventGuid |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1129 | ProfilingGuid inputWorkloadExecutionSOLEventId = VerifyTimelineEventBinaryPacket( |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1130 | arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1131 | |
| 1132 | // Input workload execution - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1133 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1134 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1135 | inputWorkloadExecutionGuid, |
| 1136 | inputWorkloadExecutionSOLEventId, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1137 | LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, |
| 1138 | readableData, |
| 1139 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1140 | |
| 1141 | // End of Input workload execution life |
| 1142 | // Event packet - timeline, threadId, eventGuid |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1143 | ProfilingGuid inputWorkloadExecutionEOLEventId = VerifyTimelineEventBinaryPacket( |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1144 | arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1145 | |
| 1146 | // Input workload execution - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1147 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1148 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1149 | inputWorkloadExecutionGuid, |
| 1150 | inputWorkloadExecutionEOLEventId, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1151 | LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, |
| 1152 | readableData, |
| 1153 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1154 | |
| 1155 | // Normalize workload execution |
| 1156 | // Normalize workload execution entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1157 | ProfilingGuid normalizeWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData( |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1158 | arm::pipe::EmptyOptional(), readableData, offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1159 | |
| 1160 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1161 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1162 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1163 | normalizeWorkloadExecutionGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1164 | LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1165 | LabelsAndEventClasses::TYPE_GUID, |
| 1166 | readableData, |
| 1167 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1168 | |
| 1169 | // Inference - Workload execution relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1170 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1171 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1172 | inferenceGuid, |
| 1173 | normalizeWorkloadExecutionGuid, |
| 1174 | LabelsAndEventClasses::CHILD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1175 | readableData, |
| 1176 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1177 | |
| 1178 | // Workload - Workload execution relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1179 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1180 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1181 | normalizationWorkloadGuid, |
| 1182 | normalizeWorkloadExecutionGuid, |
| 1183 | LabelsAndEventClasses::EXECUTION_OF_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1184 | readableData, |
| 1185 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1186 | |
| 1187 | // Start Normalize workload execution life |
| 1188 | // Event packet - timeline, threadId, eventGuid |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1189 | ProfilingGuid normalizationWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket( |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1190 | arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1191 | |
| 1192 | // Normalize workload execution - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1193 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1194 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1195 | normalizeWorkloadExecutionGuid, |
| 1196 | normalizationWorkloadExecutionSOLEventGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1197 | LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, |
| 1198 | readableData, |
| 1199 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1200 | |
| 1201 | // End of Normalize workload execution life |
| 1202 | // Event packet - timeline, threadId, eventGuid |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1203 | ProfilingGuid normalizationWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket( |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1204 | arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1205 | |
| 1206 | // Normalize workload execution - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1207 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1208 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1209 | normalizeWorkloadExecutionGuid, |
| 1210 | normalizationWorkloadExecutionEOLEventGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1211 | LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, |
| 1212 | readableData, |
| 1213 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1214 | |
| 1215 | // Output workload execution |
| 1216 | // Output workload execution entity |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1217 | ProfilingGuid outputWorkloadExecutionGuid = VerifyTimelineEntityBinaryPacketData( |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1218 | arm::pipe::EmptyOptional(), readableData, offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1219 | |
| 1220 | // Entity - Type relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1221 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1222 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1223 | outputWorkloadExecutionGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1224 | LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1225 | LabelsAndEventClasses::TYPE_GUID, |
| 1226 | readableData, |
| 1227 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1228 | |
| 1229 | // Inference - Workload execution relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1230 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1231 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1232 | inferenceGuid, |
| 1233 | outputWorkloadExecutionGuid, |
| 1234 | LabelsAndEventClasses::CHILD_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1235 | readableData, |
| 1236 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1237 | |
| 1238 | // Workload - Workload execution relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1239 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1240 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1241 | outputWorkloadGuid, |
| 1242 | outputWorkloadExecutionGuid, |
| 1243 | LabelsAndEventClasses::EXECUTION_OF_GUID, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1244 | readableData, |
| 1245 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1246 | |
| 1247 | // Start Output workload execution life |
| 1248 | // Event packet - timeline, threadId, eventGuid |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1249 | ProfilingGuid outputWorkloadExecutionSOLEventGuid = VerifyTimelineEventBinaryPacket( |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1250 | arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1251 | |
| 1252 | // Output workload execution - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1253 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1254 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1255 | outputWorkloadExecutionGuid, |
| 1256 | outputWorkloadExecutionSOLEventGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1257 | LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, |
| 1258 | readableData, |
| 1259 | offset); |
Finn Williams | 0a336dc | 2020-05-11 15:39:58 +0100 | [diff] [blame] | 1260 | |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1261 | // End of Normalize workload execution life |
| 1262 | // Event packet - timeline, threadId, eventGuid |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1263 | ProfilingGuid outputWorkloadExecutionEOLEventGuid = VerifyTimelineEventBinaryPacket( |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1264 | arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1265 | |
| 1266 | // Output workload execution - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1267 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1268 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1269 | outputWorkloadExecutionGuid, |
| 1270 | outputWorkloadExecutionEOLEventGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1271 | LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, |
| 1272 | readableData, |
| 1273 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1274 | |
| 1275 | // End of Inference life |
| 1276 | // Event packet - timeline, threadId, eventGuid |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1277 | ProfilingGuid inferenceEOLEventGuid = VerifyTimelineEventBinaryPacket( |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1278 | arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1279 | |
| 1280 | // Inference - event relationship |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1281 | VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 1282 | arm::pipe::EmptyOptional(), |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 1283 | inferenceGuid, |
| 1284 | inferenceEOLEventGuid, |
Keith Davis | 97da5e2 | 2020-03-05 16:25:28 +0000 | [diff] [blame] | 1285 | LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, |
| 1286 | readableData, |
| 1287 | offset); |
David Monahan | 6198fe0 | 2019-12-02 08:35:43 +0000 | [diff] [blame] | 1288 | |
| 1289 | bufferManager.MarkRead(inferenceReadableBuffer); |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 1290 | } |
| 1291 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1292 | TEST_CASE("ProfilingPostOptimisationStructureCpuRef") |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 1293 | { |
| 1294 | VerifyPostOptimisationStructureTestImpl(armnn::Compute::CpuRef); |
| 1295 | } |
| 1296 | |
Colm Donelan | 03bf98a | 2022-05-30 15:20:36 +0100 | [diff] [blame^] | 1297 | TEST_CASE("RuntimeOptimizeImportOff_LoadNetworkImportOn") |
| 1298 | { |
| 1299 | // In this test case we'll optimize a network with both import and export disabled. Then we'll attempt to load |
| 1300 | // that network but specify that the import memory source is Malloc. |
| 1301 | |
| 1302 | armnn::IRuntime::CreationOptions options; |
| 1303 | armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); |
| 1304 | armnn::NetworkId networkId = 1; |
| 1305 | armnn::INetworkPtr testNetwork(armnn::INetwork::Create()); |
| 1306 | |
| 1307 | auto inputLayer1 = testNetwork->AddInputLayer(0, "input 1 layer"); |
| 1308 | auto inputLayer2 = testNetwork->AddInputLayer(1, "input 2 layer"); |
| 1309 | auto addLayer = testNetwork->AddAdditionLayer("add layer"); |
| 1310 | auto outputLayer = testNetwork->AddOutputLayer(2, "output layer"); |
| 1311 | |
| 1312 | TensorInfo tensorInfo{{4}, armnn::DataType::Signed32}; |
| 1313 | |
| 1314 | inputLayer1->GetOutputSlot(0).Connect(addLayer->GetInputSlot(0)); |
| 1315 | inputLayer1->GetOutputSlot(0).SetTensorInfo(tensorInfo); |
| 1316 | |
| 1317 | inputLayer2->GetOutputSlot(0).Connect(addLayer->GetInputSlot(1)); |
| 1318 | inputLayer2->GetOutputSlot(0).SetTensorInfo(tensorInfo); |
| 1319 | |
| 1320 | addLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0)); |
| 1321 | addLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo); |
| 1322 | |
| 1323 | std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef}; |
| 1324 | |
| 1325 | OptimizerOptions optimizedOptions; |
| 1326 | // Hard set import and export to off. |
| 1327 | optimizedOptions.m_ImportEnabled = false; |
| 1328 | optimizedOptions.m_ExportEnabled = false; |
| 1329 | IOptimizedNetworkPtr optNet = Optimize(*testNetwork, backends, runtime->GetDeviceSpec(), optimizedOptions); |
| 1330 | CHECK(optNet); |
| 1331 | |
| 1332 | std::string er; |
| 1333 | // Load the network passing an import memory source. |
| 1334 | armnn::INetworkProperties networkProperties1(true, MemorySource::Malloc, MemorySource::Undefined); |
| 1335 | // There should be an InvalidArgumentException. |
| 1336 | runtime->LoadNetwork(networkId, std::move(optNet), er, networkProperties1); |
| 1337 | CHECK(er.find("However, it was disabled when this network was optimized") != -1); |
| 1338 | } |
| 1339 | |
| 1340 | TEST_CASE("RuntimeOptimizeExportOff_LoadNetworkExportOn") |
| 1341 | { |
| 1342 | // In this test case we'll optimize a network with both import and export disabled. Then we'll attempt to load |
| 1343 | // that network but specify that the export memory source as Malloc. |
| 1344 | |
| 1345 | armnn::IRuntime::CreationOptions options; |
| 1346 | armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); |
| 1347 | armnn::NetworkId networkId = 1; |
| 1348 | armnn::INetworkPtr testNetwork(armnn::INetwork::Create()); |
| 1349 | |
| 1350 | auto inputLayer1 = testNetwork->AddInputLayer(0, "input 1 layer"); |
| 1351 | auto inputLayer2 = testNetwork->AddInputLayer(1, "input 2 layer"); |
| 1352 | auto addLayer = testNetwork->AddAdditionLayer("add layer"); |
| 1353 | auto outputLayer = testNetwork->AddOutputLayer(2, "output layer"); |
| 1354 | |
| 1355 | TensorInfo tensorInfo{{4}, armnn::DataType::Signed32}; |
| 1356 | |
| 1357 | inputLayer1->GetOutputSlot(0).Connect(addLayer->GetInputSlot(0)); |
| 1358 | inputLayer1->GetOutputSlot(0).SetTensorInfo(tensorInfo); |
| 1359 | |
| 1360 | inputLayer2->GetOutputSlot(0).Connect(addLayer->GetInputSlot(1)); |
| 1361 | inputLayer2->GetOutputSlot(0).SetTensorInfo(tensorInfo); |
| 1362 | |
| 1363 | addLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0)); |
| 1364 | addLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo); |
| 1365 | |
| 1366 | std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef}; |
| 1367 | |
| 1368 | OptimizerOptions optimizedOptions; |
| 1369 | // Hard set import and export to off. |
| 1370 | optimizedOptions.m_ImportEnabled = false; |
| 1371 | optimizedOptions.m_ExportEnabled = false; |
| 1372 | IOptimizedNetworkPtr optNet = Optimize(*testNetwork, backends, runtime->GetDeviceSpec(), optimizedOptions); |
| 1373 | CHECK(optNet); |
| 1374 | |
| 1375 | std::string er; |
| 1376 | // Load the network passing an import memory source. |
| 1377 | armnn::INetworkProperties networkProperties1(true, MemorySource::Undefined, MemorySource::Malloc); |
| 1378 | // There should be an InvalidArgumentException. |
| 1379 | runtime->LoadNetwork(networkId, std::move(optNet), er, networkProperties1); |
| 1380 | CHECK(er.find("However, it was disabled when this network was optimized") != -1); |
| 1381 | } |
| 1382 | |
| 1383 | TEST_CASE("RuntimeOptimizeImportOn_LoadNetworkImportOff") |
| 1384 | { |
| 1385 | // In this test case we'll optimize a network with import enabled. Then we'll attempt to load |
| 1386 | // that network but specify that the import memory source is Undefined. |
| 1387 | |
| 1388 | armnn::IRuntime::CreationOptions options; |
| 1389 | armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); |
| 1390 | armnn::NetworkId networkId = 1; |
| 1391 | armnn::INetworkPtr testNetwork(armnn::INetwork::Create()); |
| 1392 | |
| 1393 | auto inputLayer1 = testNetwork->AddInputLayer(0, "input 1 layer"); |
| 1394 | auto inputLayer2 = testNetwork->AddInputLayer(1, "input 2 layer"); |
| 1395 | auto addLayer = testNetwork->AddAdditionLayer("add layer"); |
| 1396 | auto outputLayer = testNetwork->AddOutputLayer(2, "output layer"); |
| 1397 | |
| 1398 | TensorInfo tensorInfo{{4}, armnn::DataType::Signed32}; |
| 1399 | |
| 1400 | inputLayer1->GetOutputSlot(0).Connect(addLayer->GetInputSlot(0)); |
| 1401 | inputLayer1->GetOutputSlot(0).SetTensorInfo(tensorInfo); |
| 1402 | |
| 1403 | inputLayer2->GetOutputSlot(0).Connect(addLayer->GetInputSlot(1)); |
| 1404 | inputLayer2->GetOutputSlot(0).SetTensorInfo(tensorInfo); |
| 1405 | |
| 1406 | addLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0)); |
| 1407 | addLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo); |
| 1408 | |
| 1409 | std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef}; |
| 1410 | |
| 1411 | OptimizerOptions optimizedOptions; |
| 1412 | // Hard set import and export to off. |
| 1413 | optimizedOptions.m_ImportEnabled = true; |
| 1414 | optimizedOptions.m_ExportEnabled = false; |
| 1415 | IOptimizedNetworkPtr optNet = Optimize(*testNetwork, backends, runtime->GetDeviceSpec(), optimizedOptions); |
| 1416 | CHECK(optNet); |
| 1417 | |
| 1418 | std::string er; |
| 1419 | // Load the network passing an import memory source. |
| 1420 | armnn::INetworkProperties networkProperties1(true, MemorySource::Undefined, MemorySource::Undefined); |
| 1421 | // There should be an InvalidArgumentException. |
| 1422 | runtime->LoadNetwork(networkId, std::move(optNet), er, networkProperties1); |
| 1423 | CHECK(er.find("However, it was enabled when this network was optimized") != -1); |
| 1424 | } |
| 1425 | |
| 1426 | TEST_CASE("RuntimeOptimizeExportOn_LoadNetworkExportOff") |
| 1427 | { |
| 1428 | // In this test case we'll optimize a network with export enabled. Then we'll attempt to load |
| 1429 | // that network but specify that the export memory source is Undefined. |
| 1430 | |
| 1431 | armnn::IRuntime::CreationOptions options; |
| 1432 | armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); |
| 1433 | armnn::NetworkId networkId = 1; |
| 1434 | armnn::INetworkPtr testNetwork(armnn::INetwork::Create()); |
| 1435 | |
| 1436 | auto inputLayer1 = testNetwork->AddInputLayer(0, "input 1 layer"); |
| 1437 | auto inputLayer2 = testNetwork->AddInputLayer(1, "input 2 layer"); |
| 1438 | auto addLayer = testNetwork->AddAdditionLayer("add layer"); |
| 1439 | auto outputLayer = testNetwork->AddOutputLayer(2, "output layer"); |
| 1440 | |
| 1441 | TensorInfo tensorInfo{{4}, armnn::DataType::Signed32}; |
| 1442 | |
| 1443 | inputLayer1->GetOutputSlot(0).Connect(addLayer->GetInputSlot(0)); |
| 1444 | inputLayer1->GetOutputSlot(0).SetTensorInfo(tensorInfo); |
| 1445 | |
| 1446 | inputLayer2->GetOutputSlot(0).Connect(addLayer->GetInputSlot(1)); |
| 1447 | inputLayer2->GetOutputSlot(0).SetTensorInfo(tensorInfo); |
| 1448 | |
| 1449 | addLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0)); |
| 1450 | addLayer->GetOutputSlot(0).SetTensorInfo(tensorInfo); |
| 1451 | |
| 1452 | std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef}; |
| 1453 | |
| 1454 | OptimizerOptions optimizedOptions; |
| 1455 | // Hard set import and export to off. |
| 1456 | optimizedOptions.m_ImportEnabled = false; |
| 1457 | optimizedOptions.m_ExportEnabled = true; |
| 1458 | IOptimizedNetworkPtr optNet = Optimize(*testNetwork, backends, runtime->GetDeviceSpec(), optimizedOptions); |
| 1459 | CHECK(optNet); |
| 1460 | |
| 1461 | std::string er; |
| 1462 | // Load the network passing an import memory source. |
| 1463 | armnn::INetworkProperties networkProperties1(true, MemorySource::Undefined, MemorySource::Undefined); |
| 1464 | // There should be an InvalidArgumentException. |
| 1465 | runtime->LoadNetwork(networkId, std::move(optNet), er, networkProperties1); |
| 1466 | CHECK(er.find("However, it was enabled when this network was optimized") != -1); |
| 1467 | } |
| 1468 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 1469 | } |