Fix delegate fallback during VisitNode
During VisitNode throwing an ArmNN exception incorrectly
terminates the process instead of handing over to tflite
* Catches ArmNN exceptions during VisitNode
Signed-off-by: Ryan OShea <ryan.oshea3@arm.com>
Change-Id: I6c71be11e9b73694747b27fe9febab8d9669b4d4
diff --git a/delegate/src/armnn_delegate.cpp b/delegate/src/armnn_delegate.cpp
index 06affca..aa6c1be 100644
--- a/delegate/src/armnn_delegate.cpp
+++ b/delegate/src/armnn_delegate.cpp
@@ -205,8 +205,20 @@
continue;
}
- if (ArmnnSubgraph::VisitNode(
- delegateData, tfLiteContext, tfLiteRegistration, tfLiteNode, nodeIndex) != kTfLiteOk)
+ TfLiteStatus visitStatus;
+
+ try
+ {
+ visitStatus = ArmnnSubgraph::VisitNode(
+ delegateData, tfLiteContext, tfLiteRegistration, tfLiteNode, nodeIndex);
+ }
+ catch(std::exception& ex)
+ {
+ ARMNN_LOG(error) << "ArmNN Failed to visit node with error: " << ex.what();
+ visitStatus = kTfLiteError;
+ }
+
+ if ( visitStatus != kTfLiteOk)
{
// node is not supported by ArmNN
unsupportedOperators.insert(tfLiteRegistration->builtin_code);
@@ -376,7 +388,7 @@
ARMNN_LOG(info) << "Optimize ArmnnSubgraph time: " << std::setprecision(2)
<< std::fixed << armnn::GetTimeDuration(optimizeStartTime).count() << " ms";
}
- catch (std::exception &ex)
+ catch (std::exception& ex)
{
std::stringstream exMessage;
exMessage << "TfLiteArmnnDelegate: Exception (" << ex.what() << ") caught from optimize.";