From 477531c258801caf3cce44eb3e43df611b42fc6d Mon Sep 17 00:00:00 2001 From: Gian Marco Iodice Date: Tue, 21 Aug 2018 17:53:38 +0100 Subject: COMPMID-1527 - Implementing ReorgLayer on OpenCL Also extended tests on NEON Change-Id: Icb0eced534e904ef807972dd3a31988f501bb02e Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/147095 Reviewed-by: Georgios Pinitas Tested-by: Jenkins --- arm_compute/core/utils/misc/ShapeCalculator.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (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 d2af844b2a..d72547ed07 100644 --- a/arm_compute/core/utils/misc/ShapeCalculator.h +++ b/arm_compute/core/utils/misc/ShapeCalculator.h @@ -61,17 +61,19 @@ inline TensorShape compute_permutation_output_shape(const ITensorInfo &input, co inline TensorShape compute_reorg_output_shape(const ITensorInfo &input, int32_t stride) { - ARM_COMPUTE_ERROR_ON(stride <= 0); + const size_t idx_width = get_data_layout_dimension_index(input.data_layout(), DataLayoutDimension::WIDTH); + const size_t idx_height = get_data_layout_dimension_index(input.data_layout(), DataLayoutDimension::HEIGHT); + const size_t idx_channel = get_data_layout_dimension_index(input.data_layout(), DataLayoutDimension::CHANNEL); - const DataLayout data_layout = input.data_layout(); - const unsigned int width_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH); - const unsigned int height_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT); - const unsigned int channel_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL); + ARM_COMPUTE_ERROR_ON(stride <= 0); + ARM_COMPUTE_ERROR_ON_MSG((input.tensor_shape()[idx_width] % stride != 0), "The width of the input tensor must be a multiple of stride"); + ARM_COMPUTE_ERROR_ON_MSG((input.tensor_shape()[idx_height] % stride != 0), "The height of the input tensor must be a multiple of stride"); TensorShape output_shape{ input.tensor_shape() }; - output_shape.set(width_idx, input.tensor_shape()[width_idx] / stride); - output_shape.set(height_idx, input.tensor_shape()[height_idx] / stride); - output_shape.set(channel_idx, input.tensor_shape()[channel_idx] * stride * stride); + + output_shape.set(idx_width, output_shape[idx_width] / stride); + output_shape.set(idx_height, output_shape[idx_height] / stride); + output_shape.set(idx_channel, output_shape[idx_channel] * stride * stride); return output_shape; } -- cgit v1.2.1