blob: 04567ed95983867a2b89cf5d869843ac3b658517 [file] [log] [blame]
Michalis Spyrouafbc5ff2018-10-03 14:18:19 +01001/*
2 * Copyright (c) 2018 ARM Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#ifndef __ARM_COMPUTE_CPP_FLIP_WEIGHTS_KERNEL_H__
25#define __ARM_COMPUTE_CPP_FLIP_WEIGHTS_KERNEL_H__
26
27#include "arm_compute/core/CPP/ICPPKernel.h"
28
29namespace arm_compute
30{
31class ITensor;
32
33/** CPP kernel to perform 180 degrees flipping on deconvolution weights. */
34class CPPFlipWeightsKernel : public ICPPKernel
35{
36public:
37 const char *name() const override
38 {
39 return "CPPFlipWeightsKernel";
40 }
41 /** Default constructor */
42 CPPFlipWeightsKernel();
43 /** Prevent instances of this class from being copied (As this class contains pointers) */
44 CPPFlipWeightsKernel(const CPPFlipWeightsKernel &) = delete;
45 /** Prevent instances of this class from being copied (As this class contains pointers) */
46 CPPFlipWeightsKernel &operator=(const CPPFlipWeightsKernel &) = delete;
47 /** Allow instances of this class to be moved */
48 CPPFlipWeightsKernel(CPPFlipWeightsKernel &&) = default;
49 /** Allow instances of this class to be moved */
50 CPPFlipWeightsKernel &operator=(CPPFlipWeightsKernel &&) = default;
51 /** Default destructor */
52 ~CPPFlipWeightsKernel() = default;
53
54 /** Set the input and output of the kernel.
55 *
Michele Di Giorgioed5a4922018-09-13 16:22:01 +010056 * @param[in] input The input tensor to flip. Data types supported: QASYMM8/F16/F32. Data layouts supported: NCHW/NHWC.
Michalis Spyrouafbc5ff2018-10-03 14:18:19 +010057 * @param[out] output The output tensor. Data types supported: Same as @p input
58 */
59 void configure(const ITensor *input, ITensor *output);
60
61 // Inherited methods overridden:
62 void run(const Window &window, const ThreadInfo &info) override;
63
64 /** Function to perform flipping.
65 *
66 * @param[in] window_input Input region on which to execute the kernel.
Michalis Spyrouafbc5ff2018-10-03 14:18:19 +010067 */
68 template <typename T>
Michele Di Giorgioed5a4922018-09-13 16:22:01 +010069 void flip_weights(const Window &window_input);
Michalis Spyrouafbc5ff2018-10-03 14:18:19 +010070
71 /** Common signature for all the specialised Flip functions
72 *
73 * @param[in] window_input Input region on which to execute the kernel.
Michalis Spyrouafbc5ff2018-10-03 14:18:19 +010074 */
Michele Di Giorgioed5a4922018-09-13 16:22:01 +010075 using FlipWeightsFunction = void (CPPFlipWeightsKernel::*)(const Window &window_input);
Michalis Spyrouafbc5ff2018-10-03 14:18:19 +010076
77private:
78 const ITensor *_input;
79 ITensor *_output;
80 FlipWeightsFunction _func;
81};
82} // namespace arm_compute
83#endif /*__ARM_COMPUTE_CPP_FLIP_WEIGHTS_KERNEL_H__ */