Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 1 | /* |
ramelg01 | c827e99 | 2022-04-08 03:52:28 +0100 | [diff] [blame] | 2 | * Copyright (c) 2021-2022 Arm Limited. |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 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 | #include "arm_gemm_local.hpp" |
| 26 | |
| 27 | #include "pooling_implementation.hpp" |
ramelg01 | c827e99 | 2022-04-08 03:52:28 +0100 | [diff] [blame] | 28 | #include "pooling_depthfirst_generic.hpp" |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 29 | |
| 30 | #if defined(__aarch64__) |
Viet-Hoa Do | 03b2971 | 2022-06-01 11:47:14 +0100 | [diff] [blame] | 31 | #if defined(ARM_COMPUTE_ENABLE_SME) |
| 32 | #include "kernels/sme_s8q_nhwc_avg_generic_depthfirst.hpp" |
| 33 | #include "kernels/sme_s8q_nhwc_max_generic_depthfirst.hpp" |
| 34 | #endif // defined(ARM_COMPUTE_ENABLE_SME) |
ramelg01 | c827e99 | 2022-04-08 03:52:28 +0100 | [diff] [blame] | 35 | #if defined(ARM_COMPUTE_ENABLE_SVE) |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 36 | #include "kernels/sve_s8q_nhwc_avg_generic_depthfirst.hpp" |
| 37 | #include "kernels/sve_s8q_nhwc_max_generic_depthfirst.hpp" |
ramelg01 | c827e99 | 2022-04-08 03:52:28 +0100 | [diff] [blame] | 38 | #endif // defined(ARM_COMPUTE_ENABLE_SVE) |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 39 | #include "kernels/a64_s8q_nhwc_avg_generic_depthfirst.hpp" |
| 40 | #include "kernels/a64_s8q_nhwc_max_generic_depthfirst.hpp" |
| 41 | #endif // defined(__aarch64__) |
| 42 | |
| 43 | #include <cstdint> |
| 44 | |
| 45 | namespace arm_conv { |
| 46 | namespace pooling { |
| 47 | |
ramelg01 | c827e99 | 2022-04-08 03:52:28 +0100 | [diff] [blame] | 48 | static const PoolingImplementation<int8_t, int8_t, Requantize32> pooling_s8q_methods[] = { |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 49 | #if defined(__aarch64__) |
Viet-Hoa Do | 03b2971 | 2022-06-01 11:47:14 +0100 | [diff] [blame] | 50 | #if defined(ARM_COMPUTE_ENABLE_SME) |
| 51 | { |
| 52 | PoolingMethod::DEPTHFIRST, |
| 53 | "sme_s8q_nhwc_avg_generic_depthfirst", |
| 54 | [] (const PoolingArgs &args, const Requantize32 &) -> bool { |
| 55 | return args.cpu_info->has_sme2() && args.pool_type == PoolingType::AVERAGE; |
| 56 | }, |
| 57 | nullptr, |
| 58 | [] (const PoolingArgs &args, const Requantize32 &rq) -> PoolingCommon<int8_t, int8_t> * { |
| 59 | auto strat = new sme_s8q_nhwc_avg_generic_depthfirst(args.cpu_info); |
| 60 | return new PoolingDepthfirstGeneric<int8_t, int8_t, Requantize32>(strat, args, rq); |
| 61 | }, |
| 62 | }, |
| 63 | { |
| 64 | PoolingMethod::DEPTHFIRST, |
| 65 | "sme_s8q_nhwc_max_generic_depthfirst", |
| 66 | [] (const PoolingArgs &args, const Requantize32 &) -> bool { |
| 67 | return args.cpu_info->has_sme2() && args.pool_type == PoolingType::MAX; |
| 68 | }, |
| 69 | nullptr, |
| 70 | [] (const PoolingArgs &args, const Requantize32 &rq) -> PoolingCommon<int8_t, int8_t> * { |
| 71 | auto strat = new sme_s8q_nhwc_max_generic_depthfirst(args.cpu_info); |
| 72 | return new PoolingDepthfirstGeneric<int8_t, int8_t, Requantize32>(strat, args, rq); |
| 73 | }, |
| 74 | }, |
| 75 | #endif // defined(ARM_COMPUTE_ENABLE_SME) |
ramelg01 | c827e99 | 2022-04-08 03:52:28 +0100 | [diff] [blame] | 76 | #if defined(ARM_COMPUTE_ENABLE_SVE) |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 77 | { |
| 78 | PoolingMethod::DEPTHFIRST, |
| 79 | "sve_s8q_nhwc_avg_generic_depthfirst", |
| 80 | [] (const PoolingArgs &args, const Requantize32 &) -> bool { |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 81 | return args.cpu_info->has_sve2() && args.pool_type == PoolingType::AVERAGE; |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 82 | }, |
| 83 | nullptr, |
ramelg01 | c827e99 | 2022-04-08 03:52:28 +0100 | [diff] [blame] | 84 | [] (const PoolingArgs &args, const Requantize32 &rq) -> PoolingCommon<int8_t, int8_t> * { |
| 85 | auto strat = new sve_s8q_nhwc_avg_generic_depthfirst(args.cpu_info); |
| 86 | return new PoolingDepthfirstGeneric<int8_t, int8_t, Requantize32>(strat, args, rq); |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 87 | }, |
| 88 | }, |
| 89 | { |
| 90 | PoolingMethod::DEPTHFIRST, |
| 91 | "sve_s8q_nhwc_max_generic_depthfirst", |
ramelg01 | c827e99 | 2022-04-08 03:52:28 +0100 | [diff] [blame] | 92 | [] (const PoolingArgs &args, const Requantize32 &) -> bool { |
| 93 | return args.cpu_info->has_sve2() && args.pool_type == PoolingType::MAX; |
| 94 | }, |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 95 | nullptr, |
ramelg01 | c827e99 | 2022-04-08 03:52:28 +0100 | [diff] [blame] | 96 | [] (const PoolingArgs &args, const Requantize32 &rq) -> PoolingCommon<int8_t, int8_t> * { |
| 97 | auto strat = new sve_s8q_nhwc_max_generic_depthfirst(args.cpu_info); |
| 98 | return new PoolingDepthfirstGeneric<int8_t, int8_t, Requantize32>(strat, args, rq); |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 99 | }, |
| 100 | }, |
ramelg01 | c827e99 | 2022-04-08 03:52:28 +0100 | [diff] [blame] | 101 | #endif // defined(ARM_COMPUTE_ENABLE_SVE) |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 102 | { |
| 103 | PoolingMethod::DEPTHFIRST, |
| 104 | "a64_s8q_nhwc_avg_generic_depthfirst", |
| 105 | [] (const PoolingArgs &args, const Requantize32 &) -> bool { |
| 106 | return args.pool_type == PoolingType::AVERAGE; |
| 107 | }, |
| 108 | nullptr, |
ramelg01 | c827e99 | 2022-04-08 03:52:28 +0100 | [diff] [blame] | 109 | [] (const PoolingArgs &args, const Requantize32 &rq) -> PoolingCommon<int8_t, int8_t> * { |
| 110 | auto strat = new a64_s8q_nhwc_avg_generic_depthfirst(args.cpu_info); |
| 111 | return new PoolingDepthfirstGeneric<int8_t, int8_t, Requantize32>(strat, args, rq); |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 112 | }, |
| 113 | }, |
| 114 | { |
| 115 | PoolingMethod::DEPTHFIRST, |
| 116 | "a64_s8q_nhwc_max_generic_depthfirst", |
| 117 | [] (const PoolingArgs &args, const Requantize32 &) -> bool { return args.pool_type == PoolingType::MAX; }, |
| 118 | nullptr, |
ramelg01 | c827e99 | 2022-04-08 03:52:28 +0100 | [diff] [blame] | 119 | [] (const PoolingArgs &args, const Requantize32 &rq) -> PoolingCommon<int8_t, int8_t> * { |
| 120 | auto strat = new a64_s8q_nhwc_max_generic_depthfirst(args.cpu_info); |
| 121 | return new PoolingDepthfirstGeneric<int8_t, int8_t, Requantize32>(strat, args, rq); |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 122 | }, |
| 123 | }, |
| 124 | #endif // defined(__aarch64__) |
| 125 | { PoolingMethod::DEFAULT, "", nullptr, nullptr, nullptr }, // End of list |
| 126 | }; |
| 127 | |
| 128 | template <> |
| 129 | const PoolingImplementation<int8_t, int8_t, Requantize32> *pooling_implementation_list() |
| 130 | { |
ramelg01 | c827e99 | 2022-04-08 03:52:28 +0100 | [diff] [blame] | 131 | return pooling_s8q_methods; |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 132 | } |
| 133 | |
ramelg01 | c827e99 | 2022-04-08 03:52:28 +0100 | [diff] [blame] | 134 | template UniquePoolingCommon<int8_t, int8_t> pooling(const PoolingArgs &, const Requantize32 &); |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 135 | |
| 136 | } // namespace pooling |
| 137 | } // namespace arm_conv |