1"""Generates the meta gemm/gemv library header.""" 2 3import cc_emitter 4import gemm_NxMxK_neon 5import gemv_1xMxK_neon 6import mul_1x8_Mx8_neon 7import mul_Nx8_Mx8_neon 8import neon_emitter 9import qnt_Nx8_neon 10import zip_Nx8_neon 11 12_HEADER_COPYRIGHT = """// Copyright 2015 Google Inc. All Rights Reserved. 13// 14// Licensed under the Apache License, Version 2.0 (the "License"); 15// you may not use this file except in compliance with the License. 16// You may obtain a copy of the License at 17// 18// http://www.apache.org/licenses/LICENSE-2.0 19// 20// Unless required by applicable law or agreed to in writing, software 21// distributed under the License is distributed on an "AS IS" BASIS, 22// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23// See the License for the specific language governing permissions and 24// limitations under the License. 25// 26// single_thread_gemm.h: programatically generated GEMM library header. 27""" 28 29 30def GenerateInternalFunctions(emitter): 31 """Generate all the functions hidden in the internal namespace.""" 32 zip_Nx8_neon.GenerateFunctions(neon_emitter.NeonEmitter()) 33 emitter.EmitNewline() 34 35 mul_Nx8_Mx8_neon.GenerateFunctions(neon_emitter.NeonEmitter(), 'int32', False, 36 True) 37 emitter.EmitNewline() 38 39 mul_Nx8_Mx8_neon.GenerateFunctions(neon_emitter.NeonEmitter(), 'int32', True, 40 True) 41 emitter.EmitNewline() 42 43 mul_Nx8_Mx8_neon.GenerateFunctions(neon_emitter.NeonEmitter(), 'float', True, 44 True) 45 emitter.EmitNewline() 46 47 mul_1x8_Mx8_neon.GenerateFunctions(neon_emitter.NeonEmitter(), 'int32', False, 48 True) 49 emitter.EmitNewline() 50 51 mul_1x8_Mx8_neon.GenerateFunctions(neon_emitter.NeonEmitter(), 'int32', True, 52 True) 53 emitter.EmitNewline() 54 55 mul_1x8_Mx8_neon.GenerateFunctions(neon_emitter.NeonEmitter(), 'float', True, 56 True) 57 emitter.EmitNewline() 58 59 qnt_Nx8_neon.GenerateFunctions(neon_emitter.NeonEmitter(), emitter) 60 emitter.EmitNewline() 61 62 gemm_NxMxK_neon.GenerateInternalFunctions(emitter) 63 emitter.EmitNewline() 64 65 gemv_1xMxK_neon.GenerateInternalFunctions(emitter) 66 emitter.EmitNewline() 67 68 69def GeneratePublicFunctions(emitter): 70 gemm_NxMxK_neon.GeneratePublicFunctions(emitter) 71 emitter.EmitNewline() 72 73 gemv_1xMxK_neon.GeneratePublicFunctions(emitter) 74 emitter.EmitNewline() 75 76 77def Main(): 78 """Generate the single threaded meta gemm library.""" 79 emitter = cc_emitter.CCEmitter() 80 81 emitter.EmitCodeNoSemicolon(_HEADER_COPYRIGHT) 82 emitter.EmitHeaderBegin('gemmlowp_meta_single_thread_gemm') 83 84 emitter.EmitPreprocessor1('ifdef', 'GEMMLOWP_NEON_32') 85 emitter.EmitNewline() 86 87 emitter.EmitInclude('<cassert>') 88 emitter.EmitNewline() 89 90 emitter.EmitNamespaceBegin('gemmlowp') 91 emitter.EmitNamespaceBegin('meta') 92 emitter.EmitNamespaceBegin('internal') 93 emitter.EmitNewline() 94 95 GenerateInternalFunctions(emitter) 96 97 emitter.EmitNamespaceEnd() 98 emitter.EmitNewline() 99 100 GeneratePublicFunctions(emitter) 101 102 emitter.EmitNamespaceEnd() 103 emitter.EmitNamespaceEnd() 104 emitter.EmitNewline() 105 106 emitter.EmitPreprocessor('else') 107 emitter.EmitPreprocessor1('warning', 108 '"Meta gemm fast-path requires GEMMLOWP_NEON_32!"') 109 emitter.EmitPreprocessor('endif') 110 emitter.EmitNewline() 111 112 emitter.EmitHeaderEnd() 113 114 115if __name__ == '__main__': 116 Main() 117