Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 1 | /* |
giuros01 | a69a88b | 2019-01-31 16:29:19 +0000 | [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_CLDECONVOLUTIONLAYER_H__ |
| 25 | #define __ARM_COMPUTE_CLDECONVOLUTIONLAYER_H__ |
| 26 | |
giuros01 | 4a8ec80 | 2019-03-18 13:25:05 +0000 | [diff] [blame^] | 27 | #include "arm_compute/runtime/CL/functions/CLDirectDeconvolutionLayer.h" |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 28 | #include "arm_compute/runtime/IFunction.h" |
| 29 | #include "arm_compute/runtime/IMemoryManager.h" |
| 30 | |
| 31 | #include <memory> |
| 32 | |
| 33 | namespace arm_compute |
| 34 | { |
giuros01 | 4a8ec80 | 2019-03-18 13:25:05 +0000 | [diff] [blame^] | 35 | /** Basic function to compute the deconvolution layer. This function calls the following OpenCL kernels/functions: |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 36 | * |
giuros01 | 4a8ec80 | 2019-03-18 13:25:05 +0000 | [diff] [blame^] | 37 | * -# @ref CLDirectDeconvolutionLayer |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 38 | */ |
| 39 | class CLDeconvolutionLayer : public IFunction |
| 40 | { |
| 41 | public: |
giuros01 | 4a8ec80 | 2019-03-18 13:25:05 +0000 | [diff] [blame^] | 42 | /** Default constructor */ |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 43 | CLDeconvolutionLayer(std::shared_ptr<IMemoryManager> memory_manager = nullptr); |
giuros01 | 4a8ec80 | 2019-03-18 13:25:05 +0000 | [diff] [blame^] | 44 | |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 45 | /** Set the input, weights, biases and output tensors. |
| 46 | * |
Manuel Bottini | 581c898 | 2019-02-07 10:31:57 +0000 | [diff] [blame] | 47 | * @deprecated This method is deprecated and will be removed in release 19.05 |
giuros01 | a69a88b | 2019-01-31 16:29:19 +0000 | [diff] [blame] | 48 | * |
Michele Di Giorgio | 9fef38a | 2018-07-06 18:06:58 +0100 | [diff] [blame] | 49 | * @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: QASYMM8/F16/F32. |
Michalis Spyrou | a8ca2b0 | 2018-04-04 11:03:51 +0100 | [diff] [blame] | 50 | * @param[in] weights The 4d weights with dimensions [width, height, IFM, OFM]. Data type supported: Same as @p input. |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 51 | * @param[in] bias (Optional) The biases have one dimension. Data type supported: Same as @p input. |
| 52 | * @param[out] output Output tensor. The output has the same number of dimensions as the @p input. |
giuros01 | 4a8ec80 | 2019-03-18 13:25:05 +0000 | [diff] [blame^] | 53 | * @param[in] deconv_info Contains padding and policies to be used in the deconvolution, this is described in @ref PadStrideInfo. |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 54 | * @param[in] inner_border_right The number of zeros added to right edge of the input. |
| 55 | * @param[in] inner_border_top The number of zeros added to top edge of the input. |
Michele Di Giorgio | 70ba7d6 | 2018-06-06 17:03:36 +0100 | [diff] [blame] | 56 | * @param[in] weights_info (Optional) Weights information needed for @ref CLConvolutionLayer, specifies if the weights tensor has been reshaped with @ref CLWeightsReshapeKernel. |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 57 | * |
| 58 | */ |
giuros01 | 4a8ec80 | 2019-03-18 13:25:05 +0000 | [diff] [blame^] | 59 | void configure(ICLTensor *input, ICLTensor *weights, const ICLTensor *bias, ICLTensor *output, const PadStrideInfo &deconv_info, |
Michele Di Giorgio | 70ba7d6 | 2018-06-06 17:03:36 +0100 | [diff] [blame] | 60 | unsigned int inner_border_right, unsigned int inner_border_top, const WeightsInfo &weights_info = WeightsInfo()); |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 61 | /** Static function to check if given info will lead to a valid configuration of @ref CLDeconvolutionLayer |
| 62 | * |
Manuel Bottini | 581c898 | 2019-02-07 10:31:57 +0000 | [diff] [blame] | 63 | * @deprecated This method is deprecated and will be removed in release 19.05 |
giuros01 | a69a88b | 2019-01-31 16:29:19 +0000 | [diff] [blame] | 64 | * |
Michele Di Giorgio | 9fef38a | 2018-07-06 18:06:58 +0100 | [diff] [blame] | 65 | * @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: QASYMM8/F16/F32. |
Michalis Spyrou | a8ca2b0 | 2018-04-04 11:03:51 +0100 | [diff] [blame] | 66 | * @param[in] weights The 4d weights info with dimensions [width, height, IFM, OFM]. Data type supported: Same as @p input. |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 67 | * @param[in] bias (Optional) The biases have one dimension. Data type supported: Same as @p input. |
| 68 | * @param[in] output Output tensor info. The output has the same number of dimensions as the @p input. |
giuros01 | 4a8ec80 | 2019-03-18 13:25:05 +0000 | [diff] [blame^] | 69 | * @param[in] deconv_info Contains padding and policies to be used in the deconvolution, this is described in @ref PadStrideInfo. |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 70 | * @param[in] inner_border_right The number of zeros added to right edge of the input. |
| 71 | * @param[in] inner_border_top The number of zeros added to top edge of the input. |
Michele Di Giorgio | 70ba7d6 | 2018-06-06 17:03:36 +0100 | [diff] [blame] | 72 | * @param[in] weights_info (Optional) Weights information needed for @ref CLConvolutionLayer, specifies if the weights tensor has been reshaped with @ref CLWeightsReshapeKernel. |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 73 | * |
| 74 | * @return a status |
| 75 | */ |
giuros01 | 4a8ec80 | 2019-03-18 13:25:05 +0000 | [diff] [blame^] | 76 | static Status validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *bias, ITensorInfo *output, const PadStrideInfo &deconv_info, |
Michele Di Giorgio | 70ba7d6 | 2018-06-06 17:03:36 +0100 | [diff] [blame] | 77 | unsigned int inner_border_right, unsigned int inner_border_top, const WeightsInfo &weights_info = WeightsInfo()); |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 78 | |
giuros01 | a69a88b | 2019-01-31 16:29:19 +0000 | [diff] [blame] | 79 | /** Set the input, weights, biases and output tensors. |
| 80 | * |
| 81 | * @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: QASYMM8/F16/F32. |
| 82 | * @param[in] weights The 4d weights with dimensions [width, height, IFM, OFM]. Data type supported: Same as @p input. |
| 83 | * @param[in] bias (Optional) The biases have one dimension. Data type supported: Same as @p input. |
| 84 | * @param[out] output Output tensor. The output has the same number of dimensions as the @p input. |
giuros01 | 4a8ec80 | 2019-03-18 13:25:05 +0000 | [diff] [blame^] | 85 | * @param[in] deconv_info Contains padding and policies to be used in the deconvolution, this is described in @ref PadStrideInfo. |
giuros01 | a69a88b | 2019-01-31 16:29:19 +0000 | [diff] [blame] | 86 | * @param[in] weights_info (Optional) Weights information needed for @ref CLConvolutionLayer, specifies if the weights tensor has been reshaped with @ref CLWeightsReshapeKernel. |
| 87 | * |
| 88 | */ |
giuros01 | 4a8ec80 | 2019-03-18 13:25:05 +0000 | [diff] [blame^] | 89 | void configure(ICLTensor *input, ICLTensor *weights, const ICLTensor *bias, ICLTensor *output, const PadStrideInfo &deconv_info, const WeightsInfo &weights_info = WeightsInfo()); |
giuros01 | a69a88b | 2019-01-31 16:29:19 +0000 | [diff] [blame] | 90 | /** Static function to check if given info will lead to a valid configuration of @ref CLDeconvolutionLayer |
| 91 | * |
| 92 | * @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: QASYMM8/F16/F32. |
| 93 | * @param[in] weights The 4d weights info with dimensions [width, height, IFM, OFM]. Data type supported: Same as @p input. |
| 94 | * @param[in] bias (Optional) The biases have one dimension. Data type supported: Same as @p input. |
| 95 | * @param[in] output Output tensor info. The output has the same number of dimensions as the @p input. |
giuros01 | 4a8ec80 | 2019-03-18 13:25:05 +0000 | [diff] [blame^] | 96 | * @param[in] deconv_info Contains padding and policies to be used in the deconvolution, this is described in @ref PadStrideInfo. |
giuros01 | a69a88b | 2019-01-31 16:29:19 +0000 | [diff] [blame] | 97 | * @param[in] weights_info (Optional) Weights information needed for @ref CLConvolutionLayer, specifies if the weights tensor has been reshaped with @ref CLWeightsReshapeKernel. |
| 98 | * |
| 99 | * @return a status |
| 100 | */ |
giuros01 | 4a8ec80 | 2019-03-18 13:25:05 +0000 | [diff] [blame^] | 101 | static Status validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *bias, ITensorInfo *output, const PadStrideInfo &deconv_info, |
| 102 | const WeightsInfo &weights_info = WeightsInfo()); |
giuros01 | a69a88b | 2019-01-31 16:29:19 +0000 | [diff] [blame] | 103 | |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 104 | // Inherited methods overridden: |
| 105 | void run() override; |
Georgios Pinitas | 7221933 | 2018-06-05 14:56:06 +0100 | [diff] [blame] | 106 | void prepare() override; |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 107 | |
| 108 | private: |
giuros01 | 4a8ec80 | 2019-03-18 13:25:05 +0000 | [diff] [blame^] | 109 | std::shared_ptr<IMemoryManager> _memory_manager; |
| 110 | std::unique_ptr<IFunction> _function; |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 111 | }; |
| 112 | } |
Michele Di Giorgio | 70ba7d6 | 2018-06-06 17:03:36 +0100 | [diff] [blame] | 113 | #endif /* __ARM_COMPUTE_CLDECONVOLUTIONLAYER_H__ */ |