blob: 2e4823756da400cb4e5fcb7a48b4dbe86d7344ac [file] [log] [blame]
ramelg0137515692022-02-26 22:06:20 +00001/*
2 * Copyright (c) 2022 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_CLPOOLING3DLAYER_H
25#define ARM_COMPUTE_CLPOOLING3DLAYER_H
26
27#include "arm_compute/runtime/IFunction.h"
28
29#include "arm_compute/core/Types.h"
30
31#include <memory>
32
33namespace arm_compute
34{
35class CLCompileContext;
36class ICLTensor;
37class ITensorInfo;
38
39/** Basic function to run @ref opencl::ClPool3d */
40class CLPooling3dLayer : public IFunction
41{
42public:
43 /** Default Constructor */
44 CLPooling3dLayer();
45 /** Default Destructor */
46 ~CLPooling3dLayer();
47 /** Prevent instances of this class from being copied (As this class contains pointers) */
48 CLPooling3dLayer(const CLPooling3dLayer &) = delete;
49 /** Default move constructor */
50 CLPooling3dLayer(CLPooling3dLayer &&) = default;
51 /** Prevent instances of this class from being copied (As this class contains pointers) */
52 CLPooling3dLayer &operator=(const CLPooling3dLayer &) = delete;
53 /** Default move assignment operator */
54 CLPooling3dLayer &operator=(CLPooling3dLayer &&) = default;
55 /** Set the input and output tensors.
56 *
57 * Valid data layout:
58 * - NDHWC
59 *
60 * Valid data type configurations:
61 * |src |dst |
62 * |:--------------|:--------------|
63 * |F16 |F16 |
64 * |F32 |F32 |
65 *
66 * @note Source tensor is padded with -inf for MAX pooling and 0 otherwise
67 * Cases where pooling region is completely outside input tensor are not supported
68 *
69 * @note Asymmetric padding is not supported when dimension rounding type == CEIL.
70 *
71 * @param[in,out] input Source tensor. Data types supported: F16/F32.
72 * @param[out] output Destination tensor. Data types supported: Same as @p input.
73 * @param[in] pool_info Contains 3d pooling operation information described in @ref Pooling3dLayerInfo.
74 */
75 void configure(const ICLTensor *input, ICLTensor *output, const Pooling3dLayerInfo &pool_info);
76 /** Set the input and output tensors.
77 *
78 * @param[in] compile_context The compile context to be used.
79 * @param[in,out] input Source tensor. Data types supported: F16/F32.
80 * @param[out] output Destination tensor. Data types supported: Same as @p input.
81 * @param[in] pool_info Contains 3d pooling operation information described in @ref Pooling3dLayerInfo.
82 */
83 void configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, const Pooling3dLayerInfo &pool_info);
84 /** Static function to check if given info will lead to a valid configuration of @ref CLPooling3dLayer
85 *
86 * @param[in] input Source tensor info. Data types supported: F16/F32.
87 * @param[in] output Destination tensor info. Data types supported: Same as @p input.
88 * @param[in] pool_info Contains 3d pooling operation information described in @ref Pooling3dLayerInfo.
89 *
90 * @return a status
91 */
92 static Status validate(const ITensorInfo *input, const ITensorInfo *output, const Pooling3dLayerInfo &pool_info);
93
94 // Inherited methods overridden:
95 void run() override;
96
97private:
98 struct Impl;
99 std::unique_ptr<Impl> _impl;
100};
101} // namespace arm_compute
102#endif /* ARM_COMPUTE_CLPOOLING3DLAYER_H */