Michalis Spyrou | 71ac903 | 2019-11-14 14:31:44 +0000 | [diff] [blame] | 1 | /* |
Francesco.Petrogalli@arm.com | 193cad3 | 2022-03-07 13:39:21 +0000 | [diff] [blame] | 2 | * Copyright (c) 2019-2020, 2022 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 | |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 41 | #include "kernels/sve_hybrid_s8qa_dot_4x4VL.hpp" |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 42 | #include "kernels/sve_hybrid_s8qa_mmla_4x4VL.hpp" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 43 | #include "kernels/sve_hybrid_s8qs_dot_6x4VL.hpp" |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 44 | #include "kernels/sve_hybrid_s8qs_mmla_6x4VL.hpp" |
| 45 | #include "kernels/sve_hybrid_s8s32_dot_6x4VL.hpp" |
| 46 | #include "kernels/sve_hybrid_s8s32_mmla_6x4VL.hpp" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 47 | #include "kernels/sve_interleaved_s8s32_dot_8x3VL.hpp" |
| 48 | #include "kernels/sve_interleaved_s8s32_mmla_8x3VL.hpp" |
| 49 | #include "kernels/sve_smallK_hybrid_s8s32_dot_8x1VL.hpp" |
| 50 | |
| 51 | #include "gemm_hybrid_indirect.hpp" |
Michalis Spyrou | 71ac903 | 2019-11-14 14:31:44 +0000 | [diff] [blame] | 52 | #include "gemm_hybrid_quantized.hpp" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 53 | #include "gemm_hybrid_quantized_inline.hpp" |
| 54 | #include "gemm_interleaved.hpp" |
Michalis Spyrou | 71ac903 | 2019-11-14 14:31:44 +0000 | [diff] [blame] | 55 | #include "quantize_wrapper.hpp" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 56 | #include "utils.hpp" |
Michalis Spyrou | 71ac903 | 2019-11-14 14:31:44 +0000 | [diff] [blame] | 57 | |
| 58 | namespace arm_gemm { |
| 59 | |
| 60 | static const GemmImplementation<int8_t, int8_t, Requantize32> gemm_qint8_methods[] = |
| 61 | { |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 62 | #ifdef ARM_COMPUTE_ENABLE_SVE |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 63 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
| 64 | GemmMethod::GEMM_HYBRID, |
| 65 | "sve_hybrid_s8qa_mmla_4x4VL", |
| 66 | [](const GemmArgs &args, const Requantize32 &qp) { return quant_hybrid_asymmetric(qp) && args._ci->has_sve2() && args._ci->has_svei8mm(); }, |
| 67 | [](const GemmArgs &args, const Requantize32 &) { return GemmHybridIndirect<cls_sve_hybrid_s8qa_mmla_4x4VL, int8_t, int8_t, Requantize32>::estimate_cycles<int8_t>(args); }, |
| 68 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridIndirect<cls_sve_hybrid_s8qa_mmla_4x4VL, int8_t, int8_t, Requantize32>(args, qp); } |
| 69 | ), |
| 70 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
| 71 | GemmMethod::GEMM_HYBRID, |
| 72 | "sve_hybrid_s8qs_mmla_6x4VL", |
| 73 | [](const GemmArgs &args, const Requantize32 &qp) { return quant_hybrid_symmetric(qp) && args._ci->has_sve2() && args._ci->has_svei8mm(); }, |
| 74 | [](const GemmArgs &args, const Requantize32 &) { return GemmHybridIndirect<cls_sve_hybrid_s8qs_mmla_6x4VL, int8_t, int8_t, Requantize32>::estimate_cycles<int8_t>(args); }, |
| 75 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridIndirect<cls_sve_hybrid_s8qs_mmla_6x4VL, int8_t, int8_t, Requantize32>(args, qp); } |
| 76 | ), |
| 77 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 78 | GemmMethod::GEMM_INTERLEAVED, |
| 79 | "sve_interleaved_s8s32_mmla_8x3VL", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 80 | [](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] | 81 | [](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] | 82 | [](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] | 83 | ), |
| 84 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
| 85 | GemmMethod::GEMM_INTERLEAVED, |
| 86 | "sve_hybrid_s8s32_mmla_6x4VL", |
| 87 | [](const GemmArgs &args, const Requantize32 &) { return args._ci->has_svei8mm(); }, |
| 88 | [](const GemmArgs &args, const Requantize32 &) { return GemmHybridIndirect<cls_sve_hybrid_s8s32_mmla_6x4VL, int8_t, int8_t, Requantize32, true>::estimate_cycles<int8_t>(args); }, |
| 89 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridIndirect<cls_sve_hybrid_s8s32_mmla_6x4VL, int8_t, int8_t, Requantize32, true>(args, qp); } |
| 90 | ), |
Michalis Spyrou | 71ac903 | 2019-11-14 14:31:44 +0000 | [diff] [blame] | 91 | { |
| 92 | GemmMethod::GEMM_HYBRID_QUANTIZED, |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 93 | "sve_smallK_hybrid_s8s32_dot_8x1VL", |
Pablo Marquez Tello | a50f193 | 2021-03-08 17:27:05 +0000 | [diff] [blame] | 94 | [](const GemmArgs &args, const Requantize32 &) { return args._ci->has_sve() && args._Ksize<=64 && !args._indirect_input; }, |
Gunes Bayir | e42a87f | 2021-09-13 13:24:38 +0100 | [diff] [blame] | 95 | [](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] | 96 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridQuantized<cls_sve_smallK_hybrid_s8s32_dot_8x1VL, int8_t, int8_t>(args, qp); } |
| 97 | }, |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 98 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 99 | GemmMethod::GEMM_HYBRID, |
| 100 | "sve_hybrid_s8qs_dot_6x4VL", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 101 | [](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] | 102 | [](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] | 103 | [](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] | 104 | ), |
| 105 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 106 | GemmMethod::GEMM_HYBRID, |
| 107 | "sve_hybrid_s8qa_dot_4x4VL", |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 108 | [](const GemmArgs &args, const Requantize32 &qp) { return args._ci->has_sve2() && quant_hybrid_asymmetric(qp); }, |
| 109 | [](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] | 110 | [](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] | 111 | ), |
| 112 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 113 | GemmMethod::GEMM_HYBRID, |
| 114 | "sve_hybrid_s8s32_dot_6x4VL", |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 115 | [](const GemmArgs &args, const Requantize32 &) { return args._ci->has_sve(); }, |
| 116 | [](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] | 117 | [](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] | 118 | ), |
| 119 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 120 | GemmMethod::GEMM_INTERLEAVED, |
| 121 | "sve_interleaved_s8s32_dot_8x3VL", |
Pablo Marquez Tello | a50f193 | 2021-03-08 17:27:05 +0000 | [diff] [blame] | 122 | [](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] | 123 | [](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] | 124 | [](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] | 125 | ), |
| 126 | #endif // ARM_COMPUTE_ENABLE_SVE |
| 127 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
| 128 | GemmMethod::GEMM_HYBRID, |
| 129 | "a64_hybrid_s8qa_mmla_4x16", |
| 130 | [](const GemmArgs &args, const Requantize32 &qp) { return args._ci->has_i8mm() && quant_hybrid_asymmetric(qp); }, |
| 131 | [](const GemmArgs &args, const Requantize32 &) { return GemmHybridIndirect<cls_a64_hybrid_s8qa_mmla_4x16, int8_t, int8_t, Requantize32>::estimate_cycles<int8_t>(args); }, |
| 132 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridIndirect<cls_a64_hybrid_s8qa_mmla_4x16, int8_t, int8_t, Requantize32>(args, qp); } |
| 133 | ), |
| 134 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
| 135 | GemmMethod::GEMM_HYBRID, |
| 136 | "a64_hybrid_s8qs_mmla_6x16", |
| 137 | [](const GemmArgs &args, const Requantize32 &qp) { return args._ci->has_i8mm() && quant_hybrid_symmetric(qp); }, |
| 138 | [](const GemmArgs &args, const Requantize32 &) { return GemmHybridIndirect<cls_a64_hybrid_s8qs_mmla_6x16, int8_t, int8_t, Requantize32>::estimate_cycles<int8_t>(args); }, |
| 139 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridIndirect<cls_a64_hybrid_s8qs_mmla_6x16, int8_t, int8_t, Requantize32>(args, qp); } |
| 140 | ), |
| 141 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 142 | GemmMethod::GEMM_INTERLEAVED, |
| 143 | "a64_interleaved_s8s32_mmla_8x12", |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 144 | [](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] | 145 | [](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] | 146 | [](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] | 147 | ), |
| 148 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
| 149 | GemmMethod::GEMM_INTERLEAVED, |
| 150 | "a64_hybrid_s8s32_mmla_6x16", |
| 151 | [](const GemmArgs &args, const Requantize32 &) { return args._ci->has_i8mm(); }, |
| 152 | [](const GemmArgs &args, const Requantize32 &) { return GemmHybridIndirect<cls_a64_hybrid_s8s32_mmla_6x16, int8_t, int8_t, Requantize32, true>::estimate_cycles<int8_t>(args); }, |
| 153 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridIndirect<cls_a64_hybrid_s8s32_mmla_6x16, int8_t, int8_t, Requantize32, true>(args, qp); } |
| 154 | ), |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 155 | { |
| 156 | GemmMethod::GEMM_HYBRID_QUANTIZED, |
| 157 | "a64_smallK_hybrid_s8s32_dot_8x4", |
| 158 | [](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] | 159 | [](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] | 160 | [](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] | 161 | }, |
| 162 | { |
| 163 | GemmMethod::GEMM_HYBRID_QUANTIZED, |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 164 | "a64_smallK_hybrid_s8s32_dot_6x4", |
| 165 | [](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] | 166 | [](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] | 167 | [](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] | 168 | }, |
| 169 | { |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 170 | GemmMethod::GEMM_INTERLEAVED, |
| 171 | "a64_gemm_s16_8x12", |
Aleksandr Nikolaev | a084b46 | 2020-06-25 12:25:52 +0100 | [diff] [blame] | 172 | nullptr, |
Georgios Pinitas | cd22cbf | 2020-12-02 16:06:01 +0000 | [diff] [blame] | 173 | [](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] | 174 | [](const GemmArgs &args, const Requantize32 &qp) { return new GemmInterleavedQuantized<cls_a64_gemm_s16_8x12, int8_t, int8_t>(args, qp); } |
| 175 | }, |
Georgios Pinitas | 33e0307 | 2021-01-14 13:43:40 +0000 | [diff] [blame] | 176 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 177 | GemmMethod::GEMM_HYBRID, |
| 178 | "a64_hybrid_s8qs_dot_6x16", |
| 179 | [](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] | 180 | [](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] | 181 | [](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] | 182 | ), |
| 183 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 184 | GemmMethod::GEMM_HYBRID, |
| 185 | "a64_hybrid_s8qa_dot_4x16", |
| 186 | [](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] | 187 | [](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] | 188 | [](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] | 189 | ), |
| 190 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 191 | GemmMethod::GEMM_HYBRID, |
| 192 | "a64_hybrid_s8s32_dot_6x16", |
| 193 | [](const GemmArgs &args, const Requantize32 &) { return args._ci->has_dotprod(); }, |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 194 | [](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] | 195 | [](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] | 196 | ), |
| 197 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 198 | GemmMethod::GEMM_INTERLEAVED, |
| 199 | "a64_gemm_s8_8x12", |
| 200 | [](const GemmArgs &args, const Requantize32 &) { return args._ci->has_dotprod(); }, |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 201 | [](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] | 202 | [](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] | 203 | ), |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 204 | GemmImplementation<int8_t, int8_t, Requantize32>::with_estimate( |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 205 | GemmMethod::GEMM_INTERLEAVED, |
| 206 | "a64_gemm_s8_4x4", |
| 207 | nullptr, |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 208 | [](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] | 209 | [](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] | 210 | ), |
Michalis Spyrou | 71ac903 | 2019-11-14 14:31:44 +0000 | [diff] [blame] | 211 | { |
| 212 | GemmMethod::QUANTIZE_WRAPPER, |
| 213 | "quantized_wrapper", |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 214 | [](const GemmArgs &args, const Requantize32 &) { return !args._indirect_input; }, |
Georgios Pinitas | 4ee8b15 | 2021-07-16 16:16:43 +0100 | [diff] [blame] | 215 | [](const GemmArgs &, const Requantize32 &) { return false; }, |
Michalis Spyrou | 71ac903 | 2019-11-14 14:31:44 +0000 | [diff] [blame] | 216 | [](const GemmArgs &args, const Requantize32 &qp) { return new QuantizeWrapper<int8_t, int8_t, int32_t>(args, qp); } |
| 217 | }, |
| 218 | { |
| 219 | GemmMethod::DEFAULT, |
| 220 | "", |
| 221 | nullptr, |
| 222 | nullptr, |
| 223 | nullptr |
| 224 | } |
| 225 | }; |
| 226 | |
| 227 | template<> |
| 228 | const GemmImplementation<int8_t, int8_t, Requantize32> *gemm_implementation_list<int8_t, int8_t, Requantize32>() { |
| 229 | return gemm_qint8_methods; |
| 230 | } |
| 231 | |
| 232 | 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^] | 233 | template bool has_opt_gemm<int8_t, int8_t, Requantize32>(WeightFormat &weight_format, const GemmArgs &args, const Requantize32 &os); |
Michalis Spyrou | 71ac903 | 2019-11-14 14:31:44 +0000 | [diff] [blame] | 234 | template std::vector<KernelDescription> get_compatible_kernels<int8_t, int8_t, Requantize32>(const GemmArgs &args, const Requantize32 &os); |
| 235 | |
| 236 | } // namespace arm_gemm |
| 237 | |
| 238 | #endif // __aarch64__ |