diff options
author | Colm Donelan <colm.donelan@arm.com> | 2023-06-22 10:19:17 +0100 |
---|---|---|
committer | Colm Donelan <colm.donelan@arm.com> | 2023-06-30 14:20:56 +0100 |
commit | 0dfb2658ce521571aa0f9e859f813c60fda9d8d6 (patch) | |
tree | ef4605cebb29c6754da8dfea0decd4250288e2a5 /tests/ExecuteNetwork/TfliteExecutor.cpp | |
parent | 16e27cf81424dcad05d129f9ba368a8c446cd25f (diff) | |
download | armnn-0dfb2658ce521571aa0f9e859f813c60fda9d8d6.tar.gz |
IVGCVSW-7666 Add a FileComparisonExecutor to ExecuteNetwork.
* Implement the "-C" command line option of executenetwork.
* Add a FileComparisonExecutorFile which will read tensors from
a previously written text file and compare them to the execution
output.
Signed-off-by: Colm Donelan <colm.donelan@arm.com>
Change-Id: I8380fd263028af13d65a67fb6afd89626d1b07b8
Diffstat (limited to 'tests/ExecuteNetwork/TfliteExecutor.cpp')
-rw-r--r-- | tests/ExecuteNetwork/TfliteExecutor.cpp | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/tests/ExecuteNetwork/TfliteExecutor.cpp b/tests/ExecuteNetwork/TfliteExecutor.cpp index 6455650404..04e510f938 100644 --- a/tests/ExecuteNetwork/TfliteExecutor.cpp +++ b/tests/ExecuteNetwork/TfliteExecutor.cpp @@ -11,6 +11,50 @@ #include "TfliteExecutor.hpp" #include "tensorflow/lite/kernels/kernel_util.h" +#include <string> + +std::string TfLiteStatusToString(const TfLiteStatus status) +{ + switch (status) + { + case kTfLiteOk: + return "Status: Ok."; + // Generally referring to an error in the runtime (i.e. interpreter) + case kTfLiteError: + return "Status: Tf runtime error."; + // Generally referring to an error from a TfLiteDelegate itself. + case kTfLiteDelegateError: + return "Status: The loaded delegate has returned an error."; + // Generally referring to an error in applying a delegate due to + // incompatibility between runtime and delegate, e.g., this error is returned + // when trying to apply a TF Lite delegate onto a model graph that's already + // immutable. + case kTfLiteApplicationError: + return "Status: Application error. An incompatibility between the Tf runtime and the loaded delegate."; + // Generally referring to serialized delegate data not being found. + // See tflite::delegates::Serialization. + case kTfLiteDelegateDataNotFound: + return "Status: data not found."; + // Generally referring to data-writing issues in delegate serialization. + // See tflite::delegates::Serialization. + case kTfLiteDelegateDataWriteError: + return "Status: Error writing serialization data."; + // Generally referring to data-reading issues in delegate serialization. + // See tflite::delegates::Serialization. + case kTfLiteDelegateDataReadError: + return "Status: Error reading serialization data."; + // Generally referring to issues when the TF Lite model has ops that cannot be + // resolved at runtime. This could happen when the specific op is not + // registered or built with the TF Lite framework. + case kTfLiteUnresolvedOps: + return "Status: Model contains an operation that is not recognised by the runtime."; + // Generally referring to invocation cancelled by the user. + case kTfLiteCancelled: + return "Status: invocation has been cancelled by the user."; + } + return "Unknown status result."; +} + TfLiteExecutor::TfLiteExecutor(const ExecuteNetworkParams& params, armnn::IRuntime::CreationOptions runtimeOptions) : m_Params(params) { @@ -67,9 +111,11 @@ TfLiteExecutor::TfLiteExecutor(const ExecuteNetworkParams& params, armnn::IRunti theArmnnDelegate(armnnDelegate::TfLiteArmnnDelegateCreate(delegateOptions), armnnDelegate::TfLiteArmnnDelegateDelete); // Register armnn_delegate to TfLiteInterpreter - if (m_TfLiteInterpreter->ModifyGraphWithDelegate(std::move(theArmnnDelegate)) != kTfLiteOk) + auto result = m_TfLiteInterpreter->ModifyGraphWithDelegate(std::move(theArmnnDelegate)); + if (result != kTfLiteOk) { - LogAndThrow("Could not register ArmNN TfLite Delegate to TfLiteInterpreter."); + LogAndThrow("Could not register ArmNN TfLite Delegate to TfLiteInterpreter: " + + TfLiteStatusToString(result) + "."); } #else LogAndThrow("Not built with Arm NN Tensorflow-Lite delegate support."); |