diff options
author | Colm Donelan <colm.donelan@arm.com> | 2022-09-27 16:46:09 +0100 |
---|---|---|
committer | Colm Donelan <colm.donelan@arm.com> | 2022-09-27 21:58:00 +0100 |
commit | 7804481027056c6a2aec406d4cb2ab9c39e8418d (patch) | |
tree | c87580dd136ee3477b11c4524b0a2d6535121933 | |
parent | 4abe72f869d55347da506d24691da0c213f88db0 (diff) | |
download | armnn-7804481027056c6a2aec406d4cb2ab9c39e8418d.tar.gz |
IVGCVSW-7235 Errors from LoadNetwork are being ignored in ArmNNExecutor.
In ArmNNExecutor::ArmNNExecutor the call to m_Runtime->LoadNetwork was
ignoring the Status result and continuing to execute with a failed
network. In addition throwing an exception from the constructor resulted
in a segmentation fault.
* Modify IExecutor to allow the constructor to mark itself as failed.
* Modify ArmNNExecutor to mark itself as failed when LoadNetwork returns
an error.
* Modify ExecuteNetwork to check the value of m_constructionFailed.
Signed-off-by: Colm Donelan <colm.donelan@arm.com>
Change-Id: Idf222cb2b66e1051875dc67046734f2b00b288d1
-rw-r--r-- | tests/ExecuteNetwork/ArmNNExecutor.cpp | 15 | ||||
-rw-r--r-- | tests/ExecuteNetwork/ExecuteNetwork.cpp | 15 | ||||
-rw-r--r-- | tests/ExecuteNetwork/IExecutor.hpp | 1 |
3 files changed, 25 insertions, 6 deletions
diff --git a/tests/ExecuteNetwork/ArmNNExecutor.cpp b/tests/ExecuteNetwork/ArmNNExecutor.cpp index d1892f9d42..1e409e8d0a 100644 --- a/tests/ExecuteNetwork/ArmNNExecutor.cpp +++ b/tests/ExecuteNetwork/ArmNNExecutor.cpp @@ -28,8 +28,6 @@ ArmNNExecutor::ArmNNExecutor(const ExecuteNetworkParams& params, armnn::IRuntime m_IOInfo = GetIOInfo(optNet.get()); SetupInputsAndOutputs(); - std::string errorMsg; - armnn::ProfilingDetailsMethod profilingDetailsMethod = ProfilingDetailsMethod::Undefined; if (params.m_OutputDetailsOnlyToStdOut) { @@ -46,7 +44,18 @@ ArmNNExecutor::ArmNNExecutor(const ExecuteNetworkParams& params, armnn::IRuntime params.m_EnableProfiling, profilingDetailsMethod}; - m_Runtime->LoadNetwork(m_NetworkId, std::move(optNet), errorMsg, networkProperties); + std::string errorMsg; + Status status = m_Runtime->LoadNetwork(m_NetworkId, std::move(optNet), errorMsg, networkProperties); + if (status != Status::Success) + { + std::string message("Failed to create Arm NN Executor: "); + message.append(errorMsg); + // Throwing an exception at this point in the constructor causes lots of problems. We'll instead mark this + // executor as not constructed. + ARMNN_LOG(fatal) << message; + m_constructionFailed = true; + return; + } if (m_Params.m_Iterations > 1) { diff --git a/tests/ExecuteNetwork/ExecuteNetwork.cpp b/tests/ExecuteNetwork/ExecuteNetwork.cpp index e9ebd0db8e..c6c8cc0b27 100644 --- a/tests/ExecuteNetwork/ExecuteNetwork.cpp +++ b/tests/ExecuteNetwork/ExecuteNetwork.cpp @@ -55,13 +55,22 @@ int main(int argc, const char* argv[]) } std::vector<const void*> outputResults; - - auto executor = BuildExecutor(programOptions); - if (!executor) + std::unique_ptr<IExecutor> executor; + try + { + executor = BuildExecutor(programOptions); + if (executor->m_constructionFailed) + { + return EXIT_FAILURE; + } + } + catch (const std::exception& e) { + ARMNN_LOG(fatal) << e.what(); return EXIT_FAILURE; } + executor->PrintNetworkInfo(); outputResults = executor->Execute(); diff --git a/tests/ExecuteNetwork/IExecutor.hpp b/tests/ExecuteNetwork/IExecutor.hpp index 4ed6cbde84..21ec9040e9 100644 --- a/tests/ExecuteNetwork/IExecutor.hpp +++ b/tests/ExecuteNetwork/IExecutor.hpp @@ -19,4 +19,5 @@ public: /// Compare the output with the result of another IExecutor virtual void CompareAndPrintResult(std::vector<const void*> otherOutput) = 0; virtual ~IExecutor(){}; + bool m_constructionFailed = false; }; |