Gian Marco Iodice | eb65f6d | 2020-04-15 11:42:15 +0100 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2020 Arm Limited. |
Gian Marco Iodice | eb65f6d | 2020-04-15 11:42:15 +0100 | [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 | */ |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame] | 24 | #include "src/core/CL/gemm/native/CLGEMMNativeKernelConfigurationMidgard.h" |
Gian Marco Iodice | eb65f6d | 2020-04-15 11:42:15 +0100 | [diff] [blame] | 25 | |
| 26 | #include "arm_compute/core/CL/CLHelpers.h" |
| 27 | #include "arm_compute/core/CL/CLKernelLibrary.h" |
Gian Marco Iodice | eb65f6d | 2020-04-15 11:42:15 +0100 | [diff] [blame] | 28 | #include "arm_compute/core/GPUTarget.h" |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame] | 29 | #include "src/core/CL/gemm/CLGEMMHelpers.h" |
Gian Marco Iodice | eb65f6d | 2020-04-15 11:42:15 +0100 | [diff] [blame] | 30 | |
| 31 | #include <map> |
| 32 | #include <utility> |
| 33 | |
| 34 | namespace arm_compute |
| 35 | { |
| 36 | namespace cl_gemm |
| 37 | { |
| 38 | CLGEMMNativeKernelConfigurationMidgard::CLGEMMNativeKernelConfigurationMidgard(GPUTarget gpu) |
| 39 | : ICLGEMMKernelConfiguration(gpu) |
| 40 | { |
| 41 | } |
| 42 | |
| 43 | std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMNativeKernelConfigurationMidgard::configure(unsigned int m, unsigned int n, unsigned int k, unsigned int b, DataType data_type) |
| 44 | { |
| 45 | using ConfigurationFunctionExecutorPtr = std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> (CLGEMMNativeKernelConfigurationMidgard::*)(unsigned int m, unsigned int n, unsigned int k, |
| 46 | unsigned int b); |
| 47 | |
| 48 | // Configurations for Midgard architectures |
| 49 | static std::map<DataType, ConfigurationFunctionExecutorPtr> default_configs = |
| 50 | { |
| 51 | { DataType::QASYMM8, &CLGEMMNativeKernelConfigurationMidgard::default_q8 }, |
| 52 | { DataType::QASYMM8_SIGNED, &CLGEMMNativeKernelConfigurationMidgard::default_q8 }, |
| 53 | { DataType::QSYMM8, &CLGEMMNativeKernelConfigurationMidgard::default_q8 }, |
| 54 | { DataType::QSYMM8_PER_CHANNEL, &CLGEMMNativeKernelConfigurationMidgard::default_q8 } |
| 55 | }; |
| 56 | |
| 57 | if(default_configs.find(data_type) != default_configs.end()) |
| 58 | { |
| 59 | return (this->*default_configs[data_type])(m, n, k, b); |
| 60 | } |
| 61 | ARM_COMPUTE_ERROR("Not supported data type"); |
| 62 | } |
| 63 | |
| 64 | std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMNativeKernelConfigurationMidgard::default_q8(unsigned int m, unsigned int n, unsigned int k, unsigned int b) |
| 65 | { |
| 66 | ARM_COMPUTE_UNUSED(k); |
| 67 | ARM_COMPUTE_UNUSED(b); |
| 68 | |
| 69 | const unsigned int m0 = std::min(m, static_cast<unsigned int>(4)); |
| 70 | const unsigned int n0 = std::min(n, static_cast<unsigned int>(4)); |
| 71 | |
| 72 | return configure_lhs_rhs_info(m, n, m0, n0, 2, 1, 1, false, false, false, false); |
| 73 | } |
| 74 | } // namespace cl_gemm |
| 75 | } // namespace arm_compute |