diff options
Diffstat (limited to 'src/armnn')
-rw-r--r-- | src/armnn/BackendHelper.cpp | 14 | ||||
-rw-r--r-- | src/armnn/LoadedNetwork.cpp | 13 | ||||
-rw-r--r-- | src/armnn/Runtime.cpp | 4 | ||||
-rw-r--r-- | src/armnn/test/OptimizerTests.cpp | 4 |
4 files changed, 24 insertions, 11 deletions
diff --git a/src/armnn/BackendHelper.cpp b/src/armnn/BackendHelper.cpp index 0a55a08087..f025193006 100644 --- a/src/armnn/BackendHelper.cpp +++ b/src/armnn/BackendHelper.cpp @@ -74,6 +74,16 @@ bool HasCapability(const std::string& name, const armnn::BackendId& backend) bool HasCapability(const BackendOptions::BackendOption& capability, const BackendCapabilities& capabilities) { + return HasMatchingCapability(capability, capabilities); +} + +bool HasCapability(const BackendOptions::BackendOption& backendOption, const armnn::BackendId& backend) +{ + return HasMatchingCapability(backendOption, backend); +} + +bool HasMatchingCapability(const BackendOptions::BackendOption& capability, const BackendCapabilities& capabilities) +{ for (size_t i=0; i < capabilities.GetOptionCount(); i++) { const auto& backendCapability = capabilities.GetOption(i); @@ -104,7 +114,7 @@ bool HasCapability(const BackendOptions::BackendOption& capability, const Backen return false; } -bool HasCapability(const BackendOptions::BackendOption& backendOption, const armnn::BackendId& backend) +bool HasMatchingCapability(const BackendOptions::BackendOption& backendOption, const armnn::BackendId& backend) { auto const& backendRegistry = armnn::BackendRegistryInstance(); if (backendRegistry.IsBackendRegistered(backend)) @@ -112,7 +122,7 @@ bool HasCapability(const BackendOptions::BackendOption& backendOption, const arm auto factoryFunc = backendRegistry.GetFactory(backend); auto backendObject = factoryFunc(); auto capabilities = backendObject->GetCapabilities(); - return HasCapability(backendOption, capabilities); + return HasMatchingCapability(backendOption, capabilities); } return false; } diff --git a/src/armnn/LoadedNetwork.cpp b/src/armnn/LoadedNetwork.cpp index 3d84054b69..7150261ddd 100644 --- a/src/armnn/LoadedNetwork.cpp +++ b/src/armnn/LoadedNetwork.cpp @@ -255,14 +255,15 @@ LoadedNetwork::LoadedNetwork(std::unique_ptr<IOptimizedNetwork> net, // If we're doing async execution verify that the backend supports it and ExternallyManagedMemory. if (networkProperties.m_AsyncEnabled) { - if (!HasCapability(BackendOptions::BackendOption{"AsyncExecution", true}, backend->GetCapabilities())) + if (!HasMatchingCapability(BackendOptions::BackendOption{"AsyncExecution", true}, + backend->GetCapabilities())) { std::string er = backend->GetId(); er += " does not support AsyncExecution"; throw BackendCapabilityException(er); } - if (!HasCapability(BackendOptions::BackendOption{"ExternallyManagedMemory", true}, - backend->GetCapabilities())) + if (!HasMatchingCapability(BackendOptions::BackendOption{"ExternallyManagedMemory", true}, + backend->GetCapabilities())) { std::string er = backend->GetId(); er += " does not support ExternallyManagedMemory\n"; @@ -1508,7 +1509,8 @@ std::vector<ImportedInputId> LoadedNetwork::ImportInputs(const InputTensors& inp } auto& backend = m_Backends.at(layer->GetBackendId()); - if (!HasCapability(BackendOptions::BackendOption{"PreImportIOTensors", true}, backend->GetCapabilities())) + if (!HasMatchingCapability(BackendOptions::BackendOption{"PreImportIOTensors", true}, + backend->GetCapabilities())) { std::string er = backend->GetId(); er += " does not have PreImportIOTensors capability"; @@ -1641,7 +1643,8 @@ std::vector<ImportedOutputId> LoadedNetwork::ImportOutputs(const OutputTensors& } auto& backend = m_Backends.at(layer->GetBackendId()); - if (!HasCapability(BackendOptions::BackendOption{"PreImportIOTensors", true}, backend->GetCapabilities())) + if (!HasMatchingCapability(BackendOptions::BackendOption{"PreImportIOTensors", true}, + backend->GetCapabilities())) { std::string er = backend->GetId(); er += " does not have PreImportIOTensors capability"; diff --git a/src/armnn/Runtime.cpp b/src/armnn/Runtime.cpp index f71fad1f35..b0fc55010d 100644 --- a/src/armnn/Runtime.cpp +++ b/src/armnn/Runtime.cpp @@ -371,7 +371,7 @@ RuntimeImpl::RuntimeImpl(const IRuntime::CreationOptions& options) // check if backend supports ProtectedMode using BackendCapability = BackendOptions::BackendOption; BackendCapability protectedContentCapability {"ProtectedContentAllocation", true}; - if (!HasCapability(protectedContentCapability, id)) + if (!HasMatchingCapability(protectedContentCapability, id)) { // Protected Content Allocation is not supported by the backend // backend should not be registered @@ -480,7 +480,7 @@ RuntimeImpl::RuntimeImpl(const IRuntime::CreationOptions& options) using BackendCapability = BackendOptions::BackendOption; auto strategyType = GetMemBlockStrategyTypeName(strategy->GetMemBlockStrategyType()); BackendCapability memOptimizeStrategyCapability {strategyType, true}; - if (HasCapability(memOptimizeStrategyCapability, id)) + if (HasMatchingCapability(memOptimizeStrategyCapability, id)) { BackendRegistryInstance().RegisterMemoryOptimizerStrategy(id, strategy); diff --git a/src/armnn/test/OptimizerTests.cpp b/src/armnn/test/OptimizerTests.cpp index f83900404b..de077c19f0 100644 --- a/src/armnn/test/OptimizerTests.cpp +++ b/src/armnn/test/OptimizerTests.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2017,2022 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2017,2022-2023 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -724,7 +724,7 @@ TEST_CASE("BackendCapabilityTest") armnn::BackendOptions::BackendOption nonConstWeights{"NonConstWeights", true}; // MockBackend does not support the NonConstWeights capability - CHECK(!armnn::HasCapability(nonConstWeights, backendId)); + CHECK(!armnn::HasMatchingCapability(nonConstWeights, backendId)); CHECK(!armnn::HasCapability("NonConstWeights", backendId)); // MockBackend does not support the AsyncExecution capability |