aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/optimizations/PermuteAndBatchToSpaceAsDepthToSpace.hpp
diff options
context:
space:
mode:
authorRob Hughes <robert.hughes@arm.com>2019-09-24 16:59:56 +0100
committerÁron Virginás-Tar <aron.virginas-tar@arm.com>2019-09-27 10:17:26 +0000
commit3a7d3a70d99cbe22f5e4711d5dbbea2a245da7ed (patch)
tree445967fa35016374657b5c7e38b2715773a25e02 /src/armnn/optimizations/PermuteAndBatchToSpaceAsDepthToSpace.hpp
parent83239f995e7b86062450794b85bfe4c4c387fda0 (diff)
downloadarmnn-3a7d3a70d99cbe22f5e4711d5dbbea2a245da7ed.tar.gz
NNXSW-1826 Add an optimization step which combines Permute and BatchToSpace into DepthToSpace
This is only possible in some limited cases, but removes an extra layer from the graph and so should improve performance in all cases. Change-Id: I7b3e6ba5dacb4fdb816ad270edaecda1436ab4cf Signed-off-by: Rob Hughes <robert.hughes@arm.com>
Diffstat (limited to 'src/armnn/optimizations/PermuteAndBatchToSpaceAsDepthToSpace.hpp')
-rw-r--r--src/armnn/optimizations/PermuteAndBatchToSpaceAsDepthToSpace.hpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/armnn/optimizations/PermuteAndBatchToSpaceAsDepthToSpace.hpp b/src/armnn/optimizations/PermuteAndBatchToSpaceAsDepthToSpace.hpp
new file mode 100644
index 0000000000..4a73efca40
--- /dev/null
+++ b/src/armnn/optimizations/PermuteAndBatchToSpaceAsDepthToSpace.hpp
@@ -0,0 +1,27 @@
+//
+// Copyright © 2019 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+#pragma once
+
+#include "Optimization.hpp"
+
+namespace armnn
+{
+namespace optimizations
+{
+
+/// Replaces Permute leading into BatchToSpace with a DepthToSpace
+/// in the case where the Permute swaps the batch and channels dimensions
+/// such that the replacement is valid.
+class PermuteAndBatchToSpaceAsDepthToSpaceImpl
+{
+public:
+ void Run(Graph& graph, InputSlot& connection) const;
+};
+
+using PermuteAndBatchToSpaceAsDepthToSpace =
+ OptimizeForConnection<PermuteLayer, BatchToSpaceNdLayer, PermuteAndBatchToSpaceAsDepthToSpaceImpl>;
+
+} // namespace optimizations
+} // namespace armnn