aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/Runtime.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/armnn/Runtime.cpp')
-rw-r--r--src/armnn/Runtime.cpp27
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