diff options
author | Matthew Sloyan <matthew.sloyan@arm.com> | 2021-05-03 12:22:03 +0100 |
---|---|---|
committer | TeresaARM <teresa.charlinreyes@arm.com> | 2021-05-20 13:57:36 +0000 |
commit | 5fc0fd6661f9647092deb052d052973a237bd52d (patch) | |
tree | f46c8ad169414ae400b22b046e25cedf7ba76c9d /src/backends/neon/NeonBackend.cpp | |
parent | 1bed2f4f297d16f738b2c14f9e0fd24b7b03dade (diff) | |
download | armnn-5fc0fd6661f9647092deb052d052973a237bd52d.tar.gz |
MLCE-418 Reduce layer does not support multiple axes
* Added backend specific optimization to chain new reduces layers
for each axis to simulate behaviour of a layer with multiple axes.
* Added function to calculate reduced output shape.
* Added unit tests.
* Includes rework to fix IVGCVSW-5987.
Signed-off-by: Matthew Sloyan <matthew.sloyan@arm.com>
Change-Id: I154b3698b5e6756b05b2a0b5a3f0896184efce72
Diffstat (limited to 'src/backends/neon/NeonBackend.cpp')
-rw-r--r-- | src/backends/neon/NeonBackend.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/backends/neon/NeonBackend.cpp b/src/backends/neon/NeonBackend.cpp index a1299fb458..b496238cf3 100644 --- a/src/backends/neon/NeonBackend.cpp +++ b/src/backends/neon/NeonBackend.cpp @@ -29,6 +29,7 @@ #include "workloads/NeonDivisionWorkload.hpp" #include "workloads/NeonFullyConnectedWorkload.hpp" #include "workloads/NeonMultiplicationWorkload.hpp" +#include "workloads/NeonReduceWorkload.hpp" #include "workloads/NeonSubtractionWorkload.hpp" #include <Optimizer.hpp> @@ -161,6 +162,7 @@ OptimizationViews NeonBackend::OptimizeSubgraphView(const SubgraphView& subgraph --it; Layer& base = **it; + // Fuse activation into previous layer if supported by backend if ((base.GetType() == LayerType::DepthwiseConvolution2d || base.GetType() == LayerType::Convolution2d || base.GetType() == LayerType::BatchNormalization || base.GetType() == LayerType::FullyConnected || base.GetType() == LayerType::Addition || base.GetType() == LayerType::Multiplication @@ -393,6 +395,25 @@ OptimizationViews NeonBackend::OptimizeSubgraphView(const SubgraphView& subgraph } } } + + // Separate reduce layer with multiple axes into multiple reduce layers with 1 axis. + if (base.GetType() == LayerType::Reduce) + { + ReduceLayer* baseLayer = PolymorphicDowncast<ReduceLayer*>(&base); + ReduceDescriptor reduceDescriptor = baseLayer->GetParameters(); + + if (!reduceDescriptor.m_vAxis.empty() && reduceDescriptor.m_vAxis.size() > 1) + { + // Add new layers to the graph and connect them. + std::vector<Layer*> layers = ChainReduceLayers<ReduceLayer>(optimizationViews, + baseLayer, + reduceDescriptor); + + // Replace existing baselayer with new subgraph. + ReplaceLayers<ReduceLayer>(optimizationViews, baseLayer, layers); + untouched.erase(baseLayer->GetGuid()); + } + } } if (optimizationViews.GetSubstitutions().empty()) |