COMPMID-1294: (Nightly) Fix Im2Col mismatches

Changes input_access to StaticWindow to manually add the bottom padding
that is not taken into account through RectangleAccess.

Change-Id: Id39223eaff08688c9ade37973023959faa6b42a6
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/136566
Tested-by: Jenkins <bsgcomp@arm.com>
Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
diff --git a/src/core/CL/kernels/CLIm2ColKernel.cpp b/src/core/CL/kernels/CLIm2ColKernel.cpp
index 00d9fcb..328b396 100644
--- a/src/core/CL/kernels/CLIm2ColKernel.cpp
+++ b/src/core/CL/kernels/CLIm2ColKernel.cpp
@@ -23,6 +23,7 @@
  */
 #include "arm_compute/core/CL/kernels/CLIm2ColKernel.h"
 
+#include "arm_compute/core/AccessWindowStatic.h"
 #include "arm_compute/core/CL/CLHelpers.h"
 #include "arm_compute/core/CL/CLKernelLibrary.h"
 #include "arm_compute/core/CL/CLValidate.h"
@@ -95,6 +96,13 @@
     const bool       squared_im2col    = kernel_dims.width == kernel_dims.height;
     const DataLayout data_layout       = input->info()->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);
+    const unsigned int input_width   = input->info()->dimension(width_idx);
+    const unsigned int input_height  = input->info()->dimension(height_idx);
+    const unsigned int input_channel = input->info()->dimension(channel_idx);
+
     if(!reduced)
     {
         // Default kernel name
@@ -107,13 +115,6 @@
             kernel_name = "im2col_generic_nhwc";
         }
 
-        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);
-        const unsigned int input_width   = input->info()->dimension(width_idx);
-        const unsigned int input_height  = input->info()->dimension(height_idx);
-        const unsigned int input_channel = input->info()->dimension(channel_idx);
-
         _convolved_dims = scaled_dimensions(input_width, input_height, kernel_dims.width, kernel_dims.height, conv_info, dilation);
 
         build_opts.add_option("-DKERNEL_WIDTH=" + support::cpp11::to_string(kernel_dims.width));
@@ -255,16 +256,14 @@
         }
         else
         {
+            const BorderSize border(conv_info.pad_top(), conv_info.pad_right(), conv_info.pad_bottom(), conv_info.pad_left());
             win = calculate_max_window(*input->info(),
-                                       Steps(_num_elems_processed_per_iteration),
-                                       false,
-                                       BorderSize(conv_info.pad_top(), conv_info.pad_right(), conv_info.pad_bottom(), conv_info.pad_left()));
-
-            const int             x = -conv_info.pad_left();
-            const int             y = -conv_info.pad_top();
-            const int             w = kernel_dims.width * _num_elems_processed_per_iteration;
-            const int             h = kernel_dims.height;
-            AccessWindowRectangle input_access(input->info(), x, y, w, h);
+                                       Steps(_num_elems_processed_per_iteration * conv_info.stride().first, conv_info.stride().second));
+            AccessWindowStatic input_access(input->info(),
+                                            -border.left,
+                                            -border.top,
+                                            ceil_to_multiple(input_width + border.right, kernel_dims.width),
+                                            input_height + border.bottom);
             update_window_and_padding(win, input_access);
         }
     }