blob: 5c8548f9e065eb0f6ebf58114e4511530abaf3ff [file] [log] [blame]
Gian Marco Iodice4d81d752020-07-14 15:05:31 +01001/*
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/runtime/IFunction.h"
28
29#include "arm_compute/core/CL/kernels/CLMaxUnpoolingLayerKernel.h"
30#include "arm_compute/core/CL/kernels/CLMemsetKernel.h"
31
32namespace arm_compute
33{
34class ITensor;
35
36/** Function to perform MaxUnpooling. This function calls the following OpenCL kernels:
37 *
38 * -# @ref CLMemsetKernel
39 * -# @ref CLMaxUnpoolingLayerKernel
40 */
41class CLMaxUnpoolingLayer : public IFunction
42{
43public:
44 /** Constructor */
45 CLMaxUnpoolingLayer();
46 /** Set the input and output tensors.
47 *
48 * @note Output shape must be equal to the shape of the original input to pool.
49 *
50 * @param[in] input Source tensor. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
51 * @param[in] indices Tensor containing the offset to store the input elements in the output tensor.
52 * @ref CLPoolingLayer with indices should precede this function in order to
53 * properly reconstruct the output tensor.
54 * The tensor shape of this tensor has to be equal to the input tensor shape. Data type supported: U32.
55 * @param[out] output Destination tensor. Data types supported: Same as @p input.
56 * @param[in] pool_info Contains pooling operation information described in @ref PoolingLayerInfo.
57 */
58 void configure(ICLTensor *input, ICLTensor *indices, ICLTensor *output, const PoolingLayerInfo &pool_info);
59 /** Set the input and output tensors.
60 *
61 * @note Output shape must be equal to the shape of the original input to pool.
62 *
63 * @param[in] compile_context The compile context to be used.
64 * @param[in] input Source tensor. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
65 * @param[in] indices Tensor containing the offset to store the input elements in the output tensor.
66 * @ref CLPoolingLayer with indices should precede this function in order to
67 * properly reconstruct the output tensor.
68 * The tensor shape of this tensor has to be equal to the input tensor shape. Data type supported: U32.
69 * @param[out] output Destination tensor. Data types supported: Same as @p input.
70 * @param[in] pool_info Contains pooling operation information described in @ref PoolingLayerInfo.
71 */
72 void configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *indices, ICLTensor *output, const PoolingLayerInfo &pool_info);
73 /** Static function to check if given info will lead to a valid configuration of @ref CLMaxUnpoolingLayer
74 *
75 * @param[in] input Source tensor info. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
76 * @param[in] output Destination tensor info. Data types supported: Same as @p input.
77 * @param[in] indices TensorInfo associated to the tensor containing the offset to store the input elements in the output tensor.
78 * @ref CLPoolingLayer with indices should precede this function in order to
79 * properly reconstruct the output tensor.
80 * The tensor shape of this tensor has to be equal to the input tensor shape. Data type supported: U32.
81 * @param[in] pool_info Contains pooling operation information described in @ref PoolingLayerInfo.
82 *
83 * @return a status
84 */
85 static Status validate(const ITensorInfo *input, const ITensorInfo *indices, const ITensorInfo *output, const PoolingLayerInfo &pool_info);
86
87 // Inherited methods overridden:
88 void run() override;
89
90private:
91 CLMemsetKernel _memset_kernel;
92 CLMaxUnpoolingLayerKernel _unpooling_layer_kernel;
93};
94}
95#endif /* ARM_COMPUTE_CLMAXUNPOOLINGLAYER_H */