From afbc5ffb0b567ae93fa2765066bd136d72be88ff Mon Sep 17 00:00:00 2001 From: Michalis Spyrou Date: Wed, 3 Oct 2018 14:18:19 +0100 Subject: COMPMID-1621 Deconvolution wrong output calculation Change-Id: Ida71312bcf6dbd854f2ab1efc65f74910c79e152 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/151510 Tested-by: bsgcomp Reviewed-by: Michele DiGiorgio --- arm_compute/core/CPP/CPPKernels.h | 1 + .../core/CPP/kernels/CPPFlipWeightsKernel.h | 85 ++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 arm_compute/core/CPP/kernels/CPPFlipWeightsKernel.h (limited to 'arm_compute/core/CPP') diff --git a/arm_compute/core/CPP/CPPKernels.h b/arm_compute/core/CPP/CPPKernels.h index a0c5707a79..bf24a94aa7 100644 --- a/arm_compute/core/CPP/CPPKernels.h +++ b/arm_compute/core/CPP/CPPKernels.h @@ -27,6 +27,7 @@ /* Header regrouping all the CPP kernels */ #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/CPPPermuteKernel.h" #include "arm_compute/core/CPP/kernels/CPPSortEuclideanDistanceKernel.h" #include "arm_compute/core/CPP/kernels/CPPUpsampleKernel.h" diff --git a/arm_compute/core/CPP/kernels/CPPFlipWeightsKernel.h b/arm_compute/core/CPP/kernels/CPPFlipWeightsKernel.h new file mode 100644 index 0000000000..801934159d --- /dev/null +++ b/arm_compute/core/CPP/kernels/CPPFlipWeightsKernel.h @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2018 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 + * @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. + * @param[in] window Output region on which to execute the kernel. + */ + template + void flip_weights(const Window &window_input, const Window &window); + + /** Common signature for all the specialised Flip functions + * + * @param[in] window_input Input region on which to execute the kernel. + * @param[in] window Output region on which to execute the kernel. + */ + using FlipWeightsFunction = void (CPPFlipWeightsKernel::*)(const Window &window_input, const Window &window); + +private: + const ITensor *_input; + ITensor *_output; + FlipWeightsFunction _func; +}; +} // namespace arm_compute +#endif /*__ARM_COMPUTE_CPP_FLIP_WEIGHTS_KERNEL_H__ */ -- cgit v1.2.1