Set CLDirectConvolutionLayerKernel NCHW _border_size to input padding
authorGiorgio Arena <giorgio.arena@arm.com>
Wed, 17 Feb 2021 16:04:05 +0000 (16:04 +0000)
committerGiorgio Arena <giorgio.arena@arm.com>
Thu, 18 Feb 2021 14:01:18 +0000 (14:01 +0000)
Change-Id: I5802c470683647b7426b3b6e7d17280cabc32163
Signed-off-by: Giorgio Arena <giorgio.arena@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5100
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Michalis Spyrou <michalis.spyrou@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>

src/core/CL/kernels/CLDirectConvolutionLayerKernel.cpp
src/core/CL/kernels/CLDirectConvolutionLayerKernel.h

index 3948261bc368ac961553ea4ea2f0714f000f91a5..2fc3c60f6763cc8d4d04a8517051ee36f1e314aa 100644 (file)
@@ -317,7 +317,7 @@ std::pair<Status, Window> validate_and_configure_window(ITensorInfo *input, ITen
 } // namespace
 
 CLDirectConvolutionLayerKernel::CLDirectConvolutionLayerKernel()
-    : _input(nullptr), _biases(nullptr), _weights(nullptr), _output(nullptr), _data_layout(DataLayout::UNKNOWN), _border_size(0), _conv_stride_x(0), _conv_stride_y(0)
+    : _input(nullptr), _biases(nullptr), _weights(nullptr), _output(nullptr), _data_layout(DataLayout::UNKNOWN), _border_size(0), _conv_stride_x(0), _conv_stride_y(0), _conv_info()
 {
 }
 
@@ -350,6 +350,7 @@ void CLDirectConvolutionLayerKernel::configure(const CLCompileContext &compile_c
     _weights       = weights;
     _output        = output;
     _biases        = biases;
+    _conv_info     = conv_info;
 
     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);
@@ -381,7 +382,7 @@ void CLDirectConvolutionLayerKernel::configure(const CLCompileContext &compile_c
         const unsigned int pad_left         = conv_info.pad_left();
         const unsigned int pad_top          = conv_info.pad_top();
 
-        if (_biases != nullptr)
+        if(_biases != nullptr)
         {
             build_options.add_option(std::string("-DHAS_BIAS"));
             build_options.add_option(std::string("-DBIA_DATA_TYPE=" + get_cl_type_from_data_type(_biases->info()->data_type())));
@@ -440,7 +441,7 @@ void CLDirectConvolutionLayerKernel::configure(const CLCompileContext &compile_c
     }
     else
     {
-        _border_size = BorderSize(conv_info.pad_top(), conv_info.pad_right(), conv_info.pad_bottom(), conv_info.pad_left());
+        _border_size = BorderSize(_input->info()->padding());
 
         kernel_name << "direct_convolution" << kernel_size << "x" << kernel_size;
 
@@ -549,8 +550,8 @@ void CLDirectConvolutionLayerKernel::run(const Window &window, cl::CommandQueue
     {
         Window win_in = window;
 
-        win_in.adjust(Window::DimX, -_border_size.left, true);
-        win_in.adjust(Window::DimY, -_border_size.top, true);
+        win_in.adjust(Window::DimX, -_conv_info.pad_left(), true);
+        win_in.adjust(Window::DimY, -_conv_info.pad_top(), true);
 
         const int width_idx  = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::WIDTH);
         const int height_idx = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::HEIGHT);
index 5cd674f6315f254694015634040074b29a8f18d1..0257d0c2dd0165e2e43d294374b857ed08eb494c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017-2020 Arm Limited.
+ * Copyright (c) 2017-2021 Arm Limited.
  *
  * SPDX-License-Identifier: MIT
  *
@@ -120,6 +120,7 @@ public:
     BorderSize       _border_size;
     int              _conv_stride_x;
     int              _conv_stride_y;
+    PadStrideInfo    _conv_info;
 };
 } // namespace arm_compute
 #endif /*ARM_COMPUTE_CLDIRECTCONVOLUTIONLAYERKERNEL_H */