Michalis Spyrou | 71ac903 | 2019-11-14 14:31:44 +0000 | [diff] [blame] | 1 | /* |
David Mansell | e695579 | 2024-01-12 11:08:56 +0000 | [diff] [blame^] | 2 | * Copyright (c) 2019-2020, 2022-2024 Arm Limited. |
Michalis Spyrou | 71ac903 | 2019-11-14 14:31:44 +0000 | [diff] [blame] | 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 | #ifdef __aarch64__ |
| 25 | |
| 26 | #include "arm_gemm.hpp" |
| 27 | |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 28 | #include "kernels/a64_gemm_s16_8x12.hpp" |
| 29 | #include "kernels/a64_gemm_s8_4x4.hpp" |
| 30 | #include "kernels/a64_gemm_s8_8x12.hpp" |
| 31 | #include "kernels/a64_hybrid_s8qa_dot_4x16.hpp" |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 32 | #include "kernels/a64_hybrid_s8qa_mmla_4x16.hpp" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 33 | #include "kernels/a64_hybrid_s8qs_dot_6x16.hpp" |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 34 | #include "kernels/a64_hybrid_s8qs_mmla_6x16.hpp" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 35 | #include "kernels/a64_hybrid_s8s32_dot_6x16.hpp" |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 36 | #include "kernels/a64_hybrid_s8s32_mmla_6x16.hpp" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 37 | #include "kernels/a64_interleaved_s8s32_mmla_8x12.hpp" |
| 38 | #include "kernels/a64_smallK_hybrid_s8s32_dot_6x4.hpp" |
| 39 | #include "kernels/a64_smallK_hybrid_s8s32_dot_8x4.hpp" |
Michalis Spyrou | 71ac903 | 2019-11-14 14:31:44 +0000 | [diff] [blame] | 40 | |
Viet-Hoa Do | 03b2971 | 2022-06-01 11:47:14 +0100 | [diff] [blame] | 41 | #ifdef ARM_COMPUTE_ENABLE_SVE |
| 42 | #ifdef ARM_COMPUTE_ENABLE_SME2 |
| 43 | #include "kernels/sme2_gemv_s8qa_dot_16VL.hpp" |
| 44 | #include "kernels/sme2_interleaved_nomerge_s8q_mopa_1VLx4VL.hpp" |
| 45 | #include "kernels/sme2_interleaved_nomerge_s8q_mopa_2VLx2VL.hpp" |
| 46 | #include "kernels/sme2_interleaved_nomerge_s8q_mopa_4VLx1VL.hpp" |
| 47 | #endif // ARM_COMPUTE_ENABLE_SME2 |
| 48 | |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 49 | #include "kernels/sve_hybrid_s8qa_dot_4x4VL.hpp" |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 50 | #include "kernels/sve_hybrid_s8qa_mmla_4x4VL.hpp" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 51 | #include "kernels/sve_hybrid_s8qs_dot_6x4VL.hpp" |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 52 | #include "kernels/sve_hybrid_s8qs_mmla_6x4VL.hpp" |
| 53 | #include "kernels/sve_hybrid_s8s32_dot_6x4VL.hpp" |
| 54 | #include "kernels/sve_hybrid_s8s32_mmla_6x4VL.hpp" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 55 | #include "kernels/sve_interleaved_s8s32_dot_8x3VL.hpp" |
| 56 | #include "kernels/sve_interleaved_s8s32_mmla_8x3VL.hpp" |
Viet-Hoa Do | 03b2971 | 2022-06-01 11:47:14 +0100 | [diff] [blame] | 57 | #endif // ARM_COMPUTE_ENABLE_SVE |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 58 | |
| 59 | #include "gemm_hybrid_indirect.hpp" |
Michalis Spyrou | 71ac903 | 2019-11-14 14:31:44 +0000 | [diff] [blame] | 60 | #include "gemm_hybrid_quantized.hpp" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 61 | #include "gemm_hybrid_quantized_inline.hpp" |
| 62 | #include "gemm_interleaved.hpp" |
Viet-Hoa Do | 03b2971 | 2022-06-01 11:47:14 +0100 | [diff] [blame] | 63 | #include "gemv_pretransposed.hpp" |
Michalis Spyrou | 71ac903 | 2019-11-14 14:31:44 +0000 | [diff] [blame] | 64 | #include "quantize_wrapper.hpp" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 65 | #include "utils.hpp" |
Michalis Spyrou | 71ac903 | 2019-11-14 14:31:44 +0000 | [diff] [blame] | 66 | |
| 67 | namespace arm_gemm { |
| 68 | |
| 69 | static const GemmImplementation<int8_t, int8_t, Requantize32> gemm_qint8_methods[] = |
| 70 | { |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 71 | #ifdef ARM_COMPUTE_ENABLE_SVE |
Viet-Hoa Do | 03b2971 | 2022-06-01 11:47:14 +0100 | [diff] [blame] | 72 | #ifdef ARM_COMPUTE_ENABLE_SME2 |
| 73 | { |
| 74 | GemmMethod::GEMM_HYBRID, |
| 75 | "sme2_gemv_s8qa_dot_16VL", |
| 76 | [](const GemmArgs &args, const Requantize32 &qp) { return args._ci->has_sme2() && quant_hybrid_asymmetric(qp) && args._Msize == 1 && !args._indirect_input && args._nbatches == 1; }, |
| 77 | nullptr, |
| 78 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemvPretransposed<cls_sme2_gemv_s8qa_dot_16VL, int8_t, int8_t, Requantize32>(args, qp); } |
| 79 | }, |
| 80 | { |
| 81 | GemmMethod::GEMM_INTERLEAVED, |
| 82 | "sme2_interleaved_nomerge_s8q_mopa_1VLx4VL", |
David Mansell | e695579 | 2024-01-12 11:08:56 +0000 | [diff] [blame^] | 83 | [](const GemmArgs &args, const Requantize32 &qp) { return args._ci->has_sme2() && ((qp.per_channel_requant && (qp.per_channel_left_shifts == nullptr)) || (!qp.per_channel_requant && (qp.per_layer_left_shift == 0)));}, |
Viet-Hoa Do | 03b2971 | 2022-06-01 11:47:14 +0100 | [diff] [blame] | 84 | [](const GemmArgs &args, const Requantize32 &) { const auto VL = sme::get_vector_length<int32_t>(); |
| 85 | return args._Msize <= VL || (2*VL < args._Msize && args._Msize <= 3*VL); }, |
| 86 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmInterleavedPretransposedNoMergeQuantizedInline<cls_sme2_interleaved_nomerge_s8q_mopa_1VLx4VL, int8_t, int8_t>(args, qp); } |
| 87 | }, |
| 88 | { |
| 89 | GemmMethod::GEMM_INTERLEAVED, |
| 90 | "sme2_interleaved_nomerge_s8q_mopa_4VLx1VL", |
David Mansell | e695579 | 2024-01-12 11:08:56 +0000 | [diff] [blame^] | 91 | [](const GemmArgs &args, const Requantize32 &qp) { return args._ci->has_sme2() && ((qp.per_channel_requant && (qp.per_channel_left_shifts == nullptr)) || (!qp.per_channel_requant && (qp.per_layer_left_shift == 0)));}, |
Viet-Hoa Do | 03b2971 | 2022-06-01 11:47:14 +0100 | [diff] [blame] | 92 | [](const GemmArgs &args, const Requantize32 &) { const auto VL = sme::get_vector_length<int32_t>(); |
| 93 | return args._Nsize <= VL || (2*VL < args._Nsize && args._Nsize <= 3*VL); }, |
| 94 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmInterleavedPretransposedNoMergeQuantizedInline<cls_sme2_interleaved_nomerge_s8q_mopa_4VLx1VL, int8_t, int8_t>(args, qp); } |
| 95 | }, |
| 96 | { |
| 97 | GemmMethod::GEMM_INTERLEAVED, |
| 98 | "sme2_interleaved_nomerge_s8q_mopa_2VLx2VL", |
David Mansell | e695579 | 2024-01-12 11:08:56 +0000 | [diff] [blame^] | 99 | [](const GemmArgs &args, const Requantize32 &qp) { return args._ci->has_sme2() && ((qp.per_channel_requant && (qp.per_channel_left_shifts == nullptr)) || (!qp.per_channel_requant && (qp.per_layer_left_shift == 0)));}, |
Viet-Hoa Do | 03b2971 | 2022-06-01 11:47:14 +0100 | [diff] [blame] | 100 | nullptr, |
| 101 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmInterleavedPretransposedNoMergeQuantizedInline<cls_sme2_interleaved_nomerge_s8q_mopa_2VLx2VL, int8_t, int8_t>(args, qp); } |
| 102 | }, |
| 103 | #endif // ARM_COMPUTE_ENABLE_SME2 |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 104 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
| 105 | GemmMethod::GEMM_HYBRID, |
| 106 | "sve_hybrid_s8qa_mmla_4x4VL", |
| 107 | [](const GemmArgs &args, const Requantize32 &qp) { return quant_hybrid_asymmetric(qp) && args._ci->has_sve2() && args._ci->has_svei8mm(); }, |
| 108 | [](const GemmArgs &args, const Requantize32 &) { return GemmHybridIndirect<cls_sve_hybrid_s8qa_mmla_4x4VL, int8_t, int8_t, Requantize32>::estimate_cycles<int8_t>(args); }, |
| 109 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridIndirect<cls_sve_hybrid_s8qa_mmla_4x4VL, int8_t, int8_t, Requantize32>(args, qp); } |
| 110 | ), |
| 111 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
| 112 | GemmMethod::GEMM_HYBRID, |
| 113 | "sve_hybrid_s8qs_mmla_6x4VL", |
| 114 | [](const GemmArgs &args, const Requantize32 &qp) { return quant_hybrid_symmetric(qp) && args._ci->has_sve2() && args._ci->has_svei8mm(); }, |
| 115 | [](const GemmArgs &args, const Requantize32 &) { return GemmHybridIndirect<cls_sve_hybrid_s8qs_mmla_6x4VL, int8_t, int8_t, Requantize32>::estimate_cycles<int8_t>(args); }, |
| 116 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridIndirect<cls_sve_hybrid_s8qs_mmla_6x4VL, int8_t, int8_t, Requantize32>(args, qp); } |
| 117 | ), |
| 118 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 119 | GemmMethod::GEMM_INTERLEAVED, |
| 120 | "sve_interleaved_s8s32_mmla_8x3VL", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 121 | [](const GemmArgs &args, const Requantize32 &) { return args._ci->has_svei8mm() && (args._Ksize>8); }, |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 122 | [](const GemmArgs &args, const Requantize32 &) { return GemmInterleavedQuantized<cls_sve_interleaved_s8s32_mmla_8x3VL, int8_t, int8_t>::estimate_cycles<int8_t>(args); }, |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 123 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmInterleavedQuantized<cls_sve_interleaved_s8s32_mmla_8x3VL, int8_t, int8_t>(args, qp); } |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 124 | ), |
| 125 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
| 126 | GemmMethod::GEMM_INTERLEAVED, |
| 127 | "sve_hybrid_s8s32_mmla_6x4VL", |
| 128 | [](const GemmArgs &args, const Requantize32 &) { return args._ci->has_svei8mm(); }, |
| 129 | [](const GemmArgs &args, const Requantize32 &) { return GemmHybridIndirect<cls_sve_hybrid_s8s32_mmla_6x4VL, int8_t, int8_t, Requantize32, true>::estimate_cycles<int8_t>(args); }, |
| 130 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridIndirect<cls_sve_hybrid_s8s32_mmla_6x4VL, int8_t, int8_t, Requantize32, true>(args, qp); } |
| 131 | ), |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 132 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 133 | GemmMethod::GEMM_HYBRID, |
| 134 | "sve_hybrid_s8qs_dot_6x4VL", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 135 | [](const GemmArgs &args, const Requantize32 &qp) { return args._ci->has_sve2() && quant_hybrid_symmetric(qp); }, |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 136 | [](const GemmArgs &args, const Requantize32 &) { return GemmHybridIndirect<cls_sve_hybrid_s8qs_dot_6x4VL, int8_t, int8_t, Requantize32>::estimate_cycles<int8_t>(args); }, |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 137 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridIndirect<cls_sve_hybrid_s8qs_dot_6x4VL, int8_t, int8_t, Requantize32>(args, qp); } |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 138 | ), |
| 139 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 140 | GemmMethod::GEMM_HYBRID, |
| 141 | "sve_hybrid_s8qa_dot_4x4VL", |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 142 | [](const GemmArgs &args, const Requantize32 &qp) { return args._ci->has_sve2() && quant_hybrid_asymmetric(qp); }, |
| 143 | [](const GemmArgs &args, const Requantize32 &) { return GemmHybridIndirect<cls_sve_hybrid_s8qa_dot_4x4VL, int8_t, int8_t, Requantize32>::estimate_cycles<int8_t>(args); }, |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 144 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridIndirect<cls_sve_hybrid_s8qa_dot_4x4VL, int8_t, int8_t, Requantize32>(args, qp); } |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 145 | ), |
| 146 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 147 | GemmMethod::GEMM_HYBRID, |
| 148 | "sve_hybrid_s8s32_dot_6x4VL", |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 149 | [](const GemmArgs &args, const Requantize32 &) { return args._ci->has_sve(); }, |
| 150 | [](const GemmArgs &args, const Requantize32 &) { return GemmHybridIndirect<cls_sve_hybrid_s8s32_dot_6x4VL, int8_t, int8_t, Requantize32, true>::estimate_cycles<int8_t>(args); }, |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 151 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridIndirect<cls_sve_hybrid_s8s32_dot_6x4VL, int8_t, int8_t, Requantize32, true>(args, qp); } |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 152 | ), |
| 153 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 154 | GemmMethod::GEMM_INTERLEAVED, |
| 155 | "sve_interleaved_s8s32_dot_8x3VL", |
Pablo Marquez Tello | a50f193 | 2021-03-08 17:27:05 +0000 | [diff] [blame] | 156 | [](const GemmArgs &args, const Requantize32 &) { return args._ci->has_sve() && (args._Ksize>4); }, |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 157 | [](const GemmArgs &args, const Requantize32 &) { return GemmInterleavedQuantized<cls_sve_interleaved_s8s32_dot_8x3VL, int8_t, int8_t>::estimate_cycles<int8_t>(args); }, |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 158 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmInterleavedQuantized<cls_sve_interleaved_s8s32_dot_8x3VL, int8_t, int8_t>(args, qp); } |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 159 | ), |
| 160 | #endif // ARM_COMPUTE_ENABLE_SVE |
| 161 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
| 162 | GemmMethod::GEMM_HYBRID, |
| 163 | "a64_hybrid_s8qa_mmla_4x16", |
| 164 | [](const GemmArgs &args, const Requantize32 &qp) { return args._ci->has_i8mm() && quant_hybrid_asymmetric(qp); }, |
| 165 | [](const GemmArgs &args, const Requantize32 &) { return GemmHybridIndirect<cls_a64_hybrid_s8qa_mmla_4x16, int8_t, int8_t, Requantize32>::estimate_cycles<int8_t>(args); }, |
| 166 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridIndirect<cls_a64_hybrid_s8qa_mmla_4x16, int8_t, int8_t, Requantize32>(args, qp); } |
| 167 | ), |
| 168 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
| 169 | GemmMethod::GEMM_HYBRID, |
| 170 | "a64_hybrid_s8qs_mmla_6x16", |
| 171 | [](const GemmArgs &args, const Requantize32 &qp) { return args._ci->has_i8mm() && quant_hybrid_symmetric(qp); }, |
| 172 | [](const GemmArgs &args, const Requantize32 &) { return GemmHybridIndirect<cls_a64_hybrid_s8qs_mmla_6x16, int8_t, int8_t, Requantize32>::estimate_cycles<int8_t>(args); }, |
| 173 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridIndirect<cls_a64_hybrid_s8qs_mmla_6x16, int8_t, int8_t, Requantize32>(args, qp); } |
| 174 | ), |
| 175 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 176 | GemmMethod::GEMM_INTERLEAVED, |
| 177 | "a64_interleaved_s8s32_mmla_8x12", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 178 | [](const GemmArgs &args, const Requantize32 &) { return args._ci->has_i8mm() && (args._Ksize>8); }, |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 179 | [](const GemmArgs &args, const Requantize32 &) { return GemmInterleavedQuantized<cls_a64_interleaved_s8s32_mmla_8x12, int8_t, int8_t>::estimate_cycles<int8_t>(args); }, |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 180 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmInterleavedQuantized<cls_a64_interleaved_s8s32_mmla_8x12, int8_t, int8_t>(args, qp); } |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 181 | ), |
| 182 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
| 183 | GemmMethod::GEMM_INTERLEAVED, |
| 184 | "a64_hybrid_s8s32_mmla_6x16", |
| 185 | [](const GemmArgs &args, const Requantize32 &) { return args._ci->has_i8mm(); }, |
| 186 | [](const GemmArgs &args, const Requantize32 &) { return GemmHybridIndirect<cls_a64_hybrid_s8s32_mmla_6x16, int8_t, int8_t, Requantize32, true>::estimate_cycles<int8_t>(args); }, |
| 187 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridIndirect<cls_a64_hybrid_s8s32_mmla_6x16, int8_t, int8_t, Requantize32, true>(args, qp); } |
| 188 | ), |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 189 | { |
| 190 | GemmMethod::GEMM_HYBRID_QUANTIZED, |
| 191 | "a64_smallK_hybrid_s8s32_dot_8x4", |
| 192 | [](const GemmArgs &args, const Requantize32 &) { return args._ci->has_dotprod() && (args._Nsize % 4 == 0) && (args._Ksize<=32) && !args._indirect_input; }, |
Gunes Bayir | e42a87f | 2021-09-13 13:24:38 +0100 | [diff] [blame] | 193 | [](const GemmArgs &args, const Requantize32 &) { return !(args._ci->has_svei8mm() || args._ci->has_i8mm()); }, |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 194 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridQuantized<cls_a64_smallK_hybrid_s8s32_dot_8x4, int8_t, int8_t>(args, qp); } |
Michalis Spyrou | 71ac903 | 2019-11-14 14:31:44 +0000 | [diff] [blame] | 195 | }, |
| 196 | { |
| 197 | GemmMethod::GEMM_HYBRID_QUANTIZED, |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 198 | "a64_smallK_hybrid_s8s32_dot_6x4", |
| 199 | [](const GemmArgs &args, const Requantize32 &) { return args._ci->has_dotprod() && (args._Nsize % 4 == 0) && (args._Ksize>32) && (args._Ksize<=64) && !args._indirect_input; }, |
Gunes Bayir | e42a87f | 2021-09-13 13:24:38 +0100 | [diff] [blame] | 200 | [](const GemmArgs &args, const Requantize32 &) { return !(args._ci->has_svei8mm() || args._ci->has_i8mm()); }, |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 201 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridQuantized<cls_a64_smallK_hybrid_s8s32_dot_6x4, int8_t, int8_t>(args, qp); } |
Michalis Spyrou | 71ac903 | 2019-11-14 14:31:44 +0000 | [diff] [blame] | 202 | }, |
| 203 | { |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 204 | GemmMethod::GEMM_INTERLEAVED, |
| 205 | "a64_gemm_s16_8x12", |
Aleksandr Nikolaev | a084b46 | 2020-06-25 12:25:52 +0100 | [diff] [blame] | 206 | nullptr, |
Georgios Pinitas | cd22cbf | 2020-12-02 16:06:01 +0000 | [diff] [blame] | 207 | [](const GemmArgs &args, const Requantize32 &) { return args._ci->get_cpu_model() == CPUModel::A53 && ((args._Msize > 28) || ((args._Msize % 8) > 4)); }, |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 208 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmInterleavedQuantized<cls_a64_gemm_s16_8x12, int8_t, int8_t>(args, qp); } |
| 209 | }, |
Georgios Pinitas | 33e0307 | 2021-01-14 13:43:40 +0000 | [diff] [blame] | 210 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 211 | GemmMethod::GEMM_HYBRID, |
| 212 | "a64_hybrid_s8qs_dot_6x16", |
| 213 | [](const GemmArgs &args, const Requantize32 &qp) { return args._ci->has_dotprod() && quant_hybrid_symmetric(qp); }, |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 214 | [](const GemmArgs &args, const Requantize32 &) { return GemmHybridIndirect<cls_a64_hybrid_s8qs_dot_6x16, int8_t, int8_t, Requantize32>::estimate_cycles<int8_t>(args); }, |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 215 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridIndirect<cls_a64_hybrid_s8qs_dot_6x16, int8_t, int8_t, Requantize32>(args, qp); } |
Georgios Pinitas | 33e0307 | 2021-01-14 13:43:40 +0000 | [diff] [blame] | 216 | ), |
| 217 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 218 | GemmMethod::GEMM_HYBRID, |
| 219 | "a64_hybrid_s8qa_dot_4x16", |
| 220 | [](const GemmArgs &args, const Requantize32 &qp) { return args._ci->has_dotprod() && quant_hybrid_asymmetric(qp); }, |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 221 | [](const GemmArgs &args, const Requantize32 &) { return GemmHybridIndirect<cls_a64_hybrid_s8qa_dot_4x16, int8_t, int8_t, Requantize32>::estimate_cycles<int8_t>(args); }, |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 222 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridIndirect<cls_a64_hybrid_s8qa_dot_4x16, int8_t, int8_t, Requantize32>(args, qp); } |
Georgios Pinitas | 33e0307 | 2021-01-14 13:43:40 +0000 | [diff] [blame] | 223 | ), |
| 224 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 225 | GemmMethod::GEMM_HYBRID, |
| 226 | "a64_hybrid_s8s32_dot_6x16", |
| 227 | [](const GemmArgs &args, const Requantize32 &) { return args._ci->has_dotprod(); }, |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 228 | [](const GemmArgs &args, const Requantize32 &) { return GemmHybridIndirect<cls_a64_hybrid_s8s32_dot_6x16, int8_t, int8_t, Requantize32, true>::estimate_cycles<int8_t>(args); }, |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 229 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridIndirect<cls_a64_hybrid_s8s32_dot_6x16, int8_t, int8_t, Requantize32, true>(args, qp); } |
Georgios Pinitas | 33e0307 | 2021-01-14 13:43:40 +0000 | [diff] [blame] | 230 | ), |
| 231 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 232 | GemmMethod::GEMM_INTERLEAVED, |
| 233 | "a64_gemm_s8_8x12", |
| 234 | [](const GemmArgs &args, const Requantize32 &) { return args._ci->has_dotprod(); }, |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 235 | [](const GemmArgs &args, const Requantize32 &) { return GemmInterleavedQuantized<cls_a64_gemm_s8_8x12, int8_t, int8_t>::estimate_cycles<int8_t>(args); }, |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 236 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmInterleavedQuantized<cls_a64_gemm_s8_8x12, int8_t, int8_t>(args, qp); } |
Georgios Pinitas | 33e0307 | 2021-01-14 13:43:40 +0000 | [diff] [blame] | 237 | ), |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 238 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 239 | GemmMethod::GEMM_INTERLEAVED, |
| 240 | "a64_gemm_s8_4x4", |
| 241 | nullptr, |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 242 | [](const GemmArgs &args, const Requantize32 &) { return GemmInterleavedQuantized<cls_a64_gemm_s8_4x4, int8_t, int8_t>::estimate_cycles<int8_t>(args); }, |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 243 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmInterleavedQuantized<cls_a64_gemm_s8_4x4, int8_t, int8_t>(args, qp); } |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 244 | ), |
Michalis Spyrou | 71ac903 | 2019-11-14 14:31:44 +0000 | [diff] [blame] | 245 | { |
| 246 | GemmMethod::QUANTIZE_WRAPPER, |
| 247 | "quantized_wrapper", |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 248 | [](const GemmArgs &args, const Requantize32 &) { return !args._indirect_input; }, |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 249 | [](const GemmArgs &, const Requantize32 &) { return false; }, |
Michalis Spyrou | 71ac903 | 2019-11-14 14:31:44 +0000 | [diff] [blame] | 250 | [](const GemmArgs &args, const Requantize32 &qp) { return new QuantizeWrapper<int8_t, int8_t, int32_t>(args, qp); } |
| 251 | }, |
| 252 | { |
| 253 | GemmMethod::DEFAULT, |
| 254 | "", |
| 255 | nullptr, |
| 256 | nullptr, |
| 257 | nullptr |
| 258 | } |
| 259 | }; |
| 260 | |
| 261 | template<> |
| 262 | const GemmImplementation<int8_t, int8_t, Requantize32> *gemm_implementation_list<int8_t, int8_t, Requantize32>() { |
| 263 | return gemm_qint8_methods; |
| 264 | } |
| 265 | |
| 266 | template UniqueGemmCommon<int8_t, int8_t> gemm<int8_t, int8_t, Requantize32>(const GemmArgs &args, const Requantize32 &os); |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 267 | template bool has_opt_gemm<int8_t, int8_t, Requantize32>(WeightFormat &weight_format, const GemmArgs &args, const Requantize32 &os); |
Michael Tyler | 74921ee | 2023-04-12 17:43:17 +0100 | [diff] [blame] | 268 | template KernelDescription get_gemm_method<int8_t, int8_t, Requantize32>(const GemmArgs &args, const Requantize32 &os); |
Michalis Spyrou | 71ac903 | 2019-11-14 14:31:44 +0000 | [diff] [blame] | 269 | template std::vector<KernelDescription> get_compatible_kernels<int8_t, int8_t, Requantize32>(const GemmArgs &args, const Requantize32 &os); |
| 270 | |
| 271 | } // namespace arm_gemm |
| 272 | |
| 273 | #endif // __aarch64__ |