ramelg01 | 3751569 | 2022-02-26 22:06:20 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 33 | namespace arm_compute |
| 34 | { |
| 35 | class CLCompileContext; |
| 36 | class ICLTensor; |
| 37 | class ITensorInfo; |
| 38 | |
| 39 | /** Basic function to run @ref opencl::ClPool3d */ |
| 40 | class CLPooling3dLayer : public IFunction |
| 41 | { |
| 42 | public: |
| 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 | * |
Adnan AlSinan | 171fc3d | 2022-03-15 18:46:42 +0000 | [diff] [blame] | 57 | * Valid data layouts: |
ramelg01 | 3751569 | 2022-02-26 22:06:20 +0000 | [diff] [blame] | 58 | * - NDHWC |
| 59 | * |
| 60 | * Valid data type configurations: |
| 61 | * |src |dst | |
| 62 | * |:--------------|:--------------| |
| 63 | * |F16 |F16 | |
| 64 | * |F32 |F32 | |
Mohammed Suhail Munshi | 5e549fa | 2022-03-16 11:14:06 +0000 | [diff] [blame] | 65 | * |QASYMM8 |QASYMM8 | |
| 66 | * |QASYMM8_SIGNED |QASYMM8_SIGNED | |
ramelg01 | 3751569 | 2022-02-26 22:06:20 +0000 | [diff] [blame] | 67 | * |
| 68 | * @note Source tensor is padded with -inf for MAX pooling and 0 otherwise |
| 69 | * Cases where pooling region is completely outside input tensor are not supported |
| 70 | * |
| 71 | * @note Asymmetric padding is not supported when dimension rounding type == CEIL. |
| 72 | * |
Mohammed Suhail Munshi | 5e549fa | 2022-03-16 11:14:06 +0000 | [diff] [blame] | 73 | * @param[in,out] input Source tensor. Data types supported: F16/F32/QASYMM8/QASYMM8_SIGNED. |
ramelg01 | 3751569 | 2022-02-26 22:06:20 +0000 | [diff] [blame] | 74 | * @param[out] output Destination tensor. Data types supported: Same as @p input. |
| 75 | * @param[in] pool_info Contains 3d pooling operation information described in @ref Pooling3dLayerInfo. |
| 76 | */ |
| 77 | void configure(const ICLTensor *input, ICLTensor *output, const Pooling3dLayerInfo &pool_info); |
| 78 | /** Set the input and output tensors. |
| 79 | * |
| 80 | * @param[in] compile_context The compile context to be used. |
Mohammed Suhail Munshi | 5e549fa | 2022-03-16 11:14:06 +0000 | [diff] [blame] | 81 | * @param[in,out] input Source tensor. Data types supported: F16/F32/QASYMM8/QASYMM8_SIGNED. |
ramelg01 | 3751569 | 2022-02-26 22:06:20 +0000 | [diff] [blame] | 82 | * @param[out] output Destination tensor. Data types supported: Same as @p input. |
| 83 | * @param[in] pool_info Contains 3d pooling operation information described in @ref Pooling3dLayerInfo. |
| 84 | */ |
| 85 | void configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, const Pooling3dLayerInfo &pool_info); |
| 86 | /** Static function to check if given info will lead to a valid configuration of @ref CLPooling3dLayer |
| 87 | * |
Mohammed Suhail Munshi | 5e549fa | 2022-03-16 11:14:06 +0000 | [diff] [blame] | 88 | * @param[in] input Source tensor info. Data types supported: F16/F32/QASYMM8/QASYMM8_SIGNED. |
ramelg01 | 3751569 | 2022-02-26 22:06:20 +0000 | [diff] [blame] | 89 | * @param[in] output Destination tensor info. Data types supported: Same as @p input. |
| 90 | * @param[in] pool_info Contains 3d pooling operation information described in @ref Pooling3dLayerInfo. |
| 91 | * |
| 92 | * @return a status |
| 93 | */ |
| 94 | static Status validate(const ITensorInfo *input, const ITensorInfo *output, const Pooling3dLayerInfo &pool_info); |
| 95 | |
| 96 | // Inherited methods overridden: |
| 97 | void run() override; |
| 98 | |
| 99 | private: |
| 100 | struct Impl; |
| 101 | std::unique_ptr<Impl> _impl; |
| 102 | }; |
| 103 | } // namespace arm_compute |
| 104 | #endif /* ARM_COMPUTE_CLPOOLING3DLAYER_H */ |