From 0b51d5ad533f8ecde71f957077690195eea29ffc Mon Sep 17 00:00:00 2001 From: Narumol Prangnawarat Date: Wed, 20 Jan 2021 15:58:29 +0000 Subject: IVGCVSW-5619 Add OptimizerOptions and NetworkProperties to ArmNN Delegate * Add OptimizerOptions, NetworkProperties, DebugCallbackFunction to DelegateOptions * Enable OptimizerOptions when the network is being optimized * Enable NetworkProperties when loading network * Enable DebugCallbackFunction * Add error message when loading network * Log warning instead of error when operator is not supported but could fallback to another backend * Improve uint16_t CompareData * Unit tests Signed-off-by: Narumol Prangnawarat Change-Id: I353035afb442774bfeb1c62570a90755c2ceaf38 --- delegate/src/armnn_delegate.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'delegate/src/armnn_delegate.cpp') diff --git a/delegate/src/armnn_delegate.cpp b/delegate/src/armnn_delegate.cpp index 6250a5f638..6dba890509 100644 --- a/delegate/src/armnn_delegate.cpp +++ b/delegate/src/armnn_delegate.cpp @@ -134,6 +134,10 @@ Delegate::Delegate(armnnDelegate::DelegateOptions options) { runtimeOptions.m_BackendOptions = backendOptions; } + else if (!m_Options.GetOptimizerOptions().m_ModelOptions.empty()) + { + runtimeOptions.m_BackendOptions = m_Options.GetOptimizerOptions().m_ModelOptions; + } m_Runtime = armnn::IRuntime::Create(runtimeOptions); std::vector backends; @@ -288,7 +292,6 @@ ArmnnSubgraph* ArmnnSubgraph::Create(TfLiteContext* tfLiteContext, delegateData.m_OutputSlotForNode = std::vector(tfLiteContext->tensors_size, nullptr); - std::vector inputBindings; std::vector outputBindings; @@ -331,7 +334,8 @@ ArmnnSubgraph* ArmnnSubgraph::Create(TfLiteContext* tfLiteContext, { optNet = armnn::Optimize(*(delegateData.m_Network.get()), delegate->m_Options.GetBackends(), - delegate->m_Runtime->GetDeviceSpec()); + delegate->m_Runtime->GetDeviceSpec(), + delegate->m_Options.GetOptimizerOptions()); } catch (std::exception &ex) { @@ -348,11 +352,15 @@ ArmnnSubgraph* ArmnnSubgraph::Create(TfLiteContext* tfLiteContext, try { // Load graph into runtime - auto loadingStatus = delegate->m_Runtime->LoadNetwork(networkId, std::move(optNet)); + std::string errorMessage; + auto loadingStatus = delegate->m_Runtime->LoadNetwork(networkId, + std::move(optNet), + errorMessage, + delegate->m_Options.GetNetworkProperties()); if (loadingStatus != armnn::Status::Success) { // Optimize failed - throw armnn::Exception("TfLiteArmnnDelegate: Network could not be loaded!");; + throw armnn::Exception("TfLiteArmnnDelegate: Network could not be loaded:" + errorMessage); } } catch (std::exception& ex) @@ -362,6 +370,12 @@ ArmnnSubgraph* ArmnnSubgraph::Create(TfLiteContext* tfLiteContext, throw armnn::Exception(exMessage.str()); } + // Register debug callback function + if (delegate->m_Options.GetDebugCallbackFunction().has_value()) + { + delegate->m_Runtime->RegisterDebugCallback(networkId, delegate->m_Options.GetDebugCallbackFunction().value()); + } + // Create a new SubGraph with networkId and runtime return new ArmnnSubgraph(networkId, delegate->m_Runtime.get(), inputBindings, outputBindings); } -- cgit v1.2.1