Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 1 | /* |
| 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 Mansell | e39334c | 2018-07-06 17:53:35 +0100 | [diff] [blame] | 28 | #include "gemm_implementation.hpp" |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 29 | #include "gemm_interleaved.hpp" |
| 30 | |
David Mansell | e39334c | 2018-07-06 17:53:35 +0100 | [diff] [blame] | 31 | #include "kernels/a64_gemm_u16_12x8.hpp" |
Anthony Barbier | 5f70773 | 2018-07-03 16:22:02 +0100 | [diff] [blame] | 32 | #include "kernels/a64_gemm_u8_12x8.hpp" |
David Mansell | e39334c | 2018-07-06 17:53:35 +0100 | [diff] [blame] | 33 | #include "kernels/a64_gemm_u8_4x4.hpp" |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 34 | |
Anthony Barbier | 5f70773 | 2018-07-03 16:22:02 +0100 | [diff] [blame] | 35 | namespace arm_gemm { |
| 36 | |
David Mansell | e39334c | 2018-07-06 17:53:35 +0100 | [diff] [blame] | 37 | class GemmImpl_gemm_u8_interleaved_dot : public GemmImplementation<uint8_t, uint32_t> { |
| 38 | public: |
| 39 | bool is_supported(const GemmArgs<uint32_t> &args) override { |
| 40 | return args._ci->has_dotprod(); |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 41 | } |
| 42 | |
David Mansell | e39334c | 2018-07-06 17:53:35 +0100 | [diff] [blame] | 43 | UniqueGemmCommon<uint8_t, uint32_t> instantiate(const GemmArgs<uint32_t> &args) override { |
| 44 | return UniqueGemmCommon<uint8_t, uint32_t>(new GemmInterleaved<gemm_u8_12x8, uint8_t, uint32_t>(args)); |
| 45 | } |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 46 | |
David Mansell | e39334c | 2018-07-06 17:53:35 +0100 | [diff] [blame] | 47 | GemmImpl_gemm_u8_interleaved_dot() : GemmImplementation<uint8_t, uint32_t>(GemmMethod::GEMM_INTERLEAVED_DOT) { } |
| 48 | }; |
| 49 | |
| 50 | class GemmImpl_gemm_u8_interleaved : public GemmImplementation<uint8_t, uint32_t> { |
| 51 | public: |
| 52 | UniqueGemmCommon<uint8_t, uint32_t> instantiate(const GemmArgs<uint32_t> &args) override { |
| 53 | return UniqueGemmCommon<uint8_t, uint32_t>(new GemmInterleaved<gemm_u8_4x4, uint8_t, uint32_t>(args)); |
| 54 | } |
| 55 | |
| 56 | GemmImpl_gemm_u8_interleaved() : GemmImplementation<uint8_t, uint32_t>(GemmMethod::GEMM_INTERLEAVED) { } |
| 57 | }; |
| 58 | |
Anthony Barbier | 92d2081 | 2018-07-13 11:35:30 +0100 | [diff] [blame] | 59 | static GemmImpl_gemm_u8_interleaved_dot gemm_u8_interleaved_dot_impl{}; |
| 60 | static GemmImpl_gemm_u8_interleaved gemm_u8_interleaved_impl{}; |
| 61 | |
David Mansell | e39334c | 2018-07-06 17:53:35 +0100 | [diff] [blame] | 62 | static std::vector<GemmImplementation<uint8_t, uint32_t> *> gemm_u8_methods = { |
Anthony Barbier | 92d2081 | 2018-07-13 11:35:30 +0100 | [diff] [blame] | 63 | &gemm_u8_interleaved_dot_impl, |
| 64 | &gemm_u8_interleaved_impl |
David Mansell | e39334c | 2018-07-06 17:53:35 +0100 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | template<> |
| 68 | std::vector<GemmImplementation<uint8_t, uint32_t> *> &gemm_implementation_list<uint8_t, uint32_t>() { |
| 69 | return gemm_u8_methods; |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 70 | } |
| 71 | |
David Mansell | e39334c | 2018-07-06 17:53:35 +0100 | [diff] [blame] | 72 | /* Explicitly instantiate the external functions for these types. */ |
| 73 | template UniqueGemmCommon<uint8_t, uint32_t> gemm<uint8_t, uint32_t>(GemmArgs<uint32_t> &args, GemmConfig *cfg); |
| 74 | template GemmMethod get_gemm_method<uint8_t, uint32_t>(GemmArgs<uint32_t> &args); |
| 75 | template bool method_is_compatible<uint8_t, uint32_t>(GemmMethod method, GemmArgs<uint32_t> &args); |
| 76 | |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 77 | } // namespace arm_gemm |
| 78 | |
David Mansell | e39334c | 2018-07-06 17:53:35 +0100 | [diff] [blame] | 79 | #endif // __aarch64__ |