1 /* 2 * Copyright (c) 2017-2022 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 #pragma once 25 26 #ifdef __aarch64__ 27 28 #include "../performance_parameters.hpp" 29 #include "../std_transforms_fixed.hpp" 30 31 namespace arm_gemm { 32 33 // Kernel definition 34 void a64_gemm_u8_4x4(const uint8_t *Apanel, const uint8_t *Bpanel, uint32_t *Cpanel, int ablocks, int bblocks, int K); 35 36 class cls_a64_gemm_u8_4x4 { 37 public: 38 typedef uint8_t operand_type; 39 typedef uint32_t result_type; 40 41 typedef void (*kern_type)(const uint8_t *, const uint8_t *, uint32_t *, int, int, int); 42 43 /* Describes the data layout for A input */ 44 static const int A_interleave = 4; 45 static const int A_block = 16; 46 static const bool A_transpose = false; 47 48 /* Same for B input */ 49 static const int B_interleave = 4; 50 static const int B_block = 16; 51 static const bool B_transpose = true; 52 53 /* Kernel blocking parameters */ out_width()54 static unsigned int out_width() { 55 return 4; 56 } 57 out_height()58 static unsigned int out_height() { 59 return 4; 60 } 61 k_unroll()62 static unsigned int k_unroll() { 63 return 16; 64 } 65 66 // Use the standard fixed size transforms. 67 StdTransformsFixed<operand_type, result_type, 4, 4, 16> transforms = {}; 68 StdTransformsFixed<operand_type, result_type, 4, 4, 16, true> transforms_quantized = {}; 69 70 template<typename T> get_performance_parameters(const CPUInfo * ci)71 static PerformanceParameters get_performance_parameters(const CPUInfo *ci) { 72 if (std::is_same<T, uint32_t>::value) { 73 switch (ci->get_cpu_model()) { 74 case CPUModel::A55r0: 75 case CPUModel::A55r1: 76 return { 2.25, 2.92, 1.84 }; 77 case CPUModel::A510: 78 return { 2.64, 2.72, 2.64 }; 79 default: 80 return { 7.95, 3.76, 7.27 }; 81 } 82 } 83 84 if (std::is_same<T, uint8_t>::value) { 85 switch(ci->get_cpu_model()) { 86 case CPUModel::A55r0: 87 case CPUModel::A55r1: 88 return { 2.25, 2.18, 0.09 }; 89 case CPUModel::A510: 90 return { 2.64, 1.79, 0.10 }; 91 default: 92 return { 7.95, 4.09, 0.33 }; 93 } 94 } 95 96 return { 0.0 }; 97 } 98 99 kern_type kernel = a64_gemm_u8_4x4; 100 cls_a64_gemm_u8_4x4(const CPUInfo *)101 cls_a64_gemm_u8_4x4(const CPUInfo *) { } 102 }; 103 104 } // namespace arm_gemm 105 106 #endif // __aarch64__ 107