From b4e3e1c371d8091e86ee1c6e704057559bbe1554 Mon Sep 17 00:00:00 2001 From: Ioan-Cristian Szabo Date: Thu, 30 Nov 2017 17:17:17 +0000 Subject: COMPMID-617: Add validate support for NEON FullyConnectedLayer Change-Id: I08987022c8d4cc335c00b8af27bd3edb8fe64d3b Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/111596 Tested-by: Jenkins Reviewed-by: Alexander Gilday Reviewed-by: Anthony Barbier --- arm_compute/core/utils/misc/ShapeCalculator.h | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'arm_compute/core/utils/misc') diff --git a/arm_compute/core/utils/misc/ShapeCalculator.h b/arm_compute/core/utils/misc/ShapeCalculator.h index c53ac4c71f..e21e5cd0d6 100644 --- a/arm_compute/core/utils/misc/ShapeCalculator.h +++ b/arm_compute/core/utils/misc/ShapeCalculator.h @@ -157,6 +157,43 @@ inline TensorShape compute_deconvolution_shape(const ITensorInfo &input, unsigne return scale_out_shape; } +inline TensorShape compute_im2col_shape(const ITensorInfo *input, const int num_input_dimensions = 3) +{ + TensorShape output_shape{ input->tensor_shape() }; + + output_shape.collapse(num_input_dimensions); + + return output_shape; +} +inline TensorShape compute_interleave_custom_shape(const TensorShape &input, const int x_interleave, const int y_interleave) +{ + TensorShape output_shape{ input }; + + output_shape.set(0, output_shape.x() * x_interleave); + output_shape.set(1, std::ceil(output_shape.y() / static_cast(y_interleave))); + + return output_shape; +} + +inline TensorShape compute_fully_connected_reshaped_weights_shape(const ITensorInfo *input, bool transpose_weights, bool is_batched_fc_layer, const int interleave) +{ + TensorShape output_shape{ input->tensor_shape() }; + + // Transpose weights if the user hasn't done it + if(transpose_weights) + { + output_shape = compute_transposed_shape(*input); + } + + // If the we run multiple batches we need 1xW transpose, too. + if(is_batched_fc_layer) + { + output_shape = compute_transposed_shape(input->clone()->set_tensor_shape(output_shape)); + output_shape = compute_interleave_custom_shape(output_shape, interleave, interleave); + } + + return output_shape; +} } // namespace shape_calculator } // namespace misc } // namespace arm_compute -- cgit v1.2.1