blob: 5ee08842942897d122f94aa93da3f3d33acba215 [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"
28#include "pooling_depthfirst.hpp"
29#include "pooling_depthfirst_generic.hpp"
30
31#include "kernels/cpp_nhwc_1x1_stride_any_depthfirst.hpp"
32#if defined(__aarch64__)
Michalis Spyrou20fca522021-06-07 14:23:57 +010033#if defined(ARM_COMPUTE_ENABLE_SVE)
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000034#include "kernels/sve_fp32_nhwc_max_2x2_s1_output2x2_depthfirst.hpp"
35#include "kernels/sve_fp32_nhwc_avg_3x3_s1_output2x2_depthfirst.hpp"
36#include "kernels/sve_fp32_nhwc_avg_generic_depthfirst.hpp"
37#include "kernels/sve_fp32_nhwc_max_generic_depthfirst.hpp"
Michalis Spyrou20fca522021-06-07 14:23:57 +010038#endif // defined(ARM_COMPUTE_ENABLE_SVE)
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000039#include "kernels/a64_fp32_nhwc_max_2x2_s1_output2x2_depthfirst.hpp"
40#include "kernels/a64_fp32_nhwc_avg_3x3_s1_output2x2_depthfirst.hpp"
41#include "kernels/a64_fp32_nhwc_avg_generic_depthfirst.hpp"
42#include "kernels/a64_fp32_nhwc_max_generic_depthfirst.hpp"
43#endif // defined(__aarch64__)
44
45namespace arm_conv {
46namespace pooling {
47
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000048static const PoolingImplementation<float, float> pooling_fp32_methods[] = {
49 {
50 PoolingMethod::DEPTHFIRST,
51 "cpp_fp32_nhwc_1x1_stride_any_depthfirst",
52 [] (const PoolingArgs &args, const Nothing &) -> bool {
53 return args.pool_window.rows == 1 && args.pool_window.cols == 1;
54 },
55 nullptr,
56 [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<float, float> * {
ramelg01c827e992022-04-08 03:52:28 +010057 auto strat = new cpp_nhwc_1x1_stride_any_depthfirst<float>(args.cpu_info);
58 return new PoolingDepthfirstGeneric<float, float, Nothing>(strat, args);
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000059 },
60 },
61#if defined(__aarch64__)
Michalis Spyrou20fca522021-06-07 14:23:57 +010062#if defined(ARM_COMPUTE_ENABLE_SVE)
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000063 {
64 PoolingMethod::DEPTHFIRST,
65 "sve_fp32_nhwc_max_2x2_s1_output2x2_depthfirst",
ramelg01c827e992022-04-08 03:52:28 +010066 [] (const PoolingArgs &args, const Nothing &os) -> bool {
67 return args.cpu_info->has_sve() &&
68 is_supported<sve_fp32_nhwc_max_2x2_s1_output2x2_depthfirst>(args, os);
Michalis Spyrou20fca522021-06-07 14:23:57 +010069 },
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000070 nullptr,
71 [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<float, float> * {
ramelg01c827e992022-04-08 03:52:28 +010072 auto strat = new sve_fp32_nhwc_max_2x2_s1_output2x2_depthfirst(args.cpu_info);
73 return new PoolingDepthfirst<float>(strat, args);
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000074 },
75 },
76 {
77 PoolingMethod::DEPTHFIRST,
78 "sve_fp32_nhwc_avg_3x3_s1_output2x2_depthfirst",
ramelg01c827e992022-04-08 03:52:28 +010079 [] (const PoolingArgs &args, const Nothing &os) -> bool {
80 return args.cpu_info->has_sve() &&
81 is_supported<sve_fp32_nhwc_avg_3x3_s1_output2x2_depthfirst>(args, os);
Michalis Spyrou20fca522021-06-07 14:23:57 +010082 },
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000083 nullptr,
84 [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<float, float> * {
ramelg01c827e992022-04-08 03:52:28 +010085 auto strat = new sve_fp32_nhwc_avg_3x3_s1_output2x2_depthfirst(args.cpu_info);
86 return new PoolingDepthfirst<float>(strat, args);
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000087 },
88 },
89 {
90 PoolingMethod::DEPTHFIRST,
91 "sve_fp32_nhwc_avg_generic_depthfirst",
Michalis Spyrou20fca522021-06-07 14:23:57 +010092 [] (const PoolingArgs &args, const Nothing &) -> bool {
93 return args.cpu_info->has_sve() && args.pool_type == PoolingType::AVERAGE;
94 },
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000095 nullptr,
96 [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<float, float> * {
ramelg01c827e992022-04-08 03:52:28 +010097 auto strat = new sve_fp32_nhwc_avg_generic_depthfirst(args.cpu_info);
98 return new PoolingDepthfirstGeneric<float>(strat, args);
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000099 },
100 },
101 {
102 PoolingMethod::DEPTHFIRST,
103 "sve_fp32_nhwc_max_generic_depthfirst",
Michalis Spyrou20fca522021-06-07 14:23:57 +0100104 [] (const PoolingArgs &args, const Nothing &) -> bool {
105 return args.cpu_info->has_sve() && args.pool_type == PoolingType::MAX;
106 },
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +0000107 nullptr,
108 [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<float, float> * {
ramelg01c827e992022-04-08 03:52:28 +0100109 auto strat = new sve_fp32_nhwc_max_generic_depthfirst(args.cpu_info);
110 return new PoolingDepthfirstGeneric<float>(strat, args);
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +0000111 },
112 },
Michalis Spyrou20fca522021-06-07 14:23:57 +0100113#endif // defined(ARM_COMPUTE_ENABLE_SVE)
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +0000114 {
115 PoolingMethod::DEPTHFIRST,
116 "a64_fp32_nhwc_max_2x2_s1_output2x2_depthfirst",
117 is_supported<a64_fp32_nhwc_max_2x2_s1_output2x2_depthfirst>,
118 nullptr,
119 [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<float, float> * {
ramelg01c827e992022-04-08 03:52:28 +0100120 auto strat = new a64_fp32_nhwc_max_2x2_s1_output2x2_depthfirst(args.cpu_info);
121 return new PoolingDepthfirst<float>(strat, args);
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +0000122 },
123 },
124 {
125 PoolingMethod::DEPTHFIRST,
126 "a64_fp32_nhwc_avg_3x3_s1_output2x2_depthfirst",
127 is_supported<a64_fp32_nhwc_avg_3x3_s1_output2x2_depthfirst>,
128 nullptr,
129 [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<float, float> * {
ramelg01c827e992022-04-08 03:52:28 +0100130 auto strat = new a64_fp32_nhwc_avg_3x3_s1_output2x2_depthfirst(args.cpu_info);
131 return new PoolingDepthfirst<float>(strat, args);
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +0000132 },
133 },
134 {
135 PoolingMethod::DEPTHFIRST,
136 "a64_fp32_nhwc_avg_generic_depthfirst",
137 [] (const PoolingArgs &args, const Nothing &) -> bool { return args.pool_type == PoolingType::AVERAGE; },
138 nullptr,
139 [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<float, float> * {
ramelg01c827e992022-04-08 03:52:28 +0100140 auto strat = new a64_fp32_nhwc_avg_generic_depthfirst(args.cpu_info);
141 return new PoolingDepthfirstGeneric<float>(strat, args);
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +0000142 },
143 },
144 {
145 PoolingMethod::DEPTHFIRST,
146 "a64_fp32_nhwc_max_generic_depthfirst",
147 [] (const PoolingArgs &args, const Nothing &) -> bool { return args.pool_type == PoolingType::MAX; },
148 nullptr,
149 [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<float, float> * {
ramelg01c827e992022-04-08 03:52:28 +0100150 auto strat = new a64_fp32_nhwc_max_generic_depthfirst(args.cpu_info);
151 return new PoolingDepthfirstGeneric<float>(strat, args);
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +0000152 },
153 },
154#endif // defined(__aarch64__)
155 { PoolingMethod::DEFAULT, "", nullptr, nullptr, nullptr }, // End of list
156};
157
158template <>
159const PoolingImplementation<float, float> *pooling_implementation_list()
160{
161 return pooling_fp32_methods;
162}
163
164template UniquePoolingCommon<float, float> pooling(const PoolingArgs &, const Nothing &);
165
166} // namespace pooling
167} // namespace arm_conv