blob: 537a7c5e0124245f5dd0b4980ea2cfd2b51f50a8 [file] [log] [blame]
Michele Di Giorgiod02d5ed2021-01-22 09:47:04 +00001/*
2 * Copyright (c) 2021 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
27#include "depthwise_implementation.hpp"
28#include "depthwise_depthfirst_quantized.hpp"
29#include "depthwise_depthfirst_generic_quantized.hpp"
30#include "depthwise_depthfirst_multiplier_quantized.hpp"
31#include "depthwise_depthfirst_generic_multiplier_quantized.hpp"
32
33#include "depthwise_implementation_constraints.hpp"
34
35#if defined(__aarch64__)
36#if defined(__ARM_FEATURE_SVE) && defined(SVE2)
37#include "kernels/sve_u8s8u8q_nhwc_3x3_s1_output2x2_mla_depthfirst.hpp"
38#include "kernels/sve_u8s8u8q_nhwc_3x3_s2_output2x2_mla_depthfirst.hpp"
39#include "kernels/sve_u8s8u8q_nhwc_5x5_s1_output2x2_mla_depthfirst.hpp"
40#endif // defined(__ARM_FEATURE_SVE) && defined(SVE2)
41#include "kernels/a64_u8s8u8q_nhwc_3x3_s1_output2x2_mla_depthfirst.hpp"
42#include "kernels/a64_u8s8u8q_nhwc_3x3_s2_output2x2_mla_depthfirst.hpp"
43#include "kernels/a64_u8s8u8q_nhwc_5x5_s1_output2x2_mla_depthfirst.hpp"
44#include "kernels/a64_u8s8u8q_nhwc_generic_output9_mla_depthfirst.hpp"
45#include "kernels/a64_u8s8u8q_packed_to_nhwc_generic_with_multiplier_output2x8_mla_depthfirst.hpp"
46#endif // defined(__aarch64__)
47
48#include <cstdint>
49
50using arm_gemm::Requantize32;
51
52namespace arm_conv {
53namespace depthwise {
54
55static const DepthwiseImplementation<uint8_t, int8_t, uint8_t, Requantize32> depthwise_u8q_methods[] = {
56#if defined(__aarch64__)
57#if defined(__ARM_FEATURE_SVE) && defined(SVE2)
58 {
59 DepthwiseMethod::DEPTHFIRST,
60 "sve_u8s8u8q_nhwc_3x3_s1_output2x2_mla_depthfirst",
61 constraint<Requantize32>(is_supported<sve_u8s8u8q_nhwc_3x3_s1_output2x2_mla_depthfirst>,
62 has_no_channel_multiplier,
63 qp_has_no_left_shift),
64 nullptr,
65 [] (const DepthwiseArgs &args, const Requantize32 &qp) -> DepthwiseCommon<uint8_t, int8_t, uint8_t> * {
66 return new DepthwiseDepthfirstQuantized<sve_u8s8u8q_nhwc_3x3_s1_output2x2_mla_depthfirst>(args, qp);
67 },
68 },
69 {
70 DepthwiseMethod::DEPTHFIRST,
71 "sve_u8s8u8q_nhwc_3x3_s2_output2x2_mla_depthfirst",
72 constraint<Requantize32>(is_supported<sve_u8s8u8q_nhwc_3x3_s2_output2x2_mla_depthfirst>,
73 has_no_channel_multiplier,
74 qp_has_no_left_shift),
75 nullptr,
76 [] (const DepthwiseArgs &args, const Requantize32 &qp) -> DepthwiseCommon<uint8_t, int8_t, uint8_t> * {
77 return new DepthwiseDepthfirstQuantized<sve_u8s8u8q_nhwc_3x3_s2_output2x2_mla_depthfirst>(args, qp);
78 },
79 },
80 {
81 DepthwiseMethod::DEPTHFIRST,
82 "sve_u8s8u8q_nhwc_5x5_s1_output2x2_mla_depthfirst",
83 constraint<Requantize32>(is_supported<sve_u8s8u8q_nhwc_5x5_s1_output2x2_mla_depthfirst>,
84 has_no_channel_multiplier,
85 qp_has_no_left_shift),
86 nullptr,
87 [] (const DepthwiseArgs &args, const Requantize32 &qp) -> DepthwiseCommon<uint8_t, int8_t, uint8_t> * {
88 return new DepthwiseDepthfirstQuantized<sve_u8s8u8q_nhwc_5x5_s1_output2x2_mla_depthfirst>(args, qp);
89 },
90 },
91#endif // defined(__ARM_FEATURE_SVE) && defined(SVE2)
92 {
93 DepthwiseMethod::DEPTHFIRST,
94 "a64_u8s8u8q_nhwc_3x3_s1_output2x2_mla_depthfirst",
95 constraint<Requantize32>(is_supported<a64_u8s8u8q_nhwc_3x3_s1_output2x2_mla_depthfirst>,
96 has_no_channel_multiplier,
97 qp_has_no_left_shift),
98 nullptr,
99 [] (const DepthwiseArgs &args, const Requantize32 &qp) -> DepthwiseCommon<uint8_t, int8_t, uint8_t> * {
100 return new DepthwiseDepthfirstQuantized<a64_u8s8u8q_nhwc_3x3_s1_output2x2_mla_depthfirst>(args, qp);
101 },
102 },
103 {
104 DepthwiseMethod::DEPTHFIRST,
105 "a64_u8s8u8q_nhwc_3x3_s2_output2x2_mla_depthfirst",
106 constraint<Requantize32>(is_supported<a64_u8s8u8q_nhwc_3x3_s2_output2x2_mla_depthfirst>,
107 has_no_channel_multiplier,
108 qp_has_no_left_shift),
109 nullptr,
110 [] (const DepthwiseArgs &args, const Requantize32 &qp) -> DepthwiseCommon<uint8_t, int8_t, uint8_t> * {
111 return new DepthwiseDepthfirstQuantized<a64_u8s8u8q_nhwc_3x3_s2_output2x2_mla_depthfirst>(args, qp);
112 },
113 },
114 {
115 DepthwiseMethod::DEPTHFIRST,
116 "a64_u8s8u8q_nhwc_5x5_s1_output2x2_mla_depthfirst",
117 constraint<Requantize32>(is_supported<a64_u8s8u8q_nhwc_5x5_s1_output2x2_mla_depthfirst>,
118 has_no_channel_multiplier,
119 qp_has_no_left_shift),
120 nullptr,
121 [] (const DepthwiseArgs &args, const Requantize32 &qp) -> DepthwiseCommon<uint8_t, int8_t, uint8_t> * {
122 return new DepthwiseDepthfirstQuantized<a64_u8s8u8q_nhwc_5x5_s1_output2x2_mla_depthfirst>(args, qp);
123 },
124 },
125 {
126 DepthwiseMethod::DEPTHFIRST,
127 "a64_u8s8u8q_nhwc_generic_output3x3_mla_depthfirst",
128 constraint<Requantize32>(has_no_channel_multiplier),
129 nullptr,
130 [] (const DepthwiseArgs &args, const Requantize32 &qp) -> DepthwiseCommon<uint8_t, int8_t, uint8_t> * {
131 return new DepthwiseDepthfirstGenericQuantized<a64_u8s8u8q_nhwc_generic_output9_mla_depthfirst, 3, 3>(args, qp);
132 },
133 },
134 {
135 DepthwiseMethod::DEPTHFIRST,
136 "a64_u8s8u8q_packed_to_nhwc_generic_with_multiplier_output2x8_mla_depthfirst",
137 nullptr,
138 nullptr,
139 [] (const DepthwiseArgs &args, const Requantize32 &qp) -> DepthwiseCommon<uint8_t, int8_t, uint8_t> * {
140 return new DepthwiseDepthfirstGenericWithMultiplierQuantized<a64_u8s8u8q_packed_to_nhwc_generic_with_multiplier_output2x8_mla_depthfirst>(args, qp);
141 },
142 },
143#endif // defined(__aarch64__)
144 { DepthwiseMethod::DEFAULT, "", nullptr, nullptr, nullptr }, // End of list
145};
146
147template <>
148const DepthwiseImplementation<uint8_t, int8_t, uint8_t, Requantize32> *depthwise_implementation_list()
149{
150 return depthwise_u8q_methods;
151}
152
153template UniqueDepthwiseCommon<uint8_t, int8_t, uint8_t> depthwise(const DepthwiseArgs &, const Requantize32 &);
154template std::vector<KernelDescription> get_compatible_kernels<uint8_t, int8_t, uint8_t, Requantize32>(const DepthwiseArgs &, const Requantize32 &);
155
156} // namespace depthwise
157} // namespace arm_conv