COMPMID-1687: Optimize CLGEMMMatrixMultiplyKernel

Change-Id: I040478ff7aa04f0523ed6e302129b829442cb194
Reviewed-on: https://review.mlplatform.org/534
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Michalis Spyrou <michalis.spyrou@arm.com>
diff --git a/SConscript b/SConscript
index 2dd9b38..9045e9d 100644
--- a/SConscript
+++ b/SConscript
@@ -190,6 +190,7 @@
     runtime_files += Glob('src/runtime/CL/*.cpp')
     runtime_files += Glob('src/runtime/CL/functions/*.cpp')
     runtime_files += Glob('src/runtime/CL/tuners/*.cpp')
+    runtime_files += Glob('src/runtime/CL/gemm_reshaped/*.cpp')
 
     graph_files += Glob('src/graph/backends/CL/*.cpp')
 
diff --git a/arm_compute/runtime/CL/ICLGEMMReshapedConfiguration.h b/arm_compute/runtime/CL/ICLGEMMReshapedConfiguration.h
new file mode 100644
index 0000000..500d9cd
--- /dev/null
+++ b/arm_compute/runtime/CL/ICLGEMMReshapedConfiguration.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2019 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_ICLGEMMRESHAPEDCONFIGURATION_H__
+#define __ARM_COMPUTE_ICLGEMMRESHAPEDCONFIGURATION_H__
+
+#include "arm_compute/core/Types.h"
+
+namespace arm_compute
+{
+/** Basic interface for the GEMM selection */
+class ICLGEMMReshapedConfiguration
+{
+public:
+    /** Virtual destructor */
+    virtual ~ICLGEMMReshapedConfiguration() = default;
+    /** Given M, N, K and B, this method returns the @ref GEMMLHSMatrixInfo and @ref GEMMRHSMatrixInfo to be used with @ref CLGEMMMatrixMultiplyReshapedKernel
+     *
+     * @param[in] m         Number of rows LHS matrix
+     * @param[in] n         Number of columns RHS matrix
+     * @param[in] k         Number of columns LHS matrix or number of rows RHS matrix
+     * @param[in] b         Batch size
+     * @param[in] data_type Data type
+     */
+    virtual std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> configure(unsigned int m, unsigned int n, unsigned int k, unsigned int b, DataType data_type) = 0;
+};
+} // namespace arm_compute
+#endif /*__ARM_COMPUTE_ICLGEMMRESHAPEDCONFIGURATION_H__ */
diff --git a/arm_compute/runtime/CL/functions/CLGEMM.h b/arm_compute/runtime/CL/functions/CLGEMM.h
index 624df33..3ec07cf 100644
--- a/arm_compute/runtime/CL/functions/CLGEMM.h
+++ b/arm_compute/runtime/CL/functions/CLGEMM.h
@@ -115,7 +115,7 @@
     bool                               _run_addition;
     bool                               _reshape_b_only_on_first_run;
     bool                               _is_prepared;
-    bool                               _is_G76_path;
+    bool                               _is_new_gemm_reshaped; // Removed when COMPMID-1892 is completed
 };
 } // namespace arm_compute
 
