From 3a613cc9103484249ffcd7c63a7ae57783b1ea18 Mon Sep 17 00:00:00 2001 From: Mike Kelly Date: Tue, 29 Sep 2020 20:50:35 +0100 Subject: Refactored Optimize(...) function to throw exceptions instead of returning null * INetwork::Optimize(...) states that the function should throw an exception if it fails but the implementation in Network.cpp returned null in some scenarios instead. This has led to some confusion amongst users. Signed-off-by: Mike Kelly Change-Id: I358d1293232c9464772aa0e39ab3355e3570c823 --- src/armnn/Network.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/armnn/Network.cpp') diff --git a/src/armnn/Network.cpp b/src/armnn/Network.cpp index 1f59ed51a2..668b634bc7 100644 --- a/src/armnn/Network.cpp +++ b/src/armnn/Network.cpp @@ -1018,7 +1018,7 @@ IOptimizedNetworkPtr Optimize(const INetwork& inNetwork, { if (backendPreferences.empty()) { - throw armnn::InvalidArgumentException("Invoked Optimize with no backends specified"); + throw InvalidArgumentException("Invoked Optimize with no backends specified"); } if (options.m_ReduceFp32ToFp16 && options.m_ReduceFp32ToBf16) @@ -1082,7 +1082,7 @@ IOptimizedNetworkPtr Optimize(const INetwork& inNetwork, failureMsg << "None of the preferred backends " << backendPreferences << " are supported. Current platform provides " << backendSettings.m_SupportedBackends; ReportError(failureMsg.str(), messages); - return IOptimizedNetworkPtr(nullptr, &IOptimizedNetwork::Destroy); + throw InvalidArgumentException(failureMsg.str()); } // Create a map to temporarily hold initialized backend objects @@ -1100,7 +1100,7 @@ IOptimizedNetworkPtr Optimize(const INetwork& inNetwork, if (assignBackendsResult.m_Error) { // Failed to assign a backend to each layer - return IOptimizedNetworkPtr(nullptr, &IOptimizedNetwork::Destroy); + throw InvalidArgumentException("Failed to assign a backend to each layer"); } Optimizer::Pass(optGraph, MakeOptimizations(OptimizeInverseConversionsFp16(), @@ -1114,7 +1114,7 @@ IOptimizedNetworkPtr Optimize(const INetwork& inNetwork, if (backendOptimizationResult.m_Error) { // Failed to apply the backend-specific optimizations - return IOptimizedNetworkPtr(nullptr, &IOptimizedNetwork::Destroy); + throw InvalidArgumentException("Failed to apply the backend-specific optimizations"); } // If the debug flag is set, then insert a DebugLayer after each layer -- cgit v1.2.1