blob: 69842fec80c6d0e57e19376df67b1f1fdeb3e438 [file] [log] [blame]
Anthony Barbier3d677cc2018-07-23 16:42:59 +01001/*
2 * Copyright (c) 2018 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#ifndef __ARM_COMPUTE_NEGEMMINTERLEAVEDSTRATEGIES_H__
25#define __ARM_COMPUTE_NEGEMMINTERLEAVEDSTRATEGIES_H__
26
27#include "../arm_gemm/utils.hpp"
28#include "arm_gemm.hpp"
29
30#include "../arm_gemm/mergeresults.hpp"
31#include "../arm_gemm/transform.hpp"
32
33#include "../arm_gemm/kernels/a32_sgemm_8x6.hpp"
34#include "../arm_gemm/kernels/a64_gemm_s8_12x8.hpp"
35#include "../arm_gemm/kernels/a64_gemm_s8_4x4.hpp"
36#include "../arm_gemm/kernels/a64_gemm_u8_12x8.hpp"
37#include "../arm_gemm/kernels/a64_gemm_u8_4x4.hpp"
38#include "../arm_gemm/kernels/a64_hgemm_24x8.hpp"
39#include "../arm_gemm/kernels/a64_sgemm_12x8.hpp"
Georgios Pinitas421405b2018-10-26 19:05:32 +010040#include "../arm_gemm/kernels/sve_interleaved_fp16_mla_3VLx8.hpp"
41#include "../arm_gemm/kernels/sve_interleaved_fp32_mla_3VLx8.hpp"
42#include "../arm_gemm/kernels/sve_interleaved_s8s32_dot_3VLx8.hpp"
43#include "../arm_gemm/kernels/sve_interleaved_u8u32_dot_3VLx8.hpp"
Anthony Barbier3d677cc2018-07-23 16:42:59 +010044
45namespace arm_compute
46{
47namespace
48{
49template <typename To, bool use_dot = false>
50struct Kernel
51{
52};
53
Anthony Barbierac314c22018-09-11 17:49:10 +010054#define DEFINE_STRATEGY_SUFFIX(strat, suffix) \
55 using strategy = arm_gemm::strat; \
56 static constexpr const char *name = #strat suffix;
57
58#define DEFINE_STRATEGY(strat) \
59 DEFINE_STRATEGY_SUFFIX(strat, "")
60
Georgios Pinitas421405b2018-10-26 19:05:32 +010061#ifdef __ARM_FEATURE_SVE
62template <>
63struct Kernel<float, false>
64{
65 DEFINE_STRATEGY(interleaved_fp32_mla_3VLx8)
66};
67template <>
68struct Kernel<float16_t, false>
69{
70 DEFINE_STRATEGY(interleaved_fp16_mla_3VLx8)
71};
72template <bool use_dot>
73struct Kernel<int8_t, use_dot>
74{
75 DEFINE_STRATEGY(interleaved_s8s32_dot_3VLx8)
76};
77template <bool use_dot>
78struct Kernel<uint8_t, use_dot>
79{
80 DEFINE_STRATEGY(interleaved_u8u32_dot_3VLx8)
81};
82#else /* __ARM_FEATURE_SVE */
83
Anthony Barbier3d677cc2018-07-23 16:42:59 +010084#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
85template <>
86struct Kernel<float16_t, false>
87{
Anthony Barbierac314c22018-09-11 17:49:10 +010088 DEFINE_STRATEGY(hgemm_24x8)
Anthony Barbier3d677cc2018-07-23 16:42:59 +010089};
90#endif /*__ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
91#ifdef __aarch64__
92template <>
93struct Kernel<float, false>
94{
Anthony Barbierac314c22018-09-11 17:49:10 +010095 DEFINE_STRATEGY(sgemm_12x8)
Anthony Barbier3d677cc2018-07-23 16:42:59 +010096};
97template <>
98struct Kernel<int8_t, false>
99{
Anthony Barbierac314c22018-09-11 17:49:10 +0100100 DEFINE_STRATEGY(gemm_s8_4x4)
Anthony Barbier3d677cc2018-07-23 16:42:59 +0100101};
102template <>
103struct Kernel<uint8_t, false>
104{
Anthony Barbierac314c22018-09-11 17:49:10 +0100105 DEFINE_STRATEGY(gemm_u8_4x4)
Anthony Barbier3d677cc2018-07-23 16:42:59 +0100106};
107
108//Use different strategies for 8bit dot product:
109template <>
110struct Kernel<int8_t, true>
111{
Anthony Barbierac314c22018-09-11 17:49:10 +0100112 DEFINE_STRATEGY_SUFFIX(gemm_s8_12x8, "_dot")
Anthony Barbier3d677cc2018-07-23 16:42:59 +0100113};
114template <>
115struct Kernel<uint8_t, true>
116{
Anthony Barbierac314c22018-09-11 17:49:10 +0100117 DEFINE_STRATEGY_SUFFIX(gemm_u8_12x8, "_dot")
Anthony Barbier3d677cc2018-07-23 16:42:59 +0100118};
119#else
120template <>
121struct Kernel<float, false>
122{
Anthony Barbierac314c22018-09-11 17:49:10 +0100123 DEFINE_STRATEGY(sgemm_8x6)
Anthony Barbier3d677cc2018-07-23 16:42:59 +0100124};
125#endif /* __aarch64__ */
Georgios Pinitas421405b2018-10-26 19:05:32 +0100126#endif /* __ARM_FEATURE_SVE */
Anthony Barbier3d677cc2018-07-23 16:42:59 +0100127
Anthony Barbierac314c22018-09-11 17:49:10 +0100128#undef DEFINE_STRATEGY
129#undef DEFINE_STRATEGY_SUFFIX
130
Anthony Barbier3d677cc2018-07-23 16:42:59 +0100131} // namespace
132} // namespace arm_compute
133#endif /* __ARM_COMPUTE_NEGEMMINTERLEAVEDSTRATEGIES_H__ */