1 /* 2 * Copyright (c) 2020 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_CLMAXUNPOOLINGLAYER_H 25 #define ARM_COMPUTE_CLMAXUNPOOLINGLAYER_H 26 27 #include "arm_compute/core/Error.h" 28 #include "arm_compute/runtime/IFunction.h" 29 30 #include <memory> 31 32 namespace arm_compute 33 { 34 class CLCompileContext; 35 class ICLTensor; 36 class ITensorInfo; 37 class CLMaxUnpoolingLayerKernel; 38 class CLMemsetKernel; 39 struct PoolingLayerInfo; 40 41 /** Function to perform MaxUnpooling. This function calls the following OpenCL kernels: 42 * 43 * -# @ref CLMemsetKernel 44 * -# @ref CLMaxUnpoolingLayerKernel 45 */ 46 class CLMaxUnpoolingLayer : public IFunction 47 { 48 public: 49 /** Constructor */ 50 CLMaxUnpoolingLayer(); 51 /** Prevent instances of this class from being copied */ 52 CLMaxUnpoolingLayer(const CLMaxUnpoolingLayer &) = delete; 53 /** Prevent instances of this class from being copied */ 54 CLMaxUnpoolingLayer &operator=(const CLMaxUnpoolingLayer &) = delete; 55 /** Default destructor */ 56 ~CLMaxUnpoolingLayer(); 57 /** Set the input and output tensors. 58 * 59 * @note Output shape must be equal to the shape of the original input to pool. 60 * 61 * @param[in] input Source tensor. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32. 62 * @param[in] indices Tensor containing the offset to store the input elements in the output tensor. 63 * @ref CLPoolingLayer with indices should precede this function in order to 64 * properly reconstruct the output tensor. 65 * The tensor shape of this tensor has to be equal to the input tensor shape. Data type supported: U32. 66 * @param[out] output Destination tensor. Data types supported: Same as @p input. 67 * @param[in] pool_info Contains pooling operation information described in @ref PoolingLayerInfo. 68 */ 69 void configure(ICLTensor *input, ICLTensor *indices, ICLTensor *output, const PoolingLayerInfo &pool_info); 70 /** Set the input and output tensors. 71 * 72 * @note Output shape must be equal to the shape of the original input to pool. 73 * 74 * @param[in] compile_context The compile context to be used. 75 * @param[in] input Source tensor. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32. 76 * @param[in] indices Tensor containing the offset to store the input elements in the output tensor. 77 * @ref CLPoolingLayer with indices should precede this function in order to 78 * properly reconstruct the output tensor. 79 * The tensor shape of this tensor has to be equal to the input tensor shape. Data type supported: U32. 80 * @param[out] output Destination tensor. Data types supported: Same as @p input. 81 * @param[in] pool_info Contains pooling operation information described in @ref PoolingLayerInfo. 82 */ 83 void configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *indices, ICLTensor *output, const PoolingLayerInfo &pool_info); 84 /** Static function to check if given info will lead to a valid configuration of @ref CLMaxUnpoolingLayer 85 * 86 * @param[in] input Source tensor info. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32. 87 * @param[in] output Destination tensor info. Data types supported: Same as @p input. 88 * @param[in] indices TensorInfo associated to the tensor containing the offset to store the input elements in the output tensor. 89 * @ref CLPoolingLayer with indices should precede this function in order to 90 * properly reconstruct the output tensor. 91 * The tensor shape of this tensor has to be equal to the input tensor shape. Data type supported: U32. 92 * @param[in] pool_info Contains pooling operation information described in @ref PoolingLayerInfo. 93 * 94 * @return a status 95 */ 96 static Status validate(const ITensorInfo *input, const ITensorInfo *indices, const ITensorInfo *output, const PoolingLayerInfo &pool_info); 97 98 // Inherited methods overridden: 99 void run() override; 100 101 private: 102 std::unique_ptr<CLMemsetKernel> _memset_kernel; 103 std::unique_ptr<CLMaxUnpoolingLayerKernel> _unpooling_layer_kernel; 104 }; 105 } 106 #endif /* ARM_COMPUTE_CLMAXUNPOOLINGLAYER_H */ 107