blob: dcb3c8f57cee3cae4fdb31db7a2a102711b6937a [file] [log] [blame]
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +00001/*
ramelg01c827e992022-04-08 03:52:28 +01002 * Copyright (c) 2021-2022 Arm Limited.
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +00003 *
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"
ramelg01c827e992022-04-08 03:52:28 +010028#include "pooling_depthfirst_generic.hpp"
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000029
30#if defined(__aarch64__)
Viet-Hoa Do03b29712022-06-01 11:47:14 +010031#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)
ramelg01c827e992022-04-08 03:52:28 +010035#if defined(ARM_COMPUTE_ENABLE_SVE)
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000036#include "kernels/sve_s8q_nhwc_avg_generic_depthfirst.hpp"
37#include "kernels/sve_s8q_nhwc_max_generic_depthfirst.hpp"
ramelg01c827e992022-04-08 03:52:28 +010038#endif // defined(ARM_COMPUTE_ENABLE_SVE)
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000039#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
45namespace arm_conv {
46namespace pooling {
47
ramelg01c827e992022-04-08 03:52:28 +010048static const PoolingImplementation<int8_t, int8_t, Requantize32> pooling_s8q_methods[] = {
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000049#if defined(__aarch64__)
Viet-Hoa Do03b29712022-06-01 11:47:14 +010050#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)
ramelg01c827e992022-04-08 03:52:28 +010076#if defined(ARM_COMPUTE_ENABLE_SVE)
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000077 {
78 PoolingMethod::DEPTHFIRST,
79 "sve_s8q_nhwc_avg_generic_depthfirst",
80 [] (const PoolingArgs &args, const Requantize32 &) -> bool {
Michalis Spyrou20fca522021-06-07 14:23:57 +010081 return args.cpu_info->has_sve2() && args.pool_type == PoolingType::AVERAGE;
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000082 },
83 nullptr,
ramelg01c827e992022-04-08 03:52:28 +010084 [] (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 Giorgiod556d7b2020-10-27 10:56:31 +000087 },
88 },
89 {
90 PoolingMethod::DEPTHFIRST,
91 "sve_s8q_nhwc_max_generic_depthfirst",
ramelg01c827e992022-04-08 03:52:28 +010092 [] (const PoolingArgs &args, const Requantize32 &) -> bool {
93 return args.cpu_info->has_sve2() && args.pool_type == PoolingType::MAX;
94 },
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000095 nullptr,
ramelg01c827e992022-04-08 03:52:28 +010096 [] (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 Giorgiod556d7b2020-10-27 10:56:31 +000099 },
100 },
ramelg01c827e992022-04-08 03:52:28 +0100101#endif // defined(ARM_COMPUTE_ENABLE_SVE)
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +0000102 {
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,
ramelg01c827e992022-04-08 03:52:28 +0100109 [] (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 Giorgiod556d7b2020-10-27 10:56:31 +0000112 },
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,
ramelg01c827e992022-04-08 03:52:28 +0100119 [] (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 Giorgiod556d7b2020-10-27 10:56:31 +0000122 },
123 },
124#endif // defined(__aarch64__)
125 { PoolingMethod::DEFAULT, "", nullptr, nullptr, nullptr }, // End of list
126};
127
128template <>
129const PoolingImplementation<int8_t, int8_t, Requantize32> *pooling_implementation_list()
130{
ramelg01c827e992022-04-08 03:52:28 +0100131 return pooling_s8q_methods;
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +0000132}
133
ramelg01c827e992022-04-08 03:52:28 +0100134template UniquePoolingCommon<int8_t, int8_t> pooling(const PoolingArgs &, const Requantize32 &);
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +0000135
136} // namespace pooling
137} // namespace arm_conv