aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/core/utils
diff options
context:
space:
mode:
authorGian Marco Iodice <gianmarco.iodice@arm.com>2018-12-07 11:18:09 +0000
committerGian Marco Iodice <gianmarco.iodice@arm.com>2018-12-11 14:55:03 +0000
commit3b0a2654034714c16f5930d2b24936d8be7b18a6 (patch)
tree2a3ed3703a4f454ef42084363049aba3bf54ebd6 /arm_compute/core/utils
parentff0bccfb4697c591d569db9c2dc223f2e311a7d3 (diff)
downloadComputeLibrary-3b0a2654034714c16f5930d2b24936d8be7b18a6.tar.gz
COMPMID-1775: Implement CLGEMMReshapeRHSMatrixKernel to reshape the RHS matrix of GEMM/GEMMLowp
Change-Id: I77f2bfcc5d170bcc2428a2f27104942c1ec877d7 Reviewed-on: https://review.mlplatform.org/375 Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'arm_compute/core/utils')
-rw-r--r--arm_compute/core/utils/misc/ShapeCalculator.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/arm_compute/core/utils/misc/ShapeCalculator.h b/arm_compute/core/utils/misc/ShapeCalculator.h
index 88ce8d9e7b..33893ad877 100644
--- a/arm_compute/core/utils/misc/ShapeCalculator.h
+++ b/arm_compute/core/utils/misc/ShapeCalculator.h
@@ -138,6 +138,34 @@ inline TensorShape compute_lhs_reshaped_shape(const ITensorInfo &a, const GEMMLH
return lhs_shape;
}
+inline TensorShape compute_rhs_reshaped_shape(const ITensorInfo &a, const GEMMRHSMatrixInfo &rhs_info)
+{
+ ARM_COMPUTE_ERROR_ON(rhs_info.n0 == 0);
+ ARM_COMPUTE_ERROR_ON(rhs_info.k0 == 0);
+ ARM_COMPUTE_ERROR_ON(rhs_info.h0 == 0);
+
+ // Input width/height
+ const unsigned int input_width = a.dimension(0);
+ const unsigned int input_height = a.dimension(1);
+
+ // Number of horizontal/vertical blocks in the input tensor
+ const unsigned int num_horiz_blocks = std::ceil(input_width / static_cast<float>(rhs_info.n0));
+ const unsigned int num_vert_blocks = std::ceil(input_height / static_cast<float>(rhs_info.k0));
+
+ // Block size
+ const unsigned int block_size = rhs_info.n0 * rhs_info.k0;
+
+ // Output width/height
+ const unsigned int output_width = block_size * num_vert_blocks * rhs_info.h0;
+ const unsigned int output_height = std::ceil(num_horiz_blocks / static_cast<float>(rhs_info.h0));
+
+ TensorShape rhs_shape{ a.tensor_shape() };
+ rhs_shape.set(0, output_width);
+ rhs_shape.set(1, output_height);
+
+ return rhs_shape;
+}
+
inline TensorShape compute_interleaved_shape(const ITensorInfo &a, int mult_interleave4x4_height = 1, bool reinterpret_input_as_3d = false)
{
// The interleaved output matrix will have the following shape: [ a_height * W, ceil(a_width / W) ] where W = 4 * mult_interleave4x4_height