blob: 09ac08c0a4f740da2c00b9a8334287a944a07f56 [file] [log] [blame]
Anthony Barbierac314c22018-09-11 17:49:10 +01001/*
2 * Copyright (c) 2018 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
25#include "arm_compute/core/NEON/kernels/assembly/Helpers.h"
26
27#include "NEGEMMInterleavedStrategies.h"
28
29namespace arm_compute
30{
31namespace
32{
33template <typename InputType, bool use_dot = false>
34BlockSizes calculate_block_sizes_template(const CPUInfo &ci, unsigned int M, unsigned int N, unsigned int K)
35{
36 using strategy = typename Kernel<InputType, use_dot>::strategy;
37 return calculate_block_sizes<strategy>(ci, M, N, K);
38}
39} // namespace
40
41const char *get_strategy_name(DataType input_type, bool use_dot)
42{
43 switch(input_type)
44 {
45 case DataType::F32:
46 return Kernel<float>::name;
47#ifdef __aarch64__
48 case DataType::U8:
49 case DataType::QASYMM8:
50 if(use_dot)
51 {
52 return Kernel<uint8_t, true>::name;
53 }
54 else
55 {
56 return Kernel<uint8_t, false>::name;
57 }
58 case DataType::S8:
59 if(use_dot)
60 {
61 return Kernel<int8_t, true>::name;
62 }
63 else
64 {
65 return Kernel<int8_t, false>::name;
66 }
67#endif /* __aarch64__ */
68#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
69 case DataType::F16:
70 return Kernel<__fp16>::name;
71#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
72 default:
73 ARM_COMPUTE_ERROR("DataType not supported");
74 break;
75 }
76}
77
78BlockSizes calculate_block_sizes_from_data_type(const CPUInfo &ci, unsigned int M, unsigned int N, unsigned int K, DataType input_type, bool use_dot)
79{
80 switch(input_type)
81 {
82 case DataType::F32:
83 return calculate_block_sizes_template<float>(ci, M, N, K);
84#ifdef __aarch64__
85 case DataType::U8:
86 case DataType::QASYMM8:
87 if(use_dot)
88 {
89 return calculate_block_sizes_template<uint8_t, true>(ci, M, N, K);
90 }
91 else
92 {
93 return calculate_block_sizes_template<uint8_t, false>(ci, M, N, K);
94 }
95 case DataType::S8:
96 if(use_dot)
97 {
98 return calculate_block_sizes_template<int8_t, true>(ci, M, N, K);
99 }
100 else
101 {
102 return calculate_block_sizes_template<int8_t, false>(ci, M, N, K);
103 }
104#endif /* __aarch64__ */
105#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
106 case DataType::F16:
107 return calculate_block_sizes_template<__fp16>(ci, M, N, K);
108#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
109 default:
110 ARM_COMPUTE_ERROR("DataType not supported");
111 break;
112 }
113}
114} // namespace arm_compute