From 920f2b6c2070f6328891e26538e8bcad63e2a79c Mon Sep 17 00:00:00 2001 From: Pablo Marquez Tello Date: Wed, 27 Apr 2022 11:46:31 +0100 Subject: Add support for 2d and 3d indices for axis 0 * Partially resolves COMPMID-5055 Change-Id: Id05374b8c69e6b9ab4c2790a4de93d7172063b71 Signed-off-by: Pablo Marquez Tello Change-Id: Ic6e2c2d1d34abbf6222c8d56859514e267447266 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/7488 Tested-by: Arm Jenkins Reviewed-by: Giorgio Arena Comments-Addressed: Arm Jenkins --- arm_compute/core/utils/misc/ShapeCalculator.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 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 df907c106e..aa51ad209a 100644 --- a/arm_compute/core/utils/misc/ShapeCalculator.h +++ b/arm_compute/core/utils/misc/ShapeCalculator.h @@ -1496,13 +1496,24 @@ inline TensorShape compute_pool3d_shape(const TensorShape &src, Pooling3dLayerIn inline TensorShape compute_gather_shape(const TensorShape &input_shape, const TensorShape &indices_shape, uint32_t actual_axis) { - ARM_COMPUTE_ERROR_ON(indices_shape.num_dimensions() > 1); ARM_COMPUTE_ERROR_ON(input_shape.num_dimensions() > 4); ARM_COMPUTE_ERROR_ON(actual_axis >= input_shape.num_dimensions()); - TensorShape output_shape = input_shape; - output_shape[actual_axis] = indices_shape[0]; - + TensorShape output_shape = input_shape; + if(indices_shape.num_dimensions() == 1u) + { + output_shape[actual_axis] = indices_shape[0]; + } + else + { + const auto inddims{ indices_shape.num_dimensions() }; + output_shape.shift_right(indices_shape.num_dimensions() - 1); + output_shape[0] = input_shape[0]; + for(size_t idx(1); (idx - 1) < inddims; ++idx) + { + output_shape.set(actual_axis + idx, indices_shape[idx - 1], false); + } + } return output_shape; } } // namespace shape_calculator -- cgit v1.2.1