Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 1 | /* |
Georgios Pinitas | dbfc2dc | 2019-04-02 12:51:21 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2019 ARM Limited. |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 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_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 Pinitas | dbfc2dc | 2019-04-02 12:51:21 +0100 | [diff] [blame] | 30 | #include "arm_compute/core/CL/kernels/CLMemsetKernel.h" |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 31 | #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 | |
| 36 | namespace arm_compute |
| 37 | { |
Georgios Pinitas | dbfc2dc | 2019-04-02 12:51:21 +0100 | [diff] [blame] | 38 | // Forward declarations |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 39 | class ICLTensor; |
| 40 | |
Georgios Pinitas | dbfc2dc | 2019-04-02 12:51:21 +0100 | [diff] [blame] | 41 | /** 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 Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 46 | class CLDeconvolutionLayerUpsample : public IFunction |
| 47 | { |
| 48 | public: |
| 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 Giorgio | 9fef38a | 2018-07-06 18:06:58 +0100 | [diff] [blame] | 64 | * @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 Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 66 | * @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 Giorgio | 9fef38a | 2018-07-06 18:06:58 +0100 | [diff] [blame] | 73 | * @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 Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 75 | * @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 | |
| 86 | private: |
| 87 | CLDeconvolutionLayerUpsampleKernel _upsample; |
Georgios Pinitas | dbfc2dc | 2019-04-02 12:51:21 +0100 | [diff] [blame] | 88 | CLMemsetKernel _memset; |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 89 | ICLTensor *_output; |
| 90 | }; |
Georgios Pinitas | dbfc2dc | 2019-04-02 12:51:21 +0100 | [diff] [blame] | 91 | } // namespace arm_compute |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 92 | #endif /* __ARM_COMPUTE_CLDECONVOLUTIONLAYERUPSAMPLE_H__ */ |