From 05b6a3e5946a3f58b6f5b0caface9153a1c2b364 Mon Sep 17 00:00:00 2001 From: Ryan OShea Date: Wed, 11 Jan 2023 15:27:50 +0000 Subject: 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 Change-Id: I6c71be11e9b73694747b27fe9febab8d9669b4d4 --- delegate/src/armnn_delegate.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/delegate/src/armnn_delegate.cpp b/delegate/src/armnn_delegate.cpp index 06affca752..aa6c1be37d 100644 --- a/delegate/src/armnn_delegate.cpp +++ b/delegate/src/armnn_delegate.cpp @@ -205,8 +205,20 @@ TfLiteIntArray* Delegate::IdentifyOperatorsToDelegate(TfLiteContext* tfLiteConte 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 @@ ArmnnSubgraph* ArmnnSubgraph::Create(TfLiteContext* tfLiteContext, 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."; -- cgit v1.2.1