diff options
author | Jan Eilers <jan.eilers@arm.com> | 2021-07-14 13:50:15 +0100 |
---|---|---|
committer | Jan Eilers <jan.eilers@arm.com> | 2021-07-22 11:58:01 +0100 |
commit | 15fcc7ed3163c9d4b1856955271854198c3c2696 (patch) | |
tree | a4c2991ec2150c23c593f683df749f12b425cc84 /src/armnn/Runtime.cpp | |
parent | 801e2d55de7a02b98f3d77dc9775b10b2bd9f16b (diff) | |
download | armnn-15fcc7ed3163c9d4b1856955271854198c3c2696.tar.gz |
IVGCVSW-6073 Add protected mode to ArmNN CreationOptions
* Adds logic to the Runtime to activate protected mode
* Adds ProtectedContentAllocation backend capability to ClBackend
It's not fully activated yet because the CustomAllocator is
missing. Will print an error message and won't register the backend
but won't fail.
* Extends IBackendInternal with an UseCustomAllocator function.
* Adds related unit tests
Signed-off-by: Jan Eilers <jan.eilers@arm.com>
Change-Id: I64f465c5800eb104aa90db1bbf772a4148b5072f
Diffstat (limited to 'src/armnn/Runtime.cpp')
-rw-r--r-- | src/armnn/Runtime.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/armnn/Runtime.cpp b/src/armnn/Runtime.cpp index f16d186191..c2b748653d 100644 --- a/src/armnn/Runtime.cpp +++ b/src/armnn/Runtime.cpp @@ -6,6 +6,7 @@ #include <armnn/Version.hpp> #include <armnn/BackendRegistry.hpp> +#include <armnn/BackendHelper.hpp> #include <armnn/Logging.hpp> #include <armnn/utility/Timer.hpp> @@ -282,6 +283,32 @@ RuntimeImpl::RuntimeImpl(const IRuntime::CreationOptions& options) auto backend = factoryFun(); ARMNN_ASSERT(backend.get() != nullptr); + // If the runtime is created in protected mode only add backends that support this mode + if (options.m_ProtectedMode) + { + // check if backend supports ProtectedMode + using BackendCapability = BackendOptions::BackendOption; + BackendCapability protectedContentCapability {"ProtectedContentAllocation", true}; + if (!HasCapability(protectedContentCapability, id)) + { + // Protected Content Allocation is not supported by the backend + // backend should not be registered + ARMNN_LOG(warning) << "Backend " + << id + << " is not registered as does not support protected content allocation \n"; + continue; + } + std::string err; + if (!backend->UseCustomMemoryAllocator(err)) + { + ARMNN_LOG(error) << "The backend " + << id + << " reported an error when entering protected mode. Backend won't be used." + << " ErrorMsg: " << err; + continue; + } + } + auto context = backend->CreateBackendContext(options); // backends are allowed to return nullptrs if they |