1 /* 2 * Copyright (c) 2022 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_CL_TRANSPOSED_CONVOLUTION_H 25 #define ARM_COMPUTE_CL_TRANSPOSED_CONVOLUTION_H 26 27 #include "src/gpu/cl/ClCompileContext.h" 28 #include "src/gpu/cl/IClKernel.h" 29 #include "src/gpu/cl/IClOperator.h" 30 namespace arm_compute 31 { 32 namespace opencl 33 { 34 /** Basic function to simulate a directly convolution layer. This function calls the following OpenCL kernels: 35 * 36 * -# @ref opencl::ClTransposedConvolution 37 */ 38 class ClTransposedConvolution : public IClOperator 39 { 40 public: 41 /** Default constructor */ 42 ClTransposedConvolution() = default; 43 /** Default Destructor */ 44 ~ClTransposedConvolution() = default; 45 /** Prevent instances of this class from being copied (As this class contains pointers) */ 46 ClTransposedConvolution(const ClTransposedConvolution &) = delete; 47 /** Default move constructor */ 48 ClTransposedConvolution(ClTransposedConvolution &&) = default; 49 /** Prevent instances of this class from being copied (As this class contains pointers) */ 50 ClTransposedConvolution &operator=(const ClTransposedConvolution &) = delete; 51 /** Default move assignment operator */ 52 ClTransposedConvolution &operator=(ClTransposedConvolution &&) = default; 53 54 /** Set the input, weights, biases and output tensors. 55 * 56 * @note: Only NHWC data layout is supported 57 * 58 * @param[in] compile_context The compile context to be used. 59 * @param[in] input Input tensor info with dimensions [IFM, width, height, batch] 60 * Data types supported: F16/F32/QASYMM8/QASYMM8_SIGNED. 61 * @param[in] weights Weight tensor info with dimensions [IFM, width, height, OFM]. 62 * Data type supported: Same as @p input 63 * @param[in] biases (Optional) Biases tensor info. Biases are 1D tensor with dimension [OFM]. 64 * Data type supported: Should match @p input data type if floating point, otherwise S32. 65 * @param[out] output Output tensor info with dimensions [OFM, width, height, batch] 66 * The 1st dimension must be equal to the 4th dimension of the @p weights tensor. 67 * Data types supported: Same as @p input. 68 * @param[in] deconv_info Contains padding and stride information described in @ref PadStrideInfo. 69 * 70 */ 71 void configure(const CLCompileContext &compile_context, const ITensorInfo *input, const ITensorInfo *weights, 72 const ITensorInfo *biases, ITensorInfo *output, const PadStrideInfo &deconv_info); 73 /** Static function to check if given info will lead to a valid configuration 74 * 75 * Similar to ClTransposedConvolution::configure() 76 * 77 * @return a status 78 */ 79 static Status validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, 80 const ITensorInfo *output, const PadStrideInfo &deconv_info); 81 82 // Inherited method overridden 83 void run(ITensorPack &tensors) override; 84 85 private: 86 std::unique_ptr<IClKernel> _transposed_conv_kernel{ nullptr }; 87 }; 88 } // namespace opencl 89 } // namespace arm_compute 90 #endif /* ARM_COMPUTE_CL_TRANSPOSED_CONVOLUTION_H */