aboutsummaryrefslogtreecommitdiff
path: root/src/armnn
diff options
context:
space:
mode:
authorColm Donelan <Colm.Donelan@arm.com>2021-08-17 00:52:23 +0100
committerColm Donelan <Colm.Donelan@arm.com>2021-08-17 09:25:52 +0100
commit380c1a0b5c5bb28d0773af4870e104675074e148 (patch)
tree4596c0087309179344436e50150cb202bc215af5 /src/armnn
parentb80eaff042d928690eedda6652be5c66e2a81e53 (diff)
downloadarmnn-380c1a0b5c5bb28d0773af4870e104675074e148.tar.gz
IVGCVSW-6317 Cleaning up BackendRegistry following negative tests.
* Deregister backends in BackendHintTest. * Deregister backend in ThrowBackendUnavailableException * Clean up dynamic backends when an exception is thrown from RuntimeImpl::RuntimeImpl. * Use CHECK_THROWS_AS_MESSAGE syntax in ClCustomAllocatorTests. Signed-off-by: Colm Donelan <Colm.Donelan@arm.com> Change-Id: I0e6e5413dd074b5fcfc9515c85cb8d40a4a0b73c
Diffstat (limited to 'src/armnn')
-rw-r--r--src/armnn/Runtime.cpp6
-rw-r--r--src/armnn/test/OptimizerTests.cpp3
2 files changed, 8 insertions, 1 deletions
diff --git a/src/armnn/Runtime.cpp b/src/armnn/Runtime.cpp
index 824a2b077c..bbcbb9f6f6 100644
--- a/src/armnn/Runtime.cpp
+++ b/src/armnn/Runtime.cpp
@@ -265,7 +265,6 @@ RuntimeImpl::RuntimeImpl(const IRuntime::CreationOptions& options)
{
const auto start_time = armnn::GetTimeNow();
ARMNN_LOG(info) << "ArmNN v" << ARMNN_VERSION << "\n";
-
if ( options.m_ProfilingOptions.m_TimelineEnabled && !options.m_ProfilingOptions.m_EnableProfiling )
{
throw RuntimeException(
@@ -282,13 +281,18 @@ RuntimeImpl::RuntimeImpl(const IRuntime::CreationOptions& options)
// Store backend contexts for the supported ones
try {
auto factoryFun = BackendRegistryInstance().GetFactory(id);
+ ARMNN_ASSERT(factoryFun != nullptr);
auto backend = factoryFun();
+ ARMNN_ASSERT(backend != nullptr);
ARMNN_ASSERT(backend.get() != nullptr);
auto customAllocatorMapIterator = options.m_CustomAllocatorMap.find(id);
if (customAllocatorMapIterator != options.m_CustomAllocatorMap.end() &&
customAllocatorMapIterator->second == nullptr)
{
+ // We need to manually clean up the dynamic backends before throwing an exception.
+ DynamicBackendUtils::DeregisterDynamicBackends(m_DeviceSpec.GetDynamicBackends());
+ m_DeviceSpec.ClearDynamicBackends();
throw armnn::Exception("Allocator associated with id " + id.Get() + " is null");
}
diff --git a/src/armnn/test/OptimizerTests.cpp b/src/armnn/test/OptimizerTests.cpp
index 38aef671d2..66da3ad1ff 100644
--- a/src/armnn/test/OptimizerTests.cpp
+++ b/src/armnn/test/OptimizerTests.cpp
@@ -804,6 +804,9 @@ TEST_CASE("BackendHintTest")
{
(*it)->Accept(visitor);
}
+ // Clean up the registry for the next test.
+ backendRegistry.Deregister("MockBackend");
+ backendRegistry.Deregister("CustomBackend");
}
// Tests that OptimizeForExclusiveConnections works, fusing when needed, using BatchNorm fusing as example