telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
| 5 | #include "Runtime.hpp" |
| 6 | |
David Beck | 056be3c | 2018-10-22 13:16:00 +0100 | [diff] [blame] | 7 | #include <armnn/Version.hpp> |
Matteo Martincigh | c601aa6 | 2019-10-29 15:03:22 +0000 | [diff] [blame] | 8 | #include <armnn/BackendRegistry.hpp> |
Matthew Bentham | f48afc6 | 2020-01-15 17:55:08 +0000 | [diff] [blame] | 9 | #include <armnn/Logging.hpp> |
Matteo Martincigh | e54aa06 | 2019-08-05 14:12:11 +0100 | [diff] [blame] | 10 | |
Matteo Martincigh | e5b8eb9 | 2019-11-28 15:45:42 +0000 | [diff] [blame] | 11 | #include <armnn/backends/IBackendContext.hpp> |
Matteo Martincigh | e54aa06 | 2019-08-05 14:12:11 +0100 | [diff] [blame] | 12 | #include <backendsCommon/DynamicBackendUtils.hpp> |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 13 | #include <armnn/utility/PolymorphicDowncast.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 14 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 15 | #include <iostream> |
| 16 | |
Colm Donelan | 1aff393 | 2020-02-05 17:48:59 +0000 | [diff] [blame] | 17 | #include <backends/BackendProfiling.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 18 | |
| 19 | using namespace armnn; |
| 20 | using namespace std; |
| 21 | |
| 22 | namespace armnn |
| 23 | { |
| 24 | |
| 25 | IRuntime* IRuntime::CreateRaw(const CreationOptions& options) |
| 26 | { |
| 27 | return new Runtime(options); |
| 28 | } |
| 29 | |
| 30 | IRuntimePtr IRuntime::Create(const CreationOptions& options) |
| 31 | { |
| 32 | return IRuntimePtr(CreateRaw(options), &IRuntime::Destroy); |
| 33 | } |
| 34 | |
| 35 | void IRuntime::Destroy(IRuntime* runtime) |
| 36 | { |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 37 | delete PolymorphicDowncast<Runtime*>(runtime); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | int Runtime::GenerateNetworkId() |
| 41 | { |
| 42 | return m_NetworkIdCounter++; |
| 43 | } |
| 44 | |
| 45 | Status Runtime::LoadNetwork(NetworkId& networkIdOut, IOptimizedNetworkPtr inNetwork) |
| 46 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 47 | std::string ignoredErrorMessage; |
| 48 | return LoadNetwork(networkIdOut, std::move(inNetwork), ignoredErrorMessage); |
| 49 | } |
| 50 | |
| 51 | Status Runtime::LoadNetwork(NetworkId& networkIdOut, |
| 52 | IOptimizedNetworkPtr inNetwork, |
David Monahan | 4f1e8e4 | 2019-09-04 09:22:10 +0100 | [diff] [blame] | 53 | std::string& errorMessage) |
| 54 | { |
| 55 | INetworkProperties networkProperties; |
| 56 | return LoadNetwork(networkIdOut, std::move(inNetwork), errorMessage, networkProperties); |
| 57 | } |
| 58 | |
| 59 | Status Runtime::LoadNetwork(NetworkId& networkIdOut, |
| 60 | IOptimizedNetworkPtr inNetwork, |
| 61 | std::string& errorMessage, |
| 62 | const INetworkProperties& networkProperties) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 63 | { |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 64 | IOptimizedNetwork* rawNetwork = inNetwork.release(); |
David Beck | 1b61be5 | 2018-11-08 09:19:14 +0000 | [diff] [blame] | 65 | |
| 66 | networkIdOut = GenerateNetworkId(); |
| 67 | |
| 68 | for (auto&& context : m_BackendContexts) |
| 69 | { |
| 70 | context.second->BeforeLoadNetwork(networkIdOut); |
| 71 | } |
| 72 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 73 | unique_ptr<LoadedNetwork> loadedNetwork = LoadedNetwork::MakeLoadedNetwork( |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 74 | std::unique_ptr<OptimizedNetwork>(PolymorphicDowncast<OptimizedNetwork*>(rawNetwork)), |
David Monahan | 4f1e8e4 | 2019-09-04 09:22:10 +0100 | [diff] [blame] | 75 | errorMessage, |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 76 | networkProperties, |
| 77 | m_ProfilingService); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 78 | |
| 79 | if (!loadedNetwork) |
| 80 | { |
| 81 | return Status::Failure; |
| 82 | } |
| 83 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 84 | { |
| 85 | std::lock_guard<std::mutex> lockGuard(m_Mutex); |
| 86 | |
| 87 | // Stores the network |
| 88 | m_LoadedNetworks[networkIdOut] = std::move(loadedNetwork); |
| 89 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 90 | |
David Beck | 1b61be5 | 2018-11-08 09:19:14 +0000 | [diff] [blame] | 91 | for (auto&& context : m_BackendContexts) |
| 92 | { |
| 93 | context.second->AfterLoadNetwork(networkIdOut); |
| 94 | } |
| 95 | |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 96 | if (m_ProfilingService.IsProfilingEnabled()) |
Keith Davis | e394bd9 | 2019-12-02 15:12:19 +0000 | [diff] [blame] | 97 | { |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 98 | m_ProfilingService.IncrementCounterValue(armnn::profiling::NETWORK_LOADS); |
Keith Davis | e394bd9 | 2019-12-02 15:12:19 +0000 | [diff] [blame] | 99 | } |
| 100 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 101 | return Status::Success; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | Status Runtime::UnloadNetwork(NetworkId networkId) |
| 105 | { |
David Beck | 1b61be5 | 2018-11-08 09:19:14 +0000 | [diff] [blame] | 106 | bool unloadOk = true; |
| 107 | for (auto&& context : m_BackendContexts) |
David Beck | 9efb57d | 2018-11-05 13:40:33 +0000 | [diff] [blame] | 108 | { |
David Beck | 1b61be5 | 2018-11-08 09:19:14 +0000 | [diff] [blame] | 109 | unloadOk &= context.second->BeforeUnloadNetwork(networkId); |
David Beck | 9efb57d | 2018-11-05 13:40:33 +0000 | [diff] [blame] | 110 | } |
David Beck | 1b61be5 | 2018-11-08 09:19:14 +0000 | [diff] [blame] | 111 | |
| 112 | if (!unloadOk) |
| 113 | { |
Derek Lamberti | 0844697 | 2019-11-26 16:38:31 +0000 | [diff] [blame] | 114 | ARMNN_LOG(warning) << "Runtime::UnloadNetwork(): failed to unload " |
| 115 | "network with ID:" << networkId << " because BeforeUnloadNetwork failed"; |
David Beck | 1b61be5 | 2018-11-08 09:19:14 +0000 | [diff] [blame] | 116 | return Status::Failure; |
| 117 | } |
David Beck | 9efb57d | 2018-11-05 13:40:33 +0000 | [diff] [blame] | 118 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 119 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 120 | std::lock_guard<std::mutex> lockGuard(m_Mutex); |
| 121 | |
| 122 | if (m_LoadedNetworks.erase(networkId) == 0) |
| 123 | { |
Derek Lamberti | 0844697 | 2019-11-26 16:38:31 +0000 | [diff] [blame] | 124 | ARMNN_LOG(warning) << "WARNING: Runtime::UnloadNetwork(): " << networkId << " not found!"; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 125 | return Status::Failure; |
| 126 | } |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 127 | |
| 128 | if (m_ProfilingService.IsProfilingEnabled()) |
Keith Davis | e394bd9 | 2019-12-02 15:12:19 +0000 | [diff] [blame] | 129 | { |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 130 | m_ProfilingService.IncrementCounterValue(armnn::profiling::NETWORK_UNLOADS); |
Keith Davis | e394bd9 | 2019-12-02 15:12:19 +0000 | [diff] [blame] | 131 | } |
David Beck | 1b61be5 | 2018-11-08 09:19:14 +0000 | [diff] [blame] | 132 | } |
David Beck | 9efb57d | 2018-11-05 13:40:33 +0000 | [diff] [blame] | 133 | |
David Beck | 1b61be5 | 2018-11-08 09:19:14 +0000 | [diff] [blame] | 134 | for (auto&& context : m_BackendContexts) |
| 135 | { |
| 136 | context.second->AfterUnloadNetwork(networkId); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 137 | } |
| 138 | |
Derek Lamberti | 0844697 | 2019-11-26 16:38:31 +0000 | [diff] [blame] | 139 | ARMNN_LOG(debug) << "Runtime::UnloadNetwork(): Unloaded network with ID: " << networkId; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 140 | return Status::Success; |
| 141 | } |
| 142 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 143 | const std::shared_ptr<IProfiler> Runtime::GetProfiler(NetworkId networkId) const |
| 144 | { |
| 145 | auto it = m_LoadedNetworks.find(networkId); |
| 146 | if (it != m_LoadedNetworks.end()) |
| 147 | { |
| 148 | auto& loadedNetwork = it->second; |
| 149 | return loadedNetwork->GetProfiler(); |
| 150 | } |
| 151 | |
| 152 | return nullptr; |
| 153 | } |
| 154 | |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 155 | void Runtime::ReportStructure() // armnn::profiling::IProfilingService& profilingService as param |
| 156 | { |
| 157 | // No-op for the time being, but this may be useful in future to have the profilingService available |
| 158 | // if (profilingService.IsProfilingEnabled()){} |
| 159 | |
| 160 | LoadedNetworks::iterator it = m_LoadedNetworks.begin(); |
| 161 | while (it != m_LoadedNetworks.end()) |
| 162 | { |
| 163 | auto& loadedNetwork = it->second; |
| 164 | loadedNetwork->SendNetworkStructure(); |
| 165 | // Increment the Iterator to point to next entry |
| 166 | it++; |
| 167 | } |
| 168 | } |
| 169 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 170 | Runtime::Runtime(const CreationOptions& options) |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 171 | : m_NetworkIdCounter(0), |
| 172 | m_ProfilingService(*this) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 173 | { |
Derek Lamberti | 0844697 | 2019-11-26 16:38:31 +0000 | [diff] [blame] | 174 | ARMNN_LOG(info) << "ArmNN v" << ARMNN_VERSION << "\n"; |
David Beck | 1b61be5 | 2018-11-08 09:19:14 +0000 | [diff] [blame] | 175 | |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 176 | if ( options.m_ProfilingOptions.m_TimelineEnabled && !options.m_ProfilingOptions.m_EnableProfiling ) |
| 177 | { |
| 178 | throw RuntimeException("It is not possible to enable timeline reporting without profiling being enabled"); |
| 179 | } |
| 180 | |
Matteo Martincigh | e54aa06 | 2019-08-05 14:12:11 +0100 | [diff] [blame] | 181 | // Load any available/compatible dynamic backend before the runtime |
| 182 | // goes through the backend registry |
| 183 | LoadDynamicBackends(options.m_DynamicBackendsPath); |
| 184 | |
Matthew Bentham | 9a61fa6 | 2020-02-04 10:03:55 +0000 | [diff] [blame] | 185 | BackendIdSet supportedBackends; |
David Beck | 1b61be5 | 2018-11-08 09:19:14 +0000 | [diff] [blame] | 186 | for (const auto& id : BackendRegistryInstance().GetBackendIds()) |
| 187 | { |
| 188 | // Store backend contexts for the supported ones |
Matthew Bentham | 9a61fa6 | 2020-02-04 10:03:55 +0000 | [diff] [blame] | 189 | try { |
David Beck | 1b61be5 | 2018-11-08 09:19:14 +0000 | [diff] [blame] | 190 | auto factoryFun = BackendRegistryInstance().GetFactory(id); |
| 191 | auto backend = factoryFun(); |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 192 | ARMNN_ASSERT(backend.get() != nullptr); |
David Beck | 1b61be5 | 2018-11-08 09:19:14 +0000 | [diff] [blame] | 193 | |
| 194 | auto context = backend->CreateBackendContext(options); |
| 195 | |
| 196 | // backends are allowed to return nullptrs if they |
| 197 | // don't wish to create a backend specific context |
| 198 | if (context) |
| 199 | { |
| 200 | m_BackendContexts.emplace(std::make_pair(id, std::move(context))); |
| 201 | } |
Matthew Bentham | 9a61fa6 | 2020-02-04 10:03:55 +0000 | [diff] [blame] | 202 | supportedBackends.emplace(id); |
Colm Donelan | 1aff393 | 2020-02-05 17:48:59 +0000 | [diff] [blame] | 203 | |
| 204 | unique_ptr<armnn::profiling::IBackendProfiling> profilingIface = |
| 205 | std::make_unique<armnn::profiling::BackendProfiling>(armnn::profiling::BackendProfiling( |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 206 | options, m_ProfilingService, id)); |
Colm Donelan | 1aff393 | 2020-02-05 17:48:59 +0000 | [diff] [blame] | 207 | |
| 208 | // Backends may also provide a profiling context. Ask for it now. |
| 209 | auto profilingContext = backend->CreateBackendProfilingContext(options, profilingIface); |
| 210 | // Backends that don't support profiling will return a null profiling context. |
| 211 | if (profilingContext) |
| 212 | { |
Finn Williams | fe5a24b | 2020-04-09 16:05:28 +0100 | [diff] [blame] | 213 | // Pass the context onto the profiling service. |
| 214 | m_ProfilingService.AddBackendProfilingContext(id, profilingContext); |
Colm Donelan | 1aff393 | 2020-02-05 17:48:59 +0000 | [diff] [blame] | 215 | } |
David Beck | 1b61be5 | 2018-11-08 09:19:14 +0000 | [diff] [blame] | 216 | } |
Matthew Bentham | 9a61fa6 | 2020-02-04 10:03:55 +0000 | [diff] [blame] | 217 | catch (const BackendUnavailableException&) |
| 218 | { |
| 219 | // Ignore backends which are unavailable |
| 220 | } |
David Beck | 1b61be5 | 2018-11-08 09:19:14 +0000 | [diff] [blame] | 221 | } |
Finn Williams | fe5a24b | 2020-04-09 16:05:28 +0100 | [diff] [blame] | 222 | |
Finn Williams | 45a7362 | 2020-05-15 18:41:05 +0100 | [diff] [blame^] | 223 | BackendRegistryInstance().SetProfilingService(m_ProfilingService); |
Finn Williams | fe5a24b | 2020-04-09 16:05:28 +0100 | [diff] [blame] | 224 | // pass configuration info to the profiling service |
| 225 | m_ProfilingService.ConfigureProfilingService(options.m_ProfilingOptions); |
| 226 | |
Matthew Bentham | 9a61fa6 | 2020-02-04 10:03:55 +0000 | [diff] [blame] | 227 | m_DeviceSpec.AddSupportedBackends(supportedBackends); |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | Runtime::~Runtime() |
| 231 | { |
| 232 | std::vector<int> networkIDs; |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 233 | try |
| 234 | { |
| 235 | // Coverity fix: The following code may throw an exception of type std::length_error. |
| 236 | std::transform(m_LoadedNetworks.begin(), m_LoadedNetworks.end(), |
| 237 | std::back_inserter(networkIDs), |
| 238 | [](const auto &pair) { return pair.first; }); |
| 239 | } |
| 240 | catch (const std::exception& e) |
| 241 | { |
| 242 | // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an |
| 243 | // exception of type std::length_error. |
| 244 | // Using stderr instead in this context as there is no point in nesting try-catch blocks here. |
| 245 | std::cerr << "WARNING: An error has occurred when getting the IDs of the networks to unload: " << e.what() |
| 246 | << "\nSome of the loaded networks may not be unloaded" << std::endl; |
| 247 | } |
| 248 | // We then proceed to unload all the networks which IDs have been appended to the list |
| 249 | // up to the point the exception was thrown (if any). |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 250 | |
| 251 | for (auto networkID : networkIDs) |
| 252 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 253 | try |
| 254 | { |
| 255 | // Coverity fix: UnloadNetwork() may throw an exception of type std::length_error, |
| 256 | // boost::log::v2s_mt_posix::odr_violation or boost::log::v2s_mt_posix::system_error |
| 257 | UnloadNetwork(networkID); |
| 258 | } |
| 259 | catch (const std::exception& e) |
| 260 | { |
| 261 | // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an |
| 262 | // exception of type std::length_error. |
| 263 | // Using stderr instead in this context as there is no point in nesting try-catch blocks here. |
| 264 | std::cerr << "WARNING: An error has occurred when unloading network " << networkID << ": " << e.what() |
| 265 | << std::endl; |
| 266 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 267 | } |
Narumol Prangnawarat | 60a20fb | 2019-12-09 17:24:41 +0000 | [diff] [blame] | 268 | |
| 269 | // Clear all dynamic backends. |
| 270 | DynamicBackendUtils::DeregisterDynamicBackends(m_DeviceSpec.GetDynamicBackends()); |
| 271 | m_DeviceSpec.ClearDynamicBackends(); |
Colm Donelan | 1aff393 | 2020-02-05 17:48:59 +0000 | [diff] [blame] | 272 | m_BackendContexts.clear(); |
Finn Williams | 45a7362 | 2020-05-15 18:41:05 +0100 | [diff] [blame^] | 273 | |
| 274 | BackendRegistryInstance().SetProfilingService(armnn::EmptyOptional()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 275 | } |
| 276 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 277 | LoadedNetwork* Runtime::GetLoadedNetworkPtr(NetworkId networkId) const |
| 278 | { |
| 279 | std::lock_guard<std::mutex> lockGuard(m_Mutex); |
| 280 | return m_LoadedNetworks.at(networkId).get(); |
| 281 | } |
| 282 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 283 | TensorInfo Runtime::GetInputTensorInfo(NetworkId networkId, LayerBindingId layerId) const |
| 284 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 285 | return GetLoadedNetworkPtr(networkId)->GetInputTensorInfo(layerId); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | TensorInfo Runtime::GetOutputTensorInfo(NetworkId networkId, LayerBindingId layerId) const |
| 289 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 290 | return GetLoadedNetworkPtr(networkId)->GetOutputTensorInfo(layerId); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 291 | } |
| 292 | |
Derek Lamberti | 03614f6 | 2018-10-02 15:52:46 +0100 | [diff] [blame] | 293 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 294 | Status Runtime::EnqueueWorkload(NetworkId networkId, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 295 | const InputTensors& inputTensors, |
| 296 | const OutputTensors& outputTensors) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 297 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 298 | LoadedNetwork* loadedNetwork = GetLoadedNetworkPtr(networkId); |
Derek Lamberti | 03614f6 | 2018-10-02 15:52:46 +0100 | [diff] [blame] | 299 | |
| 300 | static thread_local NetworkId lastId = networkId; |
| 301 | if (lastId != networkId) |
| 302 | { |
| 303 | LoadedNetworkFuncSafe(lastId, [](LoadedNetwork* network) |
| 304 | { |
| 305 | network->FreeWorkingMemory(); |
| 306 | }); |
| 307 | } |
| 308 | lastId=networkId; |
| 309 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 310 | return loadedNetwork->EnqueueWorkload(inputTensors, outputTensors); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 311 | } |
| 312 | |
Nattapat Chaimanowong | 6e94820 | 2019-03-22 14:01:46 +0000 | [diff] [blame] | 313 | void Runtime::RegisterDebugCallback(NetworkId networkId, const DebugCallbackFunction& func) |
| 314 | { |
| 315 | LoadedNetwork* loadedNetwork = GetLoadedNetworkPtr(networkId); |
| 316 | loadedNetwork->RegisterDebugCallback(func); |
| 317 | } |
| 318 | |
Matteo Martincigh | e54aa06 | 2019-08-05 14:12:11 +0100 | [diff] [blame] | 319 | void Runtime::LoadDynamicBackends(const std::string& overrideBackendPath) |
| 320 | { |
| 321 | // Get the paths where to load the dynamic backends from |
| 322 | std::vector<std::string> backendPaths = DynamicBackendUtils::GetBackendPaths(overrideBackendPath); |
| 323 | |
| 324 | // Get the shared objects to try to load as dynamic backends |
| 325 | std::vector<std::string> sharedObjects = DynamicBackendUtils::GetSharedObjects(backendPaths); |
| 326 | |
| 327 | // Create a list of dynamic backends |
Matteo Martincigh | 0c2b289 | 2019-08-05 14:12:11 +0100 | [diff] [blame] | 328 | m_DynamicBackends = DynamicBackendUtils::CreateDynamicBackends(sharedObjects); |
| 329 | |
| 330 | // Register the dynamic backends in the backend registry |
Matteo Martincigh | 8953390 | 2019-08-15 12:08:06 +0100 | [diff] [blame] | 331 | BackendIdSet registeredBackendIds = DynamicBackendUtils::RegisterDynamicBackends(m_DynamicBackends); |
| 332 | |
| 333 | // Add the registered dynamic backend ids to the list of supported backends |
Narumol Prangnawarat | 60a20fb | 2019-12-09 17:24:41 +0000 | [diff] [blame] | 334 | m_DeviceSpec.AddSupportedBackends(registeredBackendIds, true); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 335 | } |
Matteo Martincigh | e54aa06 | 2019-08-05 14:12:11 +0100 | [diff] [blame] | 336 | |
| 337 | } // namespace armnn |