From 15fcc7ed3163c9d4b1856955271854198c3c2696 Mon Sep 17 00:00:00 2001 From: Jan Eilers Date: Wed, 14 Jul 2021 13:50:15 +0100 Subject: 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 Change-Id: I64f465c5800eb104aa90db1bbf772a4148b5072f --- include/armnn/backends/IBackendInternal.hpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'include/armnn/backends') diff --git a/include/armnn/backends/IBackendInternal.hpp b/include/armnn/backends/IBackendInternal.hpp index b8edfe1f71..3b4ef95703 100644 --- a/include/armnn/backends/IBackendInternal.hpp +++ b/include/armnn/backends/IBackendInternal.hpp @@ -56,6 +56,13 @@ struct BackendVersion (this->m_Major == other.m_Major && this->m_Minor <= other.m_Minor); } + + bool operator>=(const BackendVersion& other) const + { + return this->m_Major > other.m_Major || + (this->m_Major == other.m_Major && + this->m_Minor >= other.m_Minor); + } }; inline std::ostream& operator<<(std::ostream& os, const BackendVersion& backendVersion) @@ -176,7 +183,7 @@ public: MemorySourceFlags outputFlags); /// Returns the version of the Backend API - static constexpr BackendVersion GetApiVersion() { return BackendVersion(1, 0); } + static constexpr BackendVersion GetApiVersion() { return BackendVersion(1, 1); } /// Returns a BackendCapability if the backend lists the capability /// The BackendCapability must then be inspected to check whether or not that BackendCapability is supported @@ -189,6 +196,24 @@ public: /// Returns true if backend support the capability false otherwise ARMNN_DEPRECATED_MSG("This function has been deprecated in favour of GetCapability") virtual bool HasCapability(BackendCapability /*capabilityClass*/) const { return false; } + + /// Signals the backend to use a custom memory allocator provided by the user + /// + /// \param errMsg - Optional string variable to return error messages + /// \return - Returns true if switching to custom allocator was successful + virtual bool UseCustomMemoryAllocator(armnn::Optional errMsg) + { + if (errMsg) + { + std::stringstream message; + message << "The backend " << GetId() << " doesn't support using a custom allocator. This error might" + " be related with the protected mode if the backend doesn't" + " fully support it."; + + errMsg.value() = message.str(); + } + return false; + } }; using IBackendInternalUniquePtr = std::unique_ptr; -- cgit v1.2.1