diff options
author | Mike Kelly <mike.kelly@arm.com> | 2022-11-25 13:55:24 +0000 |
---|---|---|
committer | mike.kelly <mike.kelly@arm.com> | 2022-12-12 15:58:21 +0000 |
commit | ec67a0f08e0f96a5aebf3cac65331c67f6649f5e (patch) | |
tree | 94146a1f43c74d89d83fd5da54688ae0fc19cf85 /src/armnn/optimizations | |
parent | 5383767a7a759c867235ab66bd71f88281e3bd06 (diff) | |
download | armnn-ec67a0f08e0f96a5aebf3cac65331c67f6649f5e.tar.gz |
IVGCVSW-7209 Remove deprecated code due to be removed in 23.02
* Removed weights and bias from Convolution, DepthwiseConv & FullyConnected
layers
* Removed the weight and bias ConstTensorHandles from the QueueDescriptors
* Updated Workloads to take tensors from WorkloadInfo rather than the
QueueDescriptors
* Removed unused RedirectMembersToConstantInputs optimization and tests.
Signed-off-by: Teresa Charlin <teresa.charlinreyes@arm.com>
Signed-off-by: Mike Kelly <mike.kelly@arm.com>
Change-Id: I9ffcdc4a1c0dff725539dd69fc435b700bd98a56
Diffstat (limited to 'src/armnn/optimizations')
-rw-r--r-- | src/armnn/optimizations/All.hpp | 1 | ||||
-rw-r--r-- | src/armnn/optimizations/FoldPadIntoLayer2d.hpp | 19 | ||||
-rw-r--r-- | src/armnn/optimizations/FuseBatchNorm.hpp | 8 | ||||
-rw-r--r-- | src/armnn/optimizations/RedirectMembersToConstantInputs.hpp | 90 |
4 files changed, 6 insertions, 112 deletions
diff --git a/src/armnn/optimizations/All.hpp b/src/armnn/optimizations/All.hpp index a11dec9446..0e67516193 100644 --- a/src/armnn/optimizations/All.hpp +++ b/src/armnn/optimizations/All.hpp @@ -20,6 +20,5 @@ #include "PermuteAsReshape.hpp" #include "PermuteAndBatchToSpaceAsDepthToSpace.hpp" #include "PermuteDepthwiseConv2dWeights.hpp" -#include "RedirectMembersToConstantInputs.hpp" #include "SquashEqualSiblings.hpp" #include "TransposeAsReshape.hpp"
\ No newline at end of file diff --git a/src/armnn/optimizations/FoldPadIntoLayer2d.hpp b/src/armnn/optimizations/FoldPadIntoLayer2d.hpp index 7a50c4ac06..874749fda9 100644 --- a/src/armnn/optimizations/FoldPadIntoLayer2d.hpp +++ b/src/armnn/optimizations/FoldPadIntoLayer2d.hpp @@ -1,5 +1,5 @@ // -// Copyright © 2022 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2017,2022 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -196,21 +196,14 @@ public: if (newConv2dLayer != nullptr) { const auto conv2dLayer = PolymorphicDowncast<Convolution2dLayer*>(&connection.GetOwningLayer()); - // Copy weights and bias to the new convolution layer ARMNN_ASSERT_MSG(newConv2dLayer->GetInputSlot(1).GetConnection() != nullptr, "FoldPadIntoConvolution2d: New convolution layer is missing connection to weights layer"); - // Deprecated. Removal date is 23.02. - newConv2dLayer->m_Weight = std::move(conv2dLayer->m_Weight); - if (conv2dLayer->GetParameters().m_BiasEnabled) { ARMNN_ASSERT_MSG(newConv2dLayer->GetInputSlot(2).GetConnection() != nullptr, "FoldPadIntoConvolution2d: New convolution layer is missing " "connection to bias layer."); - - // Deprecated. Removal date is 23.02. - newConv2dLayer->m_Bias = std::move(conv2dLayer->m_Bias); } } } @@ -230,24 +223,18 @@ public: if (newConv2dLayer != nullptr) { const auto conv2dLayer = PolymorphicDowncast<DepthwiseConvolution2dLayer*>(&connection.GetOwningLayer()); - // Copy weights and bias to the new convolution layer ARMNN_ASSERT_MSG(newConv2dLayer->GetInputSlot(1).GetConnection() != nullptr, - "FoldPadIntoDepthwiseConvolution2d: New convolution layer is missing connection to weights layer"); - - // Deprecated. Removal date is 23.02. - newConv2dLayer->m_Weight = std::move(conv2dLayer->m_Weight); + "FoldPadIntoDepthwiseConvolution2d: New convolution layer is missing " + "connection to weights layer"); if (conv2dLayer->GetParameters().m_BiasEnabled) { ARMNN_ASSERT_MSG(newConv2dLayer->GetInputSlot(2).GetConnection() != nullptr, "FoldPadIntoConvolution2d: New convolution layer is missing " "connection to bias layer."); - // Deprecated. Removal date is 23.02. - newConv2dLayer->m_Bias = std::move(conv2dLayer->m_Bias); } } } - protected: FoldPadIntoDepthwiseConvolution2dImpl() = default; ~FoldPadIntoDepthwiseConvolution2dImpl() = default; diff --git a/src/armnn/optimizations/FuseBatchNorm.hpp b/src/armnn/optimizations/FuseBatchNorm.hpp index bca0c7d00a..88ac97cd0c 100644 --- a/src/armnn/optimizations/FuseBatchNorm.hpp +++ b/src/armnn/optimizations/FuseBatchNorm.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 // @@ -167,8 +167,6 @@ public: auto& newConv2dLayer = *graph.InsertNewLayer<ConvLayer>(base.GetInputSlot(0), convDescriptor, name.c_str()); - newConv2dLayer.m_Weight = std::make_unique<ScopedTensorHandle>(fusedWeightsTensor); - newConv2dLayer.m_Bias = std::make_unique<ScopedTensorHandle>(ConstTensor(fusedBiasTensor)); // Connect weights and bias from old to new Conv2d layer // This optimization will always have 3 input slots on the Conv2d base layer @@ -177,7 +175,7 @@ public: // Remove old connection and connect to new layer2d weightLayer->GetOutputSlot(0).Disconnect(base.GetInputSlot(1)); weightLayer->GetOutputSlot(0).Connect(newConv2dLayer.GetInputSlot(1)); - weightLayer->m_LayerOutput = newConv2dLayer.m_Weight; + weightLayer->m_LayerOutput = std::make_unique<ScopedTensorHandle>(fusedWeightsTensor); // Move bias const layers as normal if it was enabled before the optimisation ConstantLayer* biasLayer; @@ -198,7 +196,7 @@ public: biasLayer->GetOutputSlot(0).SetTensorInfo(fusedBiasTensor.GetInfo()); biasLayer->GetOutputSlot(0).Connect(newConv2dLayer.GetInputSlot(2)); } - biasLayer->m_LayerOutput = newConv2dLayer.m_Bias; + biasLayer->m_LayerOutput = std::make_unique<ScopedTensorHandle>(ConstTensor(fusedBiasTensor)); } diff --git a/src/armnn/optimizations/RedirectMembersToConstantInputs.hpp b/src/armnn/optimizations/RedirectMembersToConstantInputs.hpp deleted file mode 100644 index a2bad710e6..0000000000 --- a/src/armnn/optimizations/RedirectMembersToConstantInputs.hpp +++ /dev/null @@ -1,90 +0,0 @@ -// -// Copyright © 2021 Arm Ltd and Contributors. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#pragma once - -#include "Optimization.hpp" - -#include <armnn/utility/IgnoreUnused.hpp> -#include <armnn/utility/PolymorphicDowncast.hpp> - -namespace armnn -{ -namespace optimizations -{ - -class RedirectMembersToConstantInputsImpl -{ -public: - /// Search for layers with ConstantLayers as inputs. If the inputs are constant redirect the layers member - /// variable for ConstTensors (e.g. m_weights) to the data stored in the ConstantLayer it is connected to. - void Run(Graph& graph, Layer& layer) const - { - IgnoreUnused(graph); - - switch (layer.GetType()) - { - case LayerType::BatchNormalization: - break; - case LayerType::Convolution2d: - RedirectWeightsAndBiases<Convolution2dLayer>(&layer); - break; - case LayerType::DepthwiseConvolution2d: - RedirectWeightsAndBiases<DepthwiseConvolution2dLayer>(&layer); - break; - case LayerType::DetectionPostProcess: - break; - case LayerType::FullyConnected: - RedirectWeightsAndBiases<FullyConnectedLayer>(&layer); - break; - case LayerType::Lstm: - break; - case LayerType::TransposeConvolution2d: - break; - default: - break; - } - } - -protected: - RedirectMembersToConstantInputsImpl() = default; - ~RedirectMembersToConstantInputsImpl() = default; - -private: - template <typename LayerT> - static LayerT* RedirectWeightsAndBiases(Layer* layer) - { - LayerT* layerPtr = PolymorphicDowncast<LayerT*>(layer); - - // Loop through input slots to check for constant weights and biases layers. - // Weights index = 1, Biases index = 2. - for (unsigned int inputSlotIndex = 1; inputSlotIndex != layerPtr->GetNumInputSlots(); ++inputSlotIndex) - { - OutputSlot* outputSlot = layerPtr->GetInputSlot(inputSlotIndex).GetConnectedOutputSlot(); - // Debug layers should not be inserted in optimize process yet - ARMNN_ASSERT(outputSlot->GetOwningLayer().GetType() != LayerType::Debug); - if (outputSlot->GetOwningLayer().GetType() == LayerType::Constant) - { - // Get constant layer and redirect base layer member variables. - ConstantLayer& constantLayer = dynamic_cast<ConstantLayer&>(outputSlot->GetOwningLayer()); - if (inputSlotIndex == 1) - { - layerPtr->m_Weight = constantLayer.m_LayerOutput; - } - else if (inputSlotIndex == 2) - { - layerPtr->m_Bias = constantLayer.m_LayerOutput; - } - } - } - - return layerPtr; - } -}; - -using RedirectMembersToConstantInputs = OptimizeForType<Layer, RedirectMembersToConstantInputsImpl>; - -} // namespace optimizations -} // namespace armnn |