blob: b56165927d4629ec6ae785ef8d64ba74c8ea6806 [file] [log] [blame]
Pablo Telloeb82fd22018-02-23 13:43:50 +00001/*
Georgios Pinitas7cd26d42019-01-09 18:35:17 +00002 * Copyright (c) 2017-2019 ARM Limited.
Pablo Telloeb82fd22018-02-23 13:43:50 +00003 *
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 */
Pablo Tello99ef8402018-03-20 16:46:55 +000024
25// This can only be built if the target/compiler supports FP16 arguments.
26#ifdef __ARM_FP16_ARGS
Pablo Telloeb82fd22018-02-23 13:43:50 +000027
28#include "arm_gemm.hpp"
29
30#include "gemm_common.hpp"
David Manselle39334c2018-07-06 17:53:35 +010031#include "gemm_implementation.hpp"
Pablo Telloeb82fd22018-02-23 13:43:50 +000032#include "gemm_interleaved.hpp"
33
Pablo Telloeb82fd22018-02-23 13:43:50 +000034#include "kernels/a64_hgemm_24x8.hpp"
35#include "kernels/a64_sgemm_12x8.hpp"
Anthony Barbier5f707732018-07-03 16:22:02 +010036#include "kernels/a32_sgemm_8x6.hpp"
Georgios Pinitas421405b2018-10-26 19:05:32 +010037#include "kernels/sve_interleaved_fp16_mla_3VLx8.hpp"
Pablo Telloeb82fd22018-02-23 13:43:50 +000038
Anthony Barbier5f707732018-07-03 16:22:02 +010039namespace arm_gemm {
40
Georgios Pinitas7cd26d42019-01-09 18:35:17 +000041static const GemmImplementation<__fp16, __fp16> gemm_fp16_methods[] = {
42#if defined(__ARM_FEATURE_SVE)
43{
44 GemmMethod::GEMM_INTERLEAVED,
45 "interleaved_fp16_mla_3VLx8",
46 [](const GemmArgs<__fp16> &args) { return (args._Ksize > 4); },
47 [](const GemmArgs<__fp16> &args) { return true; },
48 [](const GemmArgs<__fp16> &args) { return new GemmInterleaved<interleaved_fp16_mla_3VLx8, __fp16, __fp16>(args); }
49},
50#endif
51#if defined(__aarch64__) && (defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) || defined(FP16_KERNELS))
52{
53 GemmMethod::GEMM_INTERLEAVED,
54 "hgemm_24x8",
55 [](const GemmArgs<__fp16> &args) {
David Manselle39334c2018-07-06 17:53:35 +010056#ifndef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
David Manselle39334c2018-07-06 17:53:35 +010057 return args._ci->has_fp16();
David Manselle39334c2018-07-06 17:53:35 +010058#else
Georgios Pinitas7cd26d42019-01-09 18:35:17 +000059 return true;
David Manselle39334c2018-07-06 17:53:35 +010060#endif
Georgios Pinitas7cd26d42019-01-09 18:35:17 +000061 },
62 [](const GemmArgs<__fp16> &args) { return true; },
63 [](const GemmArgs<__fp16> &args) { return new GemmInterleaved<hgemm_24x8, __fp16, __fp16>(args); }
64},
Anthony Barbier92d20812018-07-13 11:35:30 +010065#endif
Georgios Pinitasa41c54b2019-01-30 18:16:43 +000066#if defined(__arm__)
67{
68 GemmMethod::GEMM_INTERLEAVED,
69 "sgemm_8x6",
70 [](const GemmArgs<__fp16> &args) { return true; },
71 [](const GemmArgs<__fp16> &args) { return true; },
72 [](const GemmArgs<__fp16> &args) { return new GemmInterleaved<sgemm_8x6, __fp16, __fp16>(args); }
73},
74#endif
Georgios Pinitas7cd26d42019-01-09 18:35:17 +000075{
76 GemmMethod::DEFAULT,
77 "",
78 nullptr,
79 nullptr,
80 nullptr,
81}
David Manselle39334c2018-07-06 17:53:35 +010082};
83
84template<>
Georgios Pinitas7cd26d42019-01-09 18:35:17 +000085const GemmImplementation<__fp16, __fp16> *gemm_implementation_list<__fp16, __fp16>() {
David Manselle39334c2018-07-06 17:53:35 +010086 return gemm_fp16_methods;
Pablo Telloeb82fd22018-02-23 13:43:50 +000087}
88
David Manselle39334c2018-07-06 17:53:35 +010089/* Explicitly instantiate the external functions for these types. */
Georgios Pinitas7cd26d42019-01-09 18:35:17 +000090template UniqueGemmCommon<__fp16, __fp16> gemm<__fp16, __fp16>(const GemmArgs<__fp16> &args);
91template KernelDescription get_gemm_method<__fp16, __fp16>(const GemmArgs<__fp16> &args);
92template bool method_is_compatible<__fp16, __fp16>(GemmMethod method, const GemmArgs<__fp16> &args);
93template std::vector<std::string> get_compatible_kernels<__fp16, __fp16> (const GemmArgs<__fp16> &args);
David Manselle39334c2018-07-06 17:53:35 +010094
Pablo Telloeb82fd22018-02-23 13:43:50 +000095} // namespace arm_gemm
96
Georgios Pinitas7cd26d42019-01-09 18:35:17 +000097#endif // __ARM_FP16_ARGS