diff --git a/arm_compute/runtime/CL/gemm_reshaped/CLGEMMReshapedConfiguration.h b/arm_compute/runtime/CL/gemm_reshaped/CLGEMMReshapedConfiguration.h
new file mode 100644
index 0000000..3458911
--- /dev/null
+++ b/arm_compute/runtime/CL/gemm_reshaped/CLGEMMReshapedConfiguration.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2019 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_CLGEMMRESHAPEDCONFIGURATION_H__
+#define __ARM_COMPUTE_CLGEMMRESHAPEDCONFIGURATION_H__
+
+#include "arm_compute/runtime/CL/CLScheduler.h"
+#include "arm_compute/runtime/CL/ICLGEMMReshapedConfiguration.h"
+#include "arm_compute/runtime/CL/gemm_reshaped/CLGEMMReshapedConfigurationBifrost.h"
+
+#include <memory>
+
+namespace arm_compute
+{
+namespace cl_gemm
+{
+/** Tuner factory class */
+class CLGEMMReshapedConfigurationFactory final
+{
+public:
+    static std::unique_ptr<ICLGEMMReshapedConfiguration> create()
+    {
+        GPUTarget arch = get_arch_from_target(CLScheduler::get().target());
+
+        switch(arch)
+        {
+            case GPUTarget::BIFROST:
+                return support::cpp14::make_unique<CLGEMMReshapedConfigurationBifrost>();
+            default:
+                return nullptr;
+        }
+    }
+};
+} // namespace tuners
+} // namespace arm_compute
+#endif /*__ARM_COMPUTE_CLGEMMRESHAPEDCONFIGURATION_H__ */
diff --git a/arm_compute/runtime/CL/gemm_reshaped/CLGEMMReshapedConfigurationBifrost.h b/arm_compute/runtime/CL/gemm_reshaped/CLGEMMReshapedConfigurationBifrost.h
new file mode 100644
index 0000000..b452c53
--- /dev/null
+++ b/arm_compute/runtime/CL/gemm_reshaped/CLGEMMReshapedConfigurationBifrost.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2019 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_CLGEMMRESHAPEDCONFIGURATIONBIFROST_H__
+#define __ARM_COMPUTE_CLGEMMRESHAPEDCONFIGURATIONBIFROST_H__
+
+#include "arm_compute/runtime/CL/ICLGEMMReshapedConfiguration.h"
+
+namespace arm_compute
+{
+namespace cl_gemm
+{
+/** Bifrost based OpenCL GEMM reshaped configuration */
+class CLGEMMReshapedConfigurationBifrost final : public ICLGEMMReshapedConfiguration
+{
+public:
+    // Inherited overridden method
+    std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> configure(unsigned int m, unsigned int n, unsigned int k, unsigned int b, DataType data_type) override;
+
+private:
+    std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> configure_G7x_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b);
+    std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> configure_G76_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b);
+};
+} // namespace cl_gemm
+} // namespace arm_compute
+#endif /*__ARM_COMPUTE_CLGEMMRESHAPEDCONFIGURATIONBIFROST_H__ */
diff --git a/src/runtime/CL/functions/CLGEMM.cpp b/src/runtime/CL/functions/CLGEMM.cpp
index a3612f3..cd40fc6 100644
--- a/src/runtime/CL/functions/CLGEMM.cpp
+++ b/src/runtime/CL/functions/CLGEMM.cpp
@@ -33,11 +33,13 @@
 #include "arm_compute/core/Validate.h"
 #include "arm_compute/core/utils/misc/ShapeCalculator.h"
 #include "arm_compute/runtime/CL/CLScheduler.h"
+#include "arm_compute/runtime/CL/gemm_reshaped/CLGEMMReshapedConfiguration.h"
 #include "arm_compute/runtime/ITensorAllocator.h"
 
 namespace arm_compute
 {
 using namespace arm_compute::misc::shape_calculator;
+using namespace arm_compute::cl_gemm;
 
 namespace
 {
@@ -77,43 +79,6 @@
 
     return flag;
 }
-
-inline void select_gemm_configuration(unsigned int m, unsigned int n, GEMMLHSMatrixInfo &lhs_info, GEMMRHSMatrixInfo &rhs_info)
-{
-    // Heuristic selection for GEMM
-    if(n <= 4)
-    {
-        // Configure GEMMLHSMatrixInfo
-        lhs_info.m0         = 4;
-        lhs_info.k0         = 8;
-        lhs_info.v0         = lhs_info.m0 * 16 < m ? 2 : 16;
-        lhs_info.interleave = true;
-        lhs_info.transpose  = false;
-
-        // Configure GEMMRHSMatrixInfo
-        rhs_info.n0         = 2;
-        rhs_info.k0         = lhs_info.k0;
-        rhs_info.h0         = rhs_info.n0 * 16 < n ? 2 : 16;
-        rhs_info.interleave = false;
-        rhs_info.transpose  = true;
-    }
-    else
-    {
-        // Configure GEMMLHSMatrixInfo
-        lhs_info.m0         = (m * n) / 24 > 2048 ? 6 : 5;
-        lhs_info.k0         = 4;
-        lhs_info.v0         = 32;
-        lhs_info.interleave = false;
-        lhs_info.transpose  = false;
-
-        // Configure GEMMRHSMatrixInfo
-        rhs_info.n0         = 4;
-        rhs_info.k0         = lhs_info.k0;
-        rhs_info.h0         = 32;
-        rhs_info.interleave = true;
-        rhs_info.transpose  = true;
-    }
-}
 } // namespace
 
 CLGEMM::CLGEMM(std::shared_ptr<IMemoryManager> memory_manager)
