From 5b7d537d918becb894d94d91726ce79e63d72fc1 Mon Sep 17 00:00:00 2001 From: Manuel Bottini Date: Fri, 17 May 2019 14:04:22 +0100 Subject: COMPMID-2237 Implement SPACE_TO_DEPTH for NEON Change-Id: I9f427bceca6da52671e0096be08772612f4be152 Signed-off-by: Manuel Bottini Reviewed-on: https://review.mlplatform.org/c/1227 Tested-by: Arm Jenkins Comments-Addressed: Arm Jenkins Reviewed-by: Michalis Spyrou --- arm_compute/core/utils/misc/ShapeCalculator.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'arm_compute/core/utils') diff --git a/arm_compute/core/utils/misc/ShapeCalculator.h b/arm_compute/core/utils/misc/ShapeCalculator.h index 8394bbaed8..7eab17ba11 100644 --- a/arm_compute/core/utils/misc/ShapeCalculator.h +++ b/arm_compute/core/utils/misc/ShapeCalculator.h @@ -1058,6 +1058,29 @@ inline TensorShape compute_space_to_batch_shape(const ITensorInfo *input, const return output_shape; } +/** Calculate the space to batch output shape of a tensor + * + * @param[in] input Input tensor info + * @param[in] block_shape Block shape value + * + * @return the calculated shape + */ +inline TensorShape compute_space_to_depth_shape(const ITensorInfo *input, int32_t block_shape) +{ + TensorShape output_shape{ input->tensor_shape() }; + + const DataLayout data_layout = input->data_layout(); + const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH); + const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT); + const int idx_depth = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL); + + output_shape.set(idx_width, input->tensor_shape()[idx_width] * block_shape); + output_shape.set(idx_height, input->tensor_shape()[idx_height] * block_shape); + output_shape.set(idx_depth, input->tensor_shape()[idx_depth] / (block_shape * block_shape)); + + return output_shape; +} + /** Calculate the prior box output shape of a tensor * * @param[in] input Input tensor info -- cgit v1.2.1