From fedefc3a8d76b9dea5945414324427ef5a01835d Mon Sep 17 00:00:00 2001 From: Luca Foschiani Date: Mon, 17 Feb 2020 17:02:49 +0000 Subject: COMPMID-2765 Add support for QASYMM8_SIGNED in NEDeconvolutionLayer Signed-off-by: Luca Foschiani Change-Id: I8295fadee15311a9ab846aa24c031b82c0b799eb Signed-off-by: Michalis Spyrou Signed-off-by: Michele Di Giorgio Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/2952 Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Sheri Zhang --- arm_compute/core/CPP/CPPKernels.h | 3 +- .../core/CPP/kernels/CPPFlipWeightsKernel.h | 83 ---------------------- .../CL/functions/CLDirectDeconvolutionLayer.h | 4 +- .../runtime/NEON/functions/NEDeconvolutionLayer.h | 51 ++++++------- 4 files changed, 30 insertions(+), 111 deletions(-) delete mode 100644 arm_compute/core/CPP/kernels/CPPFlipWeightsKernel.h (limited to 'arm_compute') diff --git a/arm_compute/core/CPP/CPPKernels.h b/arm_compute/core/CPP/CPPKernels.h index d12cb2857a..c7b40baf22 100644 --- a/arm_compute/core/CPP/CPPKernels.h +++ b/arm_compute/core/CPP/CPPKernels.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 ARM Limited. + * Copyright (c) 2017-2020 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -28,7 +28,6 @@ #include "arm_compute/core/CPP/kernels/CPPBoxWithNonMaximaSuppressionLimitKernel.h" #include "arm_compute/core/CPP/kernels/CPPCornerCandidatesKernel.h" #include "arm_compute/core/CPP/kernels/CPPDetectionWindowNonMaximaSuppressionKernel.h" -#include "arm_compute/core/CPP/kernels/CPPFlipWeightsKernel.h" #include "arm_compute/core/CPP/kernels/CPPNonMaximumSuppressionKernel.h" #include "arm_compute/core/CPP/kernels/CPPPermuteKernel.h" #include "arm_compute/core/CPP/kernels/CPPSortEuclideanDistanceKernel.h" diff --git a/arm_compute/core/CPP/kernels/CPPFlipWeightsKernel.h b/arm_compute/core/CPP/kernels/CPPFlipWeightsKernel.h deleted file mode 100644 index 285aa585be..0000000000 --- a/arm_compute/core/CPP/kernels/CPPFlipWeightsKernel.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2018-2019 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_CPP_FLIP_WEIGHTS_KERNEL_H -#define ARM_COMPUTE_CPP_FLIP_WEIGHTS_KERNEL_H - -#include "arm_compute/core/CPP/ICPPKernel.h" - -namespace arm_compute -{ -class ITensor; - -/** CPP kernel to perform 180 degrees flipping on deconvolution weights. */ -class CPPFlipWeightsKernel : public ICPPKernel -{ -public: - const char *name() const override - { - return "CPPFlipWeightsKernel"; - } - /** Default constructor */ - CPPFlipWeightsKernel(); - /** Prevent instances of this class from being copied (As this class contains pointers) */ - CPPFlipWeightsKernel(const CPPFlipWeightsKernel &) = delete; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - CPPFlipWeightsKernel &operator=(const CPPFlipWeightsKernel &) = delete; - /** Allow instances of this class to be moved */ - CPPFlipWeightsKernel(CPPFlipWeightsKernel &&) = default; - /** Allow instances of this class to be moved */ - CPPFlipWeightsKernel &operator=(CPPFlipWeightsKernel &&) = default; - /** Default destructor */ - ~CPPFlipWeightsKernel() = default; - - /** Set the input and output of the kernel. - * - * @param[in] input The input tensor to flip. Data types supported: QASYMM8/F16/F32. Data layouts supported: NCHW/NHWC. - * @param[out] output The output tensor. Data types supported: Same as @p input - */ - void configure(const ITensor *input, ITensor *output); - - // Inherited methods overridden: - void run(const Window &window, const ThreadInfo &info) override; - - /** Function to perform flipping. - * - * @param[in] window_input Input region on which to execute the kernel. - */ - template - void flip_weights(const Window &window_input); - - /** Common signature for all the specialised Flip functions - * - * @param[in] window_input Input region on which to execute the kernel. - */ - using FlipWeightsFunction = void (CPPFlipWeightsKernel::*)(const Window &window_input); - -private: - const ITensor *_input; - ITensor *_output; - FlipWeightsFunction _func; -}; -} // namespace arm_compute -#endif /*ARM_COMPUTE_CPP_FLIP_WEIGHTS_KERNEL_H */ diff --git a/arm_compute/runtime/CL/functions/CLDirectDeconvolutionLayer.h b/arm_compute/runtime/CL/functions/CLDirectDeconvolutionLayer.h index 76cd0fb0c2..6632bfce80 100644 --- a/arm_compute/runtime/CL/functions/CLDirectDeconvolutionLayer.h +++ b/arm_compute/runtime/CL/functions/CLDirectDeconvolutionLayer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 ARM Limited. + * Copyright (c) 2019-2020 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -61,7 +61,7 @@ class ICLTensor; * stride_x and stride_y is the input stride of the first and second dimension. * * The weights used by Deconvolution are supposed to be the same as the ones used for Convolution. Therefore, it will be necessary to use the weights in the - * reverse order to perform an actual convolution. This is achieved by using the @ref CPPFlipWeightsKernel. + * reverse order to perform an actual convolution. This is achieved by using @ref CLReverse. * * This function calls the following OpenCL kernels/functions: * diff --git a/arm_compute/runtime/NEON/functions/NEDeconvolutionLayer.h b/arm_compute/runtime/NEON/functions/NEDeconvolutionLayer.h index d031076ee7..c4c1664f20 100644 --- a/arm_compute/runtime/NEON/functions/NEDeconvolutionLayer.h +++ b/arm_compute/runtime/NEON/functions/NEDeconvolutionLayer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 ARM Limited. + * Copyright (c) 2017-2020 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -27,8 +27,8 @@ #include "arm_compute/runtime/CPP/functions/CPPUpsample.h" #include "arm_compute/runtime/NEON/functions/NEConvolutionLayer.h" #include "arm_compute/runtime/NEON/functions/NEDirectConvolutionLayer.h" +#include "arm_compute/runtime/NEON/functions/NEReverse.h" -#include "arm_compute/core/CPP/kernels/CPPFlipWeightsKernel.h" #include "arm_compute/core/Types.h" #include "arm_compute/runtime/IFunction.h" #include "arm_compute/runtime/IMemoryManager.h" @@ -62,12 +62,14 @@ namespace arm_compute * stride_x and stride_y is the input stride of the first and second dimension. * * The weights used by Deconvolution are supposed to be the same as the ones used for Convolution. Therefore, it will be necessary to use the weights in the - * reverse order to perform an actual convolution. This is achieved by using the @ref CPPFlipWeightsKernel. + * reverse order to perform an actual convolution. This is achieved by using @ref NEReverse. * * This function calls the following NEON kernels/functions: * * -# @ref CPPUpsample * -# @ref NEConvolutionLayer + * -# @ref NEPermute + * -# @ref NEReverse * */ class NEDeconvolutionLayer : public IFunction @@ -89,9 +91,9 @@ public: /** Set the input, weights, biases and output tensors. * - * @param[in,out] input Input tensor. 3 lower dimensions represent a single input, and an optional 4th dimension for batch of inputs. Data types supported: F32/F16/QASYMM8. + * @param[in,out] input Input tensor. 3 lower dimensions represent a single input, and an optional 4th dimension for batch of inputs. Data types supported: F32/F16/QASYMM8/QASYMM8_SIGNED. * @param[in] weights The 4d weights with dimensions [width, height, IFM, OFM]. Data type supported: Same as @p input. - * @param[in] bias Optional, ignored if NULL. The biases have one dimension. Data type supported: Data types supported: S32 for QASYMM8 input, F32 for F32 input, F16 for F16 input. + * @param[in] bias Optional, ignored if NULL. The biases have one dimension. Data type supported: Data types supported: S32 for QASYMM8 and QASYMM8_SIGNED input, F32 for F32 input, F16 for F16 input. * @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. * @@ -99,9 +101,9 @@ public: void configure(ITensor *input, const ITensor *weights, const ITensor *bias, ITensor *output, const PadStrideInfo &info); /** Static function to check if given info will lead to a valid configuration of @ref NEDeconvolutionLayer * - * @param[in] input Input tensor info. 3 lower dimensions represent a single input, and an optional 4th dimension for batch of inputs. Data types supported: F32/F16/QASYMM8. + * @param[in] input Input tensor info. 3 lower dimensions represent a single input, and an optional 4th dimension for batch of inputs. Data types supported: F32/F16/QASYMM8/QASYMM8_SIGNED. * @param[in] weights The 4d weights info with dimensions [width, height, IFM, OFM]. Data type supported: Same as @p input. - * @param[in] bias (Optional) The biases have one dimension. Data type supported: Data types supported: S32 for QASYMM8 input, F32 for F32 input, F16 for F16 input. + * @param[in] bias (Optional) The biases have one dimension. Data type supported: Data types supported: S32 for QASYMM8 and QASYMM8_SIGNED input, F32 for F32 input, F16 for F16 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. * @@ -114,23 +116,24 @@ public: void prepare() override; private: - MemoryGroup _memory_group; - NEConvolutionLayer _conv_f; - CPPUpsample _upsample_f; - CPPFlipWeightsKernel _flip_weights; - NEPermute _permute_input; - NEPermute _permute_weights; - NEPermute _permute_output; - Tensor _scaled_output; - Tensor _weights_flipped; - Tensor _permuted_input; - Tensor _permuted_weights; - Tensor _permuted_output; - bool _is_nchw; - const ITensor *_original_weights; - ITensor *_input; - PadStrideInfo _info; - bool _is_prepared; + MemoryGroup _memory_group; + NEConvolutionLayer _conv_f; + CPPUpsample _upsample_f; + NEReverse _flip_weights; + NEPermute _permute_input; + NEPermute _permute_weights; + NEPermute _permute_output; + Tensor _scaled_output; + Tensor _weights_flipped; + Tensor _permuted_input; + Tensor _permuted_weights; + Tensor _permuted_output; + Tensor _flip_axis; + bool _is_nchw; + const ITensor *_original_weights; + ITensor *_input; + PadStrideInfo _info; + bool _is_prepared; }; } // arm_compute #endif /* ARM_COMPUTE_NEDECONVOLUTIONLAYER_H */ -- cgit v1.2.1