blob: f7ff1234f647ae71261710d8a31d470f1eb876cf [file] [log] [blame]
Gian Marco Iodice4d81d752020-07-14 15:05:31 +01001/*
Sheri Zhang7e20e292021-02-02 11:49:34 +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_CLMAXUNPOOLINGLAYER_H
25#define ARM_COMPUTE_CLMAXUNPOOLINGLAYER_H
26
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010027#include "arm_compute/core/Error.h"
Sheri Zhang7e20e292021-02-02 11:49:34 +000028#include "arm_compute/runtime/CL/functions/CLFill.h"
Gian Marco Iodice4d81d752020-07-14 15:05:31 +010029#include "arm_compute/runtime/IFunction.h"
30
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010031#include <memory>
Gian Marco Iodice4d81d752020-07-14 15:05:31 +010032
33namespace arm_compute
34{
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010035class CLCompileContext;
36class ICLTensor;
37class ITensorInfo;
38class CLMaxUnpoolingLayerKernel;
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010039struct PoolingLayerInfo;
Gian Marco Iodice4d81d752020-07-14 15:05:31 +010040
41/** Function to perform MaxUnpooling. This function calls the following OpenCL kernels:
42 *
Sheri Zhang7e20e292021-02-02 11:49:34 +000043 * -# @ref CLFill
Gian Marco Iodice4d81d752020-07-14 15:05:31 +010044 * -# @ref CLMaxUnpoolingLayerKernel
45 */
46class CLMaxUnpoolingLayer : public IFunction
47{
48public:
49 /** Constructor */
50 CLMaxUnpoolingLayer();
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010051 /** 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();
Gian Marco Iodice4d81d752020-07-14 15:05:31 +010057 /** Set the input and output tensors.
58 *
Teresa Charlin62687422021-04-28 10:58:49 +010059 * Valid data layouts:
60 * - NHWC
61 * - NCHW
62 *
63 * Valid data type configurations:
64 * |src |dst |
65 * |:--------------|:--------------|
66 * |QASYMM8 |QASYMM8 |
67 * |QASYMM8_SIGNED |QASYMM8_SIGNED |
68 * |F16 |F16 |
69 * |F32 |F32 |
70 *
Gian Marco Iodice4d81d752020-07-14 15:05:31 +010071 * @note Output shape must be equal to the shape of the original input to pool.
72 *
73 * @param[in] input Source tensor. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
74 * @param[in] indices Tensor containing the offset to store the input elements in the output tensor.
75 * @ref CLPoolingLayer with indices should precede this function in order to
76 * properly reconstruct the output tensor.
77 * The tensor shape of this tensor has to be equal to the input tensor shape. Data type supported: U32.
78 * @param[out] output Destination tensor. Data types supported: Same as @p input.
79 * @param[in] pool_info Contains pooling operation information described in @ref PoolingLayerInfo.
80 */
81 void configure(ICLTensor *input, ICLTensor *indices, ICLTensor *output, const PoolingLayerInfo &pool_info);
82 /** Set the input and output tensors.
83 *
84 * @note Output shape must be equal to the shape of the original input to pool.
85 *
86 * @param[in] compile_context The compile context to be used.
87 * @param[in] input Source tensor. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
88 * @param[in] indices 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[out] output Destination tensor. Data types supported: Same as @p input.
93 * @param[in] pool_info Contains pooling operation information described in @ref PoolingLayerInfo.
94 */
95 void configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *indices, ICLTensor *output, const PoolingLayerInfo &pool_info);
96 /** Static function to check if given info will lead to a valid configuration of @ref CLMaxUnpoolingLayer
97 *
98 * @param[in] input Source tensor info. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
99 * @param[in] output Destination tensor info. Data types supported: Same as @p input.
100 * @param[in] indices TensorInfo associated to the tensor containing the offset to store the input elements in the output tensor.
101 * @ref CLPoolingLayer with indices should precede this function in order to
102 * properly reconstruct the output tensor.
103 * The tensor shape of this tensor has to be equal to the input tensor shape. Data type supported: U32.
104 * @param[in] pool_info Contains pooling operation information described in @ref PoolingLayerInfo.
105 *
106 * @return a status
107 */
108 static Status validate(const ITensorInfo *input, const ITensorInfo *indices, const ITensorInfo *output, const PoolingLayerInfo &pool_info);
109
110 // Inherited methods overridden:
111 void run() override;
112
113private:
Sheri Zhang7e20e292021-02-02 11:49:34 +0000114 CLFill _fill;
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +0100115 std::unique_ptr<CLMaxUnpoolingLayerKernel> _unpooling_layer_kernel;
Gian Marco Iodice4d81d752020-07-14 15:05:31 +0100116};
117}
118#endif /* ARM_COMPUTE_CLMAXUNPOOLINGLAYER_H */