Renato Arantes | 36a75da | 2024-01-26 17:31:18 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017-2020, 2022-2024 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 | #include "bfloat.hpp" |
| 25 | #include "gemm_implementation.hpp" |
| 26 | #include "gemm_interleaved.hpp" |
| 27 | |
| 28 | #ifdef ARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS |
| 29 | #include "kernels/a64_ffinterleaved_bf16fp32_mmla_8x12.hpp" |
| 30 | #include "kernels/sve_ffinterleaved_bf16fp32_mmla_8x3VL.hpp" |
| 31 | #endif // ARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS |
| 32 | |
| 33 | namespace arm_gemm { |
| 34 | |
| 35 | static const GemmImplementation<bfloat16, bfloat16> gemm_bf16bf16_methods[] = |
| 36 | { |
| 37 | #ifdef __aarch64__ |
| 38 | #ifdef ARM_COMPUTE_ENABLE_BF16 |
| 39 | #ifdef ARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS |
| 40 | GemmImplementation<bfloat16, bfloat16>::with_estimate( |
| 41 | GemmMethod::GEMM_INTERLEAVED, |
| 42 | "a64_ffinterleaved_bf16fp32_mmla_8x12", |
| 43 | KernelWeightFormat::VL256_BL64, |
| 44 | [](const GemmArgs &args) { return args._ci->has_bf16(); }, |
| 45 | [](const GemmArgs &args) { return GemmInterleavedFixedFormat<cls_a64_ffinterleaved_bf16fp32_mmla_8x12, bfloat16, bfloat16>::estimate_cycles<bfloat16>(args); }, |
| 46 | [](const GemmArgs &args) { return new GemmInterleavedFixedFormat<cls_a64_ffinterleaved_bf16fp32_mmla_8x12, bfloat16, bfloat16>(args); } |
| 47 | ), |
| 48 | GemmImplementation<bfloat16, bfloat16>::with_estimate( |
| 49 | GemmMethod::GEMM_INTERLEAVED, |
| 50 | "sve_ffinterleaved_bf16fp32_mmla_8x3VL", |
| 51 | KernelWeightFormat::VL2VL_BL64, |
| 52 | [](const GemmArgs &args) { return args._ci->has_svebf16(); }, |
| 53 | [](const GemmArgs &args) { return GemmInterleavedFixedFormat<cls_sve_ffinterleaved_bf16fp32_mmla_8x3VL, bfloat16, bfloat16>::estimate_cycles<bfloat16>(args); }, |
| 54 | [](const GemmArgs &args) { return new GemmInterleavedFixedFormat<cls_sve_ffinterleaved_bf16fp32_mmla_8x3VL, bfloat16, bfloat16>(args); } |
| 55 | ), |
| 56 | #endif // ARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS |
| 57 | #endif // ARM_COMPUTE_ENABLE_BF16 |
| 58 | #endif // __aarch64__ |
| 59 | { |
| 60 | GemmMethod::DEFAULT, |
| 61 | "", |
| 62 | nullptr, |
| 63 | nullptr, |
| 64 | nullptr |
| 65 | } |
| 66 | }; |
| 67 | |
| 68 | template<> |
| 69 | const GemmImplementation<bfloat16, bfloat16> *gemm_implementation_list<bfloat16, bfloat16>() { |
| 70 | return gemm_bf16bf16_methods; |
| 71 | } |
| 72 | |
| 73 | /* Explicitly instantiate the external functions for these types. */ |
| 74 | template UniqueGemmCommon<bfloat16, bfloat16> gemm<bfloat16, bfloat16, Nothing>(const GemmArgs &args, const Nothing &); |
| 75 | template bool has_opt_gemm<bfloat16, bfloat16, Nothing>(WeightFormat &weight_format, const GemmArgs &args, const Nothing &); |
| 76 | template KernelDescription get_gemm_method<bfloat16, bfloat16, Nothing>(const GemmArgs &args, const Nothing &); |
| 77 | template std::vector<KernelDescription> get_compatible_kernels<bfloat16, bfloat16, Nothing>(const GemmArgs &args, const Nothing &); |
| 78 | |
| 79 | } // namespace arm_gemm |