aboutsummaryrefslogtreecommitdiff
path: root/ConversionUtils_1_3.hpp
diff options
context:
space:
mode:
authorCathal Corbett <cathal.corbett@arm.com>2022-09-01 13:34:59 +0100
committerCathal Corbett <cathal.corbett@arm.com>2022-12-13 14:31:11 +0000
commit8de96f7e72e212503dadb450ccdcd15b411a7a1a (patch)
tree07d5777ed369182b80e27d292f871c2b0e9e44a7 /ConversionUtils_1_3.hpp
parente0fd650d00a4dfd8864834cefb77a9b4b238cfd9 (diff)
downloadandroid-nn-driver-8de96f7e72e212503dadb450ccdcd15b411a7a1a.tar.gz
Optimize the calling of IsLayerSupported().
!armnn:8742 * Done as part of 22.11/23.02 innovation days. * IsLayerSupported() is called in model prepare (delegate, android-nn-driver and shim/support_library) and again in ArmNN once model optimization is performed. * From calling IsLayerSupported() the first time, we should know that the layers are supported and what backend they are supported on. * Solution is to set the BackendId of the IConnectableLayer when IsLayerSupported() is called the first time, * In the Optimize() function we then check if the backend is set. If so, we do not call IsLayerSupported() again. * In the case a layer that is supported gets optimized, then the BackendId of that layer get set to "Unknown" for the new optimized layer and IsLayerSupported() will get called on the newly optimized layer. Signed-off-by: Cathal Corbett <cathal.corbett@arm.com> Change-Id: Ie5c6c9cd10d81f90b1ee78dd6e3442f353b6c109
Diffstat (limited to 'ConversionUtils_1_3.hpp')
-rw-r--r--ConversionUtils_1_3.hpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/ConversionUtils_1_3.hpp b/ConversionUtils_1_3.hpp
index 059b79f0..761b1899 100644
--- a/ConversionUtils_1_3.hpp
+++ b/ConversionUtils_1_3.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
+// Copyright © 2020,2022 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -131,10 +131,12 @@ bool ConvertFill(const HalOperation& operation, const HalModel& model, Conversio
}
bool isSupported = false;
+ armnn::BackendId setBackend;
FORWARD_LAYER_SUPPORT_FUNC(__func__,
IsFillSupported,
data.m_Backends,
isSupported,
+ setBackend,
inputInfo,
outputInfo,
descriptor);
@@ -144,6 +146,7 @@ bool ConvertFill(const HalOperation& operation, const HalModel& model, Conversio
}
IConnectableLayer* const layer = data.m_Network->AddFillLayer(descriptor);
+ layer->SetBackendId(setBackend);
if (!layer)
{
return Fail("%s: Could not add the FillLayer", __func__);
@@ -187,13 +190,14 @@ bool ConvertLogicalBinary(const HalOperation& operation,
LogicalBinaryDescriptor descriptor(logicalOperation);
bool isSupported = false;
-
+ armnn::BackendId setBackend;
auto validateFunc = [&](const armnn::TensorInfo& outputInfo, bool& isSupported)
{
FORWARD_LAYER_SUPPORT_FUNC(__func__,
IsLogicalBinarySupported,
data.m_Backends,
isSupported,
+ setBackend,
inputInfo0,
inputInfo1,
outputInfo,
@@ -215,6 +219,7 @@ bool ConvertLogicalBinary(const HalOperation& operation,
}
IConnectableLayer* layer = data.m_Network->AddLogicalBinaryLayer(descriptor);
+ layer->SetBackendId(setBackend);
if (!layer)
{
return Fail("%s: Could not add the LogicalBinaryLayer", __func__);
@@ -680,12 +685,14 @@ bool ConvertQuantizedLstm(const HalOperation& operation, const HalModel& model,
// Check if the layer is supported
bool isSupported = false;
+ armnn::BackendId setBackend;
auto validateFunc = [&](const armnn::TensorInfo& cellStateOutInfo, bool& isSupported)
{
FORWARD_LAYER_SUPPORT_FUNC(__func__,
IsQLstmSupported,
data.m_Backends,
isSupported,
+ setBackend,
inputInfo,
outputStatePrevTimeStepInfo,
cellStatePrevTimeStepInfo,
@@ -716,6 +723,7 @@ bool ConvertQuantizedLstm(const HalOperation& operation, const HalModel& model,
// Add the layer
IConnectableLayer* layer = data.m_Network->AddQLstmLayer(desc, params, "QLstm");
+ layer->SetBackendId(setBackend);
input.Connect(layer->GetInputSlot(0));
outputStatePrevTimeStep.Connect(layer->GetInputSlot(1));
@@ -770,10 +778,12 @@ bool ConvertRank(const HalOperation& operation, const HalModel& model, Conversio
}
bool isSupported = false;
+ armnn::BackendId setBackend;
FORWARD_LAYER_SUPPORT_FUNC(__func__,
IsRankSupported,
data.m_Backends,
isSupported,
+ setBackend,
input.GetTensorInfo(),
outInfo);
if (!isSupported)
@@ -782,6 +792,7 @@ bool ConvertRank(const HalOperation& operation, const HalModel& model, Conversio
}
armnn::IConnectableLayer* layer = data.m_Network->AddRankLayer();
+ layer->SetBackendId(setBackend);
if (!layer)
{
return Fail("%s: Could not add the RankLayer", __func__);