Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | # -*- coding: utf-8 -*- |
| 3 | |
Jenkins | f8f7ede | 2023-02-16 15:41:23 +0000 | [diff] [blame^] | 4 | # Copyright (c) 2016-2023 Arm Limited. |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 5 | # |
| 6 | # SPDX-License-Identifier: MIT |
| 7 | # |
| 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 | # of this software and associated documentation files (the "Software"), to |
| 10 | # deal in the Software without restriction, including without limitation the |
| 11 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 12 | # sell copies of the Software, and to permit persons to whom the Software is |
| 13 | # furnished to do so, subject to the following conditions: |
| 14 | # |
| 15 | # The above copyright notice and this permission notice shall be included in all |
| 16 | # copies or substantial portions of the Software. |
| 17 | # |
| 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 24 | # SOFTWARE. |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 25 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 26 | import collections |
| 27 | import os.path |
| 28 | import re |
| 29 | import subprocess |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 30 | import zlib |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 31 | import json |
| 32 | import codecs |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 33 | |
Jenkins | f8f7ede | 2023-02-16 15:41:23 +0000 | [diff] [blame^] | 34 | VERSION = "v23.02" |
| 35 | LIBRARY_VERSION_MAJOR = 30 |
Jenkins | 18b685f | 2020-08-21 10:26:22 +0100 | [diff] [blame] | 36 | LIBRARY_VERSION_MINOR = 0 |
Jenkins | 6a7771e | 2020-05-28 11:28:36 +0100 | [diff] [blame] | 37 | LIBRARY_VERSION_PATCH = 0 |
| 38 | 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] | 39 | |
| 40 | Import('env') |
| 41 | Import('vars') |
Jenkins | b9abeae | 2018-11-22 11:58:08 +0000 | [diff] [blame] | 42 | Import('install_lib') |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 43 | |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 44 | def build_bootcode_objs(sources): |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 45 | arm_compute_env.Append(ASFLAGS = "-I bootcode/") |
| 46 | obj = arm_compute_env.Object(sources) |
| 47 | obj = install_lib(obj) |
| 48 | Default(obj) |
| 49 | return obj |
| 50 | |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 51 | |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 52 | |
| 53 | |
| 54 | # @brief Create a list of object from a given file list. |
| 55 | # |
| 56 | # @param arch_info A dictionary represents the architecture info such as the |
| 57 | # compiler flags and defines (filedefs.json). |
| 58 | # |
| 59 | # @param sources A list of files to build |
| 60 | # |
| 61 | # @return A list of objects for the corresponding architecture. |
| 62 | |
| 63 | def build_obj_list(arch_info, sources, static=False): |
| 64 | |
| 65 | # Clone environment |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 66 | tmp_env = arm_compute_env.Clone() |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 67 | |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 68 | # Append architecture spec |
| 69 | if 'cxxflags' in arch_info and len(arch_info['cxxflags']) > 0: |
| 70 | tmp_env.Append(CXXFLAGS = arch_info['cxxflags']) |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 71 | |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 72 | # Build and return objects |
| 73 | if static: |
| 74 | objs = tmp_env.StaticObject(sources) |
| 75 | else: |
| 76 | objs = tmp_env.SharedObject(sources) |
Jenkins | a175e88 | 2022-05-18 13:38:14 +0000 | [diff] [blame] | 77 | |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 78 | tmp_env.Default(objs) |
| 79 | return objs |
| 80 | |
| 81 | # @brief Build multi-ISA files with the respective architecture. |
| 82 | # |
| 83 | # @return Two distinct lists: |
| 84 | # A list of static objects |
| 85 | # A list of shared objects |
| 86 | |
| 87 | def build_lib_objects(): |
| 88 | lib_static_objs = [] # static objects |
| 89 | lib_shared_objs = [] # shared objects |
| 90 | |
| 91 | arm_compute_env.Append(CPPDEFINES = ['ENABLE_NEON', 'ARM_COMPUTE_ENABLE_NEON', |
| 92 | 'ENABLE_SVE', 'ARM_COMPUTE_ENABLE_SVE', |
| 93 | 'ARM_COMPUTE_ENABLE_FP16', 'ARM_COMPUTE_ENABLE_BF16', |
| 94 | 'ARM_COMPUTE_ENABLE_I8MM', 'ARM_COMPUTE_ENABLE_SVEF32MM']) |
| 95 | |
| 96 | # Build all the common files for the base architecture |
| 97 | lib_static_objs += build_obj_list(filedefs["armv8.2-a"], lib_files, static=True) |
| 98 | lib_shared_objs += build_obj_list(filedefs["armv8.2-a"], lib_files, static=False) |
Jenkins | a175e88 | 2022-05-18 13:38:14 +0000 | [diff] [blame] | 99 | |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 100 | # Build the SVE specific files |
| 101 | lib_static_objs += build_obj_list(filedefs["armv8.2-a-sve"], lib_files_sve, static=True) |
| 102 | lib_shared_objs += build_obj_list(filedefs["armv8.2-a-sve"], lib_files_sve, static=False) |
| 103 | |
| 104 | # Build the SVE2 specific files |
| 105 | arm_compute_env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_SVE2']) |
| 106 | lib_static_objs += build_obj_list(filedefs["armv8.6-a-sve2"], lib_files_sve2, static=True) |
| 107 | lib_shared_objs += build_obj_list(filedefs["armv8.6-a-sve2"], lib_files_sve2, static=False) |
| 108 | |
| 109 | return lib_static_objs, lib_shared_objs |
| 110 | |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 111 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 112 | |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 113 | def build_library(name, build_env, sources, static=False, libs=[]): |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 114 | cloned_build_env = build_env.Clone() |
| 115 | if env['os'] == 'android' and static == False: |
| 116 | cloned_build_env["LINKFLAGS"].remove('-pie') |
| 117 | cloned_build_env["LINKFLAGS"].remove('-static-libstdc++') |
| 118 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 119 | if static: |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 120 | obj = cloned_build_env.StaticLibrary(name, source=sources, LIBS = arm_compute_env["LIBS"] + libs) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 121 | else: |
| 122 | if env['set_soname']: |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 123 | obj = cloned_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] | 124 | else: |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 125 | obj = cloned_build_env.SharedLibrary(name, source=sources, LIBS = arm_compute_env["LIBS"] + libs) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 126 | |
Jenkins | 1b3192e | 2022-11-18 10:52:31 +0000 | [diff] [blame] | 127 | if env['mapfile']: |
| 128 | if not 'windows' in env['os'] and not 'macos' in env['os']: |
| 129 | cloned_build_env['LINKFLAGS'].append('"-Wl,-Map='+ name + '.map"') |
| 130 | else: |
| 131 | cloned_build_env['LINKFLAGS'].append('-Wl,-map,' + name + '.map') |
| 132 | |
Jenkins | b9abeae | 2018-11-22 11:58:08 +0000 | [diff] [blame] | 133 | obj = install_lib(obj) |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 134 | build_env.Default(obj) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 135 | return obj |
| 136 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 137 | |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 138 | def remove_incode_comments(code): |
| 139 | def replace_with_empty(match): |
| 140 | s = match.group(0) |
| 141 | if s.startswith('/'): |
| 142 | return " " |
| 143 | else: |
| 144 | return s |
| 145 | |
| 146 | comment_regex = re.compile(r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"', re.DOTALL | re.MULTILINE) |
| 147 | return re.sub(comment_regex, replace_with_empty, code) |
| 148 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 149 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 150 | def resolve_includes(target, source, env): |
| 151 | # File collection |
| 152 | FileEntry = collections.namedtuple('FileEntry', 'target_name file_contents') |
| 153 | |
| 154 | # Include pattern |
| 155 | pattern = re.compile("#include \"(.*)\"") |
| 156 | |
| 157 | # Get file contents |
| 158 | files = [] |
| 159 | for i in range(len(source)): |
| 160 | src = source[i] |
| 161 | dst = target[i] |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 162 | contents = src.get_contents().decode('utf-8') |
| 163 | contents = remove_incode_comments(contents).splitlines() |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 164 | entry = FileEntry(target_name=dst, file_contents=contents) |
| 165 | files.append((os.path.basename(src.get_path()),entry)) |
| 166 | |
| 167 | # Create dictionary of tupled list |
| 168 | files_dict = dict(files) |
| 169 | |
| 170 | # Check for includes (can only be files in the same folder) |
| 171 | final_files = [] |
| 172 | for file in files: |
| 173 | done = False |
| 174 | tmp_file = file[1].file_contents |
| 175 | while not done: |
| 176 | file_count = 0 |
| 177 | updated_file = [] |
| 178 | for line in tmp_file: |
| 179 | found = pattern.search(line) |
| 180 | if found: |
Jenkins | a175e88 | 2022-05-18 13:38:14 +0000 | [diff] [blame] | 181 | # Only get the header file name and discard the relative path. |
| 182 | # E.g. "common/experimental/gemm_fused_post_ops/fp_mixed_precision_helpers.h" -> "fp_mixed_precision_helpers.h" |
| 183 | include_file = found.group(1).split('/')[-1] |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 184 | data = files_dict[include_file].file_contents |
| 185 | updated_file.extend(data) |
| 186 | else: |
| 187 | updated_file.append(line) |
| 188 | file_count += 1 |
| 189 | |
| 190 | # Check if all include are replaced. |
| 191 | if file_count == len(tmp_file): |
| 192 | done = True |
| 193 | |
| 194 | # Update temp file |
| 195 | tmp_file = updated_file |
| 196 | |
| 197 | # 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] | 198 | entry = FileEntry(target_name=file[1].target_name, file_contents=tmp_file) |
| 199 | final_files.append((file[0], entry)) |
| 200 | |
| 201 | # Write output files |
| 202 | for file in final_files: |
| 203 | with open(file[1].target_name.get_path(), 'w+') as out_file: |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 204 | file_to_write = "\n".join( file[1].file_contents ) |
| 205 | if env['compress_kernels']: |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 206 | file_to_write = zlib.compress(file_to_write.encode('utf-8'), 9) |
| 207 | file_to_write = codecs.encode(file_to_write, "base64").decode('utf-8').replace("\n", "") |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 208 | file_to_write = "R\"(" + file_to_write + ")\"" |
| 209 | out_file.write(file_to_write) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 210 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 211 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 212 | def create_version_file(target, source, env): |
| 213 | # Generate string with build options library version to embed in the library: |
| 214 | try: |
| 215 | git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]) |
| 216 | except (OSError, subprocess.CalledProcessError): |
| 217 | git_hash="unknown" |
| 218 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 219 | build_info = "\"arm_compute_version=%s Build options: %s Git hash=%s\"" % (VERSION, vars.args, git_hash.strip()) |
| 220 | with open(target[0].get_path(), "w") as fd: |
| 221 | fd.write(build_info) |
| 222 | |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 223 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 224 | def get_attrs_list(env, data_types, data_layouts): |
| 225 | attrs = [] |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 226 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 227 | # Manage data-types |
| 228 | if 'all' in data_types: |
| 229 | attrs += ['fp16', 'fp32', 'integer', 'qasymm8', 'qasymm8_signed', 'qsymm16'] |
| 230 | else: |
| 231 | if 'fp16' in data_types: attrs += ['fp16'] |
| 232 | if 'fp32' in data_types: attrs += ['fp32'] |
| 233 | if 'integer' in data_types: attrs += ['integer'] |
| 234 | if 'qasymm8' in data_types: attrs += ['qasymm8'] |
| 235 | if 'qasymm8_signed' in data_types: attrs += ['qasymm8_signed'] |
| 236 | if 'qsymm16' in data_types: attrs += ['qsymm16'] |
| 237 | # Manage data-layouts |
| 238 | if 'all' in data_layouts: |
| 239 | attrs += ['nhwc', 'nchw'] |
| 240 | else: |
| 241 | if 'nhwc' in data_layouts: attrs += ['nhwc'] |
| 242 | if 'nchw' in data_layouts: attrs += ['nchw'] |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 243 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 244 | # Manage execution state |
| 245 | attrs += ['estate32' if (env['estate'] == 'auto' and 'v7a' in env['arch']) or '32' in env['estate'] else 'estate64'] |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 246 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 247 | return attrs |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 248 | |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 249 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 250 | def get_operator_backend_files(filelist, operators, backend='', techs=[], attrs=[]): |
| 251 | files = { "common" : [] } |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 252 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 253 | # Early return if filelist is empty |
| 254 | if backend not in filelist: |
| 255 | return files |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 256 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 257 | # Iterate over operators and create the file lists to compiler |
| 258 | for operator in operators: |
| 259 | if operator in filelist[backend]['operators']: |
| 260 | files['common'] += filelist[backend]['operators'][operator]["files"]["common"] |
| 261 | for tech in techs: |
| 262 | if tech in filelist[backend]['operators'][operator]["files"]: |
| 263 | # Add tech as a key to dictionary if not there |
| 264 | if tech not in files: |
| 265 | files[tech] = [] |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 266 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 267 | # Add tech files to the tech file list |
| 268 | tech_files = filelist[backend]['operators'][operator]["files"][tech] |
| 269 | files[tech] += tech_files.get('common', []) |
| 270 | for attr in attrs: |
| 271 | files[tech] += tech_files.get(attr, []) |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 272 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 273 | # Remove duplicates if they exist |
| 274 | return {k: list(set(v)) for k,v in files.items()} |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 275 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 276 | def collect_operators(filelist, operators, backend=''): |
| 277 | ops = set() |
| 278 | for operator in operators: |
| 279 | if operator in filelist[backend]['operators']: |
| 280 | ops.add(operator) |
| 281 | if 'deps' in filelist[backend]['operators'][operator]: |
| 282 | ops.update(filelist[backend]['operators'][operator]['deps']) |
| 283 | else: |
| 284 | print("Operator {0} is unsupported on {1} backend!".format(operator, backend)) |
| 285 | |
| 286 | return ops |
| 287 | |
| 288 | |
| 289 | def resolve_operator_dependencies(filelist, operators, backend=''): |
| 290 | resolved_operators = collect_operators(filelist, operators, backend) |
| 291 | |
| 292 | are_ops_resolved = False |
| 293 | while not are_ops_resolved: |
| 294 | resolution_pass = collect_operators(filelist, resolved_operators, backend) |
| 295 | if len(resolution_pass) != len(resolved_operators): |
| 296 | resolved_operators.update(resolution_pass) |
| 297 | else: |
| 298 | are_ops_resolved = True |
| 299 | |
| 300 | return resolved_operators |
| 301 | |
| 302 | def read_build_config_json(build_config): |
| 303 | build_config_contents = {} |
| 304 | custom_operators = [] |
| 305 | custom_types = [] |
| 306 | custom_layouts = [] |
| 307 | if os.path.isfile(build_config): |
| 308 | with open(build_config) as f: |
| 309 | try: |
| 310 | build_config_contents = json.load(f) |
| 311 | except: |
| 312 | print("Warning: Build configuration file is of invalid JSON format!") |
| 313 | else: |
| 314 | try: |
| 315 | build_config_contents = json.loads(build_config) |
| 316 | except: |
| 317 | print("Warning: Build configuration string is of invalid JSON format!") |
| 318 | if build_config_contents: |
| 319 | custom_operators = build_config_contents.get("operators", []) |
| 320 | custom_types = build_config_contents.get("data_types", []) |
| 321 | custom_layouts = build_config_contents.get("data_layouts", []) |
| 322 | return custom_operators, custom_types, custom_layouts |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 323 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 324 | arm_compute_env = env.Clone() |
Jenkins | 52ba29e | 2018-08-29 15:32:11 +0000 | [diff] [blame] | 325 | version_file = arm_compute_env.Command("src/core/arm_compute_version.embed", "", action=create_version_file) |
| 326 | arm_compute_env.AlwaysBuild(version_file) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 327 | |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 328 | default_cpp_compiler = 'g++' if env['os'] not in ['android', 'macos', 'openbsd'] else 'clang++' |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 329 | cpp_compiler = os.environ.get('CXX', default_cpp_compiler) |
| 330 | |
Anthony Barbier | 06ea048 | 2018-02-22 15:45:35 +0000 | [diff] [blame] | 331 | # Generate embed files |
Jenkins | 52ba29e | 2018-08-29 15:32:11 +0000 | [diff] [blame] | 332 | generate_embed = [ version_file ] |
Anthony Barbier | 06ea048 | 2018-02-22 15:45:35 +0000 | [diff] [blame] | 333 | if env['opencl'] and env['embed_kernels']: |
Jenkins | a175e88 | 2022-05-18 13:38:14 +0000 | [diff] [blame] | 334 | |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 335 | # Header files |
| 336 | cl_helper_files = [ 'src/core/CL/cl_kernels/activation_float_helpers.h', |
| 337 | 'src/core/CL/cl_kernels/activation_quant_helpers.h', |
| 338 | 'src/core/CL/cl_kernels/gemm_helpers.h', |
| 339 | 'src/core/CL/cl_kernels/helpers_asymm.h', |
| 340 | 'src/core/CL/cl_kernels/helpers.h', |
| 341 | 'src/core/CL/cl_kernels/load_store_utility.h', |
| 342 | 'src/core/CL/cl_kernels/repeat.h', |
| 343 | 'src/core/CL/cl_kernels/tile_helpers.h', |
| 344 | 'src/core/CL/cl_kernels/types.h', |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 345 | 'src/core/CL/cl_kernels/warp_helpers.h', |
| 346 | 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/act_eltwise_op_act/fp_post_ops_act_eltwise_op_act.h', |
| 347 | 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/fp_mixed_precision_helpers.h', |
| 348 | 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/fp_elementwise_op_helpers.h', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 349 | ] |
Anthony Barbier | 06ea048 | 2018-02-22 15:45:35 +0000 | [diff] [blame] | 350 | |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 351 | # Common kernels |
| 352 | cl_files_common = ['src/core/CL/cl_kernels/common/activation_layer.cl', |
| 353 | 'src/core/CL/cl_kernels/common/activation_layer_quant.cl', |
| 354 | 'src/core/CL/cl_kernels/common/arg_min_max.cl', |
| 355 | 'src/core/CL/cl_kernels/common/batchnormalization_layer.cl', |
| 356 | 'src/core/CL/cl_kernels/common/bounding_box_transform.cl', |
| 357 | 'src/core/CL/cl_kernels/common/bounding_box_transform_quantized.cl', |
| 358 | 'src/core/CL/cl_kernels/common/bitwise_op.cl', |
| 359 | 'src/core/CL/cl_kernels/common/cast.cl', |
| 360 | 'src/core/CL/cl_kernels/common/comparisons.cl', |
| 361 | 'src/core/CL/cl_kernels/common/concatenate.cl', |
| 362 | 'src/core/CL/cl_kernels/common/col2im.cl', |
| 363 | 'src/core/CL/cl_kernels/common/convert_fc_weights.cl', |
| 364 | 'src/core/CL/cl_kernels/common/copy_tensor.cl', |
| 365 | 'src/core/CL/cl_kernels/common/crop_tensor.cl', |
| 366 | 'src/core/CL/cl_kernels/common/deconvolution_layer.cl', |
| 367 | 'src/core/CL/cl_kernels/common/dequantization_layer.cl', |
| 368 | 'src/core/CL/cl_kernels/common/elementwise_operation.cl', |
| 369 | 'src/core/CL/cl_kernels/common/elementwise_operation_quantized.cl', |
| 370 | 'src/core/CL/cl_kernels/common/elementwise_unary.cl', |
| 371 | 'src/core/CL/cl_kernels/common/fft_digit_reverse.cl', |
| 372 | 'src/core/CL/cl_kernels/common/fft.cl', |
| 373 | 'src/core/CL/cl_kernels/common/fft_scale.cl', |
| 374 | 'src/core/CL/cl_kernels/common/fill_border.cl', |
| 375 | 'src/core/CL/cl_kernels/common/floor.cl', |
| 376 | 'src/core/CL/cl_kernels/common/gather.cl', |
| 377 | 'src/core/CL/cl_kernels/common/gemm.cl', |
Jenkins | aabef6c | 2022-08-18 12:49:09 +0000 | [diff] [blame] | 378 | 'src/core/CL/cl_kernels/common/gemm_reshaped_only_rhs_mmul.cl', |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 379 | 'src/core/CL/cl_kernels/common/gemm_utils.cl', |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 380 | 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/act_eltwise_op_act/gemm_mm_native.cl', |
| 381 | 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/act_eltwise_op_act/gemm_mm_reshaped.cl', |
| 382 | 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/act_eltwise_op_act/gemm_mm_reshaped_only_rhs.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 383 | 'src/core/CL/cl_kernels/common/gemv.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 384 | 'src/core/CL/cl_kernels/common/gemmlowp.cl', |
Jenkins | aabef6c | 2022-08-18 12:49:09 +0000 | [diff] [blame] | 385 | 'src/core/CL/cl_kernels/common/gemmlowp_reshaped_only_rhs_mmul.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 386 | 'src/core/CL/cl_kernels/common/generate_proposals.cl', |
| 387 | 'src/core/CL/cl_kernels/common/generate_proposals_quantized.cl', |
| 388 | 'src/core/CL/cl_kernels/common/instance_normalization.cl', |
| 389 | 'src/core/CL/cl_kernels/common/l2_normalize.cl', |
| 390 | 'src/core/CL/cl_kernels/common/mean_stddev_normalization.cl', |
| 391 | 'src/core/CL/cl_kernels/common/unpooling_layer.cl', |
| 392 | 'src/core/CL/cl_kernels/common/memset.cl', |
| 393 | 'src/core/CL/cl_kernels/common/nonmax.cl', |
| 394 | 'src/core/CL/cl_kernels/common/minmax_layer.cl', |
| 395 | 'src/core/CL/cl_kernels/common/pad_layer.cl', |
| 396 | 'src/core/CL/cl_kernels/common/permute.cl', |
| 397 | 'src/core/CL/cl_kernels/common/pixelwise_mul_float.cl', |
| 398 | 'src/core/CL/cl_kernels/common/pixelwise_mul_int.cl', |
| 399 | 'src/core/CL/cl_kernels/common/qlstm_layer_normalization.cl', |
| 400 | 'src/core/CL/cl_kernels/common/quantization_layer.cl', |
| 401 | 'src/core/CL/cl_kernels/common/range.cl', |
| 402 | 'src/core/CL/cl_kernels/common/reduction_operation.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 403 | 'src/core/CL/cl_kernels/common/reshape_layer.cl', |
| 404 | 'src/core/CL/cl_kernels/common/convolution_layer.cl', |
| 405 | 'src/core/CL/cl_kernels/common/reverse.cl', |
| 406 | 'src/core/CL/cl_kernels/common/roi_align_layer.cl', |
| 407 | 'src/core/CL/cl_kernels/common/roi_align_layer_quantized.cl', |
| 408 | 'src/core/CL/cl_kernels/common/roi_pooling_layer.cl', |
| 409 | 'src/core/CL/cl_kernels/common/select.cl', |
| 410 | 'src/core/CL/cl_kernels/common/softmax_layer.cl', |
| 411 | 'src/core/CL/cl_kernels/common/softmax_layer_quantized.cl', |
| 412 | 'src/core/CL/cl_kernels/common/stack_layer.cl', |
| 413 | 'src/core/CL/cl_kernels/common/slice_ops.cl', |
| 414 | 'src/core/CL/cl_kernels/common/tile.cl', |
| 415 | 'src/core/CL/cl_kernels/common/transpose.cl' |
| 416 | ] |
| 417 | |
| 418 | # NCHW kernels |
| 419 | cl_files_nchw = ['src/core/CL/cl_kernels/nchw/batch_to_space.cl', |
| 420 | 'src/core/CL/cl_kernels/nchw/batchnormalization_layer.cl', |
| 421 | 'src/core/CL/cl_kernels/nchw/channel_shuffle.cl', |
| 422 | 'src/core/CL/cl_kernels/nchw/depth_to_space.cl', |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 423 | 'src/core/CL/cl_kernels/nchw/direct_convolution.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 424 | 'src/core/CL/cl_kernels/nchw/dequantization_layer.cl', |
| 425 | 'src/core/CL/cl_kernels/nchw/im2col.cl', |
| 426 | 'src/core/CL/cl_kernels/nchw/normalization_layer.cl', |
| 427 | 'src/core/CL/cl_kernels/nchw/normalize_planar_yuv_layer.cl', |
| 428 | 'src/core/CL/cl_kernels/nchw/normalize_planar_yuv_layer_quantized.cl', |
| 429 | 'src/core/CL/cl_kernels/nchw/pooling_layer.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 430 | 'src/core/CL/cl_kernels/nchw/prior_box_layer.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 431 | 'src/core/CL/cl_kernels/nchw/reorg_layer.cl', |
| 432 | 'src/core/CL/cl_kernels/nchw/scale.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 433 | 'src/core/CL/cl_kernels/nchw/space_to_batch.cl', |
| 434 | 'src/core/CL/cl_kernels/nchw/space_to_depth.cl', |
| 435 | 'src/core/CL/cl_kernels/nchw/upsample_layer.cl', |
| 436 | 'src/core/CL/cl_kernels/nchw/winograd_filter_transform.cl', |
| 437 | 'src/core/CL/cl_kernels/nchw/winograd_input_transform.cl', |
| 438 | 'src/core/CL/cl_kernels/nchw/winograd_output_transform.cl' |
| 439 | ] |
| 440 | |
| 441 | # NHWC kernels |
| 442 | cl_files_nhwc = ['src/core/CL/cl_kernels/nhwc/batch_to_space.cl', |
| 443 | 'src/core/CL/cl_kernels/nhwc/batchnormalization_layer.cl', |
| 444 | 'src/core/CL/cl_kernels/nhwc/channel_shuffle.cl', |
| 445 | 'src/core/CL/cl_kernels/nhwc/direct_convolution.cl', |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 446 | 'src/core/CL/cl_kernels/nhwc/direct_convolution3d.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 447 | 'src/core/CL/cl_kernels/nhwc/depth_to_space.cl', |
| 448 | 'src/core/CL/cl_kernels/nhwc/dequantization_layer.cl', |
| 449 | 'src/core/CL/cl_kernels/nhwc/dwc_native_fp_nhwc.cl', |
| 450 | 'src/core/CL/cl_kernels/nhwc/dwc_native_quantized_nhwc.cl', |
| 451 | 'src/core/CL/cl_kernels/nhwc/im2col.cl', |
Jenkins | f8f7ede | 2023-02-16 15:41:23 +0000 | [diff] [blame^] | 452 | 'src/core/CL/cl_kernels/nhwc/indirect_convolution.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 453 | 'src/core/CL/cl_kernels/nhwc/normalization_layer.cl', |
| 454 | 'src/core/CL/cl_kernels/nhwc/normalize_planar_yuv_layer.cl', |
| 455 | 'src/core/CL/cl_kernels/nhwc/normalize_planar_yuv_layer_quantized.cl', |
| 456 | 'src/core/CL/cl_kernels/nhwc/pooling_layer.cl', |
Jenkins | a175e88 | 2022-05-18 13:38:14 +0000 | [diff] [blame] | 457 | 'src/core/CL/cl_kernels/nhwc/pooling_3d_layer.cl', |
| 458 | 'src/core/CL/cl_kernels/nhwc/pooling_3d_layer_quantized.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 459 | 'src/core/CL/cl_kernels/nhwc/pooling_layer_quantized.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 460 | 'src/core/CL/cl_kernels/nhwc/reorg_layer.cl', |
| 461 | 'src/core/CL/cl_kernels/nhwc/scale.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 462 | 'src/core/CL/cl_kernels/nhwc/space_to_batch.cl', |
| 463 | 'src/core/CL/cl_kernels/nhwc/space_to_depth.cl', |
Jenkins | f8f7ede | 2023-02-16 15:41:23 +0000 | [diff] [blame^] | 464 | 'src/core/CL/cl_kernels/nhwc/transposed_convolution.cl', |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 465 | 'src/core/CL/cl_kernels/nhwc/upsample_layer.cl', |
| 466 | 'src/core/CL/cl_kernels/nhwc/winograd_filter_transform.cl', |
| 467 | 'src/core/CL/cl_kernels/nhwc/winograd_input_transform.cl', |
| 468 | 'src/core/CL/cl_kernels/nhwc/winograd_output_transform.cl' |
| 469 | ] |
| 470 | |
| 471 | cl_files = cl_helper_files + cl_files_common + cl_files_nchw + cl_files_nhwc |
| 472 | |
| 473 | embed_files = [ f+"embed" for f in cl_files ] |
Anthony Barbier | 06ea048 | 2018-02-22 15:45:35 +0000 | [diff] [blame] | 474 | arm_compute_env.Append(CPPPATH =[Dir("./src/core/CL/").path] ) |
| 475 | |
| 476 | generate_embed.append(arm_compute_env.Command(embed_files, cl_files, action=resolve_includes)) |
| 477 | |
Anthony Barbier | 06ea048 | 2018-02-22 15:45:35 +0000 | [diff] [blame] | 478 | Default(generate_embed) |
| 479 | if env["build"] == "embed_only": |
| 480 | Return() |
| 481 | |
Jenkins | 6a7771e | 2020-05-28 11:28:36 +0100 | [diff] [blame] | 482 | # Append version defines for semantic versioning |
| 483 | arm_compute_env.Append(CPPDEFINES = [('ARM_COMPUTE_VERSION_MAJOR', LIBRARY_VERSION_MAJOR), |
| 484 | ('ARM_COMPUTE_VERSION_MINOR', LIBRARY_VERSION_MINOR), |
| 485 | ('ARM_COMPUTE_VERSION_PATCH', LIBRARY_VERSION_PATCH)]) |
| 486 | |
Anthony Barbier | 06ea048 | 2018-02-22 15:45:35 +0000 | [diff] [blame] | 487 | # Don't allow undefined references in the libraries: |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 488 | undefined_flag = '-Wl,-undefined,error' if 'macos' in arm_compute_env["os"] else '-Wl,--no-undefined' |
| 489 | arm_compute_env.Append(LINKFLAGS=[undefined_flag]) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 490 | arm_compute_env.Append(CPPPATH =[Dir("./src/core/").path] ) |
| 491 | |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 492 | if env['os'] != 'openbsd': |
Jenkins | f8f7ede | 2023-02-16 15:41:23 +0000 | [diff] [blame^] | 493 | if env['os'] == 'windows': |
| 494 | arm_compute_env.Append(LIBS = []) |
| 495 | else: |
| 496 | arm_compute_env.Append(LIBS = ['dl']) |
| 497 | |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 498 | |
| 499 | # Load build definitions file |
| 500 | with (open(Dir('#').path + '/filedefs.json')) as fd: |
| 501 | filedefs = json.load(fd) |
| 502 | filedefs = filedefs['cpu']['arch'] |
| 503 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 504 | |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 505 | with (open(Dir('#').path + '/filelist.json')) as fp: |
| 506 | filelist = json.load(fp) |
| 507 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 508 | # Common backend files |
| 509 | lib_files = filelist['common'] |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 510 | |
Jenkins | a175e88 | 2022-05-18 13:38:14 +0000 | [diff] [blame] | 511 | # Experimental files |
| 512 | # Dynamic fusion |
| 513 | if env['experimental_dynamic_fusion']: |
| 514 | lib_files += filelist['experimental']['dynamic_fusion'] |
Jenkins | a175e88 | 2022-05-18 13:38:14 +0000 | [diff] [blame] | 515 | |
Jenkins | aabef6c | 2022-08-18 12:49:09 +0000 | [diff] [blame] | 516 | # Fixed format GEMM kernels. |
| 517 | if env['experimental_fixed_format_kernels']: |
| 518 | arm_compute_env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS']) |
| 519 | |
Jenkins | a175e88 | 2022-05-18 13:38:14 +0000 | [diff] [blame] | 520 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 521 | # Logging files |
| 522 | if env["logging"]: |
| 523 | lib_files += filelist['logging'] |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame] | 524 | |
Jenkins | f7399fd | 2021-05-18 15:04:27 +0100 | [diff] [blame] | 525 | # C API files |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 526 | lib_files += filelist['c_api']['common'] |
| 527 | lib_files += filelist['c_api']['operators'] |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 528 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 529 | # Scheduler infrastructure |
| 530 | lib_files += filelist['scheduler']['single'] |
| 531 | if env['cppthreads']: |
| 532 | lib_files += filelist['scheduler']['threads'] |
| 533 | if env['openmp']: |
| 534 | lib_files += filelist['scheduler']['omp'] |
Jenkins | f7399fd | 2021-05-18 15:04:27 +0100 | [diff] [blame] | 535 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 536 | # Graph files |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 537 | graph_files = Glob('src/graph/*.cpp') |
| 538 | graph_files += Glob('src/graph/*/*.cpp') |
| 539 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 540 | # Specify user-defined priority operators |
| 541 | custom_operators = [] |
| 542 | custom_types = [] |
| 543 | custom_layouts = [] |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 544 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 545 | use_custom_ops = env['high_priority'] or env['build_config']; |
| 546 | |
| 547 | if env['high_priority']: |
| 548 | custom_operators = filelist['high_priority'] |
| 549 | custom_types = ['all'] |
| 550 | custom_layouts = ['all'] |
| 551 | |
| 552 | if env['build_config']: |
| 553 | custom_operators, custom_types, custom_layouts = read_build_config_json(env['build_config']) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 554 | |
| 555 | if env['opencl']: |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 556 | lib_files += filelist['c_api']['gpu'] |
| 557 | lib_files += filelist['gpu']['common'] |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 558 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 559 | cl_operators = custom_operators if use_custom_ops else filelist['gpu']['operators'].keys() |
| 560 | cl_ops_to_build = resolve_operator_dependencies(filelist, cl_operators, 'gpu') |
| 561 | lib_files += get_operator_backend_files(filelist, cl_ops_to_build, 'gpu')['common'] |
Jenkins | f7399fd | 2021-05-18 15:04:27 +0100 | [diff] [blame] | 562 | |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 563 | graph_files += Glob('src/graph/backends/CL/*.cpp') |
| 564 | |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 565 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 566 | lib_files_sve = [] |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 567 | lib_files_sve2 = [] |
| 568 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 569 | if env['neon']: |
Jenkins | 975dfe1 | 2019-09-02 11:47:54 +0100 | [diff] [blame] | 570 | # build winograd/depthwise sources for either v7a / v8a |
Jenkins | 49b8f90 | 2020-11-27 12:49:11 +0000 | [diff] [blame] | 571 | arm_compute_env.Append(CPPPATH = ["src/core/NEON/kernels/convolution/common/", |
Jenkins | 18b685f | 2020-08-21 10:26:22 +0100 | [diff] [blame] | 572 | "src/core/NEON/kernels/convolution/winograd/", |
Jenkins | a175e88 | 2022-05-18 13:38:14 +0000 | [diff] [blame] | 573 | "src/core/NEON/kernels/arm_conv/depthwise/", |
| 574 | "src/core/NEON/kernels/arm_conv/pooling/", |
| 575 | "src/core/NEON/kernels/arm_conv/", |
Jenkins | 49b8f90 | 2020-11-27 12:49:11 +0000 | [diff] [blame] | 576 | "src/core/NEON/kernels/assembly/", |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 577 | "arm_compute/core/NEON/kernels/assembly/", |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 578 | "src/cpu/kernels/assembly/"]) |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 579 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 580 | lib_files += filelist['cpu']['common'] |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 581 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 582 | # Setup SIMD file list to include |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 583 | simd = ['neon'] |
| 584 | if env['multi_isa']: |
| 585 | simd += ['sve', 'sve2'] |
| 586 | else: |
| 587 | if 'sve' in env['arch']: simd += ['sve'] |
| 588 | if 'sve2' in env['arch']: simd += ['sve2'] |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 589 | |
| 590 | # Get attributes |
| 591 | if(use_custom_ops): |
| 592 | attrs = get_attrs_list(env, custom_types, custom_layouts) |
| 593 | else: |
| 594 | attrs = get_attrs_list(env, env['data_type_support'], env['data_layout_support']) |
| 595 | |
Jenkins | aabef6c | 2022-08-18 12:49:09 +0000 | [diff] [blame] | 596 | if env['experimental_fixed_format_kernels']: |
| 597 | attrs.append("experimental_fixed_format_kernels") |
| 598 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 599 | # Setup data-type and data-layout files to include |
| 600 | cpu_operators = custom_operators if use_custom_ops else filelist['cpu']['operators'].keys() |
| 601 | cpu_ops_to_build = resolve_operator_dependencies(filelist, cpu_operators, 'cpu') |
| 602 | |
| 603 | cpu_files = get_operator_backend_files(filelist, cpu_ops_to_build, 'cpu', simd, attrs) |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 604 | |
| 605 | # Shared among ALL CPU files |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 606 | lib_files += cpu_files.get('common', []) |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 607 | |
| 608 | # Arm® Neon™ specific files |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 609 | lib_files += cpu_files.get('neon', []) |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 610 | |
| 611 | # SVE files only |
| 612 | lib_files_sve = cpu_files.get('sve', []) |
| 613 | |
| 614 | # SVE2 files only |
| 615 | lib_files_sve2 = cpu_files.get('sve2', []) |
Anthony Barbier | f45d5a9 | 2018-01-24 16:23:15 +0000 | [diff] [blame] | 616 | |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 617 | graph_files += Glob('src/graph/backends/NEON/*.cpp') |
| 618 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 619 | # Restrict from building graph API if a reduced operator list has been provided |
| 620 | if use_custom_ops: |
| 621 | print("WARNING: Graph library requires all operators to be built") |
| 622 | graph_files = [] |
| 623 | |
| 624 | # Build bootcode in case of bare-metal |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 625 | bootcode_o = [] |
| 626 | if env['os'] == 'bare_metal': |
| 627 | bootcode_files = Glob('bootcode/*.s') |
| 628 | bootcode_o = build_bootcode_objs(bootcode_files) |
| 629 | Export('bootcode_o') |
| 630 | |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 631 | |
| 632 | if (env['multi_isa']): |
| 633 | lib_static_objs, lib_shared_objs = build_lib_objects() |
| 634 | |
| 635 | |
| 636 | # STATIC library build. |
| 637 | if (env['multi_isa']): |
| 638 | arm_compute_a = build_library('arm_compute-static', arm_compute_env, lib_static_objs, static=True) |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 639 | else: |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 640 | if 'sve2' in env['arch']: |
| 641 | lib_files += lib_files_sve |
| 642 | lib_files += lib_files_sve2 |
| 643 | elif 'sve' in env['arch']: |
| 644 | lib_files += lib_files_sve |
| 645 | |
| 646 | arm_compute_a = build_library('arm_compute-static', arm_compute_env, lib_files, static=True) |
| 647 | |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 648 | Export('arm_compute_a') |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 649 | |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 650 | # SHARED library build. |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 651 | if env['os'] != 'bare_metal' and not env['standalone']: |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 652 | if (env['multi_isa']): |
| 653 | |
| 654 | arm_compute_so = build_library('arm_compute', arm_compute_env, lib_shared_objs, static=False) |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 655 | else: |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 656 | arm_compute_so = build_library('arm_compute', arm_compute_env, lib_files, static=False) |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 657 | |
| 658 | Export('arm_compute_so') |
| 659 | |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 660 | # Generate dummy core lib for backwards compatibility |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 661 | if env['os'] == 'macos': |
| 662 | # macos static library archiver fails if given an empty list of files |
| 663 | arm_compute_core_a = build_library('arm_compute_core-static', arm_compute_env, lib_files, static=True) |
| 664 | else: |
| 665 | arm_compute_core_a = build_library('arm_compute_core-static', arm_compute_env, [], static=True) |
| 666 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 667 | Export('arm_compute_core_a') |
| 668 | |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 669 | if env['os'] != 'bare_metal' and not env['standalone']: |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 670 | arm_compute_core_a_so = build_library('arm_compute_core', arm_compute_env, [], static=False) |
| 671 | Export('arm_compute_core_a_so') |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 672 | |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 673 | arm_compute_graph_env = arm_compute_env.Clone() |
| 674 | |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 675 | # Build graph libraries |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 676 | arm_compute_graph_env.Append(CXXFLAGS = ['-Wno-redundant-move', '-Wno-pessimizing-move']) |
| 677 | |
Jenkins | 8f587de | 2022-02-26 12:23:41 +0000 | [diff] [blame] | 678 | 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] | 679 | Export('arm_compute_graph_a') |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 680 | |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 681 | if env['os'] != 'bare_metal' and not env['standalone']: |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 682 | arm_compute_graph_so = build_library('arm_compute_graph', arm_compute_graph_env, graph_files, static=False, libs = [ "arm_compute" ]) |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame] | 683 | Depends(arm_compute_graph_so, arm_compute_so) |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 684 | Export('arm_compute_graph_so') |
| 685 | |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 686 | if env['standalone']: |
| 687 | alias = arm_compute_env.Alias("arm_compute", [arm_compute_a]) |
| 688 | else: |
| 689 | alias = arm_compute_env.Alias("arm_compute", [arm_compute_a, arm_compute_so]) |
| 690 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 691 | Default(alias) |
| 692 | |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 693 | if env['standalone']: |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 694 | Depends([alias], generate_embed) |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 695 | else: |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 696 | Depends([alias], generate_embed) |