Jenkins | 18b685f | 2020-08-21 10:26:22 +0100 | [diff] [blame] | 1 | # Copyright (c) 2016, 2017 Arm Limited. |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 2 | # |
| 3 | # SPDX-License-Identifier: MIT |
| 4 | # |
| 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | # of this software and associated documentation files (the "Software"), to |
| 7 | # deal in the Software without restriction, including without limitation the |
| 8 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 9 | # sell copies of the Software, and to permit persons to whom the Software is |
| 10 | # furnished to do so, subject to the following conditions: |
| 11 | # |
| 12 | # The above copyright notice and this permission notice shall be included in all |
| 13 | # copies or substantial portions of the Software. |
| 14 | # |
| 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 | # SOFTWARE. |
| 22 | import collections |
| 23 | import os.path |
| 24 | import re |
| 25 | import subprocess |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 26 | import zlib |
| 27 | import base64 |
| 28 | import string |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 29 | |
Jenkins | f7399fd | 2021-05-18 15:04:27 +0100 | [diff] [blame^] | 30 | VERSION = "v21.05" |
| 31 | LIBRARY_VERSION_MAJOR = 23 |
Jenkins | 18b685f | 2020-08-21 10:26:22 +0100 | [diff] [blame] | 32 | LIBRARY_VERSION_MINOR = 0 |
Jenkins | 6a7771e | 2020-05-28 11:28:36 +0100 | [diff] [blame] | 33 | LIBRARY_VERSION_PATCH = 0 |
| 34 | SONAME_VERSION = str(LIBRARY_VERSION_MAJOR) + "." + str(LIBRARY_VERSION_MINOR) + "." + str(LIBRARY_VERSION_PATCH) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 35 | |
| 36 | Import('env') |
| 37 | Import('vars') |
Jenkins | b9abeae | 2018-11-22 11:58:08 +0000 | [diff] [blame] | 38 | Import('install_lib') |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 39 | |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 40 | def build_bootcode_objs(sources): |
| 41 | |
| 42 | arm_compute_env.Append(ASFLAGS = "-I bootcode/") |
| 43 | obj = arm_compute_env.Object(sources) |
| 44 | obj = install_lib(obj) |
| 45 | Default(obj) |
| 46 | return obj |
| 47 | |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 48 | def build_library(name, build_env, sources, static=False, libs=[]): |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 49 | if static: |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 50 | obj = build_env.StaticLibrary(name, source=sources, LIBS = arm_compute_env["LIBS"] + libs) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 51 | else: |
| 52 | if env['set_soname']: |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 53 | obj = build_env.SharedLibrary(name, source=sources, SHLIBVERSION = SONAME_VERSION, LIBS = arm_compute_env["LIBS"] + libs) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 54 | else: |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 55 | obj = build_env.SharedLibrary(name, source=sources, LIBS = arm_compute_env["LIBS"] + libs) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 56 | |
Jenkins | b9abeae | 2018-11-22 11:58:08 +0000 | [diff] [blame] | 57 | obj = install_lib(obj) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 58 | Default(obj) |
| 59 | return obj |
| 60 | |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 61 | def remove_incode_comments(code): |
| 62 | def replace_with_empty(match): |
| 63 | s = match.group(0) |
| 64 | if s.startswith('/'): |
| 65 | return " " |
| 66 | else: |
| 67 | return s |
| 68 | |
| 69 | comment_regex = re.compile(r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"', re.DOTALL | re.MULTILINE) |
| 70 | return re.sub(comment_regex, replace_with_empty, code) |
| 71 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 72 | def resolve_includes(target, source, env): |
| 73 | # File collection |
| 74 | FileEntry = collections.namedtuple('FileEntry', 'target_name file_contents') |
| 75 | |
| 76 | # Include pattern |
| 77 | pattern = re.compile("#include \"(.*)\"") |
| 78 | |
| 79 | # Get file contents |
| 80 | files = [] |
| 81 | for i in range(len(source)): |
| 82 | src = source[i] |
| 83 | dst = target[i] |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 84 | contents = src.get_contents().decode('utf-8') |
| 85 | contents = remove_incode_comments(contents).splitlines() |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 86 | entry = FileEntry(target_name=dst, file_contents=contents) |
| 87 | files.append((os.path.basename(src.get_path()),entry)) |
| 88 | |
| 89 | # Create dictionary of tupled list |
| 90 | files_dict = dict(files) |
| 91 | |
| 92 | # Check for includes (can only be files in the same folder) |
| 93 | final_files = [] |
| 94 | for file in files: |
| 95 | done = False |
| 96 | tmp_file = file[1].file_contents |
| 97 | while not done: |
| 98 | file_count = 0 |
| 99 | updated_file = [] |
| 100 | for line in tmp_file: |
| 101 | found = pattern.search(line) |
| 102 | if found: |
| 103 | include_file = found.group(1) |
| 104 | data = files_dict[include_file].file_contents |
| 105 | updated_file.extend(data) |
| 106 | else: |
| 107 | updated_file.append(line) |
| 108 | file_count += 1 |
| 109 | |
| 110 | # Check if all include are replaced. |
| 111 | if file_count == len(tmp_file): |
| 112 | done = True |
| 113 | |
| 114 | # Update temp file |
| 115 | tmp_file = updated_file |
| 116 | |
| 117 | # Append and prepend string literal identifiers and add expanded file to final list |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 118 | entry = FileEntry(target_name=file[1].target_name, file_contents=tmp_file) |
| 119 | final_files.append((file[0], entry)) |
| 120 | |
| 121 | # Write output files |
| 122 | for file in final_files: |
| 123 | with open(file[1].target_name.get_path(), 'w+') as out_file: |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 124 | file_to_write = "\n".join( file[1].file_contents ) |
| 125 | if env['compress_kernels']: |
| 126 | file_to_write = zlib.compress(file_to_write, 9).encode("base64").replace("\n", "") |
| 127 | file_to_write = "R\"(" + file_to_write + ")\"" |
| 128 | out_file.write(file_to_write) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 129 | |
| 130 | def create_version_file(target, source, env): |
| 131 | # Generate string with build options library version to embed in the library: |
| 132 | try: |
| 133 | git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]) |
| 134 | except (OSError, subprocess.CalledProcessError): |
| 135 | git_hash="unknown" |
| 136 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 137 | build_info = "\"arm_compute_version=%s Build options: %s Git hash=%s\"" % (VERSION, vars.args, git_hash.strip()) |
| 138 | with open(target[0].get_path(), "w") as fd: |
| 139 | fd.write(build_info) |
| 140 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 141 | arm_compute_env = env.Clone() |
Jenkins | 52ba29e | 2018-08-29 15:32:11 +0000 | [diff] [blame] | 142 | version_file = arm_compute_env.Command("src/core/arm_compute_version.embed", "", action=create_version_file) |
| 143 | arm_compute_env.AlwaysBuild(version_file) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 144 | |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 145 | default_cpp_compiler = 'g++' if env['os'] not in ['android', 'macos'] else 'clang++' |
| 146 | cpp_compiler = os.environ.get('CXX', default_cpp_compiler) |
| 147 | |
Anthony Barbier | 06ea048 | 2018-02-22 15:45:35 +0000 | [diff] [blame] | 148 | # Generate embed files |
Jenkins | 52ba29e | 2018-08-29 15:32:11 +0000 | [diff] [blame] | 149 | generate_embed = [ version_file ] |
Anthony Barbier | 06ea048 | 2018-02-22 15:45:35 +0000 | [diff] [blame] | 150 | if env['opencl'] and env['embed_kernels']: |
| 151 | cl_files = Glob('src/core/CL/cl_kernels/*.cl') |
| 152 | cl_files += Glob('src/core/CL/cl_kernels/*.h') |
| 153 | |
| 154 | embed_files = [ f.get_path()+"embed" for f in cl_files ] |
| 155 | arm_compute_env.Append(CPPPATH =[Dir("./src/core/CL/").path] ) |
| 156 | |
| 157 | generate_embed.append(arm_compute_env.Command(embed_files, cl_files, action=resolve_includes)) |
| 158 | |
Anthony Barbier | 06ea048 | 2018-02-22 15:45:35 +0000 | [diff] [blame] | 159 | Default(generate_embed) |
| 160 | if env["build"] == "embed_only": |
| 161 | Return() |
| 162 | |
Jenkins | 6a7771e | 2020-05-28 11:28:36 +0100 | [diff] [blame] | 163 | # Append version defines for semantic versioning |
| 164 | arm_compute_env.Append(CPPDEFINES = [('ARM_COMPUTE_VERSION_MAJOR', LIBRARY_VERSION_MAJOR), |
| 165 | ('ARM_COMPUTE_VERSION_MINOR', LIBRARY_VERSION_MINOR), |
| 166 | ('ARM_COMPUTE_VERSION_PATCH', LIBRARY_VERSION_PATCH)]) |
| 167 | |
Anthony Barbier | 06ea048 | 2018-02-22 15:45:35 +0000 | [diff] [blame] | 168 | # Don't allow undefined references in the libraries: |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 169 | undefined_flag = '-Wl,-undefined,error' if 'macos' in arm_compute_env["os"] else '-Wl,--no-undefined' |
| 170 | arm_compute_env.Append(LINKFLAGS=[undefined_flag]) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 171 | arm_compute_env.Append(CPPPATH =[Dir("./src/core/").path] ) |
| 172 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 173 | arm_compute_env.Append(LIBS = ['dl']) |
| 174 | |
| 175 | core_files = Glob('src/core/*.cpp') |
| 176 | core_files += Glob('src/core/CPP/*.cpp') |
| 177 | core_files += Glob('src/core/CPP/kernels/*.cpp') |
Jenkins | 49b8f90 | 2020-11-27 12:49:11 +0000 | [diff] [blame] | 178 | core_files += Glob('src/core/helpers/*.cpp') |
Jenkins | 18b685f | 2020-08-21 10:26:22 +0100 | [diff] [blame] | 179 | core_files += Glob('src/core/utils/*.cpp') |
Jenkins | 514be65 | 2019-02-28 12:25:18 +0000 | [diff] [blame] | 180 | core_files += Glob('src/core/utils/helpers/*.cpp') |
| 181 | core_files += Glob('src/core/utils/io/*.cpp') |
| 182 | core_files += Glob('src/core/utils/quantization/*.cpp') |
Jenkins | 975dfe1 | 2019-09-02 11:47:54 +0100 | [diff] [blame] | 183 | core_files += Glob('src/core/utils/misc/*.cpp') |
Jenkins | 514be65 | 2019-02-28 12:25:18 +0000 | [diff] [blame] | 184 | if env["logging"]: |
| 185 | core_files += Glob('src/core/utils/logging/*.cpp') |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 186 | |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 187 | runtime_files = Glob('src/runtime/*.cpp') |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame] | 188 | runtime_files += Glob('src/runtime/CPP/ICPPSimpleFunction.cpp') |
| 189 | runtime_files += Glob('src/runtime/CPP/functions/*.cpp') |
| 190 | |
Jenkins | f7399fd | 2021-05-18 15:04:27 +0100 | [diff] [blame^] | 191 | # C API files |
| 192 | c_api_files = ['src/c/AclContext.cpp', |
| 193 | 'src/c/AclQueue.cpp', |
| 194 | 'src/c/AclTensor.cpp', |
| 195 | 'src/c/AclTensorPack.cpp', |
| 196 | 'src/c/AclVersion.cpp', |
| 197 | ] |
| 198 | if env['opencl']: |
| 199 | c_api_files += ['src/c/cl/AclOpenClExt.cpp'] |
| 200 | |
| 201 | # Common backend files |
| 202 | common_backend_files = ['src/common/utils/LegacySupport.cpp', |
| 203 | 'src/common/AllocatorWrapper.cpp', |
| 204 | 'src/common/ITensorV2.cpp', |
| 205 | 'src/common/TensorPack.cpp', |
| 206 | ] |
| 207 | |
| 208 | core_files += common_backend_files |
| 209 | runtime_files += c_api_files |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 210 | # CLHarrisCorners uses the Scheduler to run CPP kernels |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 211 | runtime_files += Glob('src/runtime/CPP/SingleThreadScheduler.cpp') |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 212 | |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 213 | graph_files = Glob('src/graph/*.cpp') |
| 214 | graph_files += Glob('src/graph/*/*.cpp') |
| 215 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 216 | if env['cppthreads']: |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 217 | runtime_files += Glob('src/runtime/CPP/CPPScheduler.cpp') |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 218 | |
| 219 | if env['openmp']: |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 220 | runtime_files += Glob('src/runtime/OMP/OMPScheduler.cpp') |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 221 | |
| 222 | if env['opencl']: |
| 223 | core_files += Glob('src/core/CL/*.cpp') |
| 224 | core_files += Glob('src/core/CL/kernels/*.cpp') |
Jenkins | 4ba87db | 2019-05-23 17:11:51 +0100 | [diff] [blame] | 225 | core_files += Glob('src/core/CL/gemm/*.cpp') |
Jenkins | 975dfe1 | 2019-09-02 11:47:54 +0100 | [diff] [blame] | 226 | core_files += Glob('src/core/CL/gemm/native/*.cpp') |
Jenkins | 4ba87db | 2019-05-23 17:11:51 +0100 | [diff] [blame] | 227 | core_files += Glob('src/core/CL/gemm/reshaped/*.cpp') |
| 228 | core_files += Glob('src/core/CL/gemm/reshaped_only_rhs/*.cpp') |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 229 | core_files += Glob('src/core/gpu/cl/*.cpp') |
| 230 | core_files += Glob('src/core/gpu/cl/kernels/*.cpp') |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 231 | |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 232 | runtime_files += Glob('src/runtime/CL/*.cpp') |
| 233 | runtime_files += Glob('src/runtime/CL/functions/*.cpp') |
Jenkins | 6a7771e | 2020-05-28 11:28:36 +0100 | [diff] [blame] | 234 | runtime_files += Glob('src/runtime/CL/gemm/*.cpp') |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 235 | runtime_files += Glob('src/runtime/CL/tuners/*.cpp') |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 236 | runtime_files += Glob('src/runtime/gpu/cl/*.cpp') |
| 237 | runtime_files += Glob('src/runtime/gpu/cl/operators/*.cpp') |
| 238 | runtime_files += Glob('src/runtime/CL/mlgo/*.cpp') |
| 239 | runtime_files += Glob('src/runtime/CL/gemm_auto_heuristics/*.cpp') |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 240 | |
Jenkins | f7399fd | 2021-05-18 15:04:27 +0100 | [diff] [blame^] | 241 | runtime_files += Glob('src/gpu/cl/*.cpp') |
| 242 | |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 243 | graph_files += Glob('src/graph/backends/CL/*.cpp') |
| 244 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 245 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 246 | if env['neon']: |
| 247 | core_files += Glob('src/core/NEON/*.cpp') |
| 248 | core_files += Glob('src/core/NEON/kernels/*.cpp') |
Jenkins | 52ba29e | 2018-08-29 15:32:11 +0000 | [diff] [blame] | 249 | core_files += Glob('src/core/NEON/kernels/assembly/*.cpp') |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 250 | |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 251 | core_files += Glob('src/core/NEON/kernels/arm_gemm/*.cpp') |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 252 | core_files += Glob('src/core/NEON/kernels/arm_conv/*.cpp') |
| 253 | core_files += Glob('src/core/NEON/kernels/arm_conv/pooling/*.cpp') |
| 254 | core_files += Glob('src/core/NEON/kernels/arm_conv/pooling/kernels/cpp_*/*.cpp') |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 255 | |
Jenkins | 975dfe1 | 2019-09-02 11:47:54 +0100 | [diff] [blame] | 256 | # build winograd/depthwise sources for either v7a / v8a |
Anthony Barbier | 06ea048 | 2018-02-22 15:45:35 +0000 | [diff] [blame] | 257 | core_files += Glob('src/core/NEON/kernels/convolution/*/*.cpp') |
| 258 | core_files += Glob('src/core/NEON/kernels/convolution/winograd/*/*.cpp') |
Jenkins | 49b8f90 | 2020-11-27 12:49:11 +0000 | [diff] [blame] | 259 | arm_compute_env.Append(CPPPATH = ["src/core/NEON/kernels/convolution/common/", |
Jenkins | 18b685f | 2020-08-21 10:26:22 +0100 | [diff] [blame] | 260 | "src/core/NEON/kernels/convolution/winograd/", |
Jenkins | 49b8f90 | 2020-11-27 12:49:11 +0000 | [diff] [blame] | 261 | "src/core/NEON/kernels/convolution/depthwise/", |
| 262 | "src/core/NEON/kernels/assembly/", |
Jenkins | 975dfe1 | 2019-09-02 11:47:54 +0100 | [diff] [blame] | 263 | "arm_compute/core/NEON/kernels/assembly/"]) |
Anthony Barbier | f45d5a9 | 2018-01-24 16:23:15 +0000 | [diff] [blame] | 264 | |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 265 | graph_files += Glob('src/graph/backends/NEON/*.cpp') |
| 266 | |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 267 | if env['estate'] == '32': |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 268 | core_files += Glob('src/core/NEON/kernels/arm_gemm/kernels/a32_*/*.cpp') |
| 269 | |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 270 | if env['estate'] == '64': |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 271 | core_files += Glob('src/core/NEON/kernels/arm_gemm/kernels/a64_*/*.cpp') |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 272 | core_files += Glob('src/core/NEON/kernels/arm_conv/pooling/kernels/a64_*/*.cpp') |
Jenkins | b9abeae | 2018-11-22 11:58:08 +0000 | [diff] [blame] | 273 | if "sve" in env['arch']: |
| 274 | core_files += Glob('src/core/NEON/kernels/arm_gemm/kernels/sve_*/*.cpp') |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 275 | core_files += Glob('src/core/NEON/kernels/arm_conv/pooling/kernels/sve_*/*.cpp') |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 276 | |
Jenkins | 49b8f90 | 2020-11-27 12:49:11 +0000 | [diff] [blame] | 277 | if any(i in env['data_type_support'] for i in ['all', 'fp16']): |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 278 | core_files += Glob('src/core/NEON/kernels/*/impl/*/fp16.cpp') |
Jenkins | 49b8f90 | 2020-11-27 12:49:11 +0000 | [diff] [blame] | 279 | if any(i in env['data_type_support'] for i in ['all', 'fp32']): |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 280 | core_files += Glob('src/core/NEON/kernels/*/impl/*/fp32.cpp') |
Jenkins | 49b8f90 | 2020-11-27 12:49:11 +0000 | [diff] [blame] | 281 | if any(i in env['data_type_support'] for i in ['all', 'qasymm8']): |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 282 | core_files += Glob('src/core/NEON/kernels/*/impl/*/qasymm8.cpp') |
Jenkins | 49b8f90 | 2020-11-27 12:49:11 +0000 | [diff] [blame] | 283 | if any(i in env['data_type_support'] for i in ['all', 'qasymm8_signed']): |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 284 | core_files += Glob('src/core/NEON/kernels/*/impl/*/qasymm8_signed.cpp') |
Jenkins | 49b8f90 | 2020-11-27 12:49:11 +0000 | [diff] [blame] | 285 | if any(i in env['data_type_support'] for i in ['all', 'qsymm16']): |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 286 | core_files += Glob('src/core/NEON/kernels/*/impl/*/qsymm16.cpp') |
| 287 | if any(i in env['data_type_support'] for i in ['all', 'integer']): |
| 288 | core_files += Glob('src/core/NEON/kernels/*/impl/*/integer.cpp') |
Jenkins | 49b8f90 | 2020-11-27 12:49:11 +0000 | [diff] [blame] | 289 | |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 290 | runtime_files += Glob('src/runtime/NEON/*.cpp') |
| 291 | runtime_files += Glob('src/runtime/NEON/functions/*.cpp') |
Jenkins | 52ba29e | 2018-08-29 15:32:11 +0000 | [diff] [blame] | 292 | runtime_files += Glob('src/runtime/NEON/functions/assembly/*.cpp') |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 293 | |
Jenkins | f7399fd | 2021-05-18 15:04:27 +0100 | [diff] [blame^] | 294 | cpu_kernel_hp_files = ['src/core/cpu/kernels/CpuActivationKernel.cpp', |
| 295 | 'src/core/cpu/kernels/CpuDepthwiseConvolutionNativeKernel.cpp', |
| 296 | 'src/core/cpu/kernels/CpuDirectConvolutionKernel.cpp', |
| 297 | 'src/core/cpu/kernels/CpuDirectConvolutionOutputStageKernel.cpp', |
| 298 | 'src/core/cpu/kernels/CpuPermuteKernel.cpp', |
| 299 | 'src/core/cpu/kernels/CpuPoolingAssemblyWrapperKernel.cpp', |
| 300 | 'src/core/cpu/kernels/CpuPoolingKernel.cpp', |
| 301 | 'src/core/cpu/kernels/CpuReshapeKernel.cpp', |
| 302 | ] |
| 303 | cpu_kernel_files = ['src/core/cpu/kernels/CpuAddKernel.cpp', |
| 304 | 'src/core/cpu/kernels/CpuConcatenateBatchKernel.cpp', |
| 305 | 'src/core/cpu/kernels/CpuConcatenateDepthKernel.cpp', |
| 306 | 'src/core/cpu/kernels/CpuConcatenateHeightKernel.cpp', |
| 307 | 'src/core/cpu/kernels/CpuConcatenateWidthKernel.cpp', |
| 308 | 'src/core/cpu/kernels/CpuConvertFullyConnectedWeightsKernel.cpp', |
| 309 | 'src/core/cpu/kernels/CpuCopyKernel.cpp', |
| 310 | 'src/core/cpu/kernels/CpuDequantizationKernel.cpp', |
| 311 | 'src/core/cpu/kernels/CpuElementwiseKernel.cpp', |
| 312 | 'src/core/cpu/kernels/CpuElementwiseUnaryKernel.cpp', |
| 313 | 'src/core/cpu/kernels/CpuFillKernel.cpp', |
| 314 | 'src/core/cpu/kernels/CpuFloorKernel.cpp', |
| 315 | 'src/core/cpu/kernels/CpuMulKernel.cpp', |
| 316 | 'src/core/cpu/kernels/CpuQuantizationKernel.cpp', |
| 317 | 'src/core/cpu/kernels/CpuScaleKernel.cpp', |
| 318 | 'src/core/cpu/kernels/CpuSoftmaxKernel.cpp', |
| 319 | 'src/core/cpu/kernels/CpuSubKernel.cpp', |
| 320 | 'src/core/cpu/kernels/CpuTransposeKernel.cpp', |
| 321 | ] |
| 322 | core_files += [cpu_kernel_hp_files, cpu_kernel_files] |
| 323 | |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 324 | core_files += Glob('src/core/cpu/kernels/*/*.cpp') |
| 325 | if any(i in env['data_type_support'] for i in ['all', 'fp16']): |
| 326 | core_files += Glob('src/core/cpu/kernels/*/*/fp16.cpp') |
| 327 | if any(i in env['data_type_support'] for i in ['all', 'fp32']): |
| 328 | core_files += Glob('src/core/cpu/kernels/*/*/fp32.cpp') |
| 329 | if any(i in env['data_type_support'] for i in ['all', 'qasymm8']): |
| 330 | core_files += Glob('src/core/cpu/kernels/*/*/qasymm8.cpp') |
| 331 | if any(i in env['data_type_support'] for i in ['all', 'qasymm8_signed']): |
| 332 | core_files += Glob('src/core/cpu/kernels/*/*/qasymm8_signed.cpp') |
| 333 | if any(i in env['data_type_support'] for i in ['all', 'qsymm16']): |
| 334 | core_files += Glob('src/core/cpu/kernels/*/*/qsymm16.cpp') |
| 335 | if any(i in env['data_type_support'] for i in ['all', 'integer']): |
| 336 | core_files += Glob('src/core/cpu/kernels/*/*/integer.cpp') |
Jenkins | f7399fd | 2021-05-18 15:04:27 +0100 | [diff] [blame^] | 337 | |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 338 | if any(i in env['data_layout_support'] for i in ['all', 'nchw']): |
| 339 | core_files += Glob('src/core/cpu/kernels/*/*/nchw/all.cpp') |
| 340 | |
Jenkins | f7399fd | 2021-05-18 15:04:27 +0100 | [diff] [blame^] | 341 | cpu_rt_files = ['src/cpu/CpuContext.cpp', |
| 342 | 'src/cpu/CpuQueue.cpp', |
| 343 | 'src/cpu/CpuTensor.cpp' |
| 344 | ] |
| 345 | cpu_operator_hp_files = ['src/runtime/cpu/operators/CpuActivation.cpp', |
| 346 | 'src/runtime/cpu/operators/CpuDepthwiseConvolution.cpp', |
| 347 | 'src/runtime/cpu/operators/CpuDepthwiseConvolutionAssemblyDispatch.cpp', |
| 348 | 'src/runtime/cpu/operators/CpuDirectConvolution.cpp', |
| 349 | 'src/runtime/cpu/operators/CpuPermute.cpp', |
| 350 | 'src/runtime/cpu/operators/CpuPooling.cpp', |
| 351 | 'src/runtime/cpu/operators/CpuPoolingAssemblyDispatch.cpp', |
| 352 | ] |
| 353 | cpu_operator_files = ['src/runtime/cpu/operators/CpuAdd.cpp', |
| 354 | 'src/runtime/cpu/operators/CpuConcatenate.cpp', |
| 355 | 'src/runtime/cpu/operators/CpuConvertFullyConnectedWeights.cpp', |
| 356 | 'src/runtime/cpu/operators/CpuCopy.cpp', |
| 357 | 'src/runtime/cpu/operators/CpuDequantization.cpp', |
| 358 | 'src/runtime/cpu/operators/CpuElementwise.cpp', |
| 359 | 'src/runtime/cpu/operators/CpuElementwiseUnary.cpp', |
| 360 | 'src/runtime/cpu/operators/CpuFill.cpp', |
| 361 | 'src/runtime/cpu/operators/CpuFloor.cpp', |
| 362 | 'src/runtime/cpu/operators/CpuMul.cpp', |
| 363 | 'src/runtime/cpu/operators/CpuQuantization.cpp', |
| 364 | 'src/runtime/cpu/operators/CpuReshape.cpp', |
| 365 | 'src/runtime/cpu/operators/CpuScale.cpp', |
| 366 | 'src/runtime/cpu/operators/CpuSoftmax.cpp', |
| 367 | 'src/runtime/cpu/operators/CpuSub.cpp', |
| 368 | 'src/runtime/cpu/operators/CpuTranspose.cpp', |
| 369 | ] |
| 370 | runtime_files += [ cpu_rt_files, cpu_operator_hp_files, cpu_operator_files ] |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 371 | |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 372 | bootcode_o = [] |
| 373 | if env['os'] == 'bare_metal': |
| 374 | bootcode_files = Glob('bootcode/*.s') |
| 375 | bootcode_o = build_bootcode_objs(bootcode_files) |
| 376 | Export('bootcode_o') |
| 377 | |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 378 | arm_compute_core_a = build_library('arm_compute_core-static', arm_compute_env, core_files, static=True) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 379 | Export('arm_compute_core_a') |
| 380 | |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 381 | if env['os'] != 'bare_metal' and not env['standalone']: |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 382 | arm_compute_core_so = build_library('arm_compute_core', arm_compute_env, core_files, static=False) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 383 | Export('arm_compute_core_so') |
| 384 | |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 385 | arm_compute_a = build_library('arm_compute-static', arm_compute_env, runtime_files, static=True, libs = [ arm_compute_core_a ]) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 386 | Export('arm_compute_a') |
| 387 | |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 388 | if env['os'] != 'bare_metal' and not env['standalone']: |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 389 | arm_compute_so = build_library('arm_compute', arm_compute_env, runtime_files, static=False, libs = [ "arm_compute_core" ]) |
Kaizen | bf8b01d | 2017-10-12 14:26:51 +0100 | [diff] [blame] | 390 | Depends(arm_compute_so, arm_compute_core_so) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 391 | Export('arm_compute_so') |
| 392 | |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 393 | arm_compute_graph_env = arm_compute_env.Clone() |
| 394 | |
| 395 | arm_compute_graph_env.Append(CXXFLAGS = ['-Wno-redundant-move', '-Wno-pessimizing-move']) |
| 396 | |
| 397 | arm_compute_graph_a = build_library('arm_compute_graph-static', arm_compute_graph_env, graph_files, static=True, libs = [ arm_compute_a]) |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 398 | Export('arm_compute_graph_a') |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 399 | |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 400 | if env['os'] != 'bare_metal' and not env['standalone']: |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 401 | arm_compute_graph_so = build_library('arm_compute_graph', arm_compute_graph_env, graph_files, static=False, libs = [ "arm_compute" , "arm_compute_core"]) |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame] | 402 | Depends(arm_compute_graph_so, arm_compute_so) |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 403 | Export('arm_compute_graph_so') |
| 404 | |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 405 | if env['standalone']: |
| 406 | alias = arm_compute_env.Alias("arm_compute", [arm_compute_a]) |
| 407 | else: |
| 408 | alias = arm_compute_env.Alias("arm_compute", [arm_compute_a, arm_compute_so]) |
| 409 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 410 | Default(alias) |
| 411 | |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 412 | if env['standalone']: |
| 413 | Depends([alias,arm_compute_core_a], generate_embed) |
| 414 | else: |
| 415 | Depends([alias,arm_compute_core_so, arm_compute_core_a], generate_embed) |