Add GEMM heuristic for Mali-G78

- Replace std::map with a basic container with std::array

Change-Id: I76f53ca61676ca0e5136ce61a3f3adb10e22b4c3
Signed-off-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5441
Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
diff --git a/src/core/CL/gemm/reshaped_only_rhs/CLGEMMDefaultConfigReshapedRHSOnlyBifrost.cpp b/src/core/CL/gemm/reshaped_only_rhs/CLGEMMDefaultConfigReshapedRHSOnlyBifrost.cpp
index 7e6ef72..3645a0e 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 @@
     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 }
-    };
+    CLGEMMConfigArray<ConfigurationFunctionExecutorPtr> configs_G51(&CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G51_f32,
+                                                                    &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G51_f16,
+                                                                    &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 }
-    };
+    CLGEMMConfigArray<ConfigurationFunctionExecutorPtr> configs_G52(&CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G52_f32,
+                                                                    &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G52_f16,
+                                                                    &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 }
-    };
+    CLGEMMConfigArray<ConfigurationFunctionExecutorPtr> configs_G76(&CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G76_f32,
+                                                                    &CLGEMMDefaultConfigReshapedRHSOnlyBifrost::configure_G76_f16,
+                                                                    &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_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)