Compute Library
 22.11
pooling_s8.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)
37 #endif // defined(ARM_COMPUTE_ENABLE_SVE)
41 #endif // defined(__aarch64__)
42 
43 #include <cstdint>
44 
45 namespace arm_conv {
46 namespace pooling {
47 
48 static 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> * {
57  auto strat = new cpp_nhwc_1x1_stride_any_depthfirst<int8_t>(args.cpu_info);
58  return new PoolingDepthfirstGeneric<int8_t>(strat, args);
59  },
60  },
61 #if defined(__aarch64__)
62 #if defined(ARM_COMPUTE_ENABLE_SVE)
63  {
64  PoolingMethod::DEPTHFIRST,
65  "sve_s8_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_s8_nhwc_max_2x2_s1_output2x2_depthfirst>(args, os);
69  },
70  nullptr,
71  [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<int8_t, int8_t> * {
72  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);
86  },
87  },
88  {
89  PoolingMethod::DEPTHFIRST,
90  "sve_s8_nhwc_max_generic_depthfirst",
91  [] (const PoolingArgs &args, const Nothing &) -> bool {
92  return args.cpu_info->has_sve() && args.pool_type == PoolingType::MAX;
93  },
94  nullptr,
95  [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<int8_t, int8_t> * {
96  auto strat = new sve_s8_nhwc_max_generic_depthfirst(args.cpu_info);
97  return new PoolingDepthfirstGeneric<int8_t>(strat, args);
98  },
99  },
100 #endif // defined(ARM_COMPUTE_ENABLE_SVE)
101  {
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> * {
107  auto strat = new a64_s8_nhwc_max_2x2_s1_output2x2_depthfirst(args.cpu_info);
108  return new PoolingDepthfirst<int8_t>(strat, args);
109  },
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> * {
117  auto strat = new a64_s8_nhwc_avg_generic_depthfirst(args.cpu_info);
118  return new PoolingDepthfirstGeneric<int8_t>(strat, args);
119  },
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> * {
127  auto strat = new a64_s8_nhwc_max_generic_depthfirst(args.cpu_info);
128  return new PoolingDepthfirstGeneric<int8_t>(strat, args);
129  },
130  },
131 #endif // defined(__aarch64__)
132  { PoolingMethod::DEFAULT, "", nullptr, nullptr, nullptr }, // End of list
133 };
134 
135 template <>
137 {
138  return pooling_s8_methods;
139 }
140 
141 template UniquePoolingCommon<int8_t, int8_t> pooling(const PoolingArgs &, const Nothing &);
142 
143 } // namespace pooling
144 } // namespace arm_conv
#define MAX(x, y)
template UniquePoolingCommon< float, float > pooling(const PoolingArgs &, const Nothing &)
const PoolingImplementation< float, float > * pooling_implementation_list()