@@ -130,7 +95,7 @@
       _run_addition(false),
       _reshape_b_only_on_first_run(false),
       _is_prepared(false),
-      _is_G76_path(false)
+      _is_new_gemm_reshaped(false)
 {
 }
 
@@ -164,6 +129,7 @@
     const unsigned int m                         = reinterpret_input_as_3d ? (a->info()->dimension(1) * a->info()->dimension(2)) : a->info()->dimension(1);
     const unsigned int n                         = b->info()->dimension(0);
     const unsigned int k                         = a->info()->dimension(0);
+    const unsigned int batch_size                = reinterpret_input_as_3d ? a->info()->dimension(3) : a->info()->dimension(2);
     const int          depth_output_gemm3d       = gemm_info.depth_output_gemm3d();
     int                mult_transpose1xW_width   = 1;
     int                mult_interleave4x4_height = 1;
@@ -191,7 +157,8 @@
     _is_interleaved_transposed = is_interleaved_transposed(m, n, k, a->info()->data_type(), _reshape_b_only_on_first_run, gpu_target);
 
     // Check if we can run the new reshaped GEMM
-    _is_G76_path = (gpu_target == GPUTarget::G76) && _is_interleaved_transposed && (data_type == DataType::F32);
+    const auto workload   = static_cast<float>((m * n) / 20.0f);
+    _is_new_gemm_reshaped = (workload > 1600.0f) && (get_arch_from_target(gpu_target) == GPUTarget::BIFROST) && _is_interleaved_transposed && (data_type == DataType::F32);
 
     // if _is_interleaved_transposed is set, force reinterpret_input_as_3d to be false as the output of CLGEMMInterleaveKernel will be 2D
     if(_is_interleaved_transposed)
@@ -209,12 +176,12 @@
         }
         // _tmp_a and _tmp_b will be auto configured in _interleave_kernel and in _transpose_kernel
 
-        if(_is_G76_path)
+        if(_is_new_gemm_reshaped)
         {
             GEMMLHSMatrixInfo lhs_info;
 
-            // Pick up the GEMM configuration based on M,N and K
-            select_gemm_configuration(m, n, lhs_info, rhs_info);
+            // Pick up the GEMM configuration
+            std::tie(lhs_info, rhs_info) = CLGEMMReshapedConfigurationFactory::create()->configure(m, n, k, batch_size, data_type);
 
             _reshape_lhs_kernel.configure(a, &_tmp_a, lhs_info, gemm_info.reinterpret_input_as_3d());
             _reshape_rhs_kernel.configure(b, &_tmp_b, rhs_info);
@@ -232,7 +199,7 @@
         }
     }
 
