Transpose convolution valid padding test (#5998)
author오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Tue, 30 Jul 2019 07:52:30 +0000 (16:52 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Tue, 30 Jul 2019 07:52:30 +0000 (16:52 +0900)
* Transpose convolution valid padding test

- Add transpose convolution valid padding test
- Fix bug transpoe valid padding
- Update comment

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
* Update comment

runtimes/libs/ARMComputeEx/arm_compute/core/utils/misc/ShapeCalculatorEx.h
runtimes/libs/ARMComputeEx/arm_compute/runtime/CL/functions/CLTransposeConvLayer.h
runtimes/libs/ARMComputeEx/src/runtime/CL/functions/CLTransposeConvLayer.cpp
tests/framework/tests/transpose_conv/same/config.sh [moved from tests/framework/tests/transpose_conv/config.sh with 100% similarity]
tests/framework/tests/transpose_conv/valid/config.sh [new file with mode: 0644]

index 367129e..bacb114 100644 (file)
@@ -39,17 +39,20 @@ namespace shape_calculator
  * @param[in] weights            Weights tensor shape
  * @param[in] info               Padding and stride info
  * @param[in] out_dims           Output shape dimensions
- * @param[in] pad_left           Padding on left
- * @param[in] pad_right          Padding on right
- * @param[in] pad_top            Padding on top
- * @param[in] pad_bottom         Padding on bottom
+ * @param[in] invalid_right      The number of zeros added to right edge of the output.
+ * @param[in] invalid_bottom     The number of zeros added to bottom edge of the output.
+ * @param[out] pad_left          Padding on left
+ * @param[out] pad_right         Padding on right
+ * @param[out] pad_top           Padding on top
+ * @param[out] pad_bottom        Padding on bottom
  *
  * @return the calculated shape
  */
 inline TensorShape compute_transposeconv_upsampled_shape(
     const ITensorInfo &input, const ITensorInfo &weights, const PadStrideInfo &info,
-    std::pair<unsigned int, unsigned int> &out_dims, unsigned int &pad_left,
-    unsigned int &pad_right, unsigned int &pad_top, unsigned int &pad_bottom)
+    std::pair<unsigned int, unsigned int> &out_dims, unsigned int invalid_right,
+    unsigned int invalid_bottom, unsigned int &pad_left, unsigned int &pad_right,
+    unsigned int &pad_top, unsigned int &pad_bottom)
 {
   unsigned int sx = info.stride().first;
   unsigned int sy = info.stride().second;
@@ -75,12 +78,13 @@ inline TensorShape compute_transposeconv_upsampled_shape(
   out_x += padx;
   out_y += pady;
 
-  unsigned int padx_all = padx + info.pad_left() + info.pad_right();
-  unsigned int pady_all = pady + info.pad_top() + info.pad_bottom();
-  pad_left = (padx_all + 1) / 2 - info.pad_left();
-  pad_right = padx_all / 2 - info.pad_right();
-  pad_top = (pady_all + 1) / 2 - info.pad_top();
-  pad_bottom = pady_all / 2 - info.pad_bottom();
+  unsigned int padx_all_except_invallid = padx + info.pad_left() + info.pad_right() - invalid_right;
+  unsigned int pady_all_except_invallid =
+      pady + info.pad_top() + info.pad_bottom() - invalid_bottom;
+  pad_left = (padx_all_except_invallid + 1) / 2 - info.pad_left();
+  pad_right = pady_all_except_invallid / 2 - info.pad_right() + invalid_right;
+  pad_top = (padx_all_except_invallid + 1) / 2 - info.pad_top();
+  pad_bottom = pady_all_except_invallid / 2 - info.pad_bottom() + invalid_bottom;
 
   TensorShape scale_out_shape(input.tensor_shape());
   scale_out_shape.set(idx_w, out_x);
index 7b58ba2..340a7bf 100644 (file)
@@ -103,9 +103,9 @@ public:
    * @param[out]    output         Output tensor. The output has the same number of dimensions
    *                               as the @p input.
    * @param[in]     info           Contains padding and policies to be used in the
-   *                               deconvolution, this is decribed in @ref PadStrideInfo.
-   * @param[in]     invalid_right  The number of zeros added to right edge of the input.
-   * @param[in]     invalid_bottom The number of zeros added to top edge of the input.
+   *                               transpose convolution, this is decribed in @ref PadStrideInfo.
+   * @param[in]     invalid_right  The number of zeros added to right edge of the output.
+   * @param[in]     invalid_bottom The number of zeros added to top edge of the output.
    * @param[in]     weights_info   (Optional) Weights information needed for @ref
    *                               CLConvolutionLayer, specifies if the weights tensor has been
    *                               reshaped with @ref CLWeightsReshapeKernel.
@@ -125,10 +125,10 @@ public:
    *                            Same as @p input.
    * @param[in] output          Output tensor info. The output has the same number of dimensions
    *                            as the @p input.
-   * @param[in] info            Contains padding and policies to be used in the deconvolution,
-   *                            this is decribed in @ref PadStrideInfo.
-   * @param[in] innvalid_right  The number of zeros added to right edge of the input.
-   * @param[in] invalid_bottom  The number of zeros added to top edge of the input.
+   * @param[in] info            Contains padding and policies to be used in the
+   *                            transpose convolution, this is decribed in @ref PadStrideInfo.
+   * @param[in] innvalid_right  The number of zeros added to right edge of the output.
+   * @param[in] invalid_bottom  The number of zeros added to top edge of the output.
    * @param[in] weights_info    (Optional) Weights information needed for @ref CLConvolutionLayer,
    *                            specifies if the weights tensor has been reshaped with @ref
    *                            CLWeightsReshapeKernel.
index 55eb3ad..40e2167 100644 (file)
@@ -112,7 +112,8 @@ Status CLTransposeConvLayer::validate(const ITensorInfo *input, const ITensorInf
   unsigned int pad_top = 0;
   unsigned int pad_bottom = 0;
   const TensorShape scale_out_shape = compute_transposeconv_upsampled_shape(
-      *input, *weights, info, out_dims, pad_left, pad_right, pad_top, pad_bottom);
+      *input, *weights, info, out_dims, invalid_right, invalid_bottom, pad_left, pad_right, pad_top,
+      pad_bottom);
   TensorInfo scale_out_info(input->clone()
                                 ->set_is_resizable(true)
                                 .reset_padding()
@@ -178,7 +179,8 @@ void CLTransposeConvLayer::configure(ICLTensor *input, ICLTensor *weights, const
   unsigned int pad_top = 0;
   unsigned int pad_bottom = 0;
   const TensorShape scale_out_shape = compute_transposeconv_upsampled_shape(
-      *input->info(), *weights->info(), info, out_dims, pad_left, pad_right, pad_top, pad_bottom);
+      *input->info(), *weights->info(), info, out_dims, invalid_right, invalid_bottom, pad_left,
+      pad_right, pad_top, pad_bottom);
 
   TensorInfo scale_out_info(scale_out_shape, 1, input->info()->data_type(),
                             input->info()->quantization_info());
diff --git a/tests/framework/tests/transpose_conv/valid/config.sh b/tests/framework/tests/transpose_conv/valid/config.sh
new file mode 100644 (file)
index 0000000..d162331
--- /dev/null
@@ -0,0 +1 @@
+MODELFILE_NAME="transpose_conv_valid_test.tflite"