blob: dffa056adcf5765f843bcefdf5605600ade7cf25 [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
31#include "kernels/a64_gemm_s16_12x8.hpp"
32#include "kernels/a64_gemm_s8_12x8.hpp"
David Manselle39334c2018-07-06 17:53:35 +010033#include "kernels/a64_gemm_s8_4x4.hpp"
Pablo Telloeb82fd22018-02-23 13:43:50 +000034
Anthony Barbier5f707732018-07-03 16:22:02 +010035namespace arm_gemm {
36
David Manselle39334c2018-07-06 17:53:35 +010037class GemmImpl_gemm_s8_interleaved_dot : public GemmImplementation<int8_t, int32_t> {
38public:
39 bool is_supported(const GemmArgs<int32_t> &args) override {
40 return args._ci->has_dotprod();
Pablo Telloeb82fd22018-02-23 13:43:50 +000041 }
42
David Manselle39334c2018-07-06 17:53:35 +010043 UniqueGemmCommon<int8_t, int32_t> instantiate(const GemmArgs<int32_t> &args) override {
44 return UniqueGemmCommon<int8_t, int32_t>(new GemmInterleaved<gemm_s8_12x8, int8_t, int32_t>(args));
45 }
Pablo Telloeb82fd22018-02-23 13:43:50 +000046
David Manselle39334c2018-07-06 17:53:35 +010047 GemmImpl_gemm_s8_interleaved_dot() : GemmImplementation<int8_t, int32_t>(GemmMethod::GEMM_INTERLEAVED_DOT) { }
48};
49
50class GemmImpl_gemm_s8_interleaved : public GemmImplementation<int8_t, int32_t> {
51public:
52 UniqueGemmCommon<int8_t, int32_t> instantiate(const GemmArgs<int32_t> &args) override {
53 return UniqueGemmCommon<int8_t, int32_t>(new GemmInterleaved<gemm_s8_4x4, int8_t, int32_t>(args));
54 }
55
56 GemmImpl_gemm_s8_interleaved() : GemmImplementation<int8_t, int32_t>(GemmMethod::GEMM_INTERLEAVED) { }
57};
58
Anthony Barbier92d20812018-07-13 11:35:30 +010059static GemmImpl_gemm_s8_interleaved_dot gemm_s8_interleaved_dot_impl{};
60static GemmImpl_gemm_s8_interleaved gemm_s8_interleaved_impl{};
61
David Manselle39334c2018-07-06 17:53:35 +010062static std::vector<GemmImplementation<int8_t, int32_t> *> gemm_s8_methods = {
Anthony Barbier92d20812018-07-13 11:35:30 +010063 &gemm_s8_interleaved_dot_impl,
64 &gemm_s8_interleaved_impl
David Manselle39334c2018-07-06 17:53:35 +010065};
66
67template<>
68std::vector<GemmImplementation<int8_t, int32_t> *> &gemm_implementation_list<int8_t, int32_t>() {
69 return gemm_s8_methods;
Pablo Telloeb82fd22018-02-23 13:43:50 +000070}
71
David Manselle39334c2018-07-06 17:53:35 +010072/* Explicitly instantiate the external functions for these types. */
73template UniqueGemmCommon<int8_t, int32_t> gemm<int8_t, int32_t>(GemmArgs<int32_t> &args, GemmConfig *cfg);
74template GemmMethod get_gemm_method<int8_t, int32_t>(GemmArgs<int32_t> &args);
75template bool method_is_compatible<int8_t, int32_t>(GemmMethod method, GemmArgs<int32_t> &args);
76
Pablo Telloeb82fd22018-02-23 13:43:50 +000077} // namespace arm_gemm
78
David Manselle39334c2018-07-06 17:53:35 +010079#endif // __aarch64__