blob: 0867abc054c5144275fb353247480142682b8d98 [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_s8_nhwc_avg_generic_depthfirst.hpp"
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000035#include "kernels/sve_s8_nhwc_max_2x2_s1_output2x2_depthfirst.hpp"
36#include "kernels/sve_s8_nhwc_max_generic_depthfirst.hpp"
Michalis Spyrou20fca522021-06-07 14:23:57 +010037#endif // defined(ARM_COMPUTE_ENABLE_SVE)
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000038#include "kernels/a64_s8_nhwc_max_2x2_s1_output2x2_depthfirst.hpp"
39#include "kernels/a64_s8_nhwc_avg_generic_depthfirst.hpp"
40#include "kernels/a64_s8_nhwc_max_generic_depthfirst.hpp"
41#endif // defined(__aarch64__)
42
43#include <cstdint>
44
45namespace arm_conv {
46namespace pooling {
47
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000048static const PoolingImplementation<int8_t, int8_t> pooling_s8_methods[] = {
49 {
50 PoolingMethod::DEPTHFIRST,
51 "cpp_s8_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<int8_t, int8_t> * {
ramelg01c827e992022-04-08 03:52:28 +010057 auto strat = new cpp_nhwc_1x1_stride_any_depthfirst<int8_t>(args.cpu_info);
58 return new PoolingDepthfirstGeneric<int8_t>(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_s8_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_s8_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<int8_t, int8_t> * {
ramelg01c827e992022-04-08 03:52:28 +010072 auto strat = new sve_s8_nhwc_max_2x2_s1_output2x2_depthfirst(args.cpu_info);
73 return new PoolingDepthfirst<int8_t>(strat, args);
74 },
75 },
76 {
77 PoolingMethod::DEPTHFIRST,
78 "sve_s8_nhwc_avg_generic_depthfirst",
79 [] (const PoolingArgs &args, const Nothing &) -> bool {
80 return args.cpu_info->has_sve2() && args.pool_type == PoolingType::AVERAGE;
81 },
82 nullptr,
83 [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<int8_t, int8_t> * {
84 auto strat = new sve_s8_nhwc_avg_generic_depthfirst(args.cpu_info);
85 return new PoolingDepthfirstGeneric<int8_t>(strat, args);
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000086 },
87 },
88 {
89 PoolingMethod::DEPTHFIRST,
90 "sve_s8_nhwc_max_generic_depthfirst",
ramelg01c827e992022-04-08 03:52:28 +010091 [] (const PoolingArgs &args, const Nothing &) -> bool {
92 return args.cpu_info->has_sve() && args.pool_type == PoolingType::MAX;
93 },
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000094 nullptr,
95 [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<int8_t, int8_t> * {
ramelg01c827e992022-04-08 03:52:28 +010096 auto strat = new sve_s8_nhwc_max_generic_depthfirst(args.cpu_info);
97 return new PoolingDepthfirstGeneric<int8_t>(strat, args);
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000098 },
99 },
Michalis Spyrou20fca522021-06-07 14:23:57 +0100100#endif // defined(ARM_COMPUTE_ENABLE_SVE)
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +0000101 {
102 PoolingMethod::DEPTHFIRST,
103 "a64_s8_nhwc_max_2x2_s1_output2x2_depthfirst",
104 is_supported<a64_s8_nhwc_max_2x2_s1_output2x2_depthfirst>,
105 nullptr,
106 [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<int8_t, int8_t> * {
ramelg01c827e992022-04-08 03:52:28 +0100107 auto strat = new a64_s8_nhwc_max_2x2_s1_output2x2_depthfirst(args.cpu_info);
108 return new PoolingDepthfirst<int8_t>(strat, args);
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +0000109 },
110 },
111 {
112 PoolingMethod::DEPTHFIRST,
113 "a64_s8_nhwc_avg_generic_depthfirst",
114 [] (const PoolingArgs &args, const Nothing &) -> bool { return args.pool_type == PoolingType::AVERAGE; },
115 nullptr,
116 [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<int8_t, int8_t> * {
ramelg01c827e992022-04-08 03:52:28 +0100117 auto strat = new a64_s8_nhwc_avg_generic_depthfirst(args.cpu_info);
118 return new PoolingDepthfirstGeneric<int8_t>(strat, args);
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +0000119 },
120 },
121 {
122 PoolingMethod::DEPTHFIRST,
123 "a64_s8_nhwc_max_generic_depthfirst",
124 [] (const PoolingArgs &args, const Nothing &) -> bool { return args.pool_type == PoolingType::MAX; },
125 nullptr,
126 [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<int8_t, int8_t> * {
ramelg01c827e992022-04-08 03:52:28 +0100127 auto strat = new a64_s8_nhwc_max_generic_depthfirst(args.cpu_info);
128 return new PoolingDepthfirstGeneric<int8_t>(strat, args);
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +0000129 },
130 },
131#endif // defined(__aarch64__)
132 { PoolingMethod::DEFAULT, "", nullptr, nullptr, nullptr }, // End of list
133};
134
135template <>
136const PoolingImplementation<int8_t, int8_t> *pooling_implementation_list()
137{
138 return pooling_s8_methods;
139}
140
141template UniquePoolingCommon<int8_t, int8_t> pooling(const PoolingArgs &, const Nothing &);
142
143} // namespace pooling
144} // namespace arm_conv