blob: 20fa3d65bff7f460a1f81895d0c37579af0aeca1 [file] [log] [blame]
Gian Marco Iodice12f2b8c2020-02-13 12:27:37 +00001/*
2 * Copyright (c) 2020 ARM Limited.
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 */
24#include "arm_compute/core/CL/gemm/reshaped/CLGEMMReshapedKernelConfigurationValhall.h"
25
26#include "arm_compute/core/CL/CLHelpers.h"
27#include "arm_compute/core/CL/CLKernelLibrary.h"
28#include "arm_compute/core/CL/gemm/CLGEMMHelpers.h"
29#include "arm_compute/core/GPUTarget.h"
30
31#include <map>
32#include <utility>
33
34namespace arm_compute
35{
36namespace cl_gemm
37{
38CLGEMMReshapedKernelConfigurationValhall::CLGEMMReshapedKernelConfigurationValhall(GPUTarget gpu)
39 : ICLGEMMKernelConfiguration(gpu)
40{
41}
42
43std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMReshapedKernelConfigurationValhall::configure(unsigned int m, unsigned int n, unsigned int k, unsigned int b, DataType data_type)
44{
45 using ConfigurationFunctionExecutorPtr = std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> (CLGEMMReshapedKernelConfigurationValhall::*)(unsigned int m, unsigned int n, unsigned int k, unsigned int b);
46
47 // Configurations for Mali-G77
48 static std::map<DataType, ConfigurationFunctionExecutorPtr> gemm_configs_G77 =
49 {
50 { DataType::F32, &CLGEMMReshapedKernelConfigurationValhall::configure_G77_f32 },
51 { DataType::F16, &CLGEMMReshapedKernelConfigurationValhall::configure_G77_f16 },
52 { DataType::QASYMM8, &CLGEMMReshapedKernelConfigurationValhall::configure_G77_u8 }
53 };
54
55 switch(_target)
56 {
57 case GPUTarget::G77:
58 default:
59 if(gemm_configs_G77.find(data_type) != gemm_configs_G77.end())
60 {
61 return (this->*gemm_configs_G77[data_type])(m, n, k, b);
62 }
63 else
64 {
65 ARM_COMPUTE_ERROR("Not supported data type");
66 }
67 }
68}
69
70std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMReshapedKernelConfigurationValhall::configure_G77_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b)
71{
72 ARM_COMPUTE_UNUSED(k);
73 ARM_COMPUTE_UNUSED(b);
74
75 if(n <= 4)
76 {
77 return configure_lhs_rhs_info(m, n, 4, 2, 8, 16, 16, true, false, false, true);
78 }
79 else
80 {
81 return configure_lhs_rhs_info(m, n, 5, 4, 4, 2, 16, false, true, false, true);
82 }
83}
84
85std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMReshapedKernelConfigurationValhall::configure_G77_f16(unsigned int m, unsigned int n, unsigned int k, unsigned int b)
86{
87 ARM_COMPUTE_UNUSED(k);
88 ARM_COMPUTE_UNUSED(b);
89
90 if(n <= 4)
91 {
92 return configure_lhs_rhs_info(m, n, 4, 2, 8, 8, 2, true, true, true, false);
93 }
94 else
95 {
96 return configure_lhs_rhs_info(m, n, 4, 8, 4, 4, 2, true, true, true, false);
97 }
98}
99
100std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMReshapedKernelConfigurationValhall::configure_G77_u8(unsigned int m, unsigned int n, unsigned int k, unsigned int b)
101{
102 ARM_COMPUTE_UNUSED(k);
103 ARM_COMPUTE_UNUSED(b);
104
105 if(n <= 4)
106 {
107 return configure_lhs_rhs_info(m, n, 4, 2, 16, 4, 1, false, false, false, true);
108 }
109 else
110 {
111 return configure_lhs_rhs_info(m, n, 4, 4, 16, 2, 2, false, true, false, true);
112 }
113}
114} // namespace cl_gemm
115} // namespace arm_compute