Fix BatchToSpaceFixture

* Use a vector to represent the (static) block shape instead of an N-D
  Tensor. The previous use of ND Tensor as block shape was wrong, not
  adhering to the specification, and non-functional (only first dim was
  used anyway).

* The fixture now accepts a static block shape, because the dynamic
  case is not properly implemented and will be deprecated for now.

* Fix an assertion error in reference implementation.

Partially resolves COMPMID-5918

Change-Id: I5221e52ccc05e7c1249dec3a42426f954a73729a
Signed-off-by: SiCong Li <sicong.li@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9357
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Pablo Marquez Tello <pablo.tello@arm.com>
Reviewed-by: Omar Al Khatib <omar.alkhatib@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Benchmark: Arm Jenkins <bsgcomp@arm.com>
diff --git a/arm_compute/core/utils/misc/ShapeCalculator.h b/arm_compute/core/utils/misc/ShapeCalculator.h
index a895b58..916da1b 100644
--- a/arm_compute/core/utils/misc/ShapeCalculator.h
+++ b/arm_compute/core/utils/misc/ShapeCalculator.h
@@ -1100,28 +1100,28 @@
 
 /** Calculate the batch to space output shape of a tensor
  *
- * @param[in] input     Input tensor info
- * @param[in] block_x   Block shape x value
- * @param[in] block_y   Block shape y value
- * @param[in] crop_info Information about how the output shape is cropped after batch to space is performed
+ * @param[in] data_layout Data layout
+ * @param[in] input       Input tensor shape
+ * @param[in] block_x     Block shape x value
+ * @param[in] block_y     Block shape y value
+ * @param[in] crop_info   Information about how the output shape is cropped after batch to space is performed
  *
  * @return the calculated shape
  */
-inline TensorShape compute_batch_to_space_shape(const ITensorInfo *input, const int block_x, const int block_y, const CropInfo &crop_info = CropInfo{})
+inline TensorShape compute_batch_to_space_shape(DataLayout data_layout, const TensorShape &input, int block_x, int block_y, const CropInfo &crop_info = CropInfo{})
 {
-    ARM_COMPUTE_ERROR_ON(block_x <= 0 || block_y <= 0);
+    ARM_COMPUTE_ERROR_ON(block_x < 1 || block_y < 1);
 
-    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_batch   = get_data_layout_dimension_index(data_layout, DataLayoutDimension::BATCHES);
+    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_batch  = get_data_layout_dimension_index(data_layout, DataLayoutDimension::BATCHES);
 
-    TensorShape output_shape{ input->tensor_shape() };
+    TensorShape output_shape{ input };
 
-    auto       new_width   = input->tensor_shape()[idx_width] * block_x;
-    auto       new_height  = input->tensor_shape()[idx_height] * block_y;
-    const auto width_crop  = crop_info.left + crop_info.right;
-    const auto height_crop = crop_info.top + crop_info.bottom;
+    unsigned int       new_width   = input[idx_width] * static_cast<unsigned int>(block_x);
+    unsigned int       new_height  = input[idx_height] * static_cast<unsigned int>(block_y);
+    const unsigned int width_crop  = crop_info.left + crop_info.right;
+    const unsigned int height_crop = crop_info.top + crop_info.bottom;
     ARM_COMPUTE_ERROR_ON(new_width <= width_crop);
     ARM_COMPUTE_ERROR_ON(new_height <= height_crop);
     new_width -= width_crop;
@@ -1129,7 +1129,7 @@
 
     output_shape.set(idx_width, new_width);
     output_shape.set(idx_height, new_height);
-    output_shape.set(idx_batch, input->tensor_shape()[idx_batch] / (block_x * block_y));
+    output_shape.set(idx_batch, input[idx_batch] / (block_x * block_y));
 
     return output_shape;
 }