Compute Library
 22.11
pooling_u8q.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_SVE)
34 #endif // defined(ARM_COMPUTE_ENABLE_SVE)
37 #endif // defined(__aarch64__)
38 
39 #include <cstdint>
40 
41 namespace arm_conv {
42 namespace pooling {
43 
44 static const PoolingImplementation<uint8_t, uint8_t, Requantize32> pooling_u8q_methods[] = {
45 #if defined(__aarch64__)
46 #if defined(ARM_COMPUTE_ENABLE_SVE)
47  {
48  PoolingMethod::DEPTHFIRST,
49  "sve_u8q_nhwc_avg_generic_depthfirst",
50  [] (const PoolingArgs &args, const Requantize32 &) -> bool {
51  return args.cpu_info->has_sve2() && args.pool_type == PoolingType::AVERAGE;
52  },
53  nullptr,
54  [] (const PoolingArgs &args, const Requantize32 &rq) -> PoolingCommon<uint8_t, uint8_t> * {
55  auto strat = new sve_u8q_nhwc_avg_generic_depthfirst(args.cpu_info);
56  return new PoolingDepthfirstGeneric<uint8_t, uint8_t, Requantize32>(strat, args, rq);
57  },
58  },
59  {
60  PoolingMethod::DEPTHFIRST,
61  "sve_u8q_nhwc_max_generic_depthfirst",
62  [] (const PoolingArgs &args, const Requantize32 &) -> bool {
63  return args.cpu_info->has_sve2() && args.pool_type == PoolingType::MAX;
64  },
65  nullptr,
66  [] (const PoolingArgs &args, const Requantize32 &rq) -> PoolingCommon<uint8_t, uint8_t> * {
67  auto strat = new sve_u8q_nhwc_max_generic_depthfirst(args.cpu_info);
68  return new PoolingDepthfirstGeneric<uint8_t, uint8_t, Requantize32>(strat, args, rq);
69  },
70  },
71 #endif // defined(ARM_COMPUTE_ENABLE_SVE)
72  {
73  PoolingMethod::DEPTHFIRST,
74  "a64_u8q_nhwc_avg_generic_depthfirst",
75  [] (const PoolingArgs &args, const Requantize32 &) -> bool {
76  return args.pool_type == PoolingType::AVERAGE;
77  },
78  nullptr,
79  [] (const PoolingArgs &args, const Requantize32 &rq) -> PoolingCommon<uint8_t, uint8_t> * {
80  auto strat = new a64_u8q_nhwc_avg_generic_depthfirst(args.cpu_info);
81  return new PoolingDepthfirstGeneric<uint8_t, uint8_t, Requantize32>(strat, args, rq);
82  },
83  },
84  {
85  PoolingMethod::DEPTHFIRST,
86  "a64_u8q_nhwc_max_generic_depthfirst",
87  [] (const PoolingArgs &args, const Requantize32 &) -> bool { return args.pool_type == PoolingType::MAX; },
88  nullptr,
89  [] (const PoolingArgs &args, const Requantize32 &rq) -> PoolingCommon<uint8_t, uint8_t> * {
90  auto strat = new a64_u8q_nhwc_max_generic_depthfirst(args.cpu_info);
91  return new PoolingDepthfirstGeneric<uint8_t, uint8_t, Requantize32>(strat, args, rq);
92  },
93  },
94 #endif // defined(__aarch64__)
95  { PoolingMethod::DEFAULT, "", nullptr, nullptr, nullptr }, // End of list
96 };
97 
98 template <>
100 {
101  return pooling_u8q_methods;
102 }
103 
104 template UniquePoolingCommon<uint8_t, uint8_t> pooling(const PoolingArgs &, const Requantize32 &);
105 
106 } // namespace pooling
107 } // namespace arm_conv
#define MAX(x, y)
template UniquePoolingCommon< float, float > pooling(const PoolingArgs &, const Nothing &)
const PoolingImplementation< float, float > * pooling_implementation_list()