From 3a7d3a70d99cbe22f5e4711d5dbbea2a245da7ed Mon Sep 17 00:00:00 2001 From: Rob Hughes Date: Tue, 24 Sep 2019 16:59:56 +0100 Subject: 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 --- .../PermuteAndBatchToSpaceAsDepthToSpace.hpp | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/armnn/optimizations/PermuteAndBatchToSpaceAsDepthToSpace.hpp (limited to 'src/armnn/optimizations/PermuteAndBatchToSpaceAsDepthToSpace.hpp') 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; + +} // namespace optimizations +} // namespace armnn -- cgit v1.2.1