diff options
Diffstat (limited to 'src/core/CL/gemm')
9 files changed, 783 insertions, 302 deletions
diff --git a/src/core/CL/gemm/native/CLGEMMDefaultConfigNativeBifrost.cpp b/src/core/CL/gemm/native/CLGEMMDefaultConfigNativeBifrost.cpp index b769802663..52023dd835 100644 --- a/src/core/CL/gemm/native/CLGEMMDefaultConfigNativeBifrost.cpp +++ b/src/core/CL/gemm/native/CLGEMMDefaultConfigNativeBifrost.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020 Arm Limited. + * Copyright (c) 2019-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -28,7 +28,6 @@ #include "arm_compute/core/GPUTarget.h" #include "src/core/CL/gemm/CLGEMMHelpers.h" -#include <map> #include <utility> namespace arm_compute @@ -45,66 +44,35 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigNativeBifrost using ConfigurationFunctionExecutorPtr = std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> (CLGEMMDefaultConfigNativeBifrost::*)(unsigned int m, unsigned int n, unsigned int k, unsigned int b); - // Configurations for Mali-G71 - static std::map<DataType, ConfigurationFunctionExecutorPtr> gemm_configs_G71 = - { - { DataType::F32, &CLGEMMDefaultConfigNativeBifrost::configure_G71_f32 }, - { DataType::QASYMM8, &CLGEMMDefaultConfigNativeBifrost::configure_G71_u8 }, - { DataType::QSYMM8, &CLGEMMDefaultConfigNativeBifrost::configure_G71_u8 }, - { DataType::QASYMM8_SIGNED, &CLGEMMDefaultConfigNativeBifrost::configure_G71_u8 }, - { DataType::QSYMM8_PER_CHANNEL, &CLGEMMDefaultConfigNativeBifrost::configure_G71_u8 } - }; + CLGEMMConfigArray<ConfigurationFunctionExecutorPtr> configs_G71(&CLGEMMDefaultConfigNativeBifrost::configure_G71_f32, + &CLGEMMDefaultConfigNativeBifrost::configure_G71_f32, // We use the F32 heuristic + &CLGEMMDefaultConfigNativeBifrost::configure_G71_u8); - // Configurations for Mali-G76 - static std::map<DataType, ConfigurationFunctionExecutorPtr> gemm_configs_G76 = - { - { DataType::F32, &CLGEMMDefaultConfigNativeBifrost::configure_G76_f32 }, - { DataType::QASYMM8, &CLGEMMDefaultConfigNativeBifrost::configure_G76_u8 }, - { DataType::QSYMM8, &CLGEMMDefaultConfigNativeBifrost::configure_G76_u8 }, - { DataType::QASYMM8_SIGNED, &CLGEMMDefaultConfigNativeBifrost::configure_G76_u8 }, - { DataType::QSYMM8_PER_CHANNEL, &CLGEMMDefaultConfigNativeBifrost::configure_G76_u8 } - }; + CLGEMMConfigArray<ConfigurationFunctionExecutorPtr> configs_G76(&CLGEMMDefaultConfigNativeBifrost::configure_G76_f32, + &CLGEMMDefaultConfigNativeBifrost::configure_G76_f32, // We use the F32 heuristic + &CLGEMMDefaultConfigNativeBifrost::configure_G76_u8); - // Default configurations - static std::map<DataType, ConfigurationFunctionExecutorPtr> gemm_configs_default = - { - { DataType::F32, &CLGEMMDefaultConfigNativeBifrost::configure_default_f32 }, - { DataType::QASYMM8, &CLGEMMDefaultConfigNativeBifrost::configure_default_u8 }, - { DataType::QSYMM8, &CLGEMMDefaultConfigNativeBifrost::configure_default_u8 }, - { DataType::QASYMM8_SIGNED, &CLGEMMDefaultConfigNativeBifrost::configure_default_u8 }, - { DataType::QSYMM8_PER_CHANNEL, &CLGEMMDefaultConfigNativeBifrost::configure_default_u8 } - }; + CLGEMMConfigArray<ConfigurationFunctionExecutorPtr> configs_G7x(&CLGEMMDefaultConfigNativeBifrost::configure_default_f32, + &CLGEMMDefaultConfigNativeBifrost::configure_default_f32, // We use the F32 heuristic + &CLGEMMDefaultConfigNativeBifrost::configure_default_u8); + + ConfigurationFunctionExecutorPtr func = nullptr; switch(_target) { - case GPUTarget::G71: - if(gemm_configs_G71.find(data_type) != gemm_configs_G71.end()) - { - return (this->*gemm_configs_G71[data_type])(m, n, k, b); - } - else - { - ARM_COMPUTE_ERROR("Not supported data type"); - } case GPUTarget::G76: - if(gemm_configs_G76.find(data_type) != gemm_configs_G76.end()) - { - return (this->*gemm_configs_G76[data_type])(m, n, k, b); - } - else - { - ARM_COMPUTE_ERROR("Not supported data type"); - } + func = configs_G76.get_function(data_type); + break; + case GPUTarget::G71: + func = configs_G71.get_function(data_type); + break; default: - if(gemm_configs_default.find(data_type) != gemm_configs_default.end()) - { - return (this->*gemm_configs_default[data_type])(m, n, k, b); - } - else - { - ARM_COMPUTE_ERROR("Not supported data type"); - } + func = configs_G7x.get_function(data_type); + break; } + + ARM_COMPUTE_ERROR_ON_MSG(func == nullptr, "Data type not support for GEMM"); + return (this->*func)(m, n, k, b); } std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigNativeBifrost::configure_G71_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b) diff --git a/src/core/CL/gemm/native/CLGEMMDefaultConfigNativeMidgard.cpp b/src/core/CL/gemm/native/CLGEMMDefaultConfigNativeMidgard.cpp index 18a899047a..cf9bb1828f 100644 --- a/src/core/CL/gemm/native/CLGEMMDefaultConfigNativeMidgard.cpp +++ b/src/core/CL/gemm/native/CLGEMMDefaultConfigNativeMidgard.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -28,7 +28,6 @@ #include "arm_compute/core/GPUTarget.h" #include "src/core/CL/gemm/CLGEMMHelpers.h" -#include <map> #include <utility> namespace arm_compute @@ -45,20 +44,13 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigNativeMidgard using ConfigurationFunctionExecutorPtr = std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> (CLGEMMDefaultConfigNativeMidgard::*)(unsigned int m, unsigned int n, unsigned int k, unsigned int b); - // Configurations for Midgard architectures - static std::map<DataType, ConfigurationFunctionExecutorPtr> default_configs = - { - { DataType::QASYMM8, &CLGEMMDefaultConfigNativeMidgard::default_q8 }, - { DataType::QASYMM8_SIGNED, &CLGEMMDefaultConfigNativeMidgard::default_q8 }, - { DataType::QSYMM8, &CLGEMMDefaultConfigNativeMidgard::default_q8 }, - { DataType::QSYMM8_PER_CHANNEL, &CLGEMMDefaultConfigNativeMidgard::default_q8 } - }; + CLGEMMConfigArray<ConfigurationFunctionExecutorPtr> configs_default(nullptr, + nullptr, + &CLGEMMDefaultConfigNativeMidgard::default_q8); - if(default_configs.find(data_type) != default_configs.end()) - { - return (this->*default_configs[data_type])(m, n, k, b); - } - ARM_COMPUTE_ERROR("Not supported data type"); + auto func = configs_default.get_function(data_type); + ARM_COMPUTE_ERROR_ON_MSG(func == nullptr, "Data type not support for GEMM"); + return (this->*func)(m, n, k, b); } std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigNativeMidgard::default_q8(unsigned int m, unsigned int n, unsigned int k, unsigned int b) diff --git a/src/core/CL/gemm/native/CLGEMMDefaultConfigNativeValhall.cpp b/src/core/CL/gemm/native/CLGEMMDefaultConfigNativeValhall.cpp index ab5aa11bf8..3b55be747f 100644 --- a/src/core/CL/gemm/native/CLGEMMDefaultConfigNativeValhall.cpp +++ b/src/core/CL/gemm/native/CLGEMMDefaultConfigNativeValhall.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -28,7 +28,6 @@ #include "arm_compute/core/GPUTarget.h" #include "src/core/CL/gemm/CLGEMMHelpers.h" -#include <map> #include <utility> namespace arm_compute @@ -45,30 +44,13 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigNativeValhall using ConfigurationFunctionExecutorPtr = std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> (CLGEMMDefaultConfigNativeValhall::*)(unsigned int m, unsigned int n, unsigned int k, unsigned int b); - // Configurations for Mali-G77 - static std::map<DataType, ConfigurationFunctionExecutorPtr> gemm_configs_G77 = - { - { DataType::F32, &CLGEMMDefaultConfigNativeValhall::configure_G77_f32 }, - { DataType::F16, &CLGEMMDefaultConfigNativeValhall::configure_G77_f16 }, - { DataType::QASYMM8, &CLGEMMDefaultConfigNativeValhall::configure_G77_u8 }, - { DataType::QSYMM8, &CLGEMMDefaultConfigNativeValhall::configure_G77_u8 }, - { DataType::QASYMM8_SIGNED, &CLGEMMDefaultConfigNativeValhall::configure_G77_u8 }, - { DataType::QSYMM8_PER_CHANNEL, &CLGEMMDefaultConfigNativeValhall::configure_G77_u8 } - }; + CLGEMMConfigArray<ConfigurationFunctionExecutorPtr> configs_default(&CLGEMMDefaultConfigNativeValhall::configure_G77_f32, + &CLGEMMDefaultConfigNativeValhall::configure_G77_f16, + &CLGEMMDefaultConfigNativeValhall::configure_G77_u8); - switch(_target) - { - case GPUTarget::G77: - default: - if(gemm_configs_G77.find(data_type) != gemm_configs_G77.end()) - { - return (this->*gemm_configs_G77[data_type])(m, n, k, b); - } - else - { - ARM_COMPUTE_ERROR("Not supported data type"); - } - } + auto func = configs_default.get_function(data_type); + ARM_COMPUTE_ERROR_ON_MSG(func == nullptr, "Data type not support for GEMM"); + return (this->*func)(m, n, k, b); } std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigNativeValhall::configure_G77_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b) diff --git a/src/core/CL/gemm/reshaped/CLGEMMDefaultConfigReshapedBifrost.cpp b/src/core/CL/gemm/reshaped/CLGEMMDefaultConfigReshapedBifrost.cpp index 749d125c01..5877ab96e7 100644 --- a/src/core/CL/gemm/reshaped/CLGEMMDefaultConfigReshapedBifrost.cpp +++ b/src/core/CL/gemm/reshaped/CLGEMMDefaultConfigReshapedBifrost.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020 Arm Limited. + * Copyright (c) 2019-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -31,7 +31,6 @@ #include "arm_compute/core/utils/misc/ShapeCalculator.h" #include "src/core/CL/gemm/CLGEMMHelpers.h" -#include <map> #include <utility> namespace arm_compute @@ -49,60 +48,35 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedBifro { using ConfigurationFunctionExecutorPtr = std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> (CLGEMMDefaultConfigReshapedBifrost::*)(unsigned int m, unsigned int n, unsigned int k, unsigned int b); - // Configurations for Mali-G76 - static std::map<DataType, ConfigurationFunctionExecutorPtr> gemm_configs_G76 = - { - { DataType::F32, &CLGEMMDefaultConfigReshapedBifrost::configure_G76_f32 }, - { DataType::F16, &CLGEMMDefaultConfigReshapedBifrost::configure_G76_f16 }, - { DataType::QASYMM8, &CLGEMMDefaultConfigReshapedBifrost::configure_G76_u8 }, - { DataType::QSYMM8, &CLGEMMDefaultConfigReshapedBifrost::configure_G76_u8 }, - { DataType::QASYMM8_SIGNED, &CLGEMMDefaultConfigReshapedBifrost::configure_G76_u8 }, - { DataType::QSYMM8_PER_CHANNEL, &CLGEMMDefaultConfigReshapedBifrost::configure_G76_u8 } - }; - - // Configurations for Mali-G52 - static std::map<DataType, ConfigurationFunctionExecutorPtr> gemm_configs_G52 = - { - { DataType::F32, &CLGEMMDefaultConfigReshapedBifrost::configure_G52_f32 }, - { DataType::F16, &CLGEMMDefaultConfigReshapedBifrost::configure_G52_f16 }, - { DataType::QASYMM8, &CLGEMMDefaultConfigReshapedBifrost::configure_G7x_u8 }, - { DataType::QSYMM8, &CLGEMMDefaultConfigReshapedBifrost::configure_G7x_u8 }, - { DataType::QASYMM8_SIGNED, &CLGEMMDefaultConfigReshapedBifrost::configure_G7x_u8 }, - { DataType::QSYMM8_PER_CHANNEL, &CLGEMMDefaultConfigReshapedBifrost::configure_G7x_u8 } - }; - - // Configurations for Mali-G7x - static std::map<DataType, ConfigurationFunctionExecutorPtr> gemm_configs_G7x = - { - { DataType::F32, &CLGEMMDefaultConfigReshapedBifrost::configure_G7x_f32 }, - { DataType::F16, &CLGEMMDefaultConfigReshapedBifrost::configure_G7x_f16 }, - { DataType::QASYMM8, &CLGEMMDefaultConfigReshapedBifrost::configure_G7x_u8 }, - { DataType::QSYMM8, &CLGEMMDefaultConfigReshapedBifrost::configure_G7x_u8 }, - { DataType::QASYMM8_SIGNED, &CLGEMMDefaultConfigReshapedBifrost::configure_G7x_u8 }, - { DataType::QSYMM8_PER_CHANNEL, &CLGEMMDefaultConfigReshapedBifrost::configure_G7x_u8 } - }; + CLGEMMConfigArray<ConfigurationFunctionExecutorPtr> configs_G7x(&CLGEMMDefaultConfigReshapedBifrost::configure_G7x_f32, + &CLGEMMDefaultConfigReshapedBifrost::configure_G7x_f16, + &CLGEMMDefaultConfigReshapedBifrost::configure_G7x_u8); + + CLGEMMConfigArray<ConfigurationFunctionExecutorPtr> configs_G52(&CLGEMMDefaultConfigReshapedBifrost::configure_G52_f32, + &CLGEMMDefaultConfigReshapedBifrost::configure_G52_f16, + &CLGEMMDefaultConfigReshapedBifrost::configure_G7x_u8); + + CLGEMMConfigArray<ConfigurationFunctionExecutorPtr> configs_G76(&CLGEMMDefaultConfigReshapedBifrost::configure_G76_f32, + &CLGEMMDefaultConfigReshapedBifrost::configure_G76_f16, + &CLGEMMDefaultConfigReshapedBifrost::configure_G76_u8); + + ConfigurationFunctionExecutorPtr func = nullptr; switch(_target) { case GPUTarget::G76: - if(gemm_configs_G76.find(data_type) != gemm_configs_G76.end()) - { - return (this->*gemm_configs_G76[data_type])(m, n, k, b); - } - else - { - ARM_COMPUTE_ERROR("Not supported data type"); - } + func = configs_G76.get_function(data_type); + break; + case GPUTarget::G52: + func = configs_G52.get_function(data_type); + break; default: - if(gemm_configs_G7x.find(data_type) != gemm_configs_G7x.end()) - { - return (this->*gemm_configs_G7x[data_type])(m, n, k, b); - } - else - { - ARM_COMPUTE_ERROR("Not supported data type"); - } + func = configs_G7x.get_function(data_type); + break; } + + ARM_COMPUTE_ERROR_ON_MSG(func == nullptr, "Data type not support for GEMM"); + return (this->*func)(m, n, k, b); } std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedBifrost::configure_G7x_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b) diff --git a/src/core/CL/gemm/reshaped/CLGEMMDefaultConfigReshapedValhall.cpp b/src/core/CL/gemm/reshaped/CLGEMMDefaultConfigReshapedValhall.cpp index 13c139e201..b07092ab83 100644 --- a/src/core/CL/gemm/reshaped/CLGEMMDefaultConfigReshapedValhall.cpp +++ b/src/core/CL/gemm/reshaped/CLGEMMDefaultConfigReshapedValhall.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -28,7 +28,6 @@ #include "arm_compute/core/GPUTarget.h" #include "src/core/CL/gemm/CLGEMMHelpers.h" -#include <map> #include <utility> namespace arm_compute @@ -44,30 +43,29 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedValha { using ConfigurationFunctionExecutorPtr = std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> (CLGEMMDefaultConfigReshapedValhall::*)(unsigned int m, unsigned int n, unsigned int k, unsigned int b); - // Configurations for Mali-G77 - static std::map<DataType, ConfigurationFunctionExecutorPtr> gemm_configs_G77 = - { - { DataType::F32, &CLGEMMDefaultConfigReshapedValhall::configure_G77_f32 }, - { DataType::F16, &CLGEMMDefaultConfigReshapedValhall::configure_G77_f16 }, - { DataType::QASYMM8, &CLGEMMDefaultConfigReshapedValhall::configure_G77_u8 }, - { DataType::QSYMM8, &CLGEMMDefaultConfigReshapedValhall::configure_G77_u8 }, - { DataType::QASYMM8_SIGNED, &CLGEMMDefaultConfigReshapedValhall::configure_G77_u8 }, - { DataType::QSYMM8_PER_CHANNEL, &CLGEMMDefaultConfigReshapedValhall::configure_G77_u8 } - }; + CLGEMMConfigArray<ConfigurationFunctionExecutorPtr> configs_G77(&CLGEMMDefaultConfigReshapedValhall::configure_G77_f32, + &CLGEMMDefaultConfigReshapedValhall::configure_G77_f16, + &CLGEMMDefaultConfigReshapedValhall::configure_G77_u8); + + CLGEMMConfigArray<ConfigurationFunctionExecutorPtr> configs_G78(&CLGEMMDefaultConfigReshapedValhall::configure_G78_f32, + &CLGEMMDefaultConfigReshapedValhall::configure_G78_f16, + &CLGEMMDefaultConfigReshapedValhall::configure_G77_u8); + + ConfigurationFunctionExecutorPtr func = nullptr; switch(_target) { + case GPUTarget::G78: + func = configs_G78.get_function(data_type); + break; case GPUTarget::G77: default: - if(gemm_configs_G77.find(data_type) != gemm_configs_G77.end()) - { - return (this->*gemm_configs_G77[data_type])(m, n, k, b); - } - else - { - ARM_COMPUTE_ERROR("Not supported data type"); - } + func = configs_G77.get_function(data_type); + break; } + + ARM_COMPUTE_ERROR_ON_MSG(func == nullptr, "Data type not support for GEMM"); + return (this->*func)(m, n, k, b); } std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedValhall::configure_G77_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b) @@ -77,11 +75,11 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedValha if(n <= 4) { - return configure_lhs_rhs_info(m, n, 4, 2, 8, 16, 16, true, false, false, true); + return configure_lhs_rhs_info(m, n, 4, 2, 8, 16, 16, 1, 0, 0, 1); } else { - return configure_lhs_rhs_info(m, n, 5, 4, 4, 2, 16, false, true, false, true); + return configure_lhs_rhs_info(m, n, 5, 4, 4, 2, 16, 0, 1, 0, 1); } } @@ -100,13 +98,13 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedValha GEMMLHSMatrixInfo lhs_info_img; GEMMRHSMatrixInfo rhs_info_img; - std::tie(lhs_info_buf, rhs_info_buf) = configure_lhs_rhs_info(m, n, 4, 4, 4, 4, 4, false, false, true, false, false); + std::tie(lhs_info_buf, rhs_info_buf) = configure_lhs_rhs_info(m, n, 4, 4, 4, 4, 4, 0, 0, 1, 0, 0); if(r_mk <= 0.11824845522642136) { if(workload <= 880.0) { - return configure_lhs_rhs_info(m, n, 2, 4, 4, 1, 4, false, false, true, false, false); + return configure_lhs_rhs_info(m, n, 2, 4, 4, 1, 4, 0, 0, 1, 0, 0); } else { @@ -114,11 +112,11 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedValha { if(workload <= 1726.4000244140625) { - return configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 2, false, false, true, false, false); + return configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 2, 0, 0, 1, 0, 0); } else { - std::tie(lhs_info_img, rhs_info_img) = configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 1, false, true, true, false, true); + std::tie(lhs_info_img, rhs_info_img) = configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 1, 0, 1, 1, 0, 1); return select_lhs_rhs_info(std::make_pair(lhs_info_img, rhs_info_img), std::make_pair(lhs_info_buf, rhs_info_buf), @@ -129,11 +127,11 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedValha { if(workload <= 1241.6000366210938) { - return configure_lhs_rhs_info(m, n, 2, 4, 4, 1, 4, false, false, true, false, false); + return configure_lhs_rhs_info(m, n, 2, 4, 4, 1, 4, 0, 0, 1, 0, 0); } else { - return configure_lhs_rhs_info(m, n, 4, 4, 4, 4, 4, false, false, true, false, false); + return configure_lhs_rhs_info(m, n, 4, 4, 4, 4, 4, 0, 0, 1, 0, 0); } } } @@ -146,7 +144,7 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedValha { if(r_mn <= 2.545312523841858) { - std::tie(lhs_info_img, rhs_info_img) = configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 1, false, true, true, false, true); + std::tie(lhs_info_img, rhs_info_img) = configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 1, 0, 1, 1, 0, 1); return select_lhs_rhs_info(std::make_pair(lhs_info_img, rhs_info_img), std::make_pair(lhs_info_buf, rhs_info_buf), @@ -154,14 +152,14 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedValha } else { - return configure_lhs_rhs_info(m, n, 2, 4, 4, 1, 4, false, false, true, false, false); + return configure_lhs_rhs_info(m, n, 2, 4, 4, 1, 4, 0, 0, 1, 0, 0); } } else { if(workload <= 2881.199951171875) { - std::tie(lhs_info_img, rhs_info_img) = configure_lhs_rhs_info(m, n, 4, 4, 4, 4, 2, false, false, true, false, true); + std::tie(lhs_info_img, rhs_info_img) = configure_lhs_rhs_info(m, n, 4, 4, 4, 4, 2, 0, 0, 1, 0, 1); return select_lhs_rhs_info(std::make_pair(lhs_info_img, rhs_info_img), std::make_pair(lhs_info_buf, rhs_info_buf), @@ -169,7 +167,7 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedValha } else { - std::tie(lhs_info_img, rhs_info_img) = configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 1, false, true, true, false, true); + std::tie(lhs_info_img, rhs_info_img) = configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 1, 0, 1, 1, 0, 1); return select_lhs_rhs_info(std::make_pair(lhs_info_img, rhs_info_img), std::make_pair(lhs_info_buf, rhs_info_buf), @@ -183,7 +181,7 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedValha { if(r_mn <= 6.010416746139526) { - std::tie(lhs_info_img, rhs_info_img) = configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 1, false, true, true, false, true); + std::tie(lhs_info_img, rhs_info_img) = configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 1, 0, 1, 1, 0, 1); return select_lhs_rhs_info(std::make_pair(lhs_info_img, rhs_info_img), std::make_pair(lhs_info_buf, rhs_info_buf), @@ -191,7 +189,7 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedValha } else { - std::tie(lhs_info_img, rhs_info_img) = configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 1, true, false, true, false, true); + std::tie(lhs_info_img, rhs_info_img) = configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 1, 1, 0, 1, 0, 1); return select_lhs_rhs_info(std::make_pair(lhs_info_img, rhs_info_img), std::make_pair(lhs_info_buf, rhs_info_buf), @@ -200,7 +198,7 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedValha } else { - std::tie(lhs_info_img, rhs_info_img) = configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 1, true, false, true, false, true); + std::tie(lhs_info_img, rhs_info_img) = configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 1, 1, 0, 1, 0, 1); return select_lhs_rhs_info(std::make_pair(lhs_info_img, rhs_info_img), std::make_pair(lhs_info_buf, rhs_info_buf), @@ -210,6 +208,312 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedValha } } +std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedValhall::configure_G78_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b) +{ + const float r_mn = static_cast<float>(m) / static_cast<float>(n); + const float r_mk = static_cast<float>(m) / static_cast<float>(k); + const float r_nk = static_cast<float>(n) / static_cast<float>(k); + const float workload = (static_cast<float>(m) * static_cast<float>(n) * static_cast<float>(b)) / 20.0f; + + if(workload <= 1288.0000f) + { + if(workload <= 505.6000f) + { + if(r_mn <= 0.4466f) + { + if(r_nk <= 0.2384f) + { + return configure_lhs_rhs_info(m, n, 2, 4, 8, 4, 4, 0, 0, 1, 0, 1); + } + else + { + return configure_lhs_rhs_info(m, n, 2, 2, 4, 2, 2, 0, 0, 1, 0, 0); + } + } + else + { + return configure_lhs_rhs_info(m, n, 2, 2, 4, 2, 2, 0, 0, 1, 0, 0); + } + } + else + { + if(r_mn <= 0.2250f) + { + if(r_mn <= 0.1599f) + { + return configure_lhs_rhs_info(m, n, 2, 4, 8, 4, 4, 0, 0, 1, 0, 1); + } + else + { + return configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 2, 0, 0, 1, 0, 1); + } + } + else + { + if(r_mk <= 0.7609f) + { + if(r_mn <= 2.5453f) + { + if(workload <= 1089.6000f) + { + return configure_lhs_rhs_info(m, n, 2, 4, 8, 4, 4, 0, 0, 1, 0, 1); + } + else + { + return configure_lhs_rhs_info(m, n, 2, 4, 8, 2, 4, 0, 0, 1, 0, 1); + } + } + else + { + return configure_lhs_rhs_info(m, n, 2, 4, 16, 4, 4, 0, 0, 1, 0, 1); + } + } + else + { + return configure_lhs_rhs_info(m, n, 2, 4, 8, 4, 4, 0, 0, 1, 0, 1); + } + } + } + } + else + { + if(workload <= 5434.4001f) + { + if(workload <= 1603.2000f) + { + return configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 2, 0, 0, 1, 0, 1); + } + else + { + if(r_nk <= 0.6192f) + { + if(r_mn <= 16.1016f) + { + return configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 2, 0, 0, 1, 0, 1); + } + else + { + if(workload <= 2750.0000f) + { + return configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 2, 0, 0, 1, 0, 1); + } + else + { + if(r_mk <= 6.3151f) + { + return configure_lhs_rhs_info(m, n, 4, 4, 4, 4, 4, 0, 0, 0, 1, 1); + } + else + { + return configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 2, 0, 0, 1, 0, 1); + } + } + } + } + else + { + if(r_mk <= 0.0387f) + { + return configure_lhs_rhs_info(m, n, 4, 4, 4, 4, 4, 0, 0, 1, 0, 1); + } + else + { + if(r_mk <= 2.5859f) + { + if(r_mk <= 0.2734f) + { + return configure_lhs_rhs_info(m, n, 4, 4, 4, 4, 4, 0, 0, 1, 0, 1); + } + else + { + return configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 2, 0, 0, 1, 0, 1); + } + } + else + { + return configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 2, 0, 0, 1, 0, 1); + } + } + } + } + } + else + { + if(r_mk <= 25.7500f) + { + if(r_mk <= 0.3615f) + { + if(r_mn <= 0.0913f) + { + if(r_mk <= 0.0683f) + { + return configure_lhs_rhs_info(m, n, 8, 4, 4, 4, 2, 0, 0, 1, 0, 1); + } + else + { + return configure_lhs_rhs_info(m, n, 2, 4, 8, 4, 4, 0, 0, 1, 0, 1); + } + } + else + { + return configure_lhs_rhs_info(m, n, 8, 4, 4, 2, 2, 0, 0, 1, 0, 1); + } + } + else + { + if(workload <= 11174.3999f) + { + if(r_mk <= 0.8047f) + { + return configure_lhs_rhs_info(m, n, 8, 4, 4, 2, 2, 0, 0, 1, 0, 1); + } + else + { + if(workload <= 7185.5999f) + { + return configure_lhs_rhs_info(m, n, 4, 4, 4, 4, 4, 0, 0, 1, 0, 1); + } + else + { + return configure_lhs_rhs_info(m, n, 8, 4, 4, 4, 2, 0, 0, 1, 0, 1); + } + } + } + else + { + if(workload <= 17917.5000f) + { + if(r_mk <= 1.5078f) + { + return configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 2, 0, 0, 1, 0, 1); + } + else + { + return configure_lhs_rhs_info(m, n, 4, 4, 4, 4, 4, 0, 0, 1, 0, 1); + } + } + else + { + if(workload <= 34449.6016f) + { + return configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 2, 0, 0, 1, 0, 1); + } + else + { + return configure_lhs_rhs_info(m, n, 8, 4, 4, 2, 4, 0, 0, 1, 0, 1); + } + } + } + } + } + else + { + if(r_mk <= 331.1111f) + { + if(workload <= 53397.5996f) + { + if(r_mn <= 57.8063f) + { + return configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 2, 0, 0, 1, 0, 1); + } + else + { + return configure_lhs_rhs_info(m, n, 4, 4, 4, 4, 4, 0, 0, 0, 1, 1); + } + } + else + { + if(r_nk <= 0.9211f) + { + return configure_lhs_rhs_info(m, n, 8, 4, 4, 4, 2, 0, 0, 1, 0, 1); + } + else + { + return configure_lhs_rhs_info(m, n, 4, 4, 4, 4, 4, 0, 0, 0, 1, 1); + } + } + } + else + { + if(workload <= 38070.4004f) + { + return configure_lhs_rhs_info(m, n, 4, 4, 4, 4, 4, 0, 0, 0, 1, 1); + } + else + { + return configure_lhs_rhs_info(m, n, 4, 4, 4, 2, 2, 0, 0, 1, 0, 1); + } + } + } + } + } +} + +std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedValhall::configure_G78_f16(unsigned int m, unsigned int n, unsigned int k, unsigned int b) +{ + const float r_mn = static_cast<float>(m) / static_cast<float>(n); + const float r_nk = static_cast<float>(n) / static_cast<float>(k); + const float workload = (static_cast<float>(m) * static_cast<float>(n) * static_cast<float>(b)) / 20.0f; + + if(workload <= 801.6000f) + { + return configure_lhs_rhs_info(m, n, 8, 4, 4, 1, 1, 0, 0, 1, 0, 1); + } + else + { + if(r_mn <= 0.1211f) + { + if(workload <= 3296.0000f) + { + return configure_lhs_rhs_info(m, n, 8, 4, 4, 2, 2, 0, 0, 1, 0, 1); + } + else + { + if(r_nk <= 1.0625f) + { + return configure_lhs_rhs_info(m, n, 8, 4, 4, 2, 2, 0, 0, 1, 0, 1); + } + else + { + return configure_lhs_rhs_info(m, n, 8, 4, 4, 2, 4, 0, 0, 1, 0, 1); + } + } + } + else + { + if(workload <= 5068.8000f) + { + return configure_lhs_rhs_info(m, n, 8, 4, 4, 1, 1, 0, 0, 1, 0, 1); + } + else + { + if(r_nk <= 0.2361f) + { + if(workload <= 12630.0000f) + { + return configure_lhs_rhs_info(m, n, 8, 4, 4, 1, 1, 0, 0, 1, 0, 1); + } + else + { + return configure_lhs_rhs_info(m, n, 8, 4, 4, 2, 1, 0, 0, 1, 0, 1); + } + } + else + { + if(workload <= 178790.3984f) + { + return configure_lhs_rhs_info(m, n, 8, 4, 4, 2, 2, 0, 0, 1, 0, 1); + } + else + { + return configure_lhs_rhs_info(m, n, 8, 4, 4, 1, 1, 0, 0, 1, 0, 1); + } + } + } + } + } +} + std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedValhall::configure_G77_u8(unsigned int m, unsigned int n, unsigned int k, unsigned int b) { ARM_COMPUTE_UNUSED(k); @@ -217,11 +521,11 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedValha if(n <= 4) { - return configure_lhs_rhs_info(m, n, 4, 2, 16, 4, 1, false, false, false, true); + return configure_lhs_rhs_info(m, n, 4, 2, 16, 4, 1, 0, 0, 0, 1); } else { - return configure_lhs_rhs_info(m, n, 4, 4, 16, 2, 2, false, true, false, true); + return configure_lhs_rhs_info(m, n, 4, 4, 16, 2, 2, 0, 1, 0, 1); } } } // namespace cl_gemm diff --git a/src/core/CL/gemm/reshaped/CLGEMMDefaultConfigReshapedValhall.h b/src/core/CL/gemm/reshaped/CLGEMMDefaultConfigReshapedValhall.h index 2ce6482c46..52b83b09b6 100644 --- a/src/core/CL/gemm/reshaped/CLGEMMDefaultConfigReshapedValhall.h +++ b/src/core/CL/gemm/reshaped/CLGEMMDefaultConfigReshapedValhall.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -46,6 +46,8 @@ public: private: std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> configure_G77_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b); std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> configure_G77_f16(unsigned int m, unsigned int n, unsigned int k, unsigned int b); + std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> configure_G78_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b); + std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> configure_G78_f16(unsigned int m, unsigned int n, unsigned int k, unsigned int b); std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> configure_G77_u8(unsigned int m, unsigned int n, unsigned int k, unsigned int b); }; } // namespace cl_gemm diff --git a/src/core/CL/gemm/reshaped_only_rhs/CLGEMMDefaultConfigReshapedRHSOnlyBifrost.cpp b/src/core/CL/gemm/reshaped_only_rhs/CLGEMMDefaultConfigReshapedRHSOnlyBifrost.cpp index 7e6ef72f34..3645a0e141 100644 --- a/src/core/CL/gemm/reshaped_only_rhs/CLGEMMDefaultConfigReshapedRHSOnlyBifrost.cpp +++ b/src/core/CL/gemm/reshaped_only_rhs/CLGEMMDefaultConfigReshapedRHSOnlyBifrost.cpp @@ -31,7 +31,6 @@ #include "arm_compute/core/utils/misc/ShapeCalculator.h" #include "src/core/CL/gemm/CLGEMMHelpers.h" -#include <map> #include <utility> namespace arm_compute @@ -50,89 +49,42 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedRHSOn using ConfigurationFunctionExecutorPtr = std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> (CLGEMMDefaultConfigReshapedRHSOnlyBifrost::*)(unsigned int m, unsigned int n, unsigned int k, unsigned int b); - // Configurations for Mali-G51 - static std::map<DataType, ConfigurationFunctionExecutorPtr> gemm_configs_G51 = - { - { DataType::F32, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G51_f32 }, - { DataType::F16, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G51_f16 }, - { DataType::QASYMM8, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G51_u8 }, - { DataType::QSYMM8, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G51_u8 }, - { DataType::QASYMM8_SIGNED, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G51_u8 }, - { DataType::QSYMM8_PER_CHANNEL, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G51_u8 } - }; - - // Configurations for Mali-G52 - static std::map<DataType, ConfigurationFunctionExecutorPtr> gemm_configs_G52 = - { - { DataType::F32, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G52_f32 }, - { DataType::F16, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G52_f16 }, - { DataType::QASYMM8, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G7x_u8 }, - { DataType::QSYMM8, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G7x_u8 }, - { DataType::QASYMM8_SIGNED, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G7x_u8 }, - { DataType::QSYMM8_PER_CHANNEL, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G7x_u8 } - }; - - // Configurations for Mali-G76 - static std::map<DataType, ConfigurationFunctionExecutorPtr> gemm_configs_G76 = - { - { DataType::F32, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G76_f32 }, - { DataType::F16, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G76_f16 }, - { DataType::QASYMM8, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G76_u8 }, - { DataType::QSYMM8, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G76_u8 }, - { DataType::QASYMM8_SIGNED, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G76_u8 }, - { DataType::QSYMM8_PER_CHANNEL, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G76_u8 } - }; - - // Configurations for Mali-G7x - static std::map<DataType, ConfigurationFunctionExecutorPtr> gemm_configs_G7x = - { - { DataType::F32, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G7x_f32 }, - { DataType::F16, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G7x_f16 }, - { DataType::QASYMM8, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G7x_u8 }, - { DataType::QSYMM8, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G7x_u8 }, - { DataType::QASYMM8_SIGNED, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G7x_u8 }, - { DataType::QSYMM8_PER_CHANNEL, &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G7x_u8 } - }; + CLGEMMConfigArray<ConfigurationFunctionExecutorPtr> configs_G51(&CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G51_f32, + &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G51_f16, + &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G51_u8); + + CLGEMMConfigArray<ConfigurationFunctionExecutorPtr> configs_G52(&CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G52_f32, + &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G52_f16, + &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G7x_u8); + + CLGEMMConfigArray<ConfigurationFunctionExecutorPtr> configs_G76(&CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G76_f32, + &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G76_f16, + &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G76_u8); + + CLGEMMConfigArray<ConfigurationFunctionExecutorPtr> configs_G7x(&CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G7x_f32, + &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G7x_f16, + &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G7x_u8); + + ConfigurationFunctionExecutorPtr func = nullptr; switch(_target) { case GPUTarget::G76: - if(gemm_configs_G76.find(data_type) != gemm_configs_G76.end()) - { - return (this->*gemm_configs_G76[data_type])(m, n, k, b); - } - else - { - ARM_COMPUTE_ERROR("Not supported data type"); - } - case GPUTarget::G52: - if(gemm_configs_G52.find(data_type) != gemm_configs_G52.end()) - { - return (this->*gemm_configs_G52[data_type])(m, n, k, b); - } - else - { - ARM_COMPUTE_ERROR("Not supported data type"); - } + func = configs_G76.get_function(data_type); + break; case GPUTarget::G51: - if(gemm_configs_G51.find(data_type) != gemm_configs_G51.end()) - { - return (this->*gemm_configs_G51[data_type])(m, n, k, b); - } - else - { - ARM_COMPUTE_ERROR("Not supported data type"); - } + func = configs_G51.get_function(data_type); + break; + case GPUTarget::G52: + func = configs_G52.get_function(data_type); + break; default: - if(gemm_configs_G7x.find(data_type) != gemm_configs_G7x.end()) - { - return (this->*gemm_configs_G7x[data_type])(m, n, k, b); - } - else - { - ARM_COMPUTE_ERROR("Not supported data type"); - } + func = configs_G7x.get_function(data_type); + break; } + + ARM_COMPUTE_ERROR_ON_MSG(func == nullptr, "Data type not support for GEMM"); + return (this->*func)(m, n, k, b); } std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G7x_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b) diff --git a/src/core/CL/gemm/reshaped_only_rhs/CLGEMMDefaultConfigReshapedRHSOnlyValhall.cpp b/src/core/CL/gemm/reshaped_only_rhs/CLGEMMDefaultConfigReshapedRHSOnlyValhall.cpp index a0d38e44ae..a3f0509eda 100644 --- a/src/core/CL/gemm/reshaped_only_rhs/CLGEMMDefaultConfigReshapedRHSOnlyValhall.cpp +++ b/src/core/CL/gemm/reshaped_only_rhs/CLGEMMDefaultConfigReshapedRHSOnlyValhall.cpp @@ -31,7 +31,6 @@ #include "arm_compute/core/utils/misc/ShapeCalculator.h" #include "src/core/CL/gemm/CLGEMMHelpers.h" -#include <map> #include <utility> namespace arm_compute @@ -50,30 +49,29 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedRHSOn using ConfigurationFunctionExecutorPtr = std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> (CLGEMMDefaultConfigReshapedRHSOnlyValhall::*)(unsigned int m, unsigned int n, unsigned int k, unsigned int b); - // Configurations for Mali-G77 - static std::map<DataType, ConfigurationFunctionExecutorPtr> gemm_configs_G77 = - { - { DataType::F32, &CLGEMMDefaultConfigReshapedRHSOnlyValhall::configure_G77_f32 }, - { DataType::F16, &CLGEMMDefaultConfigReshapedRHSOnlyValhall::configure_G77_f16 }, - { DataType::QASYMM8, &CLGEMMDefaultConfigReshapedRHSOnlyValhall::configure_G77_u8 }, - { DataType::QSYMM8, &CLGEMMDefaultConfigReshapedRHSOnlyValhall::configure_G77_u8 }, - { DataType::QASYMM8_SIGNED, &CLGEMMDefaultConfigReshapedRHSOnlyValhall::configure_G77_u8 }, - { DataType::QSYMM8_PER_CHANNEL, &CLGEMMDefaultConfigReshapedRHSOnlyValhall::configure_G77_u8 } - }; + CLGEMMConfigArray<ConfigurationFunctionExecutorPtr> configs_G77(&CLGEMMDefaultConfigReshapedRHSOnlyValhall::configure_G77_f32, + &CLGEMMDefaultConfigReshapedRHSOnlyValhall::configure_G77_f16, + &CLGEMMDefaultConfigReshapedRHSOnlyValhall::configure_G77_u8); + + CLGEMMConfigArray<ConfigurationFunctionExecutorPtr> configs_G78(&CLGEMMDefaultConfigReshapedRHSOnlyValhall::configure_G78_f32, + &CLGEMMDefaultConfigReshapedRHSOnlyValhall::configure_G78_f16, + &CLGEMMDefaultConfigReshapedRHSOnlyValhall::configure_G77_u8); + + ConfigurationFunctionExecutorPtr func = nullptr; switch(_target) { + case GPUTarget::G78: + func = configs_G78.get_function(data_type); + break; case GPUTarget::G77: default: - if(gemm_configs_G77.find(data_type) != gemm_configs_G77.end()) - { - return (this->*gemm_configs_G77[data_type])(m, n, k, b); - } - else - { - ARM_COMPUTE_ERROR("Not supported data type"); - } + func = configs_G77.get_function(data_type); + break; } + + ARM_COMPUTE_ERROR_ON_MSG(func == nullptr, "Data type not support for GEMM"); + return (this->*func)(m, n, k, b); } std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedRHSOnlyValhall::configure_G77_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b) @@ -93,8 +91,8 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedRHSOn GEMMRHSMatrixInfo rhs_info_img; const unsigned int h0 = std::max(n / 4, 1U); - std::tie(lhs_info_img, rhs_info_img) = configure_lhs_rhs_info(m, n, 1, 4, 8, 1, 16, false, true, false, false, true); - std::tie(lhs_info_buf, rhs_info_buf) = configure_lhs_rhs_info(m, n, 1, 4, 4, 1, h0, false, true, false, true, false); + std::tie(lhs_info_img, rhs_info_img) = configure_lhs_rhs_info(m, n, 1, 4, 8, 1, 16, 0, 1, 0, 0, 1); + std::tie(lhs_info_buf, rhs_info_buf) = configure_lhs_rhs_info(m, n, 1, 4, 4, 1, h0, 0, 1, 0, 1, 0); return select_lhs_rhs_info(std::make_pair(lhs_info_img, rhs_info_img), std::make_pair(lhs_info_buf, rhs_info_buf), @@ -102,18 +100,18 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedRHSOn } else { - return configure_lhs_rhs_info(m, n, 1, 2, 16, 1, 8, false, true, false, false, false); + return configure_lhs_rhs_info(m, n, 1, 2, 16, 1, 8, 0, 1, 0, 0, 0); } } else { if(r_mk <= 0.020312500186264515) { - return configure_lhs_rhs_info(m, n, 1, 2, 16, 1, 4, false, true, false, false, false); + return configure_lhs_rhs_info(m, n, 1, 2, 16, 1, 4, 0, 1, 0, 0, 0); } else { - return configure_lhs_rhs_info(m, n, 1, 4, 16, 1, 16, false, true, false, true, false); + return configure_lhs_rhs_info(m, n, 1, 4, 16, 1, 16, 0, 1, 0, 1, 0); } } } @@ -127,7 +125,7 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedRHSOn { if(workload <= 747.1999816894531) { - return configure_lhs_rhs_info(m, n, 2, 2, 4, 1, 8, false, true, false, true, false); + return configure_lhs_rhs_info(m, n, 2, 2, 4, 1, 8, 0, 1, 0, 1, 0); } else { @@ -135,8 +133,8 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedRHSOn GEMMRHSMatrixInfo rhs_info_buf; GEMMLHSMatrixInfo lhs_info_img; GEMMRHSMatrixInfo rhs_info_img; - std::tie(lhs_info_img, rhs_info_img) = configure_lhs_rhs_info(m, n, 2, 4, 8, 1, 2, false, false, false, true, true); - std::tie(lhs_info_buf, rhs_info_buf) = configure_lhs_rhs_info(m, n, 2, 2, 4, 1, 8, false, true, false, true, false); + std::tie(lhs_info_img, rhs_info_img) = configure_lhs_rhs_info(m, n, 2, 4, 8, 1, 2, 0, 0, 0, 1, 1); + std::tie(lhs_info_buf, rhs_info_buf) = configure_lhs_rhs_info(m, n, 2, 2, 4, 1, 8, 0, 1, 0, 1, 0); return select_lhs_rhs_info(std::make_pair(lhs_info_img, rhs_info_img), std::make_pair(lhs_info_buf, rhs_info_buf), @@ -149,7 +147,7 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedRHSOn { if(r_mk <= 0.028125000186264515) { - return configure_lhs_rhs_info(m, n, 2, 2, 4, 1, 8, false, true, false, true, false); + return configure_lhs_rhs_info(m, n, 2, 2, 4, 1, 8, 0, 1, 0, 1, 0); } else { @@ -157,8 +155,8 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedRHSOn GEMMRHSMatrixInfo rhs_info_buf; GEMMLHSMatrixInfo lhs_info_img; GEMMRHSMatrixInfo rhs_info_img; - std::tie(lhs_info_img, rhs_info_img) = configure_lhs_rhs_info(m, n, 2, 4, 8, 1, 2, false, false, false, true, true); - std::tie(lhs_info_buf, rhs_info_buf) = configure_lhs_rhs_info(m, n, 2, 2, 4, 1, 8, false, true, false, true, false); + std::tie(lhs_info_img, rhs_info_img) = configure_lhs_rhs_info(m, n, 2, 4, 8, 1, 2, 0, 0, 0, 1, 1); + std::tie(lhs_info_buf, rhs_info_buf) = configure_lhs_rhs_info(m, n, 2, 2, 4, 1, 8, 0, 1, 0, 1, 0); return select_lhs_rhs_info(std::make_pair(lhs_info_img, rhs_info_img), std::make_pair(lhs_info_buf, rhs_info_buf), @@ -171,8 +169,8 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedRHSOn GEMMRHSMatrixInfo rhs_info_buf; GEMMLHSMatrixInfo lhs_info_img; GEMMRHSMatrixInfo rhs_info_img; - std::tie(lhs_info_img, rhs_info_img) = configure_lhs_rhs_info(m, n, 4, 4, 4, 1, 2, false, true, false, false, true); - std::tie(lhs_info_buf, rhs_info_buf) = configure_lhs_rhs_info(m, n, 4, 4, 4, 1, 16, false, true, false, true, false); + std::tie(lhs_info_img, rhs_info_img) = configure_lhs_rhs_info(m, n, 4, 4, 4, 1, 2, 0, 1, 0, 0, 1); + std::tie(lhs_info_buf, rhs_info_buf) = configure_lhs_rhs_info(m, n, 4, 4, 4, 1, 16, 0, 1, 0, 1, 0); return select_lhs_rhs_info(std::make_pair(lhs_info_img, rhs_info_img), std::make_pair(lhs_info_buf, rhs_info_buf), @@ -192,11 +190,11 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedRHSOn const unsigned int h0 = std::max(n / 2, 1U); if(n <= 836.0) { - return configure_lhs_rhs_info(m, n, 1, 2, 16, 1, h0, false, true, false, true, false); + return configure_lhs_rhs_info(m, n, 1, 2, 16, 1, h0, 0, 1, 0, 1, 0); } else { - return configure_lhs_rhs_info(m, n, 1, 2, 8, 1, h0, false, true, false, true, false); + return configure_lhs_rhs_info(m, n, 1, 2, 8, 1, h0, 0, 1, 0, 1, 0); } } else if(m < 128) @@ -204,11 +202,11 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedRHSOn const int h0 = std::max(std::min(static_cast<int>(n / 4), static_cast<int>(256)), static_cast<int>(1)); if(k >= 512) { - return configure_lhs_rhs_info(m, n, 2, 4, 16, 1, h0, false, true, false, false); + return configure_lhs_rhs_info(m, n, 2, 4, 16, 1, h0, 0, 1, 0, 0); } else { - return configure_lhs_rhs_info(m, n, 2, 4, 8, 1, h0, false, true, false, false); + return configure_lhs_rhs_info(m, n, 2, 4, 8, 1, h0, 0, 1, 0, 0); } } else @@ -216,17 +214,17 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedRHSOn const int h0 = std::max(std::min(static_cast<int>(n / 4), static_cast<int>(256)), static_cast<int>(1)); if(n >= 64) { - return configure_lhs_rhs_info(m, n, 4, 8, 4, 1, h0, false, true, false, false); + return configure_lhs_rhs_info(m, n, 4, 8, 4, 1, h0, 0, 1, 0, 0); } else { if(k >= 512) { - return configure_lhs_rhs_info(m, n, 2, 4, 16, 1, h0, false, true, false, false); + return configure_lhs_rhs_info(m, n, 2, 4, 16, 1, h0, 0, 1, 0, 0); } else { - return configure_lhs_rhs_info(m, n, 2, 4, 8, 1, h0, false, true, false, false); + return configure_lhs_rhs_info(m, n, 2, 4, 8, 1, h0, 0, 1, 0, 0); } } } @@ -240,18 +238,325 @@ std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedRHSOn if(m == 1) { const unsigned int h0 = std::max(n / 2, 1U); - return configure_lhs_rhs_info(m, n, 1, 4, 16, 1, h0, false, true, false, true); + return configure_lhs_rhs_info(m, n, 1, 4, 16, 1, h0, 0, 1, 0, 1); } else { const int h0 = std::max(std::min(static_cast<int>(n / 4), static_cast<int>(256)), static_cast<int>(1)); if(m >= 28) { - return configure_lhs_rhs_info(m, n, 4, 4, 16, 1, h0, false, true, false, true); + return configure_lhs_rhs_info(m, n, 4, 4, 16, 1, h0, 0, 1, 0, 1); + } + else + { + return configure_lhs_rhs_info(m, n, 2, 4, 16, 1, h0, 0, 1, 0, 1); + } + } +} + +std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedRHSOnlyValhall::configure_G78_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b) +{ + const float r_mn = static_cast<float>(m) / static_cast<float>(n); + const float r_mk = static_cast<float>(m) / static_cast<float>(k); + const float r_nk = static_cast<float>(n) / static_cast<float>(k); + const float workload = (static_cast<float>(m) * static_cast<float>(n) * static_cast<float>(b)) / 20.0f; + + if(m == 1) + { + if(workload <= 278.7000f) + { + if(workload <= 7.5000f) + { + return configure_lhs_rhs_info(m, n, 1, 2, 8, 1, 2, 0, 1, 1, 0, 0); + } + else + { + if(r_mn <= 0.0031f) + { + if(workload <= 256.6000f) + { + if(workload <= 16.7500f) + { + if(r_nk <= 1.6671f) + { + return configure_lhs_rhs_info(m, n, 1, 2, 2, 1, 32, 0, 0, 0, 1, 0); + } + else + { + return configure_lhs_rhs_info(m, n, 1, 2, 8, 1, 2, 0, 1, 1, 0, 0); + } + } + else + { + return configure_lhs_rhs_info(m, n, 1, 2, 2, 1, 32, 0, 0, 0, 1, 0); + } + } + else + { + return configure_lhs_rhs_info(m, n, 1, 2, 2, 1, 32, 0, 0, 0, 1, 0); + } + } + else + { + if(r_mk <= 0.0027f) + { + if(r_mk <= 0.0014f) + { + return configure_lhs_rhs_info(m, n, 1, 2, 2, 1, 32, 0, 0, 0, 1, 0); + } + else + { + if(workload <= 8.9500f) + { + return configure_lhs_rhs_info(m, n, 1, 2, 8, 1, 2, 0, 1, 1, 0, 0); + } + else + { + return configure_lhs_rhs_info(m, n, 1, 2, 2, 1, 32, 0, 0, 0, 1, 0); + } + } + } + else + { + if(workload <= 14.1500f) + { + return configure_lhs_rhs_info(m, n, 1, 2, 8, 1, 2, 0, 1, 1, 0, 0); + } + else + { + if(r_mk <= 0.0041f) + { + return configure_lhs_rhs_info(m, n, 1, 2, 2, 1, 32, 0, 0, 0, 1, 0); + } + else + { + return configure_lhs_rhs_info(m, n, 1, 2, 8, 1, 2, 0, 1, 1, 0, 0); + } + } + } + } + } + } + else + { + if(workload <= 363.7000f) + { + if(r_mk <= 0.0031f) + { + return configure_lhs_rhs_info(m, n, 1, 4, 2, 1, 32, 0, 1, 0, 1, 0); + } + else + { + return configure_lhs_rhs_info(m, n, 1, 4, 4, 1, 32, 0, 1, 0, 1, 0); + } + } + else + { + return configure_lhs_rhs_info(m, n, 1, 4, 2, 1, 32, 0, 1, 0, 1, 0); + } + } + } + else + { + if(workload <= 1384.8000f) + { + if(workload <= 704.0000f) + { + return configure_lhs_rhs_info(m, n, 2, 2, 4, 1, 32, 0, 1, 0, 1, 0); + } + else + { + return configure_lhs_rhs_info(m, n, 2, 4, 8, 1, 4, 0, 0, 0, 1, 1); + } + } + else + { + if(workload <= 16761.6006f) + { + if(r_mn <= 187.1250f) + { + return configure_lhs_rhs_info(m, n, 4, 4, 4, 1, 16, 0, 0, 0, 1, 1); + } + else + { + return configure_lhs_rhs_info(m, n, 2, 4, 8, 1, 4, 0, 0, 0, 1, 1); + } + } + else + { + if(r_mk <= 432.4630f) + { + return configure_lhs_rhs_info(m, n, 5, 4, 4, 1, 16, 0, 0, 0, 1, 1); + } + else + { + return configure_lhs_rhs_info(m, n, 2, 4, 4, 1, 16, 0, 1, 0, 1, 1); + } + } + } + } +} + +std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMDefaultConfigReshapedRHSOnlyValhall::configure_G78_f16(unsigned int m, unsigned int n, unsigned int k, unsigned int b) +{ + const float r_mn = static_cast<float>(m) / static_cast<float>(n); + const float r_mk = static_cast<float>(m) / static_cast<float>(k); + const float r_nk = static_cast<float>(n) / static_cast<float>(k); + const float workload = (static_cast<float>(m) * static_cast<float>(n) * static_cast<float>(b)) / 20.0f; + + if(m == 1) + { + if(r_mn <= 0.0038f) + { + if(workload <= 353.9000f) + { + if(workload <= 278.7000f) + { + return configure_lhs_rhs_info(m, n, 1, 2, 4, 1, 32, 0, 0, 1, 0, 0); + } + else + { + if(r_mk <= 0.0004f) + { + return configure_lhs_rhs_info(m, n, 1, 2, 4, 1, 32, 0, 0, 1, 0, 0); + } + else + { + if(r_mk <= 0.0030f) + { + return configure_lhs_rhs_info(m, n, 1, 8, 4, 1, 8, 0, 1, 1, 0, 1); + } + else + { + return configure_lhs_rhs_info(m, n, 1, 2, 4, 1, 32, 0, 0, 1, 0, 0); + } + } + } + } + else + { + if(r_nk <= 1.9384f) + { + return configure_lhs_rhs_info(m, n, 1, 2, 4, 1, 32, 0, 0, 1, 0, 0); + } + else + { + return configure_lhs_rhs_info(m, n, 1, 8, 4, 1, 8, 0, 1, 1, 0, 1); + } + } } else { - return configure_lhs_rhs_info(m, n, 2, 4, 16, 1, h0, false, true, false, true); + if(r_nk <= 1.0368f) + { + return configure_lhs_rhs_info(m, n, 1, 2, 16, 1, 32, 0, 0, 1, 0, 0); + } + else + { + return configure_lhs_rhs_info(m, n, 1, 2, 4, 1, 32, 0, 0, 1, 0, 0); + } + } + } + else + { + if(workload <= 1422.4000f) + { + if(workload <= 704.0000f) + { + return configure_lhs_rhs_info(m, n, 2, 2, 8, 1, 32, 0, 0, 1, 0, 0); + } + else + { + if(workload <= 1197.6000f) + { + return configure_lhs_rhs_info(m, n, 2, 4, 8, 1, 8, 0, 1, 1, 0, 1); + } + else + { + if(workload <= 1241.6000f) + { + return configure_lhs_rhs_info(m, n, 2, 8, 8, 1, 16, 0, 1, 1, 0, 0); + } + else + { + return configure_lhs_rhs_info(m, n, 2, 4, 8, 1, 8, 0, 1, 1, 0, 1); + } + } + } + } + else + { + if(workload <= 2769.6000f) + { + if(workload <= 1846.4000f) + { + if(r_mn <= 2.4927f) + { + return configure_lhs_rhs_info(m, n, 2, 8, 8, 1, 16, 0, 1, 1, 0, 0); + } + else + { + return configure_lhs_rhs_info(m, n, 4, 4, 8, 1, 32, 0, 1, 1, 0, 0); + } + } + else + { + if(r_mn <= 0.6261f) + { + return configure_lhs_rhs_info(m, n, 4, 4, 8, 1, 32, 0, 1, 1, 0, 0); + } + else + { + if(r_mk <= 3.4453f) + { + if(r_mn <= 1.4135f) + { + return configure_lhs_rhs_info(m, n, 2, 8, 8, 1, 16, 0, 1, 1, 0, 0); + } + else + { + return configure_lhs_rhs_info(m, n, 4, 4, 8, 1, 32, 0, 1, 1, 0, 0); + } + } + else + { + return configure_lhs_rhs_info(m, n, 2, 8, 8, 1, 16, 0, 1, 1, 0, 0); + } + } + } + } + else + { + if(r_nk <= 0.0302f) + { + return configure_lhs_rhs_info(m, n, 2, 4, 8, 1, 8, 0, 1, 1, 0, 1); + } + else + { + if(r_mk <= 181.3750f) + { + return configure_lhs_rhs_info(m, n, 4, 4, 8, 1, 32, 0, 1, 1, 0, 0); + } + else + { + if(workload <= 28035.2002f) + { + return configure_lhs_rhs_info(m, n, 2, 8, 8, 1, 16, 0, 1, 1, 0, 0); + } + else + { + if(r_mk <= 808.6667f) + { + return configure_lhs_rhs_info(m, n, 4, 4, 8, 1, 32, 0, 1, 1, 0, 0); + } + else + { + return configure_lhs_rhs_info(m, n, 2, 8, 8, 1, 16, 0, 1, 1, 0, 0); + } + } + } + } + } } } } diff --git a/src/core/CL/gemm/reshaped_only_rhs/CLGEMMDefaultConfigReshapedRHSOnlyValhall.h b/src/core/CL/gemm/reshaped_only_rhs/CLGEMMDefaultConfigReshapedRHSOnlyValhall.h index 94c6a43c21..a3b556c441 100644 --- a/src/core/CL/gemm/reshaped_only_rhs/CLGEMMDefaultConfigReshapedRHSOnlyValhall.h +++ b/src/core/CL/gemm/reshaped_only_rhs/CLGEMMDefaultConfigReshapedRHSOnlyValhall.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -46,6 +46,8 @@ public: private: std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> configure_G77_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b); std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> configure_G77_f16(unsigned int m, unsigned int n, unsigned int k, unsigned int b); + std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> configure_G78_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b); + std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> configure_G78_f16(unsigned int m, unsigned int n, unsigned int k, unsigned int b); std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> configure_G77_u8(unsigned int m, unsigned int n, unsigned int k, unsigned int b); }; } // namespace cl_gemm |