aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/Network.cpp
diff options
context:
space:
mode:
authorFrancis Murtagh <francis.murtagh@arm.com>2023-01-16 13:11:29 +0000
committerFrancis Murtagh <francis.murtagh@arm.com>2023-01-18 13:45:40 +0000
commitd97db7e6bb9738590e3980c6e721669006e85af4 (patch)
treeb07cc306d3f73ab040c50583397544b842188ad9 /src/armnn/Network.cpp
parente27983ccfc9f73e2ec69863dcc5d9812fba7f5ef (diff)
downloadarmnn-d97db7e6bb9738590e3980c6e721669006e85af4.tar.gz
Github #700: Fix order of optimizations so dequantization works with folding
* Folding of pad into conv2d expected a Constant layer not Dequantisation * Fusing Dequantisation with Constant to a Constant ensures that. * Group Constant layer optimizations together where possible. * Add unit test. Signed-off-by: Francis Murtagh <francis.murtagh@arm.com> Change-Id: Id0393313bf097595f2f13738b7513e427116ea4a
Diffstat (limited to 'src/armnn/Network.cpp')
-rw-r--r--src/armnn/Network.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/armnn/Network.cpp b/src/armnn/Network.cpp
index e81b87b382..08d3280cfe 100644
--- a/src/armnn/Network.cpp
+++ b/src/armnn/Network.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017,2022,2023 Arm Ltd and Contributors. All rights reserved.
+// Copyright © 2017, 2022-2023 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -1056,7 +1056,7 @@ OptimizationResult ApplyBackendOptimizations(OptimizedNetworkImpl* optNetObjPtr,
auto backendObjPtr = backends.find(selectedBackend)->second.get();
ARMNN_ASSERT(backendObjPtr);
- if(selectedBackend == armnn::Compute::GpuAcc || selectedBackend == armnn::Compute::CpuAcc)
+ if (selectedBackend == armnn::Compute::GpuAcc || selectedBackend == armnn::Compute::CpuAcc)
{
Optimizer::Pass(optGraph, MakeOptimizations(optimizations::PermuteDepthwiseConv2dWeights()));
Optimizer::Pass(optGraph, MakeOptimizations(optimizations::FusePermuteIntoConstLayer()));
@@ -1636,10 +1636,14 @@ IOptimizedNetworkPtr Optimize(const Graph& inGraph,
optGraph.InferTensorInfos();
}
- // Need to FusePermuteIntoConstantLayer before FoldPadIntoDepthwiseConvolution2d or
- // FuseBatchNormIntoDepthwiseConvolution2D optimizations are called.
- Optimizer::Pass(optGraph, MakeOptimizations(FusePermuteIntoConstLayer()));
+ // Group Constant Layer optimizations together where possible.
+ // This is important as:
+ // FusePermuteIntoConstantLayer must happen before FoldPadIntoDepthwiseConvolution2d and
+ // FuseBatchNormIntoDepthwiseConvolution2D.
+ // ConvertConstDequantisationLayersToConstLayers must happen before FoldPadIntoConvolution2d
+ Optimizer::Pass(optGraph, MakeOptimizations(FusePermuteIntoConstLayer(),
+ ConvertConstDequantisationLayersToConstLayers()));
// Perform optimisation passes
Optimizer::Pass(optGraph, MakeOptimizations(SquashEqualPermuteSiblings(),
SquashEqualTransposeSiblings(),
@@ -1659,8 +1663,7 @@ IOptimizedNetworkPtr Optimize(const Graph& inGraph,
FuseBatchNormIntoConvolution2DFloat32(),
FuseBatchNormIntoConvolution2DFloat16(),
FuseBatchNormIntoDepthwiseConvolution2DFloat32(),
- FuseBatchNormIntoDepthwiseConvolution2DFloat16(),
- ConvertConstDequantisationLayersToConstLayers()));
+ FuseBatchNormIntoDepthwiseConvolution2DFloat16()));
// If Fp32 to Fp16 optimization is set convert Fp32 network to Fp16
if (options.m_ReduceFp32ToFp16)