aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJan Eilers <jan.eilers@arm.com>2021-07-14 13:50:15 +0100
committerJan Eilers <jan.eilers@arm.com>2021-07-22 11:58:01 +0100
commit15fcc7ed3163c9d4b1856955271854198c3c2696 (patch)
treea4c2991ec2150c23c593f683df749f12b425cc84 /include
parent801e2d55de7a02b98f3d77dc9775b10b2bd9f16b (diff)
downloadarmnn-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 'include')
-rw-r--r--include/armnn/IRuntime.hpp7
-rw-r--r--include/armnn/backends/IBackendInternal.hpp27
2 files changed, 33 insertions, 1 deletions
diff --git a/include/armnn/IRuntime.hpp b/include/armnn/IRuntime.hpp
index bee61d21a9..fcb8c05e30 100644
--- a/include/armnn/IRuntime.hpp
+++ b/include/armnn/IRuntime.hpp
@@ -90,6 +90,7 @@ public:
, m_EnableGpuProfiling(false)
, m_DynamicBackendsPath("")
, m_CustomAllocator(nullptr)
+ , m_ProtectedMode(false)
{}
/// If set, uses the GpuAcc tuned parameters from the given object when executing GPU workloads.
@@ -108,6 +109,12 @@ public:
/// Only supported for GpuAcc
ICustomAllocator* m_CustomAllocator;
+ /// Setting this flag will allow the user to create the Runtime in protected mode.
+ /// It will run all the inferences on protected memory and will make sure that
+ /// INetworkProperties::m_ImportEnabled set to true with MemorySource::DmaBufProtected option
+ /// This will use Protected Memory Allocator associated with the backend
+ bool m_ProtectedMode;
+
struct ExternalProfilingOptions
{
ExternalProfilingOptions()
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<std::string&> 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<IBackendInternal>;