blob: 3751178703c1eca6cbd15b33849a736cd9e59680 [file] [log] [blame]
Michalis Spyrou780db4e2017-11-23 09:49:51 +00001/*
Georgios Pinitasdbfc2dc2019-04-02 12:51:21 +01002 * Copyright (c) 2017-2019 ARM Limited.
Michalis Spyrou780db4e2017-11-23 09:49:51 +00003 *
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_CLDECONVOLUTIONLAYERUPSAMPLE_H__
25#define __ARM_COMPUTE_CLDECONVOLUTIONLAYERUPSAMPLE_H__
26
27#include "arm_compute/runtime/IFunction.h"
28
29#include "arm_compute/core/CL/kernels/CLDeconvolutionLayerUpsampleKernel.h"
Georgios Pinitasdbfc2dc2019-04-02 12:51:21 +010030#include "arm_compute/core/CL/kernels/CLMemsetKernel.h"
Michalis Spyrou780db4e2017-11-23 09:49:51 +000031#include "arm_compute/core/Types.h"
32#include "arm_compute/runtime/CL/CLMemoryGroup.h"
33#include "arm_compute/runtime/IFunction.h"
34#include "arm_compute/runtime/IMemoryManager.h"
35
36namespace arm_compute
37{
Georgios Pinitasdbfc2dc2019-04-02 12:51:21 +010038// Forward declarations
Michalis Spyrou780db4e2017-11-23 09:49:51 +000039class ICLTensor;
40
Georgios Pinitasdbfc2dc2019-04-02 12:51:21 +010041/** Basic function to execute deconvolution upsample on OpenCL. This function calls the following OpenCL kernels and functions:
42 *
43 * -# @ref CLMemsetKernel
44 * -# @ref CLDeconvolutionLayerUpsampleKernel
45 */
Michalis Spyrou780db4e2017-11-23 09:49:51 +000046class CLDeconvolutionLayerUpsample : public IFunction
47{
48public:
49 /** Default constructor */
50 CLDeconvolutionLayerUpsample();
51 /** Prevent instances of this class from being copied (As this class contains pointers) */
52 CLDeconvolutionLayerUpsample(const CLDeconvolutionLayerUpsample &) = delete;
53 /** Prevent instances of this class from being copied (As this class contains pointers) */
54 CLDeconvolutionLayerUpsample &operator=(const CLDeconvolutionLayerUpsample &) = delete;
55 /** Allow instances of this class to be moved */
56 CLDeconvolutionLayerUpsample(CLDeconvolutionLayerUpsample &&) = default;
57 /** Allow instances of this class to be moved */
58 CLDeconvolutionLayerUpsample &operator=(CLDeconvolutionLayerUpsample &&) = default;
59 /** Default destructor */
60 virtual ~CLDeconvolutionLayerUpsample() = default;
61
62 /** Initialize the function's source, destination, interpolation type and border_mode.
63 *
Michele Di Giorgio9fef38a2018-07-06 18:06:58 +010064 * @param[in, out] input Source tensor. Data type supported: QASYMM8/F16/F32.
65 * @param[out] output Destination tensor. Data type supported: same as @p input.
Michalis Spyrou780db4e2017-11-23 09:49:51 +000066 * @param[in] inner_border The number of zeros added to right and top edges of the input.
67 * @param[in] info Contains padding and policies to be used in the deconvolution.
68 */
69 void configure(ICLTensor *input, ICLTensor *output, const BorderSize &inner_border,
70 const PadStrideInfo &info);
71 /** Static function to check if given info will lead to a valid configuration of @ref CLDeconvolutionLayerUpsample
72 *
Michele Di Giorgio9fef38a2018-07-06 18:06:58 +010073 * @param[in] input Source tensor info. Data type supported: QASYMM8/F16/F32.
74 * @param[in] output Destination tensor info. Data type supported: same as @p input.
Michalis Spyrou780db4e2017-11-23 09:49:51 +000075 * @param[in] inner_border The number of zeros added to right and top edges of the input.
76 * @param[in] info Contains padding and policies to be used in the deconvolution.
77 *
78 * @return a status
79 */
80 static Status validate(const ITensorInfo *input, const ITensorInfo *output, const BorderSize &inner_border,
81 const PadStrideInfo &info);
82
83 // Inherited methods overridden:
84 void run() override;
85
86private:
87 CLDeconvolutionLayerUpsampleKernel _upsample;
Georgios Pinitasdbfc2dc2019-04-02 12:51:21 +010088 CLMemsetKernel _memset;
Michalis Spyrou780db4e2017-11-23 09:49:51 +000089 ICLTensor *_output;
90};
Georgios Pinitasdbfc2dc2019-04-02 12:51:21 +010091} // namespace arm_compute
Michalis Spyrou780db4e2017-11-23 09:49:51 +000092#endif /* __ARM_COMPUTE_CLDECONVOLUTIONLAYERUPSAMPLE_H__ */