Compute Library
 23.11
pooling_s8q.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 
29 
30 #if defined(__aarch64__)
31 #if defined(ARM_COMPUTE_ENABLE_SME)
34 #endif // defined(ARM_COMPUTE_ENABLE_SME)
35 #if defined(ARM_COMPUTE_ENABLE_SVE)
38 #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, Requantize32> pooling_s8q_methods[] = {
49 #if defined(__aarch64__)
50 #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)
76 #if defined(ARM_COMPUTE_ENABLE_SVE)
77  {
78  PoolingMethod::DEPTHFIRST,
79  "sve_s8q_nhwc_avg_generic_depthfirst",
80  [] (const PoolingArgs &args, const Requantize32 &) -> bool {
81  return args.cpu_info->has_sve2() && args.pool_type == PoolingType::AVERAGE;
82  },
83  nullptr,
84  [] (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);
87  },
88  },
89  {
90  PoolingMethod::DEPTHFIRST,
91  "sve_s8q_nhwc_max_generic_depthfirst",
92  [] (const PoolingArgs &args, const Requantize32 &) -> bool {
93  return args.cpu_info->has_sve2() && args.pool_type == PoolingType::MAX;
94  },
95  nullptr,
96  [] (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);
99  },
100  },
101 #endif // defined(ARM_COMPUTE_ENABLE_SVE)
102  {
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,
109  [] (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);
112  },
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,
119  [] (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);
122  },
123  },
124 #endif // defined(__aarch64__)
125  { PoolingMethod::DEFAULT, "", nullptr, nullptr, nullptr }, // End of list
126 };
127 
128 template <>
129 const PoolingImplementation<int8_t, int8_t, Requantize32> *pooling_implementation_list()
130 {
131  return pooling_s8q_methods;
132 }
133 
134 template UniquePoolingCommon<int8_t, int8_t> pooling(const PoolingArgs &, const Requantize32 &);
135 
136 } // namespace pooling
137 } // namespace arm_conv
GemmTuner.args
args
Definition: GemmTuner.py:679
arm_gemm_local.hpp
a64_s8q_nhwc_max_generic_depthfirst.hpp
arm_conv::pooling::pooling
template UniquePoolingCommon< float, float > pooling(const PoolingArgs &, const Nothing &)
pooling_depthfirst_generic.hpp
arm_conv::pooling::pooling
template UniquePoolingCommon< int8_t, int8_t > pooling(const PoolingArgs &, const Requantize32 &)
sve_s8q_nhwc_max_generic_depthfirst.hpp
a64_s8q_nhwc_avg_generic_depthfirst.hpp
sme_s8q_nhwc_max_generic_depthfirst.hpp
MAX
#define MAX(x, y)
Definition: elementwise_operation_quantized.cl:28
arm_conv
Definition: addressing.cpp:30
arm_conv::pooling::pooling_implementation_list
const PoolingImplementation< float, float > * pooling_implementation_list()
Definition: pooling_fp32.cpp:217
pooling_implementation.hpp
sme_s8q_nhwc_avg_generic_depthfirst.hpp
sve_s8q_nhwc_avg_generic_depthfirst.hpp