Compute Library
 22.05
CLMaxUnpoolingLayer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020-2021 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"
30 
31 #include <memory>
32 
33 namespace arm_compute
34 {
35 class CLCompileContext;
36 class ICLTensor;
37 class ITensorInfo;
38 class CLMaxUnpoolingLayerKernel;
39 struct PoolingLayerInfo;
40 
41 /** Function to perform MaxUnpooling. This function calls the following OpenCL kernels:
42  *
43  * -# @ref CLFill
44  * -# @ref CLMaxUnpoolingLayerKernel
45  */
47 {
48 public:
49  /** Constructor */
51  /** Prevent instances of this class from being copied */
52  CLMaxUnpoolingLayer(const CLMaxUnpoolingLayer &) = delete;
53  /** Prevent instances of this class from being copied */
55  /** Default destructor */
57  /** Set the input and output tensors.
58  *
59  * 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  *
71  * @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 
113 private:
114  CLFill _fill;
115  std::unique_ptr<CLMaxUnpoolingLayerKernel> _unpooling_layer_kernel;
116 };
117 }
118 #endif /* ARM_COMPUTE_CLMAXUNPOOLINGLAYER_H */
void configure(ICLTensor *input, ICLTensor *indices, ICLTensor *output, const PoolingLayerInfo &pool_info)
Set the input and output tensors.
Base class for all functions.
Definition: IFunction.h:30
CLMaxUnpoolingLayer & operator=(const CLMaxUnpoolingLayer &)=delete
Prevent instances of this class from being copied.
Store the tensor&#39;s metadata.
Definition: ITensorInfo.h:40
Status class.
Definition: Error.h:52
Copyright (c) 2017-2022 Arm Limited.
~CLMaxUnpoolingLayer()
Default destructor.
Pooling Layer Information struct.
Definition: Types.h:1186
static Status validate(const ITensorInfo *input, const ITensorInfo *indices, const ITensorInfo *output, const PoolingLayerInfo &pool_info)
Static function to check if given info will lead to a valid configuration of CLMaxUnpoolingLayer.
Function to perform MaxUnpooling.
CLCompileContext class.
Interface for OpenCL tensor.
Definition: ICLTensor.h:42
Basic function to run opencl::kernels::ClFillKernel.
Definition: CLFill.h:38
void run() override
Run the kernels contained in the function.