aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorColm Donelan <colm.donelan@arm.com>2023-04-04 21:41:29 +0100
committerColm Donelan <colm.donelan@arm.com>2023-04-05 10:24:27 +0100
commitf0755de796bbe6a763fbfc349465484c88b9b3eb (patch)
treed7da9c8f232538fba56aa559c7121f97ad55fb64 /tests
parent6fe9ef91849b64fd4974cf8dbea909c7696166b7 (diff)
downloadarmnn-f0755de796bbe6a763fbfc349465484c88b9b3eb.tar.gz
IVGCVSW-6681 Improve error handling in TfLiteExecutor.
The initial model load and tensor allocation operations against the TfLiteInterpreter were not checking return codes resulting in segmentation faults. Signed-off-by: Colm Donelan <colm.donelan@arm.com> Change-Id: I812785f0af9012c97570065d200f72eaf781165a
Diffstat (limited to 'tests')
-rw-r--r--tests/ExecuteNetwork/TfliteExecutor.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/tests/ExecuteNetwork/TfliteExecutor.cpp b/tests/ExecuteNetwork/TfliteExecutor.cpp
index f365623d62..87731c2f83 100644
--- a/tests/ExecuteNetwork/TfliteExecutor.cpp
+++ b/tests/ExecuteNetwork/TfliteExecutor.cpp
@@ -18,10 +18,14 @@ TfLiteExecutor::TfLiteExecutor(const ExecuteNetworkParams& params, armnn::IRunti
tflite::ops::builtin::BuiltinOpResolver resolver;
tflite::InterpreterBuilder builder(*m_Model, resolver);
- builder(&m_TfLiteInterpreter);
- m_TfLiteInterpreter->AllocateTensors();
-
- int status = kTfLiteError;
+ if (builder(&m_TfLiteInterpreter) != kTfLiteOk)
+ {
+ LogAndThrow("Error loading the model into the TfLiteInterpreter.");
+ }
+ if (m_TfLiteInterpreter->AllocateTensors() != kTfLiteOk)
+ {
+ LogAndThrow("Failed to allocate tensors in the TfLiteInterpreter.");
+ }
if (m_Params.m_TfLiteExecutor == ExecuteNetworkParams::TfLiteExecutor::ArmNNTfLiteDelegate)
{
// Create the Armnn Delegate
@@ -32,10 +36,9 @@ TfLiteExecutor::TfLiteExecutor(const ExecuteNetworkParams& params, armnn::IRunti
theArmnnDelegate(armnnDelegate::TfLiteArmnnDelegateCreate(delegateOptions),
armnnDelegate::TfLiteArmnnDelegateDelete);
// Register armnn_delegate to TfLiteInterpreter
- status = m_TfLiteInterpreter->ModifyGraphWithDelegate(std::move(theArmnnDelegate));
- if (status != kTfLiteOk)
+ if (m_TfLiteInterpreter->ModifyGraphWithDelegate(std::move(theArmnnDelegate)) != kTfLiteOk)
{
- LogAndThrow("Could not register ArmNN TfLite Delegate to TfLiteInterpreter");
+ LogAndThrow("Could not register ArmNN TfLite Delegate to TfLiteInterpreter.");
}
}
else