-    if(!_is_G76_path)
+    if(!_is_new_gemm_reshaped)
     {
         // Configure and tune matrix multiply kernel
         _mm_kernel.configure(matrix_a, matrix_b, output, alpha, _is_interleaved_transposed, GEMMReshapeInfo(m, n, k,
@@ -285,6 +252,7 @@
     const unsigned int m                         = reinterpret_input_as_3d ? (a->dimension(1) * a->dimension(2)) : a->dimension(1);
     const unsigned int n                         = b->dimension(0);
     const unsigned int k                         = a->dimension(0);
+    const unsigned int batch_size                = reinterpret_input_as_3d ? a->dimension(3) : a->dimension(2);
     int                mult_transpose1xW_width   = 1;
     int                mult_interleave4x4_height = 1;
     const int          depth_output_gemm3d       = gemm_info.depth_output_gemm3d();
@@ -313,7 +281,8 @@
     const bool run_interleave_transpose = is_interleaved_transposed(m, n, k, a->data_type(), reshape_b_only_on_first_run, gpu_target);
 
     // Check if we can run the new reshaped GEMM
-    const bool is_G76_path = (gpu_target == GPUTarget::G76) && run_interleave_transpose && (data_type == DataType::F32);
+    const auto workload             = static_cast<float>((m * n) / 20.0f);
+    const bool is_new_gemm_reshaped = (workload > 1600.f) && (get_arch_from_target(gpu_target) == GPUTarget::BIFROST) && run_interleave_transpose && (data_type == DataType::F32);
 
     // if _is_interleaved_transposed is set, force reinterpret_input_as_3d to be false as the output of CLGEMMInterleaveKernel will be 2D
     if(run_interleave_transpose)
@@ -328,12 +297,12 @@
         matrix_a_info = &tmp_a_info;
         matrix_b_info = &tmp_b_info;
 
-        if(is_G76_path)
+        if(is_new_gemm_reshaped)
         {
             GEMMLHSMatrixInfo lhs_info;
 
-            // Pick up the GEMM configuration based on M,N and K
-            select_gemm_configuration(m, n, lhs_info, rhs_info);
+            // Pick up the GEMM configuration
+            std::tie(lhs_info, rhs_info) = CLGEMMReshapedConfigurationFactory::create()->configure(m, n, k, batch_size, data_type);
 
             auto_init_if_empty(tmp_a_info, a->clone()->set_tensor_shape(compute_lhs_reshaped_shape(*a, lhs_info, gemm_info.reinterpret_input_as_3d())));
             ARM_COMPUTE_RETURN_ON_ERROR(CLGEMMReshapeLHSMatrixKernel::validate(a, &tmp_a_info, lhs_info, gemm_info.reinterpret_input_as_3d()));
@@ -356,7 +325,7 @@
         }
     }
 
-    if(!is_G76_path)
+    if(!is_new_gemm_reshaped)
     {
         // Validate matrix multiply
         ARM_COMPUTE_RETURN_ON_ERROR(CLGEMMMatrixMultiplyKernel::validate(matrix_a_info, matrix_b_info, output, alpha, run_interleave_transpose, reshape_info, gpu_target, gemm_info.fp_mixed_precision()));
@@ -390,7 +359,7 @@
     }
 
     // Run matrix multiply kernel
-    if(_is_G76_path)
+    if(_is_new_gemm_reshaped)
     {
         CLScheduler::get().enqueue(_mm_reshaped_kernel, !_run_addition);
     }
diff --git a/src/runtime/CL/gemm_reshaped/CLGEMMReshapedConfigurationBifrost.cpp b/src/runtime/CL/gemm_reshaped/CLGEMMReshapedConfigurationBifrost.cpp
new file mode 100644
index 0000000..079a52e
--- /dev/null
+++ b/src/runtime/CL/gemm_reshaped/CLGEMMReshapedConfigurationBifrost.cpp
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2019 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include "arm_compute/runtime/CL/gemm_reshaped/CLGEMMReshapedConfigurationBifrost.h"
+
+#include "arm_compute/core/GPUTarget.h"
+#include "arm_compute/runtime/CL/CLScheduler.h"
+
+#include <utility>
+
+namespace arm_compute
+{
+namespace cl_gemm
+{
+std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMReshapedConfigurationBifrost::configure(unsigned int m, unsigned int n, unsigned int k, unsigned int b, DataType data_type)
+{
+    ARM_COMPUTE_ERROR_ON(data_type != DataType::F32);
+    ARM_COMPUTE_UNUSED(data_type);
+
+    const GPUTarget gpu_target = CLScheduler::get().target();
+    switch(gpu_target)
+    {
+        case GPUTarget::G76:
+            return configure_G76_f32(m, n, k, b);
+        default:
+            return configure_G7x_f32(m, n, k, b);
+    }
+}
+
+std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMReshapedConfigurationBifrost::configure_G7x_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b)
+{
+    ARM_COMPUTE_UNUSED(k);
+    ARM_COMPUTE_UNUSED(b);
+
+    GEMMLHSMatrixInfo lhs_info;
+    GEMMRHSMatrixInfo rhs_info;
+
+    if(n <= 4)
+    {
+        // Configure GEMMLHSMatrixInfo
+        lhs_info.m0         = 4;
+        lhs_info.k0         = 8;
+        lhs_info.v0         = lhs_info.m0 * 16 < m ? 2 : 16;
+        lhs_info.interleave = true;
+        lhs_info.transpose  = false;
+
+        // Configure GEMMRHSMatrixInfo
+        rhs_info.n0         = 2;
+        rhs_info.k0         = lhs_info.k0;
+        rhs_info.h0         = rhs_info.n0 * 16 < n ? 2 : 16;
+        rhs_info.interleave = false;
+        rhs_info.transpose  = true;
+    }
+    else
+    {
+        // Configure GEMMLHSMatrixInfo
+        lhs_info.m0         = 5;
+        lhs_info.k0         = 4;
+        lhs_info.v0         = lhs_info.m0 * 2 < m ? 1 : 2;
+        lhs_info.interleave = false;
+        lhs_info.transpose  = false;
+
+        // Configure GEMMRHSMatrixInfo
+        rhs_info.n0         = 4;
+        rhs_info.k0         = lhs_info.k0;
+        rhs_info.h0         = rhs_info.n0 * 16 < n ? 2 : 16;
+        rhs_info.interleave = true;
+        rhs_info.transpose  = true;
+    }
+
+    return std::make_pair(lhs_info, rhs_info);
+}
+
+std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMReshapedConfigurationBifrost::configure_G76_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b)
+{
+    ARM_COMPUTE_UNUSED(k);
+    ARM_COMPUTE_UNUSED(b);
+
+    GEMMLHSMatrixInfo lhs_info;
+    GEMMRHSMatrixInfo rhs_info;
+
+    if(n <= 4)
+    {
+        // Configure GEMMLHSMatrixInfo
+        lhs_info.m0         = 4;
+        lhs_info.k0         = 8;
+        lhs_info.v0         = lhs_info.m0 * 16 < m ? 2 : 16;
+        lhs_info.interleave = true;
+        lhs_info.transpose  = false;
+
+        // Configure GEMMRHSMatrixInfo
+        rhs_info.n0         = 2;
+        rhs_info.k0         = lhs_info.k0;
+        rhs_info.h0         = rhs_info.n0 * 16 < n ? 2 : 16;
+        rhs_info.interleave = false;
+        rhs_info.transpose  = true;
+    }
+    else
+    {
+        // Configure GEMMLHSMatrixInfo
+        lhs_info.m0         = 4;
+        lhs_info.k0         = 2;
+        lhs_info.v0         = lhs_info.m0 * 8 < m ? 2 : 8;
+        lhs_info.interleave = false;
+        lhs_info.transpose  = false;
+
+        // Configure GEMMRHSMatrixInfo
+        rhs_info.n0         = 4;
+        rhs_info.k0         = lhs_info.k0;
+        rhs_info.h0         = rhs_info.n0 * 16 < n ? 2 : 16;
+        rhs_info.interleave = false;
+        rhs_info.transpose  = true;
+    }
+
+    return std::make_pair(lhs_info, rhs_info);
+}
+} // namespace cl_gemm
+} // namespace arm_compute
\ No newline at end of file