Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 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 | |
| 25 | #pragma once |
| 26 | |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 27 | #include "common.hpp" |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 28 | |
| 29 | namespace arm_conv |
| 30 | { |
| 31 | namespace pooling |
| 32 | { |
| 33 | enum class PoolingType |
| 34 | { |
| 35 | AVERAGE, |
| 36 | MAX, |
| 37 | }; |
| 38 | |
| 39 | enum class PoolingMethod |
| 40 | { |
| 41 | DEFAULT, |
| 42 | DEPTHFIRST, |
| 43 | PLANAR, |
| 44 | }; |
| 45 | |
| 46 | struct PoolingWindow |
| 47 | { |
| 48 | unsigned int rows, cols; |
| 49 | }; |
| 50 | |
| 51 | struct PoolingStride |
| 52 | { |
| 53 | unsigned int rows, cols; |
| 54 | }; |
| 55 | |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 56 | class IPoolingCommon |
| 57 | { |
| 58 | public: |
| 59 | virtual ~IPoolingCommon() = default; |
| 60 | |
| 61 | // Determine the amount of working space required. |
| 62 | virtual size_t get_working_size(unsigned int num_threads) const = 0; |
| 63 | |
| 64 | // Execute pooling over the specified area of memory. |
| 65 | virtual void execute( |
| 66 | const void *const input, |
| 67 | void *const output, |
| 68 | void *working_space, |
| 69 | unsigned int thread_id, |
| 70 | unsigned int num_threads) const = 0; |
| 71 | |
| 72 | virtual void execute( |
| 73 | const void *const input, |
| 74 | size_t ld_input_col, |
| 75 | size_t ld_input_row, |
| 76 | size_t ld_input_batch, |
| 77 | void *const output, |
| 78 | size_t ld_output_col, |
| 79 | size_t ld_output_row, |
| 80 | size_t ld_output_batch, |
| 81 | void *working_space, |
| 82 | unsigned int thread_id, |
| 83 | unsigned int num_threads) const = 0; |
| 84 | |
| 85 | virtual void execute( |
| 86 | unsigned int batches, |
| 87 | unsigned int height, |
| 88 | unsigned int width, |
| 89 | unsigned int channels, |
| 90 | const void *const input, |
| 91 | size_t ld_input_col, |
| 92 | size_t ld_input_row, |
| 93 | size_t ld_input_batch, |
| 94 | const PaddingValues &, |
| 95 | unsigned int output_height, |
| 96 | unsigned int output_width, |
| 97 | void *const output, |
| 98 | size_t ld_output_col, |
| 99 | size_t ld_output_row, |
| 100 | size_t ld_output_batch, |
| 101 | void *working_space, |
| 102 | unsigned int thread_id, |
| 103 | unsigned int num_threads) const = 0; |
| 104 | }; |
| 105 | |
| 106 | struct Nothing |
| 107 | { |
| 108 | }; |
| 109 | |
| 110 | template <typename TInput, typename TOutput, class OutputStage = Nothing> |
| 111 | class PoolingCommon : public IPoolingCommon |
| 112 | { |
| 113 | }; |
| 114 | |
| 115 | } // namespace pooling |
| 116 | } // namespace arm_conv |