diff options
author | Francis Murtagh <francis.murtagh@arm.com> | 2021-08-12 11:55:21 +0100 |
---|---|---|
committer | Matthew Sloyan <matthew.sloyan@arm.com> | 2021-08-12 17:52:08 +0100 |
commit | 3e364ca52901475335c36a9cbb3a8360287a467c (patch) | |
tree | 21cc7d8a23e9fd0df6bc226293a9d5f0316d2a5b /src/armnn/Runtime.cpp | |
parent | 80bd5511a3c6633fcad2c2754cd788c7b414f3e1 (diff) | |
download | armnn-3e364ca52901475335c36a9cbb3a8360287a467c.tar.gz |
IVGCVSW-6077 Add Custom Allocator tests
* Add test for invalid backend and nullptr
* Small refactor
* Throw exception on nullptr allocator instead of assert
Signed-off-by: Francis Murtagh <francis.murtagh@arm.com>
Change-Id: I94ce4f61d7cb3123831f1acd98165ae14c40033a
Diffstat (limited to 'src/armnn/Runtime.cpp')
-rw-r--r-- | src/armnn/Runtime.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/armnn/Runtime.cpp b/src/armnn/Runtime.cpp index 5a52888639..824a2b077c 100644 --- a/src/armnn/Runtime.cpp +++ b/src/armnn/Runtime.cpp @@ -286,6 +286,11 @@ RuntimeImpl::RuntimeImpl(const IRuntime::CreationOptions& options) ARMNN_ASSERT(backend.get() != nullptr); auto customAllocatorMapIterator = options.m_CustomAllocatorMap.find(id); + if (customAllocatorMapIterator != options.m_CustomAllocatorMap.end() && + customAllocatorMapIterator->second == nullptr) + { + throw armnn::Exception("Allocator associated with id " + id.Get() + " is null"); + } // If the runtime is created in protected mode only add backends that support this mode if (options.m_ProtectedMode) @@ -307,8 +312,6 @@ RuntimeImpl::RuntimeImpl(const IRuntime::CreationOptions& options) if (customAllocatorMapIterator != options.m_CustomAllocatorMap.end()) { std::string err; - // Check we have actually been given an allocator. - ARMNN_ASSERT(customAllocatorMapIterator->second != nullptr); if (customAllocatorMapIterator->second->GetMemorySourceType() == armnn::MemorySource::DmaBufProtected) { |