Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 1 | /* |
Gian Marco Iodice | f16eed9 | 2023-04-19 16:29:26 +0100 | [diff] [blame] | 2 | * Copyright (c) 2020-2023 Arm Limited. |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 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 | */ |
SiCong Li | a085a0c | 2020-12-02 14:54:34 +0000 | [diff] [blame] | 24 | #include "src/runtime/CL/gemm/CLGEMMDefaultTypeValhall.h" |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 25 | |
| 26 | #include "arm_compute/core/CL/CLHelpers.h" |
| 27 | #include "arm_compute/core/CL/CLKernelLibrary.h" |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 28 | |
Georgios Pinitas | 7891a73 | 2021-08-20 21:39:25 +0100 | [diff] [blame] | 29 | #include "src/gpu/cl/kernels/gemm/ClGemmHelpers.h" |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 30 | |
| 31 | #include <map> |
| 32 | #include <utility> |
| 33 | |
| 34 | namespace arm_compute |
| 35 | { |
| 36 | namespace cl_gemm |
| 37 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 38 | CLGEMMDefaultTypeValhall::CLGEMMDefaultTypeValhall(GPUTarget gpu) : ICLGEMMKernelSelection(gpu) |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 39 | { |
| 40 | } |
| 41 | |
SiCong Li | a085a0c | 2020-12-02 14:54:34 +0000 | [diff] [blame] | 42 | CLGEMMKernelType CLGEMMDefaultTypeValhall::select_kernel(const CLGEMMKernelSelectionParams ¶ms) |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 43 | { |
| 44 | // _target could be used in the future to have a dedicated heuristic for each GPU IP |
| 45 | ARM_COMPUTE_UNUSED(_target); |
| 46 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 47 | using FunctionExecutorPtr = CLGEMMKernelType (CLGEMMDefaultTypeValhall::*)( |
| 48 | unsigned int m, unsigned int n, unsigned int k, unsigned int b, bool is_rhs_constant); |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 49 | |
Gian Marco Iodice | 491f30c | 2020-11-02 15:43:57 +0000 | [diff] [blame] | 50 | // Default configurations for Valhall architectures |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 51 | static std::map<DataType, FunctionExecutorPtr> gemm_default_configs = { |
| 52 | {DataType::F32, &CLGEMMDefaultTypeValhall::default_f32}, |
| 53 | {DataType::F16, &CLGEMMDefaultTypeValhall::default_f16}, |
| 54 | {DataType::QASYMM8, &CLGEMMDefaultTypeValhall::default_q8}, |
| 55 | {DataType::QASYMM8_SIGNED, &CLGEMMDefaultTypeValhall::default_q8}, |
| 56 | {DataType::QSYMM8, &CLGEMMDefaultTypeValhall::default_q8}, |
| 57 | {DataType::QSYMM8_PER_CHANNEL, &CLGEMMDefaultTypeValhall::default_q8}}; |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 58 | |
Gian Marco Iodice | 491f30c | 2020-11-02 15:43:57 +0000 | [diff] [blame] | 59 | // Mali-G77 configurations |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 60 | static std::map<DataType, FunctionExecutorPtr> gemm_g77_configs = { |
| 61 | {DataType::F32, &CLGEMMDefaultTypeValhall::default_f32}, |
| 62 | {DataType::F16, &CLGEMMDefaultTypeValhall::g77_f16}, |
| 63 | {DataType::QASYMM8, &CLGEMMDefaultTypeValhall::default_q8}, |
| 64 | {DataType::QASYMM8_SIGNED, &CLGEMMDefaultTypeValhall::default_q8}, |
| 65 | {DataType::QSYMM8, &CLGEMMDefaultTypeValhall::default_q8}, |
| 66 | {DataType::QSYMM8_PER_CHANNEL, &CLGEMMDefaultTypeValhall::default_q8}}; |
Gian Marco Iodice | 491f30c | 2020-11-02 15:43:57 +0000 | [diff] [blame] | 67 | |
Gian Marco Iodice | 3795491 | 2021-04-12 17:34:33 +0100 | [diff] [blame] | 68 | // Mali-G78 configurations |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 69 | static std::map<DataType, FunctionExecutorPtr> gemm_g78_configs = { |
| 70 | {DataType::F32, &CLGEMMDefaultTypeValhall::g78_f32}, |
| 71 | {DataType::F16, &CLGEMMDefaultTypeValhall::g78_f16}, |
| 72 | {DataType::QASYMM8, &CLGEMMDefaultTypeValhall::default_q8}, |
| 73 | {DataType::QASYMM8_SIGNED, &CLGEMMDefaultTypeValhall::default_q8}, |
| 74 | {DataType::QSYMM8, &CLGEMMDefaultTypeValhall::default_q8}, |
| 75 | {DataType::QSYMM8_PER_CHANNEL, &CLGEMMDefaultTypeValhall::default_q8}}; |
Gian Marco Iodice | 3795491 | 2021-04-12 17:34:33 +0100 | [diff] [blame] | 76 | |
Gian Marco Iodice | 7a0f1bd | 2023-04-26 14:55:02 +0100 | [diff] [blame] | 77 | // Mali-G710 and Mali-G610 configurations |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 78 | static std::map<DataType, FunctionExecutorPtr> gemm_g710_configs = { |
| 79 | {DataType::F32, &CLGEMMDefaultTypeValhall::default_f32}, |
| 80 | {DataType::F16, &CLGEMMDefaultTypeValhall::g710_f16}, |
| 81 | {DataType::QASYMM8, &CLGEMMDefaultTypeValhall::default_q8}, |
| 82 | {DataType::QASYMM8_SIGNED, &CLGEMMDefaultTypeValhall::default_q8}, |
| 83 | {DataType::QSYMM8, &CLGEMMDefaultTypeValhall::default_q8}, |
| 84 | {DataType::QSYMM8_PER_CHANNEL, &CLGEMMDefaultTypeValhall::default_q8}}; |
Gian Marco Iodice | 7a0f1bd | 2023-04-26 14:55:02 +0100 | [diff] [blame] | 85 | |
Gunes Bayir | 4bfc70e | 2021-12-10 16:17:56 +0000 | [diff] [blame] | 86 | // Mali-G715 and Mali-G615 configurations |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 87 | static std::map<DataType, FunctionExecutorPtr> gemm_g715_configs = { |
| 88 | {DataType::F32, &CLGEMMDefaultTypeValhall::g715_f32}, |
| 89 | {DataType::F16, &CLGEMMDefaultTypeValhall::g715_f16}, |
| 90 | {DataType::QASYMM8, &CLGEMMDefaultTypeValhall::default_q8}, |
| 91 | {DataType::QASYMM8_SIGNED, &CLGEMMDefaultTypeValhall::default_q8}, |
| 92 | {DataType::QSYMM8, &CLGEMMDefaultTypeValhall::default_q8}, |
| 93 | {DataType::QSYMM8_PER_CHANNEL, &CLGEMMDefaultTypeValhall::default_q8}}; |
Gunes Bayir | 4bfc70e | 2021-12-10 16:17:56 +0000 | [diff] [blame] | 94 | |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 95 | const DataType data_type = params.data_type; |
| 96 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 97 | switch (_target) |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 98 | { |
Gian Marco Iodice | 7a0f1bd | 2023-04-26 14:55:02 +0100 | [diff] [blame] | 99 | case GPUTarget::G710: |
| 100 | case GPUTarget::G610: |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 101 | if (gemm_g710_configs.find(data_type) != gemm_g710_configs.end()) |
Gian Marco Iodice | 7a0f1bd | 2023-04-26 14:55:02 +0100 | [diff] [blame] | 102 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 103 | return (this->*gemm_g710_configs[data_type])(params.m, params.n, params.k, params.b, |
| 104 | params.is_rhs_constant); |
Gian Marco Iodice | 7a0f1bd | 2023-04-26 14:55:02 +0100 | [diff] [blame] | 105 | } |
| 106 | ARM_COMPUTE_ERROR("Not supported data type"); |
Gunes Bayir | 4bfc70e | 2021-12-10 16:17:56 +0000 | [diff] [blame] | 107 | case GPUTarget::G715: |
| 108 | case GPUTarget::G615: |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 109 | if (gemm_g715_configs.find(data_type) != gemm_g715_configs.end()) |
Gunes Bayir | 4bfc70e | 2021-12-10 16:17:56 +0000 | [diff] [blame] | 110 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 111 | return (this->*gemm_g715_configs[data_type])(params.m, params.n, params.k, params.b, |
| 112 | params.is_rhs_constant); |
Gunes Bayir | 4bfc70e | 2021-12-10 16:17:56 +0000 | [diff] [blame] | 113 | } |
| 114 | ARM_COMPUTE_ERROR("Not supported data type"); |
Gian Marco Iodice | 3795491 | 2021-04-12 17:34:33 +0100 | [diff] [blame] | 115 | case GPUTarget::G78: |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 116 | if (gemm_g78_configs.find(data_type) != gemm_g78_configs.end()) |
Gian Marco Iodice | 3795491 | 2021-04-12 17:34:33 +0100 | [diff] [blame] | 117 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 118 | return (this->*gemm_g78_configs[data_type])(params.m, params.n, params.k, params.b, |
| 119 | params.is_rhs_constant); |
Gian Marco Iodice | 3795491 | 2021-04-12 17:34:33 +0100 | [diff] [blame] | 120 | } |
| 121 | ARM_COMPUTE_ERROR("Not supported data type"); |
Gian Marco Iodice | 491f30c | 2020-11-02 15:43:57 +0000 | [diff] [blame] | 122 | case GPUTarget::G77: |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 123 | if (gemm_g77_configs.find(data_type) != gemm_g77_configs.end()) |
Gian Marco Iodice | 491f30c | 2020-11-02 15:43:57 +0000 | [diff] [blame] | 124 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 125 | return (this->*gemm_g77_configs[data_type])(params.m, params.n, params.k, params.b, |
| 126 | params.is_rhs_constant); |
Gian Marco Iodice | 491f30c | 2020-11-02 15:43:57 +0000 | [diff] [blame] | 127 | } |
| 128 | ARM_COMPUTE_ERROR("Not supported data type"); |
| 129 | default: |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 130 | if (gemm_default_configs.find(data_type) != gemm_default_configs.end()) |
Gian Marco Iodice | 491f30c | 2020-11-02 15:43:57 +0000 | [diff] [blame] | 131 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 132 | return (this->*gemm_default_configs[data_type])(params.m, params.n, params.k, params.b, |
| 133 | params.is_rhs_constant); |
Gian Marco Iodice | 491f30c | 2020-11-02 15:43:57 +0000 | [diff] [blame] | 134 | } |
| 135 | ARM_COMPUTE_ERROR("Not supported data type"); |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 136 | } |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 137 | } |
| 138 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 139 | CLGEMMKernelType CLGEMMDefaultTypeValhall::default_f32( |
| 140 | unsigned int m, unsigned int n, unsigned int k, unsigned int b, bool is_rhs_constant) |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 141 | { |
Gian Marco Iodice | 026d045 | 2020-08-28 13:52:12 +0100 | [diff] [blame] | 142 | ARM_COMPUTE_UNUSED(m, n, k, b); |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 143 | |
Gian Marco Iodice | c9cecc0 | 2021-10-15 10:23:24 +0100 | [diff] [blame] | 144 | return is_rhs_constant ? CLGEMMKernelType::RESHAPED_ONLY_RHS : CLGEMMKernelType::NATIVE; |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 145 | } |
| 146 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 147 | CLGEMMKernelType CLGEMMDefaultTypeValhall::default_f16( |
| 148 | unsigned int m, unsigned int n, unsigned int k, unsigned int b, bool is_rhs_constant) |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 149 | { |
Gian Marco Iodice | 026d045 | 2020-08-28 13:52:12 +0100 | [diff] [blame] | 150 | ARM_COMPUTE_UNUSED(m, n, k, b); |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 151 | |
Gian Marco Iodice | c9cecc0 | 2021-10-15 10:23:24 +0100 | [diff] [blame] | 152 | return is_rhs_constant ? CLGEMMKernelType::RESHAPED_ONLY_RHS : CLGEMMKernelType::NATIVE; |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 153 | } |
| 154 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 155 | CLGEMMKernelType |
| 156 | CLGEMMDefaultTypeValhall::g77_f16(unsigned int m, unsigned int n, unsigned int k, unsigned int b, bool is_rhs_constant) |
Gian Marco Iodice | 491f30c | 2020-11-02 15:43:57 +0000 | [diff] [blame] | 157 | { |
Gian Marco Iodice | f16eed9 | 2023-04-19 16:29:26 +0100 | [diff] [blame] | 158 | ARM_COMPUTE_UNUSED(m, n, k, b); |
| 159 | |
Gian Marco Iodice | 7a0f1bd | 2023-04-26 14:55:02 +0100 | [diff] [blame] | 160 | return is_rhs_constant ? CLGEMMKernelType::RESHAPED_ONLY_RHS : CLGEMMKernelType::NATIVE; |
| 161 | } |
| 162 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 163 | CLGEMMKernelType |
| 164 | CLGEMMDefaultTypeValhall::g710_f16(unsigned int m, unsigned int n, unsigned int k, unsigned int b, bool is_rhs_constant) |
Gian Marco Iodice | 7a0f1bd | 2023-04-26 14:55:02 +0100 | [diff] [blame] | 165 | { |
| 166 | ARM_COMPUTE_UNUSED(m, n, k, b); |
| 167 | |
| 168 | return is_rhs_constant ? CLGEMMKernelType::RESHAPED_ONLY_RHS : CLGEMMKernelType::NATIVE; |
Gian Marco Iodice | 491f30c | 2020-11-02 15:43:57 +0000 | [diff] [blame] | 169 | } |
| 170 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 171 | CLGEMMKernelType CLGEMMDefaultTypeValhall::default_q8( |
| 172 | unsigned int m, unsigned int n, unsigned int k, unsigned int b, bool is_rhs_constant) |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 173 | { |
Gian Marco Iodice | 026d045 | 2020-08-28 13:52:12 +0100 | [diff] [blame] | 174 | ARM_COMPUTE_UNUSED(m, n, k, b); |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 175 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 176 | if (is_rhs_constant) |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 177 | { |
Gian Marco Iodice | eb65f6d | 2020-04-15 11:42:15 +0100 | [diff] [blame] | 178 | return CLGEMMKernelType::RESHAPED_ONLY_RHS; |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 179 | } |
| 180 | else |
| 181 | { |
Gian Marco Iodice | eb65f6d | 2020-04-15 11:42:15 +0100 | [diff] [blame] | 182 | return CLGEMMKernelType::NATIVE; |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 183 | } |
| 184 | } |
Gian Marco Iodice | 3795491 | 2021-04-12 17:34:33 +0100 | [diff] [blame] | 185 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 186 | CLGEMMKernelType |
| 187 | CLGEMMDefaultTypeValhall::g78_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b, bool is_rhs_constant) |
Gian Marco Iodice | 3795491 | 2021-04-12 17:34:33 +0100 | [diff] [blame] | 188 | { |
| 189 | ARM_COMPUTE_UNUSED(b); |
| 190 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 191 | if (!is_rhs_constant) |
Gian Marco Iodice | 3795491 | 2021-04-12 17:34:33 +0100 | [diff] [blame] | 192 | { |
Gian Marco Iodice | c9cecc0 | 2021-10-15 10:23:24 +0100 | [diff] [blame] | 193 | return CLGEMMKernelType::NATIVE; |
Gian Marco Iodice | 3795491 | 2021-04-12 17:34:33 +0100 | [diff] [blame] | 194 | } |
| 195 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 196 | if (m == 1) |
Gian Marco Iodice | 3795491 | 2021-04-12 17:34:33 +0100 | [diff] [blame] | 197 | { |
| 198 | return CLGEMMKernelType::RESHAPED_ONLY_RHS; |
| 199 | } |
| 200 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 201 | if (n <= 272.0000f) |
Gian Marco Iodice | 3795491 | 2021-04-12 17:34:33 +0100 | [diff] [blame] | 202 | { |
| 203 | return CLGEMMKernelType::RESHAPED_ONLY_RHS; |
| 204 | } |
| 205 | else |
| 206 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 207 | if (k <= 471.0000f) |
Gian Marco Iodice | 3795491 | 2021-04-12 17:34:33 +0100 | [diff] [blame] | 208 | { |
| 209 | return CLGEMMKernelType::RESHAPED_ONLY_RHS; |
| 210 | } |
| 211 | else |
| 212 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 213 | if (m <= 72.5000f) |
Gian Marco Iodice | 3795491 | 2021-04-12 17:34:33 +0100 | [diff] [blame] | 214 | { |
| 215 | return CLGEMMKernelType::RESHAPED_ONLY_RHS; |
| 216 | } |
| 217 | else |
| 218 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 219 | if (m <= 90.5000f) |
Gian Marco Iodice | 3795491 | 2021-04-12 17:34:33 +0100 | [diff] [blame] | 220 | { |
| 221 | return CLGEMMKernelType::RESHAPED; |
| 222 | } |
| 223 | else |
| 224 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 225 | if (k <= 2448.0000f) |
Gian Marco Iodice | 3795491 | 2021-04-12 17:34:33 +0100 | [diff] [blame] | 226 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 227 | if (n <= 756.0000f) |
Gian Marco Iodice | 3795491 | 2021-04-12 17:34:33 +0100 | [diff] [blame] | 228 | { |
| 229 | return CLGEMMKernelType::RESHAPED_ONLY_RHS; |
| 230 | } |
| 231 | else |
| 232 | { |
| 233 | return CLGEMMKernelType::RESHAPED; |
| 234 | } |
| 235 | } |
| 236 | else |
| 237 | { |
| 238 | return CLGEMMKernelType::RESHAPED; |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | } |
| 243 | } |
| 244 | } |
| 245 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 246 | CLGEMMKernelType |
| 247 | CLGEMMDefaultTypeValhall::g78_f16(unsigned int m, unsigned int n, unsigned int k, unsigned int b, bool is_rhs_constant) |
Gian Marco Iodice | 3795491 | 2021-04-12 17:34:33 +0100 | [diff] [blame] | 248 | { |
| 249 | ARM_COMPUTE_UNUSED(m, n, k, b); |
| 250 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 251 | if (!is_rhs_constant) |
Gian Marco Iodice | 3795491 | 2021-04-12 17:34:33 +0100 | [diff] [blame] | 252 | { |
Gian Marco Iodice | c9cecc0 | 2021-10-15 10:23:24 +0100 | [diff] [blame] | 253 | return CLGEMMKernelType::NATIVE; |
Gian Marco Iodice | 3795491 | 2021-04-12 17:34:33 +0100 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | return CLGEMMKernelType::RESHAPED_ONLY_RHS; |
| 257 | } |
Gunes Bayir | 4bfc70e | 2021-12-10 16:17:56 +0000 | [diff] [blame] | 258 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 259 | CLGEMMKernelType |
| 260 | CLGEMMDefaultTypeValhall::g715_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b, bool is_rhs_constant) |
Gunes Bayir | 4bfc70e | 2021-12-10 16:17:56 +0000 | [diff] [blame] | 261 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 262 | if (!is_rhs_constant) |
Gunes Bayir | 4bfc70e | 2021-12-10 16:17:56 +0000 | [diff] [blame] | 263 | { |
| 264 | return default_f32(m, n, k, b, is_rhs_constant); |
| 265 | } |
| 266 | |
| 267 | unsigned int best_m0; |
| 268 | unsigned int best_n0; |
| 269 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 270 | if (opencl::kernels::gemm::is_mmul_kernel_preferred(m, n, k, b, DataType::F32, best_m0, best_n0)) |
Gunes Bayir | 4bfc70e | 2021-12-10 16:17:56 +0000 | [diff] [blame] | 271 | { |
| 272 | return CLGEMMKernelType::RESHAPED_ONLY_RHS_MMUL; |
| 273 | } |
| 274 | else |
| 275 | { |
| 276 | return default_f32(m, n, k, b, is_rhs_constant); |
| 277 | } |
| 278 | } |
| 279 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 280 | CLGEMMKernelType |
| 281 | CLGEMMDefaultTypeValhall::g715_f16(unsigned int m, unsigned int n, unsigned int k, unsigned int b, bool is_rhs_constant) |
Gunes Bayir | 4bfc70e | 2021-12-10 16:17:56 +0000 | [diff] [blame] | 282 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 283 | if (!is_rhs_constant) |
Gunes Bayir | 4bfc70e | 2021-12-10 16:17:56 +0000 | [diff] [blame] | 284 | { |
| 285 | return g78_f16(m, n, k, b, is_rhs_constant); |
| 286 | } |
| 287 | |
| 288 | unsigned int best_m0; |
| 289 | unsigned int best_n0; |
| 290 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 291 | if (opencl::kernels::gemm::is_mmul_kernel_preferred(m, n, k, b, DataType::F16, best_m0, best_n0)) |
Gunes Bayir | 4bfc70e | 2021-12-10 16:17:56 +0000 | [diff] [blame] | 292 | { |
| 293 | return CLGEMMKernelType::RESHAPED_ONLY_RHS_MMUL; |
| 294 | } |
| 295 | else |
| 296 | { |
| 297 | return g78_f16(m, n, k, b, is_rhs_constant); |
| 298 | } |
| 299 | } |
| 300 | |
Gian Marco Iodice | 5a4fe19 | 2020-03-16 12:22:37 +0000 | [diff] [blame] | 301 | } // namespace cl_gemm |
| 302 | } // namespace arm_compute |