blob: 7b08041005764f2d46d6dfe0d8369bbbbb44c6a5 [file] [log] [blame]
Georgios Pinitascfa2bba2019-06-27 17:00:52 +01001/*
Aleksandr Nikolaeva084b462020-06-25 12:25:52 +01002 * Copyright (c) 2019-2020 Arm Limited.
Georgios Pinitascfa2bba2019-06-27 17:00:52 +01003 *
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 */
Georgios Pinitasf33484f2019-07-29 12:40:59 +010024#ifdef __aarch64__
25
Georgios Pinitascfa2bba2019-06-27 17:00:52 +010026#include "arm_gemm.hpp"
27
28#include "kernels/a64_hybrid_u8u32_dot_16x4.hpp"
29#include "kernels/a64_smallK_hybrid_u8u32_dot_4x6.hpp"
30#include "kernels/a64_smallK_hybrid_u8u32_dot_4x8.hpp"
31#include "kernels/sve_hybrid_u8u32_dot_4VLx4.hpp"
32#include "kernels/sve_smallK_hybrid_u8u32_dot_1VLx8.hpp"
33
34#include "gemm_hybrid_quantized.hpp"
35#include "quantize_wrapper.hpp"
36
37namespace arm_gemm {
38
Michalis Spyrou71ac9032019-11-14 14:31:44 +000039static const GemmImplementation<uint8_t, uint8_t, Requantize32> gemm_quint8_methods[] =
Georgios Pinitascfa2bba2019-06-27 17:00:52 +010040{
41#ifdef __ARM_FEATURE_SVE
42{
43 GemmMethod::GEMM_HYBRID_QUANTIZED,
44 "smallK_hybrid_u8u32_dot_1VLx8",
Georgios Pinitas0cc50ed2020-07-06 19:10:38 +010045 [](const GemmArgs &args, const Requantize32 &) { return args._Ksize<=64; },
Georgios Pinitascfa2bba2019-06-27 17:00:52 +010046 nullptr,
Michalis Spyrou71ac9032019-11-14 14:31:44 +000047 [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridQuantized<smallK_hybrid_u8u32_dot_1VLx8, uint8_t, uint8_t>(args, qp); }
Georgios Pinitascfa2bba2019-06-27 17:00:52 +010048},
49{
50 GemmMethod::GEMM_HYBRID_QUANTIZED,
51 "hybrid_u8u32_dot_4VLx4",
Georgios Pinitas0cc50ed2020-07-06 19:10:38 +010052 [](const GemmArgs &args, const Requantize32 &) { return args._Ksize>=16; },
Michalis Spyrou71ac9032019-11-14 14:31:44 +000053 [](const GemmArgs &args, const Requantize32 &) { return ((args._Ksize <= 128) && (args._Nsize <= 128)) || ((args._nmulti > 1) && ((args._Msize / args._maxthreads) < 8)); },
54 [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridQuantized<hybrid_u8u32_dot_4VLx4, uint8_t, uint8_t>(args, qp); }
Georgios Pinitascfa2bba2019-06-27 17:00:52 +010055},
56#endif
57{
58 GemmMethod::GEMM_HYBRID_QUANTIZED,
59 "smallK_hybrid_u8u32_dot_4x8",
Georgios Pinitas0cc50ed2020-07-06 19:10:38 +010060 [](const GemmArgs &args, const Requantize32 &) { return args._ci->has_dotprod() && (args._Nsize % 4 == 0) && (args._Ksize<=32); },
Georgios Pinitascfa2bba2019-06-27 17:00:52 +010061 nullptr,
Michalis Spyrou71ac9032019-11-14 14:31:44 +000062 [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridQuantized<smallK_hybrid_u8u32_dot_4x8, uint8_t, uint8_t>(args, qp); }
Georgios Pinitascfa2bba2019-06-27 17:00:52 +010063},
64{
65 GemmMethod::GEMM_HYBRID_QUANTIZED,
66 "smallK_hybrid_u8u32_dot_4x6",
Georgios Pinitas0cc50ed2020-07-06 19:10:38 +010067 [](const GemmArgs &args, const Requantize32 &) { return args._ci->has_dotprod() && (args._Nsize % 4 == 0) && (args._Ksize>32) && (args._Ksize<=64); },
Georgios Pinitascfa2bba2019-06-27 17:00:52 +010068 nullptr,
Michalis Spyrou71ac9032019-11-14 14:31:44 +000069 [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridQuantized<smallK_hybrid_u8u32_dot_4x6, uint8_t, uint8_t>(args, qp); }
Georgios Pinitascfa2bba2019-06-27 17:00:52 +010070},
71{
72 GemmMethod::GEMM_HYBRID_QUANTIZED,
73 "hybrid_u8u32_dot_16x4",
Georgios Pinitas0cc50ed2020-07-06 19:10:38 +010074 [](const GemmArgs &args, const Requantize32 &) { return args._ci->has_dotprod() && args._Ksize>=16; },
Michalis Spyrou71ac9032019-11-14 14:31:44 +000075 [](const GemmArgs &args, const Requantize32 &) { return args._Nsize<=256 && args._Ksize>128; },
76 [](const GemmArgs &args, const Requantize32 &qp) { return new GemmHybridQuantized<hybrid_u8u32_dot_16x4, uint8_t, uint8_t>(args, qp); }
Georgios Pinitascfa2bba2019-06-27 17:00:52 +010077},
Aleksandr Nikolaeva084b462020-06-25 12:25:52 +010078/** QUANTIZE_WRAPPER_2D enables 2D parallelisation hint for IScheduler in NEGEMMAssemblyDispatch */
79{
80 GemmMethod::QUANTIZE_WRAPPER_2D,
81 "quantized_wrapper_2d",
82 nullptr,
83 [](const GemmArgs &args, const Requantize32 &) { return (args._maxthreads >= 8) && (args._Msize >= 8) && (args._Nsize >= 8);},
84 [](const GemmArgs &args, const Requantize32 &qp) { return new QuantizeWrapper<uint8_t, uint8_t, uint32_t>(args, qp); }
85},
Georgios Pinitascfa2bba2019-06-27 17:00:52 +010086{
87 GemmMethod::QUANTIZE_WRAPPER,
88 "quantized_wrapper",
89 nullptr,
90 nullptr,
Michalis Spyrou71ac9032019-11-14 14:31:44 +000091 [](const GemmArgs &args, const Requantize32 &qp) { return new QuantizeWrapper<uint8_t, uint8_t, uint32_t>(args, qp); }
Georgios Pinitascfa2bba2019-06-27 17:00:52 +010092},
93{
94 GemmMethod::DEFAULT,
95 "",
96 nullptr,
97 nullptr,
98 nullptr
99}
100};
101
102template<>
Michalis Spyrou71ac9032019-11-14 14:31:44 +0000103const GemmImplementation<uint8_t, uint8_t, Requantize32> *gemm_implementation_list<uint8_t, uint8_t, Requantize32>() {
Georgios Pinitascfa2bba2019-06-27 17:00:52 +0100104 return gemm_quint8_methods;
105}
106
Michalis Spyrou71ac9032019-11-14 14:31:44 +0000107template UniqueGemmCommon<uint8_t, uint8_t> gemm<uint8_t, uint8_t, Requantize32>(const GemmArgs &args, const Requantize32 &os);
108template KernelDescription get_gemm_method<uint8_t, uint8_t, Requantize32>(const GemmArgs &args, const Requantize32 &os);
109template std::vector<KernelDescription> get_compatible_kernels<uint8_t, uint8_t, Requantize32>(const GemmArgs &args, const Requantize32 &os);
Georgios Pinitascfa2bba2019-06-27 17:00:52 +0100110
111} // namespace arm_gemm
Georgios Pinitasf33484f2019-07-29 12:40:59 +0100112
113#endif // __aarch64__