blob: 0c09f5084afa9cf4ca33ceb0367a3a8cafa8351f [file] [log] [blame]
Gian Marco Iodice12f2b8c2020-02-13 12:27:37 +00001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2020 Arm Limited.
Gian Marco Iodice12f2b8c2020-02-13 12:27:37 +00003 *
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 },
Gian Marco Iodiceeb65f6d2020-04-15 11:42:15 +010052 { DataType::QASYMM8, &CLGEMMReshapedKernelConfigurationValhall::configure_G77_u8 },
53 { DataType::QSYMM8, &CLGEMMReshapedKernelConfigurationValhall::configure_G77_u8 },
54 { DataType::QASYMM8_SIGNED, &CLGEMMReshapedKernelConfigurationValhall::configure_G77_u8 },
55 { DataType::QSYMM8_PER_CHANNEL, &CLGEMMReshapedKernelConfigurationValhall::configure_G77_u8 }
Gian Marco Iodice12f2b8c2020-02-13 12:27:37 +000056 };
57
58 switch(_target)
59 {
60 case GPUTarget::G77:
61 default:
62 if(gemm_configs_G77.find(data_type) != gemm_configs_G77.end())
63 {
64 return (this->*gemm_configs_G77[data_type])(m, n, k, b);
65 }
66 else
67 {
68 ARM_COMPUTE_ERROR("Not supported data type");
69 }
70 }
71}
72
73std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMReshapedKernelConfigurationValhall::configure_G77_f32(unsigned int m, unsigned int n, unsigned int k, unsigned int b)
74{
75 ARM_COMPUTE_UNUSED(k);
76 ARM_COMPUTE_UNUSED(b);
77
78 if(n <= 4)
79 {
80 return configure_lhs_rhs_info(m, n, 4, 2, 8, 16, 16, true, false, false, true);
81 }
82 else
83 {
84 return configure_lhs_rhs_info(m, n, 5, 4, 4, 2, 16, false, true, false, true);
85 }
86}
87
88std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMReshapedKernelConfigurationValhall::configure_G77_f16(unsigned int m, unsigned int n, unsigned int k, unsigned int b)
89{
90 ARM_COMPUTE_UNUSED(k);
91 ARM_COMPUTE_UNUSED(b);
92
93 if(n <= 4)
94 {
95 return configure_lhs_rhs_info(m, n, 4, 2, 8, 8, 2, true, true, true, false);
96 }
97 else
98 {
99 return configure_lhs_rhs_info(m, n, 4, 8, 4, 4, 2, true, true, true, false);
100 }
101}
102
103std::pair<GEMMLHSMatrixInfo, GEMMRHSMatrixInfo> CLGEMMReshapedKernelConfigurationValhall::configure_G77_u8(unsigned int m, unsigned int n, unsigned int k, unsigned int b)
104{
105 ARM_COMPUTE_UNUSED(k);
106 ARM_COMPUTE_UNUSED(b);
107
108 if(n <= 4)
109 {
110 return configure_lhs_rhs_info(m, n, 4, 2, 16, 4, 1, false, false, false, true);
111 }
112 else
113 {
114 return configure_lhs_rhs_info(m, n, 4, 4, 16, 2, 2, false, true, false, true);
115 }
116}
117} // namespace cl_gemm
118} // namespace arm_compute