blob: cc96cf1a1f9209e3cb12277deb7aa7e7ccb1638b [file] [log] [blame]
Gian Marco Iodice4d81d752020-07-14 15:05:31 +01001/*
Michele Di Giorgioe1314662021-02-01 17:09:32 +00002 * Copyright (c) 2020-2021 Arm Limited.
Gian Marco Iodice4d81d752020-07-14 15:05:31 +01003 *
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_CLMAXUNPOOLINGLAYERKERNEL_H
25#define ARM_COMPUTE_CLMAXUNPOOLINGLAYERKERNEL_H
26
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010027#include "src/core/CL/ICLKernel.h"
Gian Marco Iodice4d81d752020-07-14 15:05:31 +010028
29namespace arm_compute
30{
31class ICLTensor;
32
33/** Interface for the pooling layer kernel */
34class CLMaxUnpoolingLayerKernel : public ICLKernel
35{
36public:
37 /** Default constructor */
38 CLMaxUnpoolingLayerKernel();
39 /** Prevent instances of this class from being copied (As this class contains pointers) */
40 CLMaxUnpoolingLayerKernel(const CLMaxUnpoolingLayerKernel &) = delete;
41 /** Prevent instances of this class from being copied (As this class contains pointers) */
42 CLMaxUnpoolingLayerKernel &operator=(const CLMaxUnpoolingLayerKernel &) = delete;
43 /** Allow instances of this class to be moved */
44 CLMaxUnpoolingLayerKernel(CLMaxUnpoolingLayerKernel &&) = default;
45 /** Allow instances of this class to be moved */
46 CLMaxUnpoolingLayerKernel &operator=(CLMaxUnpoolingLayerKernel &&) = default;
47 /** Default destructor */
48 ~CLMaxUnpoolingLayerKernel() = default;
49 /** Set the input and output tensors.
50 *
51 * @note Output shape must be equal to the shape of the original input to pool.
52 *
53 * @param[in] compile_context The compile context to be used.
54 * @param[in] input Source tensor. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
55 * @param[in] indices Tensor containing the offset to store the input elements in the output tensor.
Michele Di Giorgioe1314662021-02-01 17:09:32 +000056 * @ref opencl::ClPooling with indices should precede this function in order to
Gian Marco Iodice4d81d752020-07-14 15:05:31 +010057 * properly reconstruct the output tensor.
58 * The tensor shape of this tensor has to be equal to the input tensor shape. Data type supported: U32.
59 * @param[out] output Destination tensor. Data types supported: Same as @p input.
60 * @param[in] pool_info Contains pooling operation information described in @ref PoolingLayerInfo.
61 */
62 void configure(const CLCompileContext &compile_context, const ICLTensor *input, const ICLTensor *indices, ICLTensor *output, const PoolingLayerInfo &pool_info);
63 /** Static function to check if given info will lead to a valid configuration of @ref CLMaxUnpoolingLayerKernel
64 *
65 * @param[in] input Source tensor info. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
66 * @param[in] output Destination tensor info. Data types supported: Same as @p input.
67 * @param[in] indices TensorInfo associated to the tensor containing the offset to store the input elements in the output tensor.
Michele Di Giorgioe1314662021-02-01 17:09:32 +000068 * @ref opencl::ClPooling with indices should precede this function in order to
Gian Marco Iodice4d81d752020-07-14 15:05:31 +010069 * properly reconstruct the output tensor.
70 * The tensor shape of this tensor has to be equal to the input tensor shape. Data type supported: U32.
71 * @param[in] pool_info Contains pooling operation information described in @ref PoolingLayerInfo.
72 *
73 * @return a status
74 */
75 static Status validate(const ITensorInfo *input, const ITensorInfo *indices, const ITensorInfo *output, const PoolingLayerInfo &pool_info);
76
77 // Inherited methods overridden
78 void run(const Window &window, cl::CommandQueue &queue) override;
79
80private:
81 const ICLTensor *_input;
82 ICLTensor *_output;
83 const ICLTensor *_indices;
84};
85} // namespace arm_compute
86#endif /*ARM_COMPUTE_CLMAXUNPOOLINGLAYERKERNEL_H */