blob: b7c1bab6bd87e9ec6c63fd87fef744b64a1588e1 [file] [log] [blame]
Pablo Telloeb82fd22018-02-23 13:43:50 +00001/*
2 * Copyright (c) 2017-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#ifdef __aarch64__
25
26#include "arm_gemm.hpp"
27#include "gemm_common.hpp"
David Manselle39334c2018-07-06 17:53:35 +010028#include "gemm_implementation.hpp"
Pablo Telloeb82fd22018-02-23 13:43:50 +000029#include "gemm_interleaved.hpp"
30
David Manselle39334c2018-07-06 17:53:35 +010031#include "kernels/a64_gemm_u16_12x8.hpp"
Anthony Barbier5f707732018-07-03 16:22:02 +010032#include "kernels/a64_gemm_u8_12x8.hpp"
David Manselle39334c2018-07-06 17:53:35 +010033#include "kernels/a64_gemm_u8_4x4.hpp"
Georgios Pinitas421405b2018-10-26 19:05:32 +010034#include "kernels/sve_interleaved_u8u32_dot_3VLx8.hpp"
Pablo Telloeb82fd22018-02-23 13:43:50 +000035
Anthony Barbier5f707732018-07-03 16:22:02 +010036namespace arm_gemm {
37
Georgios Pinitas421405b2018-10-26 19:05:32 +010038#ifdef __ARM_FEATURE_SVE
39class GemmImpl_gemm_u8_interleaved_dot : public GemmImplementation<uint8_t, uint32_t> {
40public:
41 UniqueGemmCommon<uint8_t, uint32_t> instantiate(const GemmArgs<uint32_t> &args) override {
42 return UniqueGemmCommon<uint8_t, uint32_t>(new GemmInterleaved<interleaved_u8u32_dot_3VLx8, uint8_t, uint32_t>(args));
43 }
44
45 GemmImpl_gemm_u8_interleaved_dot() : GemmImplementation<uint8_t, uint32_t>(GemmMethod::GEMM_INTERLEAVED_DOT) { }
46};
47#else
David Manselle39334c2018-07-06 17:53:35 +010048class GemmImpl_gemm_u8_interleaved_dot : public GemmImplementation<uint8_t, uint32_t> {
49public:
50 bool is_supported(const GemmArgs<uint32_t> &args) override {
51 return args._ci->has_dotprod();
Pablo Telloeb82fd22018-02-23 13:43:50 +000052 }
53
David Manselle39334c2018-07-06 17:53:35 +010054 UniqueGemmCommon<uint8_t, uint32_t> instantiate(const GemmArgs<uint32_t> &args) override {
55 return UniqueGemmCommon<uint8_t, uint32_t>(new GemmInterleaved<gemm_u8_12x8, uint8_t, uint32_t>(args));
56 }
Pablo Telloeb82fd22018-02-23 13:43:50 +000057
David Manselle39334c2018-07-06 17:53:35 +010058 GemmImpl_gemm_u8_interleaved_dot() : GemmImplementation<uint8_t, uint32_t>(GemmMethod::GEMM_INTERLEAVED_DOT) { }
59};
Georgios Pinitas421405b2018-10-26 19:05:32 +010060#endif
David Manselle39334c2018-07-06 17:53:35 +010061
62class GemmImpl_gemm_u8_interleaved : public GemmImplementation<uint8_t, uint32_t> {
63public:
64 UniqueGemmCommon<uint8_t, uint32_t> instantiate(const GemmArgs<uint32_t> &args) override {
65 return UniqueGemmCommon<uint8_t, uint32_t>(new GemmInterleaved<gemm_u8_4x4, uint8_t, uint32_t>(args));
66 }
67
68 GemmImpl_gemm_u8_interleaved() : GemmImplementation<uint8_t, uint32_t>(GemmMethod::GEMM_INTERLEAVED) { }
69};
70
Anthony Barbier92d20812018-07-13 11:35:30 +010071static GemmImpl_gemm_u8_interleaved_dot gemm_u8_interleaved_dot_impl{};
72static GemmImpl_gemm_u8_interleaved gemm_u8_interleaved_impl{};
73
David Manselle39334c2018-07-06 17:53:35 +010074static std::vector<GemmImplementation<uint8_t, uint32_t> *> gemm_u8_methods = {
Anthony Barbier92d20812018-07-13 11:35:30 +010075 &gemm_u8_interleaved_dot_impl,
76 &gemm_u8_interleaved_impl
David Manselle39334c2018-07-06 17:53:35 +010077};
78
79template<>
80std::vector<GemmImplementation<uint8_t, uint32_t> *> &gemm_implementation_list<uint8_t, uint32_t>() {
81 return gemm_u8_methods;
Pablo Telloeb82fd22018-02-23 13:43:50 +000082}
83
David Manselle39334c2018-07-06 17:53:35 +010084/* Explicitly instantiate the external functions for these types. */
85template UniqueGemmCommon<uint8_t, uint32_t> gemm<uint8_t, uint32_t>(GemmArgs<uint32_t> &args, GemmConfig *cfg);
86template GemmMethod get_gemm_method<uint8_t, uint32_t>(GemmArgs<uint32_t> &args);
87template bool method_is_compatible<uint8_t, uint32_t>(GemmMethod method, GemmArgs<uint32_t> &args);
88
Pablo Telloeb82fd22018-02-23 13:43:50 +000089} // namespace arm_gemm
90
David Manselle39334c2018-07-06 17:53:35 +010091#endif // __aarch64__