Compute Library
 22.11
pooling_fp32.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021-2022 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 #include "arm_gemm_local.hpp"
26 
28 #include "pooling_depthfirst.hpp"
30 
32 #if defined(__aarch64__)
33 #if defined(ARM_COMPUTE_ENABLE_SVE)
38 #endif // defined(ARM_COMPUTE_ENABLE_SVE)
43 #endif // defined(__aarch64__)
44 
45 namespace arm_conv {
46 namespace pooling {
47 
48 static 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> * {
57  auto strat = new cpp_nhwc_1x1_stride_any_depthfirst<float>(args.cpu_info);
58  return new PoolingDepthfirstGeneric<float, float, Nothing>(strat, args);
59  },
60  },
61 #if defined(__aarch64__)
62 #if defined(ARM_COMPUTE_ENABLE_SVE)
63  {
64  PoolingMethod::DEPTHFIRST,
65  "sve_fp32_nhwc_max_2x2_s1_output2x2_depthfirst",
66  [] (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);
69  },
70  nullptr,
71  [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<float, float> * {
72  auto strat = new sve_fp32_nhwc_max_2x2_s1_output2x2_depthfirst(args.cpu_info);
73  return new PoolingDepthfirst<float>(strat, args);
74  },
75  },
76  {
77  PoolingMethod::DEPTHFIRST,
78  "sve_fp32_nhwc_avg_3x3_s1_output2x2_depthfirst",
79  [] (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);
82  },
83  nullptr,
84  [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<float, float> * {
85  auto strat = new sve_fp32_nhwc_avg_3x3_s1_output2x2_depthfirst(args.cpu_info);
86  return new PoolingDepthfirst<float>(strat, args);
87  },
88  },
89  {
90  PoolingMethod::DEPTHFIRST,
91  "sve_fp32_nhwc_avg_generic_depthfirst",
92  [] (const PoolingArgs &args, const Nothing &) -> bool {
93  return args.cpu_info->has_sve() && args.pool_type == PoolingType::AVERAGE;
94  },
95  nullptr,
96  [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<float, float> * {
97  auto strat = new sve_fp32_nhwc_avg_generic_depthfirst(args.cpu_info);
98  return new PoolingDepthfirstGeneric<float>(strat, args);
99  },
100  },
101  {
102  PoolingMethod::DEPTHFIRST,
103  "sve_fp32_nhwc_max_generic_depthfirst",
104  [] (const PoolingArgs &args, const Nothing &) -> bool {
105  return args.cpu_info->has_sve() && args.pool_type == PoolingType::MAX;
106  },
107  nullptr,
108  [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<float, float> * {
109  auto strat = new sve_fp32_nhwc_max_generic_depthfirst(args.cpu_info);
110  return new PoolingDepthfirstGeneric<float>(strat, args);
111  },
112  },
113 #endif // defined(ARM_COMPUTE_ENABLE_SVE)
114  {
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> * {
120  auto strat = new a64_fp32_nhwc_max_2x2_s1_output2x2_depthfirst(args.cpu_info);
121  return new PoolingDepthfirst<float>(strat, args);
122  },
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> * {
130  auto strat = new a64_fp32_nhwc_avg_3x3_s1_output2x2_depthfirst(args.cpu_info);
131  return new PoolingDepthfirst<float>(strat, args);
132  },
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> * {
140  auto strat = new a64_fp32_nhwc_avg_generic_depthfirst(args.cpu_info);
141  return new PoolingDepthfirstGeneric<float>(strat, args);
142  },
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> * {
150  auto strat = new a64_fp32_nhwc_max_generic_depthfirst(args.cpu_info);
151  return new PoolingDepthfirstGeneric<float>(strat, args);
152  },
153  },
154 #endif // defined(__aarch64__)
155  { PoolingMethod::DEFAULT, "", nullptr, nullptr, nullptr }, // End of list
156 };
157 
158 template <>
160 {
161  return pooling_fp32_methods;
162 }
163 
164 template UniquePoolingCommon<float, float> pooling(const PoolingArgs &, const Nothing &);
165 
166 } // namespace pooling
167 } // namespace arm_conv
#define MAX(x, y)
template UniquePoolingCommon< float, float > pooling(const PoolingArgs &, const Nothing &)
const PoolingImplementation< float, float > * pooling_implementation_list()