aboutsummaryrefslogtreecommitdiff
path: root/include/armnn/INetwork.hpp
diff options
context:
space:
mode:
authorCathal Corbett <cathal.corbett@arm.com>2022-09-01 11:34:37 +0100
committerCathal Corbett <cathal.corbett@arm.com>2022-12-12 12:38:15 +0000
commit5383767a7a759c867235ab66bd71f88281e3bd06 (patch)
tree5704c33171d39dda9e4428c953e2efdd62ead656 /include/armnn/INetwork.hpp
parenta98e79a709f7c29728e1fc79c21ba5265993b8b6 (diff)
downloadarmnn-5383767a7a759c867235ab66bd71f88281e3bd06.tar.gz
Optimize the calling of IsLayerSupported().
* 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 otimization 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. * Includes bug fix IVGCVSW-7213 for Android Mean FP16 CpuAcc tests. Also related to bug IVGCVSW-7211. Signed-off-by: Cathal Corbett <cathal.corbett@arm.com> Change-Id: I7a7820d0cdb079ffb5a3a2e0c44e252f652df53b
Diffstat (limited to 'include/armnn/INetwork.hpp')
-rw-r--r--include/armnn/INetwork.hpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/include/armnn/INetwork.hpp b/include/armnn/INetwork.hpp
index 2bb9ad91f3..c9c8a04656 100644
--- a/include/armnn/INetwork.hpp
+++ b/include/armnn/INetwork.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
+// Copyright © 2017,2022 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
@@ -98,7 +98,11 @@ public:
/// Apply a visitor to this layer
virtual void ExecuteStrategy(IStrategy& strategy) const = 0;
- /// Provide a hint for the optimizer as to which backend to prefer for this layer
+ /// Provide a hint for the optimizer as to which backend to prefer for this layer.
+ /// By providing a BackendSelectionHint there is no guarantee the input backend supports that layer.
+ /// If IsLayerSupported() returns false with the backend hint, we default to calling IsLayerSupported()
+ /// on the BackendPreferences vector. Use SetBackendId() if we can guarantee a backend supports that
+ /// layer (IsLayerSupported returns true for a specific backend).
virtual void BackendSelectionHint(Optional<BackendId> backend) = 0;
/// Returns the armnn::LayerType of this layer
@@ -111,6 +115,12 @@ public:
/// the BaseDescriptor IsNull function is invoked.
virtual const BaseDescriptor& GetParameters() const = 0;
+ /// Set the backend of the IConnectableLayer.
+ /// By using SetBackendId() we guarantee that the input backend supports that
+ /// layer (IsLayerSupported returns true for a specific backend). If there is
+ /// no guarantee the input backend supports that layer use BackendSelectionHint().
+ virtual void SetBackendId(const BackendId& id) = 0;
+
using ConstantTensors = std::vector<std::reference_wrapper<std::shared_ptr<ConstTensorHandle>>>;
// Returns ConstantTensors of this Layer if it has any, otherwise returns empty vector.