aboutsummaryrefslogtreecommitdiff
path: root/src/backends/cl
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/backends/cl
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/backends/cl')
-rw-r--r--src/backends/cl/test/ClCustomAllocatorTests.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/backends/cl/test/ClCustomAllocatorTests.cpp b/src/backends/cl/test/ClCustomAllocatorTests.cpp
index a9b9e41a34..e614f4c624 100644
--- a/src/backends/cl/test/ClCustomAllocatorTests.cpp
+++ b/src/backends/cl/test/ClCustomAllocatorTests.cpp
@@ -181,7 +181,6 @@ TEST_CASE("ClCustomAllocatorCpuAccNegativeTest")
auto customAllocator = std::make_shared<SampleClBackendCustomAllocator>();
options.m_CustomAllocatorMap = {{"CpuAcc", std::move(customAllocator)}};
IRuntimePtr run = IRuntime::Create(options);
-
TensorInfo inputTensorInfo(TensorShape({1, 1}), DataType::Float32);
INetworkPtr myNetwork = CreateTestNetwork(inputTensorInfo);
@@ -191,16 +190,9 @@ TEST_CASE("ClCustomAllocatorCpuAccNegativeTest")
IOptimizedNetworkPtr optNet(nullptr, nullptr);
std::vector<std::string> errMessages;
- try
- {
- optNet = Optimize(*myNetwork, {"CpuAcc"}, run->GetDeviceSpec(), optOptions, errMessages);
- FAIL("Should have thrown an exception as GetAvailablePreferredBackends() should be empty in Optimize().");
- }
- catch (const armnn::InvalidArgumentException& e)
- {
- // Different exceptions are thrown on different backends
- }
- CHECK(errMessages.size() > 0);
+ CHECK_THROWS_AS_MESSAGE(Optimize(*myNetwork, {"CpuAcc"}, run->GetDeviceSpec(), optOptions, errMessages),
+ armnn::InvalidArgumentException,
+ "Expected an exception as GetAvailablePreferredBackends() should be empty in Optimize().");
auto& backendRegistry = armnn::BackendRegistryInstance();
backendRegistry.DeregisterAllocator(NeonBackend::GetIdStatic());
@@ -208,4 +200,18 @@ TEST_CASE("ClCustomAllocatorCpuAccNegativeTest")
#endif
+TEST_CASE("ClCustomAllocatorGpuAccNullptrTest")
+{
+ using namespace armnn;
+
+ // Create ArmNN runtime
+ IRuntime::CreationOptions options; // default options
+ auto customAllocator = std::make_shared<SampleClBackendCustomAllocator>();
+ options.m_CustomAllocatorMap = {{"GpuAcc", nullptr}};
+
+ CHECK_THROWS_AS_MESSAGE(IRuntimePtr run = IRuntime::Create(options),
+ armnn::Exception,
+ "Expected exception in RuntimeImpl::RuntimeImpl() as allocator was nullptr.");
+}
+
} // test suite ClCustomAllocatorTests \ No newline at end of file