Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | # -*- coding: utf-8 -*- |
| 3 | |
Felix Thomasmathibalan | 3a704ae | 2024-01-18 09:11:13 +0000 | [diff] [blame] | 4 | # Copyright (c) 2016-2024 Arm Limited. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +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. |
Motti Gondabi | 6f3a9f5 | 2021-11-09 15:47:17 +0200 | [diff] [blame] | 25 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 26 | import collections |
| 27 | import os.path |
| 28 | import re |
| 29 | import subprocess |
Georgios Pinitas | ea85727 | 2021-01-22 05:47:37 +0000 | [diff] [blame] | 30 | import zlib |
Georgios Pinitas | bdcdc39 | 2021-04-22 16:42:03 +0100 | [diff] [blame] | 31 | import json |
Adnan AlSinan | 39aebd1 | 2021-08-06 12:44:51 +0100 | [diff] [blame] | 32 | import codecs |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 33 | |
| 34 | VERSION = "v0.0-unreleased" |
Felix Thomasmathibalan | d98e27e | 2024-02-12 13:48:29 +0000 | [diff] [blame] | 35 | LIBRARY_VERSION_MAJOR = 35 |
Sang-Hoon Park | 6d0b384 | 2020-08-14 14:48:08 +0100 | [diff] [blame] | 36 | LIBRARY_VERSION_MINOR = 0 |
ramy.elgammal@arm.com | 1d7aefb | 2023-08-09 14:41:32 +0100 | [diff] [blame] | 37 | LIBRARY_VERSION_PATCH = 0 |
Georgios Pinitas | 35fcc43 | 2020-03-26 18:47:46 +0000 | [diff] [blame] | 38 | SONAME_VERSION = str(LIBRARY_VERSION_MAJOR) + "." + str(LIBRARY_VERSION_MINOR) + "." + str(LIBRARY_VERSION_PATCH) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 39 | |
| 40 | Import('env') |
| 41 | Import('vars') |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 42 | Import('install_lib') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 43 | |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 44 | def build_bootcode_objs(sources): |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [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 | |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 51 | |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 52 | # @brief Create a list of object from a given file list. |
Motti Gondabi | 6f3a9f5 | 2021-11-09 15:47:17 +0200 | [diff] [blame] | 53 | # |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 54 | # @param arch_info A dictionary represents the architecture info such as the |
| 55 | # compiler flags and defines (filedefs.json). |
| 56 | # |
| 57 | # @param sources A list of files to build |
Motti Gondabi | 6f3a9f5 | 2021-11-09 15:47:17 +0200 | [diff] [blame] | 58 | # |
| 59 | # @return A list of objects for the corresponding architecture. |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 60 | |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 61 | def build_obj_list(arch_info, sources, static=False): |
Motti Gondabi | 6f3a9f5 | 2021-11-09 15:47:17 +0200 | [diff] [blame] | 62 | |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 63 | # Clone environment |
Georgios Pinitas | bdcdc39 | 2021-04-22 16:42:03 +0100 | [diff] [blame] | 64 | tmp_env = arm_compute_env.Clone() |
Motti Gondabi | 6f3a9f5 | 2021-11-09 15:47:17 +0200 | [diff] [blame] | 65 | |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 66 | # Append architecture spec |
| 67 | if 'cxxflags' in arch_info and len(arch_info['cxxflags']) > 0: |
| 68 | tmp_env.Append(CXXFLAGS = arch_info['cxxflags']) |
Motti Gondabi | 6f3a9f5 | 2021-11-09 15:47:17 +0200 | [diff] [blame] | 69 | |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 70 | # Build and return objects |
| 71 | if static: |
| 72 | objs = tmp_env.StaticObject(sources) |
Motti Gondabi | 6f3a9f5 | 2021-11-09 15:47:17 +0200 | [diff] [blame] | 73 | else: |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 74 | objs = tmp_env.SharedObject(sources) |
Giorgio Arena | 892b70a | 2022-03-30 12:23:10 +0100 | [diff] [blame] | 75 | |
Motti Gondabi | f76a502 | 2021-12-21 13:19:29 +0200 | [diff] [blame] | 76 | tmp_env.Default(objs) |
| 77 | return objs |
Georgios Pinitas | bdcdc39 | 2021-04-22 16:42:03 +0100 | [diff] [blame] | 78 | |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 79 | # @brief Build multi-ISA files with the respective architecture. |
| 80 | # |
| 81 | # @return Two distinct lists: |
| 82 | # A list of static objects |
| 83 | # A list of shared objects |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 84 | |
Pablo Marquez Tello | 9f7aca9 | 2023-08-16 15:21:44 +0100 | [diff] [blame] | 85 | def build_multiisa_lib_objects(): |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 86 | lib_static_objs = [] # static objects |
| 87 | lib_shared_objs = [] # shared objects |
| 88 | |
Pablo Marquez Tello | 391f872 | 2023-12-07 15:27:26 +0000 | [diff] [blame] | 89 | # note that ARM_COMPUTE_ENABLE_FP16 is enabled in update_data_type_layout_flags() to make |
| 90 | # sure the environment is progated to the validation suite |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 91 | arm_compute_env.Append(CPPDEFINES = ['ENABLE_NEON', 'ARM_COMPUTE_ENABLE_NEON', |
Pablo Marquez Tello | 391f872 | 2023-12-07 15:27:26 +0000 | [diff] [blame] | 92 | 'ENABLE_SVE', 'ARM_COMPUTE_ENABLE_SVE','ARM_COMPUTE_ENABLE_BF16', |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 93 | 'ARM_COMPUTE_ENABLE_I8MM', 'ARM_COMPUTE_ENABLE_SVEF32MM']) |
| 94 | |
| 95 | # Build all the common files for the base architecture |
Pablo Marquez Tello | ec89b91 | 2024-01-29 16:07:17 +0000 | [diff] [blame] | 96 | if env['arch'] == 'armv8a' or env['arch'] == 'arm64-v8a': |
Pablo Marquez Tello | 9f7aca9 | 2023-08-16 15:21:44 +0100 | [diff] [blame] | 97 | lib_static_objs += build_obj_list(filedefs["armv8-a"], misa_lib_files, static=True) |
| 98 | lib_shared_objs += build_obj_list(filedefs["armv8-a"], misa_lib_files, static=False) |
Sunita Nadampalli | 911d572 | 2023-05-02 14:05:39 +0000 | [diff] [blame] | 99 | else: |
Pablo Marquez Tello | 9f7aca9 | 2023-08-16 15:21:44 +0100 | [diff] [blame] | 100 | lib_static_objs += build_obj_list(filedefs["armv8.2-a"], misa_lib_files, static=True) |
| 101 | lib_shared_objs += build_obj_list(filedefs["armv8.2-a"], misa_lib_files, static=False) |
| 102 | |
| 103 | # Build the FP16 specific files |
| 104 | lib_static_objs += build_obj_list(filedefs["armv8.2-a"], misa_lib_files_neon_fp16, static=True) |
| 105 | lib_shared_objs += build_obj_list(filedefs["armv8.2-a"], misa_lib_files_neon_fp16, static=False) |
Giorgio Arena | 892b70a | 2022-03-30 12:23:10 +0100 | [diff] [blame] | 106 | |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 107 | # Build the SVE specific files |
Pablo Marquez Tello | 9f7aca9 | 2023-08-16 15:21:44 +0100 | [diff] [blame] | 108 | lib_static_objs += build_obj_list(filedefs["armv8.2-a-sve"], misa_lib_files_sve, static=True) |
| 109 | lib_shared_objs += build_obj_list(filedefs["armv8.2-a-sve"], misa_lib_files_sve, static=False) |
| 110 | lib_static_objs += build_obj_list(filedefs["armv8.2-a-sve"], misa_lib_files_sve_fp16, static=True) |
| 111 | lib_shared_objs += build_obj_list(filedefs["armv8.2-a-sve"], misa_lib_files_sve_fp16, static=False) |
| 112 | |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 113 | |
| 114 | # Build the SVE2 specific files |
| 115 | arm_compute_env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_SVE2']) |
Pablo Marquez Tello | 9f7aca9 | 2023-08-16 15:21:44 +0100 | [diff] [blame] | 116 | lib_static_objs += build_obj_list(filedefs["armv8.6-a-sve2"], misa_lib_files_sve2, static=True) |
| 117 | lib_shared_objs += build_obj_list(filedefs["armv8.6-a-sve2"], misa_lib_files_sve2, static=False) |
| 118 | lib_static_objs += build_obj_list(filedefs["armv8.6-a-sve2"], misa_lib_files_sve2_fp16, static=True) |
| 119 | lib_shared_objs += build_obj_list(filedefs["armv8.6-a-sve2"], misa_lib_files_sve2_fp16, static=False) |
| 120 | |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 121 | |
| 122 | return lib_static_objs, lib_shared_objs |
| 123 | |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 124 | |
Jakub Sujak | e86f992 | 2023-07-05 17:30:02 +0100 | [diff] [blame] | 125 | # The built-in SCons Glob() method does not support recursive searching of directories, thus we implement our own: |
| 126 | def recursive_glob(root_dir, pattern): |
| 127 | files = [] |
| 128 | regex = re.compile(pattern) |
| 129 | |
| 130 | for dirpath, _, filenames in os.walk(root_dir): |
| 131 | for f in filenames: |
| 132 | f = os.path.join(dirpath, f) |
| 133 | if regex.match(f): |
| 134 | files.append(f) |
| 135 | |
| 136 | return files |
| 137 | |
| 138 | |
| 139 | def get_ckw_obj_list(): |
Gunes Bayir | 2b9fa59 | 2024-01-17 16:07:03 +0000 | [diff] [blame] | 140 | cmake_obj_dir = os.path.abspath("CMakeFiles/ckw.dir/src") |
Jakub Sujak | a38b4ab | 2023-07-11 14:18:35 +0100 | [diff] [blame] | 141 | return recursive_glob(root_dir=cmake_obj_dir, pattern=".*.o$") |
Jakub Sujak | e86f992 | 2023-07-05 17:30:02 +0100 | [diff] [blame] | 142 | |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 143 | |
Georgios Pinitas | 4d9687e | 2020-10-21 18:33:36 +0100 | [diff] [blame] | 144 | def build_library(name, build_env, sources, static=False, libs=[]): |
Mohammed Suhail Munshi | de60ed9 | 2021-12-21 11:07:27 +0000 | [diff] [blame] | 145 | cloned_build_env = build_env.Clone() |
Motti Gondabi | f76a502 | 2021-12-21 13:19:29 +0200 | [diff] [blame] | 146 | if env['os'] == 'android' and static == False: |
Mohammed Suhail Munshi | de60ed9 | 2021-12-21 11:07:27 +0000 | [diff] [blame] | 147 | cloned_build_env["LINKFLAGS"].remove('-pie') |
| 148 | cloned_build_env["LINKFLAGS"].remove('-static-libstdc++') |
| 149 | |
Jakub Sujak | e86f992 | 2023-07-05 17:30:02 +0100 | [diff] [blame] | 150 | # -- Static Library -- |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 151 | if static: |
Jakub Sujak | e86f992 | 2023-07-05 17:30:02 +0100 | [diff] [blame] | 152 | # Recreate the list to avoid mutating the original |
| 153 | static_sources = list(sources) |
| 154 | |
| 155 | # Dynamic Fusion has a direct dependency on the Compute Kernel Writer (CKW) subproject, therefore we collect the |
| 156 | # built CKW objects to pack into the Compute Library archive. |
| 157 | if env['experimental_dynamic_fusion'] and name == "arm_compute-static": |
| 158 | static_sources += get_ckw_obj_list() |
| 159 | |
| 160 | obj = cloned_build_env.StaticLibrary(name, source=static_sources, LIBS=arm_compute_env["LIBS"] + libs) |
| 161 | |
| 162 | # -- Shared Library -- |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 163 | else: |
Jakub Sujak | e86f992 | 2023-07-05 17:30:02 +0100 | [diff] [blame] | 164 | # Always statically link Compute Library against CKW |
| 165 | if env['experimental_dynamic_fusion'] and name == "arm_compute": |
Gunes Bayir | 2b9fa59 | 2024-01-17 16:07:03 +0000 | [diff] [blame] | 166 | libs.append('libckw.a') |
Jakub Sujak | e86f992 | 2023-07-05 17:30:02 +0100 | [diff] [blame] | 167 | |
| 168 | # Add shared library versioning |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 169 | if env['set_soname']: |
Mohammed Suhail Munshi | de60ed9 | 2021-12-21 11:07:27 +0000 | [diff] [blame] | 170 | obj = cloned_build_env.SharedLibrary(name, source=sources, SHLIBVERSION = SONAME_VERSION, LIBS = arm_compute_env["LIBS"] + libs) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 171 | else: |
Mohammed Suhail Munshi | de60ed9 | 2021-12-21 11:07:27 +0000 | [diff] [blame] | 172 | obj = cloned_build_env.SharedLibrary(name, source=sources, LIBS = arm_compute_env["LIBS"] + libs) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 173 | |
Pablo Marquez Tello | 299d3a1 | 2022-10-12 14:58:24 +0100 | [diff] [blame] | 174 | if env['mapfile']: |
Pablo Marquez Tello | a4f8870 | 2022-10-21 10:24:23 +0100 | [diff] [blame] | 175 | if not 'windows' in env['os'] and not 'macos' in env['os']: |
| 176 | cloned_build_env['LINKFLAGS'].append('"-Wl,-Map='+ name + '.map"') |
| 177 | else: |
| 178 | cloned_build_env['LINKFLAGS'].append('-Wl,-map,' + name + '.map') |
Pablo Marquez Tello | 299d3a1 | 2022-10-12 14:58:24 +0100 | [diff] [blame] | 179 | |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 180 | obj = install_lib(obj) |
Motti Gondabi | f76a502 | 2021-12-21 13:19:29 +0200 | [diff] [blame] | 181 | build_env.Default(obj) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 182 | return obj |
| 183 | |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 184 | |
Georgios Pinitas | f605bd2 | 2020-11-26 11:55:09 +0000 | [diff] [blame] | 185 | def remove_incode_comments(code): |
| 186 | def replace_with_empty(match): |
| 187 | s = match.group(0) |
| 188 | if s.startswith('/'): |
| 189 | return " " |
| 190 | else: |
| 191 | return s |
| 192 | |
| 193 | comment_regex = re.compile(r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"', re.DOTALL | re.MULTILINE) |
| 194 | return re.sub(comment_regex, replace_with_empty, code) |
| 195 | |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 196 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 197 | def resolve_includes(target, source, env): |
| 198 | # File collection |
| 199 | FileEntry = collections.namedtuple('FileEntry', 'target_name file_contents') |
| 200 | |
| 201 | # Include pattern |
| 202 | pattern = re.compile("#include \"(.*)\"") |
| 203 | |
| 204 | # Get file contents |
| 205 | files = [] |
| 206 | for i in range(len(source)): |
| 207 | src = source[i] |
| 208 | dst = target[i] |
Georgios Pinitas | f605bd2 | 2020-11-26 11:55:09 +0000 | [diff] [blame] | 209 | contents = src.get_contents().decode('utf-8') |
| 210 | contents = remove_incode_comments(contents).splitlines() |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 211 | entry = FileEntry(target_name=dst, file_contents=contents) |
| 212 | files.append((os.path.basename(src.get_path()),entry)) |
| 213 | |
| 214 | # Create dictionary of tupled list |
| 215 | files_dict = dict(files) |
| 216 | |
| 217 | # Check for includes (can only be files in the same folder) |
| 218 | final_files = [] |
| 219 | for file in files: |
| 220 | done = False |
| 221 | tmp_file = file[1].file_contents |
| 222 | while not done: |
| 223 | file_count = 0 |
| 224 | updated_file = [] |
| 225 | for line in tmp_file: |
| 226 | found = pattern.search(line) |
| 227 | if found: |
Giorgio Arena | 09adcc4 | 2022-03-08 11:12:27 +0000 | [diff] [blame] | 228 | # Only get the header file name and discard the relative path. |
Jakub Sujak | 0d27b2e | 2023-08-24 14:01:20 +0100 | [diff] [blame] | 229 | # E.g. "src/core/CL/cl_kernels/activation_float_helpers.h" -> "activation_float_helpers.h" |
Giorgio Arena | 232c452 | 2022-03-03 10:09:01 +0000 | [diff] [blame] | 230 | include_file = found.group(1).split('/')[-1] |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 231 | data = files_dict[include_file].file_contents |
| 232 | updated_file.extend(data) |
| 233 | else: |
| 234 | updated_file.append(line) |
| 235 | file_count += 1 |
| 236 | |
| 237 | # Check if all include are replaced. |
| 238 | if file_count == len(tmp_file): |
| 239 | done = True |
| 240 | |
| 241 | # Update temp file |
| 242 | tmp_file = updated_file |
| 243 | |
| 244 | # Append and prepend string literal identifiers and add expanded file to final list |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 245 | entry = FileEntry(target_name=file[1].target_name, file_contents=tmp_file) |
| 246 | final_files.append((file[0], entry)) |
| 247 | |
| 248 | # Write output files |
| 249 | for file in final_files: |
| 250 | with open(file[1].target_name.get_path(), 'w+') as out_file: |
Georgios Pinitas | ea85727 | 2021-01-22 05:47:37 +0000 | [diff] [blame] | 251 | file_to_write = "\n".join( file[1].file_contents ) |
| 252 | if env['compress_kernels']: |
Adnan AlSinan | 39aebd1 | 2021-08-06 12:44:51 +0100 | [diff] [blame] | 253 | file_to_write = zlib.compress(file_to_write.encode('utf-8'), 9) |
| 254 | file_to_write = codecs.encode(file_to_write, "base64").decode('utf-8').replace("\n", "") |
Georgios Pinitas | ea85727 | 2021-01-22 05:47:37 +0000 | [diff] [blame] | 255 | file_to_write = "R\"(" + file_to_write + ")\"" |
| 256 | out_file.write(file_to_write) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 257 | |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 258 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 259 | def create_version_file(target, source, env): |
| 260 | # Generate string with build options library version to embed in the library: |
| 261 | try: |
| 262 | git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]) |
| 263 | except (OSError, subprocess.CalledProcessError): |
| 264 | git_hash="unknown" |
| 265 | |
Matthew Bentham | dd8d7f4 | 2023-06-15 11:50:57 +0000 | [diff] [blame] | 266 | build_options = str(vars.args).replace('"', '\\"') |
| 267 | build_info = "\"arm_compute_version=%s Build options: %s Git hash=%s\"" % (VERSION,build_options, git_hash.strip()) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 268 | with open(target[0].get_path(), "w") as fd: |
| 269 | fd.write(build_info) |
| 270 | |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 271 | |
Freddie Liardet | 487d390 | 2021-09-21 12:36:43 +0100 | [diff] [blame] | 272 | def get_attrs_list(env, data_types, data_layouts): |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 273 | attrs = [] |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 274 | |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 275 | # Manage data-types |
Freddie Liardet | 487d390 | 2021-09-21 12:36:43 +0100 | [diff] [blame] | 276 | if 'all' in data_types: |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 277 | attrs += ['fp16', 'fp32', 'integer', 'qasymm8', 'qasymm8_signed', 'qsymm16'] |
| 278 | else: |
Freddie Liardet | 487d390 | 2021-09-21 12:36:43 +0100 | [diff] [blame] | 279 | if 'fp16' in data_types: attrs += ['fp16'] |
| 280 | if 'fp32' in data_types: attrs += ['fp32'] |
| 281 | if 'integer' in data_types: attrs += ['integer'] |
| 282 | if 'qasymm8' in data_types: attrs += ['qasymm8'] |
| 283 | if 'qasymm8_signed' in data_types: attrs += ['qasymm8_signed'] |
| 284 | if 'qsymm16' in data_types: attrs += ['qsymm16'] |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 285 | # Manage data-layouts |
Freddie Liardet | 487d390 | 2021-09-21 12:36:43 +0100 | [diff] [blame] | 286 | if 'all' in data_layouts: |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 287 | attrs += ['nhwc', 'nchw'] |
| 288 | else: |
Freddie Liardet | 487d390 | 2021-09-21 12:36:43 +0100 | [diff] [blame] | 289 | if 'nhwc' in data_layouts: attrs += ['nhwc'] |
| 290 | if 'nchw' in data_layouts: attrs += ['nchw'] |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 291 | |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 292 | # Manage execution state |
Freddie Liardet | 487d390 | 2021-09-21 12:36:43 +0100 | [diff] [blame] | 293 | attrs += ['estate32' if (env['estate'] == 'auto' and 'v7a' in env['arch']) or '32' in env['estate'] else 'estate64'] |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 294 | |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 295 | return attrs |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 296 | |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 297 | |
Pablo Marquez Tello | 9f7aca9 | 2023-08-16 15:21:44 +0100 | [diff] [blame] | 298 | def get_operator_backend_files(filelist, operators, backend='', techs=[], attrs=[], include_common=True): |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 299 | files = { "common" : [] } |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 300 | # Early return if filelist is empty |
| 301 | if backend not in filelist: |
| 302 | return files |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 303 | # Iterate over operators and create the file lists to compiler |
| 304 | for operator in operators: |
| 305 | if operator in filelist[backend]['operators']: |
Pablo Marquez Tello | 9f7aca9 | 2023-08-16 15:21:44 +0100 | [diff] [blame] | 306 | if include_common : |
| 307 | files['common'] += filelist[backend]['operators'][operator]["files"]["common"] |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 308 | for tech in techs: |
| 309 | if tech in filelist[backend]['operators'][operator]["files"]: |
| 310 | # Add tech as a key to dictionary if not there |
| 311 | if tech not in files: |
| 312 | files[tech] = [] |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 313 | # Add tech files to the tech file list |
| 314 | tech_files = filelist[backend]['operators'][operator]["files"][tech] |
Pablo Marquez Tello | 9f7aca9 | 2023-08-16 15:21:44 +0100 | [diff] [blame] | 315 | if include_common: |
| 316 | files[tech] += tech_files.get('common', []) |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 317 | for attr in attrs: |
| 318 | files[tech] += tech_files.get(attr, []) |
| 319 | |
Pablo Marquez Tello | 9f7aca9 | 2023-08-16 15:21:44 +0100 | [diff] [blame] | 320 | |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 321 | # Remove duplicates if they exist |
| 322 | return {k: list(set(v)) for k,v in files.items()} |
| 323 | |
| 324 | def collect_operators(filelist, operators, backend=''): |
| 325 | ops = set() |
| 326 | for operator in operators: |
| 327 | if operator in filelist[backend]['operators']: |
| 328 | ops.add(operator) |
| 329 | if 'deps' in filelist[backend]['operators'][operator]: |
| 330 | ops.update(filelist[backend]['operators'][operator]['deps']) |
| 331 | else: |
| 332 | print("Operator {0} is unsupported on {1} backend!".format(operator, backend)) |
| 333 | |
| 334 | return ops |
| 335 | |
| 336 | |
| 337 | def resolve_operator_dependencies(filelist, operators, backend=''): |
| 338 | resolved_operators = collect_operators(filelist, operators, backend) |
| 339 | |
| 340 | are_ops_resolved = False |
| 341 | while not are_ops_resolved: |
| 342 | resolution_pass = collect_operators(filelist, resolved_operators, backend) |
| 343 | if len(resolution_pass) != len(resolved_operators): |
| 344 | resolved_operators.update(resolution_pass) |
| 345 | else: |
| 346 | are_ops_resolved = True |
| 347 | |
| 348 | return resolved_operators |
| 349 | |
Freddie Liardet | 487d390 | 2021-09-21 12:36:43 +0100 | [diff] [blame] | 350 | def read_build_config_json(build_config): |
| 351 | build_config_contents = {} |
| 352 | custom_operators = [] |
| 353 | custom_types = [] |
| 354 | custom_layouts = [] |
| 355 | if os.path.isfile(build_config): |
| 356 | with open(build_config) as f: |
| 357 | try: |
| 358 | build_config_contents = json.load(f) |
| 359 | except: |
| 360 | print("Warning: Build configuration file is of invalid JSON format!") |
| 361 | else: |
| 362 | try: |
| 363 | build_config_contents = json.loads(build_config) |
| 364 | except: |
| 365 | print("Warning: Build configuration string is of invalid JSON format!") |
| 366 | if build_config_contents: |
| 367 | custom_operators = build_config_contents.get("operators", []) |
| 368 | custom_types = build_config_contents.get("data_types", []) |
| 369 | custom_layouts = build_config_contents.get("data_layouts", []) |
| 370 | return custom_operators, custom_types, custom_layouts |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 371 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 372 | arm_compute_env = env.Clone() |
Anthony Barbier | 0e72c69 | 2018-08-24 11:22:08 +0100 | [diff] [blame] | 373 | version_file = arm_compute_env.Command("src/core/arm_compute_version.embed", "", action=create_version_file) |
| 374 | arm_compute_env.AlwaysBuild(version_file) |
Anthony Barbier | 6a3daf1 | 2018-02-19 17:24:27 +0000 | [diff] [blame] | 375 | |
Kevin Lo | 7195f71 | 2022-01-07 15:46:02 +0800 | [diff] [blame] | 376 | default_cpp_compiler = 'g++' if env['os'] not in ['android', 'macos', 'openbsd'] else 'clang++' |
Georgios Pinitas | 4d9687e | 2020-10-21 18:33:36 +0100 | [diff] [blame] | 377 | cpp_compiler = os.environ.get('CXX', default_cpp_compiler) |
| 378 | |
Anthony Barbier | 6a3daf1 | 2018-02-19 17:24:27 +0000 | [diff] [blame] | 379 | # Generate embed files |
Anthony Barbier | 0e72c69 | 2018-08-24 11:22:08 +0100 | [diff] [blame] | 380 | generate_embed = [ version_file ] |
Anthony Barbier | 6a3daf1 | 2018-02-19 17:24:27 +0000 | [diff] [blame] | 381 | if env['opencl'] and env['embed_kernels']: |
Giorgio Arena | 892b70a | 2022-03-30 12:23:10 +0100 | [diff] [blame] | 382 | |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 383 | # Header files |
| 384 | cl_helper_files = [ 'src/core/CL/cl_kernels/activation_float_helpers.h', |
| 385 | 'src/core/CL/cl_kernels/activation_quant_helpers.h', |
| 386 | 'src/core/CL/cl_kernels/gemm_helpers.h', |
| 387 | 'src/core/CL/cl_kernels/helpers_asymm.h', |
| 388 | 'src/core/CL/cl_kernels/helpers.h', |
| 389 | 'src/core/CL/cl_kernels/load_store_utility.h', |
| 390 | 'src/core/CL/cl_kernels/repeat.h', |
| 391 | 'src/core/CL/cl_kernels/tile_helpers.h', |
| 392 | 'src/core/CL/cl_kernels/types.h', |
SiCongLi | 1af5416 | 2021-10-06 15:25:57 +0100 | [diff] [blame] | 393 | 'src/core/CL/cl_kernels/warp_helpers.h', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 394 | ] |
Anthony Barbier | 6a3daf1 | 2018-02-19 17:24:27 +0000 | [diff] [blame] | 395 | |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 396 | # Common kernels |
| 397 | cl_files_common = ['src/core/CL/cl_kernels/common/activation_layer.cl', |
| 398 | 'src/core/CL/cl_kernels/common/activation_layer_quant.cl', |
| 399 | 'src/core/CL/cl_kernels/common/arg_min_max.cl', |
| 400 | 'src/core/CL/cl_kernels/common/batchnormalization_layer.cl', |
| 401 | 'src/core/CL/cl_kernels/common/bounding_box_transform.cl', |
| 402 | 'src/core/CL/cl_kernels/common/bounding_box_transform_quantized.cl', |
| 403 | 'src/core/CL/cl_kernels/common/bitwise_op.cl', |
| 404 | 'src/core/CL/cl_kernels/common/cast.cl', |
| 405 | 'src/core/CL/cl_kernels/common/comparisons.cl', |
| 406 | 'src/core/CL/cl_kernels/common/concatenate.cl', |
Ramy Elgammal | 2b6ebfe | 2023-03-09 21:15:37 +0000 | [diff] [blame] | 407 | 'src/core/CL/cl_kernels/common/convolution_layer.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 408 | 'src/core/CL/cl_kernels/common/col2im.cl', |
| 409 | 'src/core/CL/cl_kernels/common/convert_fc_weights.cl', |
| 410 | 'src/core/CL/cl_kernels/common/copy_tensor.cl', |
| 411 | 'src/core/CL/cl_kernels/common/crop_tensor.cl', |
| 412 | 'src/core/CL/cl_kernels/common/deconvolution_layer.cl', |
| 413 | 'src/core/CL/cl_kernels/common/dequantization_layer.cl', |
| 414 | 'src/core/CL/cl_kernels/common/elementwise_operation.cl', |
| 415 | 'src/core/CL/cl_kernels/common/elementwise_operation_quantized.cl', |
| 416 | 'src/core/CL/cl_kernels/common/elementwise_unary.cl', |
Ramy Elgammal | 14d7b53 | 2023-01-30 04:56:47 +0000 | [diff] [blame] | 417 | 'src/core/CL/cl_kernels/common/elementwise_unary_quantized.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 418 | 'src/core/CL/cl_kernels/common/fft_digit_reverse.cl', |
| 419 | 'src/core/CL/cl_kernels/common/fft.cl', |
| 420 | 'src/core/CL/cl_kernels/common/fft_scale.cl', |
| 421 | 'src/core/CL/cl_kernels/common/fill_border.cl', |
| 422 | 'src/core/CL/cl_kernels/common/floor.cl', |
| 423 | 'src/core/CL/cl_kernels/common/gather.cl', |
| 424 | 'src/core/CL/cl_kernels/common/gemm.cl', |
Gunes Bayir | 4bfc70e | 2021-12-10 16:17:56 +0000 | [diff] [blame] | 425 | 'src/core/CL/cl_kernels/common/gemm_reshaped_only_rhs_mmul.cl', |
ramelg01 | 9cca592 | 2021-11-11 10:05:00 +0000 | [diff] [blame] | 426 | 'src/core/CL/cl_kernels/common/gemm_utils.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 427 | 'src/core/CL/cl_kernels/common/gemmlowp.cl', |
Freddie Liardet | e572dff | 2022-05-16 14:09:10 +0100 | [diff] [blame] | 428 | 'src/core/CL/cl_kernels/common/gemmlowp_reshaped_only_rhs_mmul.cl', |
Ramy Elgammal | 2b6ebfe | 2023-03-09 21:15:37 +0000 | [diff] [blame] | 429 | 'src/core/CL/cl_kernels/common/gemv.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 430 | 'src/core/CL/cl_kernels/common/generate_proposals.cl', |
| 431 | 'src/core/CL/cl_kernels/common/generate_proposals_quantized.cl', |
| 432 | 'src/core/CL/cl_kernels/common/instance_normalization.cl', |
| 433 | 'src/core/CL/cl_kernels/common/l2_normalize.cl', |
Ramy Elgammal | 2b6ebfe | 2023-03-09 21:15:37 +0000 | [diff] [blame] | 434 | 'src/core/CL/cl_kernels/common/mat_mul.cl', |
SiCong Li | a8d8058 | 2023-05-19 14:23:37 +0100 | [diff] [blame] | 435 | 'src/core/CL/cl_kernels/common/mat_mul_mmul.cl', |
Gunes Bayir | 9d0c4de | 2023-04-13 18:22:58 +0100 | [diff] [blame] | 436 | 'src/core/CL/cl_kernels/common/mat_mul_quantized.cl', |
Gunes Bayir | e87fa66 | 2023-09-07 12:20:33 +0100 | [diff] [blame] | 437 | 'src/core/CL/cl_kernels/common/mat_mul_quantized_mmul.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 438 | 'src/core/CL/cl_kernels/common/mean_stddev_normalization.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 439 | 'src/core/CL/cl_kernels/common/memset.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 440 | 'src/core/CL/cl_kernels/common/minmax_layer.cl', |
Ramy Elgammal | 2b6ebfe | 2023-03-09 21:15:37 +0000 | [diff] [blame] | 441 | 'src/core/CL/cl_kernels/common/nonmax.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 442 | 'src/core/CL/cl_kernels/common/pad_layer.cl', |
| 443 | 'src/core/CL/cl_kernels/common/permute.cl', |
| 444 | 'src/core/CL/cl_kernels/common/pixelwise_mul_float.cl', |
| 445 | 'src/core/CL/cl_kernels/common/pixelwise_mul_int.cl', |
| 446 | 'src/core/CL/cl_kernels/common/qlstm_layer_normalization.cl', |
| 447 | 'src/core/CL/cl_kernels/common/quantization_layer.cl', |
| 448 | 'src/core/CL/cl_kernels/common/range.cl', |
| 449 | 'src/core/CL/cl_kernels/common/reduction_operation.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 450 | 'src/core/CL/cl_kernels/common/reshape_layer.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 451 | 'src/core/CL/cl_kernels/common/reverse.cl', |
| 452 | 'src/core/CL/cl_kernels/common/roi_align_layer.cl', |
| 453 | 'src/core/CL/cl_kernels/common/roi_align_layer_quantized.cl', |
| 454 | 'src/core/CL/cl_kernels/common/roi_pooling_layer.cl', |
| 455 | 'src/core/CL/cl_kernels/common/select.cl', |
Ramy Elgammal | 2b6ebfe | 2023-03-09 21:15:37 +0000 | [diff] [blame] | 456 | 'src/core/CL/cl_kernels/common/slice_ops.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 457 | 'src/core/CL/cl_kernels/common/softmax_layer.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 458 | 'src/core/CL/cl_kernels/common/stack_layer.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 459 | 'src/core/CL/cl_kernels/common/tile.cl', |
Ramy Elgammal | 2b6ebfe | 2023-03-09 21:15:37 +0000 | [diff] [blame] | 460 | 'src/core/CL/cl_kernels/common/transpose.cl', |
| 461 | 'src/core/CL/cl_kernels/common/unpooling_layer.cl' |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 462 | ] |
| 463 | |
| 464 | # NCHW kernels |
| 465 | cl_files_nchw = ['src/core/CL/cl_kernels/nchw/batch_to_space.cl', |
| 466 | 'src/core/CL/cl_kernels/nchw/batchnormalization_layer.cl', |
| 467 | 'src/core/CL/cl_kernels/nchw/channel_shuffle.cl', |
| 468 | 'src/core/CL/cl_kernels/nchw/depth_to_space.cl', |
Adnan AlSinan | 3012435 | 2021-12-02 19:12:20 +0000 | [diff] [blame] | 469 | 'src/core/CL/cl_kernels/nchw/direct_convolution.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 470 | 'src/core/CL/cl_kernels/nchw/dequantization_layer.cl', |
| 471 | 'src/core/CL/cl_kernels/nchw/im2col.cl', |
| 472 | 'src/core/CL/cl_kernels/nchw/normalization_layer.cl', |
| 473 | 'src/core/CL/cl_kernels/nchw/normalize_planar_yuv_layer.cl', |
| 474 | 'src/core/CL/cl_kernels/nchw/normalize_planar_yuv_layer_quantized.cl', |
| 475 | 'src/core/CL/cl_kernels/nchw/pooling_layer.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 476 | 'src/core/CL/cl_kernels/nchw/prior_box_layer.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 477 | 'src/core/CL/cl_kernels/nchw/reorg_layer.cl', |
| 478 | 'src/core/CL/cl_kernels/nchw/scale.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 479 | 'src/core/CL/cl_kernels/nchw/space_to_batch.cl', |
| 480 | 'src/core/CL/cl_kernels/nchw/space_to_depth.cl', |
| 481 | 'src/core/CL/cl_kernels/nchw/upsample_layer.cl', |
| 482 | 'src/core/CL/cl_kernels/nchw/winograd_filter_transform.cl', |
| 483 | 'src/core/CL/cl_kernels/nchw/winograd_input_transform.cl', |
| 484 | 'src/core/CL/cl_kernels/nchw/winograd_output_transform.cl' |
| 485 | ] |
| 486 | |
| 487 | # NHWC kernels |
| 488 | cl_files_nhwc = ['src/core/CL/cl_kernels/nhwc/batch_to_space.cl', |
| 489 | 'src/core/CL/cl_kernels/nhwc/batchnormalization_layer.cl', |
| 490 | 'src/core/CL/cl_kernels/nhwc/channel_shuffle.cl', |
| 491 | 'src/core/CL/cl_kernels/nhwc/direct_convolution.cl', |
Giorgio Arena | 945ae9e | 2021-10-13 11:13:04 +0100 | [diff] [blame] | 492 | 'src/core/CL/cl_kernels/nhwc/direct_convolution3d.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 493 | 'src/core/CL/cl_kernels/nhwc/depth_to_space.cl', |
| 494 | 'src/core/CL/cl_kernels/nhwc/dequantization_layer.cl', |
| 495 | 'src/core/CL/cl_kernels/nhwc/dwc_native_fp_nhwc.cl', |
| 496 | 'src/core/CL/cl_kernels/nhwc/dwc_native_quantized_nhwc.cl', |
| 497 | 'src/core/CL/cl_kernels/nhwc/im2col.cl', |
Gian Marco Iodice | 5d01681 | 2022-11-17 11:03:39 +0000 | [diff] [blame] | 498 | 'src/core/CL/cl_kernels/nhwc/indirect_convolution.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 499 | 'src/core/CL/cl_kernels/nhwc/normalization_layer.cl', |
| 500 | 'src/core/CL/cl_kernels/nhwc/normalize_planar_yuv_layer.cl', |
| 501 | 'src/core/CL/cl_kernels/nhwc/normalize_planar_yuv_layer_quantized.cl', |
| 502 | 'src/core/CL/cl_kernels/nhwc/pooling_layer.cl', |
ramelg01 | 3751569 | 2022-02-26 22:06:20 +0000 | [diff] [blame] | 503 | 'src/core/CL/cl_kernels/nhwc/pooling_3d_layer.cl', |
Mohammed Suhail Munshi | 5e549fa | 2022-03-16 11:14:06 +0000 | [diff] [blame] | 504 | 'src/core/CL/cl_kernels/nhwc/pooling_3d_layer_quantized.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 505 | 'src/core/CL/cl_kernels/nhwc/pooling_layer_quantized.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 506 | 'src/core/CL/cl_kernels/nhwc/reorg_layer.cl', |
| 507 | 'src/core/CL/cl_kernels/nhwc/scale.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 508 | 'src/core/CL/cl_kernels/nhwc/space_to_batch.cl', |
| 509 | 'src/core/CL/cl_kernels/nhwc/space_to_depth.cl', |
Gunes Bayir | ec0113d | 2022-11-09 09:26:27 +0000 | [diff] [blame] | 510 | 'src/core/CL/cl_kernels/nhwc/transposed_convolution.cl', |
Adnan AlSinan | 7075fe2 | 2021-07-05 13:12:52 +0100 | [diff] [blame] | 511 | 'src/core/CL/cl_kernels/nhwc/upsample_layer.cl', |
| 512 | 'src/core/CL/cl_kernels/nhwc/winograd_filter_transform.cl', |
| 513 | 'src/core/CL/cl_kernels/nhwc/winograd_input_transform.cl', |
| 514 | 'src/core/CL/cl_kernels/nhwc/winograd_output_transform.cl' |
| 515 | ] |
| 516 | |
| 517 | cl_files = cl_helper_files + cl_files_common + cl_files_nchw + cl_files_nhwc |
| 518 | |
| 519 | embed_files = [ f+"embed" for f in cl_files ] |
Anthony Barbier | 6a3daf1 | 2018-02-19 17:24:27 +0000 | [diff] [blame] | 520 | arm_compute_env.Append(CPPPATH =[Dir("./src/core/CL/").path] ) |
| 521 | |
| 522 | generate_embed.append(arm_compute_env.Command(embed_files, cl_files, action=resolve_includes)) |
| 523 | |
Anthony Barbier | 6a3daf1 | 2018-02-19 17:24:27 +0000 | [diff] [blame] | 524 | Default(generate_embed) |
| 525 | if env["build"] == "embed_only": |
| 526 | Return() |
| 527 | |
Georgios Pinitas | 35fcc43 | 2020-03-26 18:47:46 +0000 | [diff] [blame] | 528 | # Append version defines for semantic versioning |
| 529 | arm_compute_env.Append(CPPDEFINES = [('ARM_COMPUTE_VERSION_MAJOR', LIBRARY_VERSION_MAJOR), |
| 530 | ('ARM_COMPUTE_VERSION_MINOR', LIBRARY_VERSION_MINOR), |
| 531 | ('ARM_COMPUTE_VERSION_PATCH', LIBRARY_VERSION_PATCH)]) |
| 532 | |
Isabella Gottardi | b28f29d | 2017-11-09 17:05:07 +0000 | [diff] [blame] | 533 | # Don't allow undefined references in the libraries: |
Georgios Pinitas | 4551403 | 2020-12-30 00:03:09 +0000 | [diff] [blame] | 534 | undefined_flag = '-Wl,-undefined,error' if 'macos' in arm_compute_env["os"] else '-Wl,--no-undefined' |
Jakub Sujak | 7ab7fca | 2024-01-31 17:20:07 +0000 | [diff] [blame] | 535 | if not env['thread_sanitizer'] and not env['address_sanitizer'] and not env['undefined_sanitizer']: |
Matthew Bentham | 0a59e69 | 2023-07-19 15:01:00 +0000 | [diff] [blame] | 536 | arm_compute_env.Append(LINKFLAGS=[undefined_flag]) |
Jakub Sujak | b5d6082 | 2024-01-28 18:30:50 +0000 | [diff] [blame] | 537 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 538 | arm_compute_env.Append(CPPPATH =[Dir("./src/core/").path] ) |
| 539 | |
Kevin Lo | 7195f71 | 2022-01-07 15:46:02 +0800 | [diff] [blame] | 540 | if env['os'] != 'openbsd': |
Pablo Tello | fbbfa53 | 2023-01-26 16:24:04 +0000 | [diff] [blame] | 541 | if env['os'] == 'windows': |
| 542 | arm_compute_env.Append(LIBS = []) |
| 543 | else: |
| 544 | arm_compute_env.Append(LIBS = ['dl']) |
| 545 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 546 | |
Motti Gondabi | 6f3a9f5 | 2021-11-09 15:47:17 +0200 | [diff] [blame] | 547 | # Load build definitions file |
| 548 | with (open(Dir('#').path + '/filedefs.json')) as fd: |
| 549 | filedefs = json.load(fd) |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 550 | filedefs = filedefs['cpu']['arch'] |
Motti Gondabi | 6f3a9f5 | 2021-11-09 15:47:17 +0200 | [diff] [blame] | 551 | |
| 552 | |
Georgios Pinitas | bdcdc39 | 2021-04-22 16:42:03 +0100 | [diff] [blame] | 553 | with (open(Dir('#').path + '/filelist.json')) as fp: |
| 554 | filelist = json.load(fp) |
| 555 | |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 556 | # Common backend files |
| 557 | lib_files = filelist['common'] |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 558 | |
Nathan John Sircombe | d7113e4 | 2023-04-26 15:02:43 +0100 | [diff] [blame] | 559 | # Fixed format GEMM kernels. |
| 560 | if env['fixed_format_kernels']: |
| 561 | arm_compute_env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS']) |
| 562 | |
Giorgio Arena | 232c452 | 2022-03-03 10:09:01 +0000 | [diff] [blame] | 563 | # Experimental files |
| 564 | # Dynamic fusion |
| 565 | if env['experimental_dynamic_fusion']: |
SiCong Li | 23882a9 | 2023-06-28 09:49:45 +0100 | [diff] [blame] | 566 | lib_files += filelist['experimental']['dynamic_fusion']['common'] |
SiCong Li | 23882a9 | 2023-06-28 09:49:45 +0100 | [diff] [blame] | 567 | lib_files += filelist['experimental']['dynamic_fusion']['ckw_driver'] |
Giorgio Arena | 232c452 | 2022-03-03 10:09:01 +0000 | [diff] [blame] | 568 | |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 569 | # Logging files |
| 570 | if env["logging"]: |
| 571 | lib_files += filelist['logging'] |
Georgios Pinitas | 8795ffb | 2017-12-01 16:13:40 +0000 | [diff] [blame] | 572 | |
Georgios Pinitas | c3c352e | 2021-03-18 10:59:40 +0000 | [diff] [blame] | 573 | # C API files |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 574 | lib_files += filelist['c_api']['common'] |
| 575 | lib_files += filelist['c_api']['operators'] |
Georgios Pinitas | bdcdc39 | 2021-04-22 16:42:03 +0100 | [diff] [blame] | 576 | |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 577 | # Scheduler infrastructure |
| 578 | lib_files += filelist['scheduler']['single'] |
| 579 | if env['cppthreads']: |
| 580 | lib_files += filelist['scheduler']['threads'] |
| 581 | if env['openmp']: |
| 582 | lib_files += filelist['scheduler']['omp'] |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 583 | |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 584 | # Graph files |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 585 | graph_files = Glob('src/graph/*.cpp') |
| 586 | graph_files += Glob('src/graph/*/*.cpp') |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 587 | |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 588 | # Specify user-defined priority operators |
Freddie Liardet | 487d390 | 2021-09-21 12:36:43 +0100 | [diff] [blame] | 589 | custom_operators = [] |
| 590 | custom_types = [] |
| 591 | custom_layouts = [] |
| 592 | |
Jakub Sujak | e86f992 | 2023-07-05 17:30:02 +0100 | [diff] [blame] | 593 | use_custom_ops = env['high_priority'] or env['build_config'] |
Freddie Liardet | 487d390 | 2021-09-21 12:36:43 +0100 | [diff] [blame] | 594 | |
| 595 | if env['high_priority']: |
| 596 | custom_operators = filelist['high_priority'] |
| 597 | custom_types = ['all'] |
| 598 | custom_layouts = ['all'] |
| 599 | |
| 600 | if env['build_config']: |
| 601 | custom_operators, custom_types, custom_layouts = read_build_config_json(env['build_config']) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 602 | |
| 603 | if env['opencl']: |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 604 | lib_files += filelist['c_api']['gpu'] |
| 605 | lib_files += filelist['gpu']['common'] |
Michele Di Giorgio | 760c783 | 2021-08-05 10:54:13 +0100 | [diff] [blame] | 606 | |
Freddie Liardet | 487d390 | 2021-09-21 12:36:43 +0100 | [diff] [blame] | 607 | cl_operators = custom_operators if use_custom_ops else filelist['gpu']['operators'].keys() |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 608 | cl_ops_to_build = resolve_operator_dependencies(filelist, cl_operators, 'gpu') |
| 609 | lib_files += get_operator_backend_files(filelist, cl_ops_to_build, 'gpu')['common'] |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 610 | |
Georgios Pinitas | 13ef176 | 2021-07-14 17:14:43 +0100 | [diff] [blame] | 611 | graph_files += Glob('src/graph/backends/CL/*.cpp') |
| 612 | |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 613 | |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 614 | lib_files_sve = [] |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 615 | lib_files_sve2 = [] |
Motti Gondabi | 6f3a9f5 | 2021-11-09 15:47:17 +0200 | [diff] [blame] | 616 | |
Pablo Marquez Tello | 9f7aca9 | 2023-08-16 15:21:44 +0100 | [diff] [blame] | 617 | # the variables below are used for the multi_isa builds |
| 618 | # please note that the variables names without the _fp16 suffix |
| 619 | # do not hold any fp16 files. |
| 620 | |
| 621 | misa_lib_files = lib_files |
| 622 | misa_lib_files_sve = [] |
| 623 | misa_lib_files_sve2 = [] |
| 624 | misa_lib_files_neon_fp16 = [] |
| 625 | misa_lib_files_sve_fp16 = [] |
| 626 | misa_lib_files_sve2_fp16 = [] |
| 627 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 628 | if env['neon']: |
Georgios Pinitas | 30271c7 | 2019-06-24 14:56:34 +0100 | [diff] [blame] | 629 | # build winograd/depthwise sources for either v7a / v8a |
Michael Tyler | 74921ee | 2023-04-12 17:43:17 +0100 | [diff] [blame] | 630 | arm_compute_env.Append(CPPPATH = ["src/core/NEON/kernels/arm_gemm", |
| 631 | "src/core/NEON/kernels/convolution/common/", |
Michele Di Giorgio | 6ad60af | 2020-06-09 14:52:15 +0100 | [diff] [blame] | 632 | "src/core/NEON/kernels/convolution/winograd/", |
ramelg01 | c827e99 | 2022-04-08 03:52:28 +0100 | [diff] [blame] | 633 | "src/core/NEON/kernels/arm_conv/depthwise/", |
| 634 | "src/core/NEON/kernels/arm_conv/pooling/", |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 635 | "src/core/NEON/kernels/arm_conv/", |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame] | 636 | "src/core/NEON/kernels/assembly/", |
Sang-Hoon Park | 4f7693d | 2021-05-12 13:59:10 +0100 | [diff] [blame] | 637 | "arm_compute/core/NEON/kernels/assembly/", |
Motti Gondabi | 6f3a9f5 | 2021-11-09 15:47:17 +0200 | [diff] [blame] | 638 | "src/cpu/kernels/assembly/"]) |
Pablo Tello | 9ceebbe | 2018-01-10 16:44:13 +0000 | [diff] [blame] | 639 | |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 640 | # Setup SIMD file list to include |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 641 | simd = ['neon'] |
| 642 | if env['multi_isa']: |
| 643 | simd += ['sve', 'sve2'] |
| 644 | else: |
| 645 | if 'sve' in env['arch']: simd += ['sve'] |
| 646 | if 'sve2' in env['arch']: simd += ['sve2'] |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 647 | |
| 648 | # Get attributes |
Freddie Liardet | 487d390 | 2021-09-21 12:36:43 +0100 | [diff] [blame] | 649 | if(use_custom_ops): |
| 650 | attrs = get_attrs_list(env, custom_types, custom_layouts) |
| 651 | else: |
| 652 | attrs = get_attrs_list(env, env['data_type_support'], env['data_layout_support']) |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 653 | |
Nathan John Sircombe | d7113e4 | 2023-04-26 15:02:43 +0100 | [diff] [blame] | 654 | if env['fixed_format_kernels']: |
| 655 | attrs.append("fixed_format_kernels") |
Francesco.Petrogalli@arm.com | 5fcf22d | 2022-04-05 10:31:08 +0000 | [diff] [blame] | 656 | |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 657 | # Setup data-type and data-layout files to include |
Freddie Liardet | 487d390 | 2021-09-21 12:36:43 +0100 | [diff] [blame] | 658 | cpu_operators = custom_operators if use_custom_ops else filelist['cpu']['operators'].keys() |
| 659 | cpu_ops_to_build = resolve_operator_dependencies(filelist, cpu_operators, 'cpu') |
| 660 | |
Pablo Marquez Tello | 9f7aca9 | 2023-08-16 15:21:44 +0100 | [diff] [blame] | 661 | if env['multi_isa']: |
| 662 | misa_lib_files += filelist['cpu']['common'] |
Motti Gondabi | 6f3a9f5 | 2021-11-09 15:47:17 +0200 | [diff] [blame] | 663 | |
Pablo Marquez Tello | 9f7aca9 | 2023-08-16 15:21:44 +0100 | [diff] [blame] | 664 | # For multi_isa builds we need to build fp16 files for armv8.2-a+fp16 so we filter them out of cpu_files removing the attribute fp16 |
| 665 | attrs.remove('fp16') |
| 666 | cpu_files = get_operator_backend_files(filelist, cpu_ops_to_build, 'cpu', simd, attrs) |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 667 | |
Pablo Marquez Tello | 9f7aca9 | 2023-08-16 15:21:44 +0100 | [diff] [blame] | 668 | # Shared among ALL CPU files |
| 669 | misa_lib_files += cpu_files.get('common', []) |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 670 | |
Pablo Marquez Tello | 9f7aca9 | 2023-08-16 15:21:44 +0100 | [diff] [blame] | 671 | # Arm® Neon™ specific files |
| 672 | misa_lib_files += cpu_files.get('neon', []) |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 673 | |
Pablo Marquez Tello | 9f7aca9 | 2023-08-16 15:21:44 +0100 | [diff] [blame] | 674 | # Get all the fp16 files |
| 675 | fp16_cpu_files = get_operator_backend_files(filelist, cpu_ops_to_build, 'cpu', simd, ['fp16'],False) |
| 676 | |
| 677 | misa_lib_files_neon_fp16 = fp16_cpu_files.get('neon',[]) |
| 678 | misa_lib_files_sve_fp16 = fp16_cpu_files.get('sve',[]) |
| 679 | misa_lib_files_sve2_fp16 = fp16_cpu_files.get('sve2',[]) |
| 680 | |
| 681 | # SVE files only minus FP16 |
| 682 | misa_lib_files_sve = cpu_files.get('sve', []) |
| 683 | |
| 684 | # SVE2 files only minus FP16 |
| 685 | misa_lib_files_sve2 = cpu_files.get('sve2', []) |
| 686 | else: |
| 687 | lib_files += filelist['cpu']['common'] |
| 688 | |
| 689 | # Non multi_isa build |
| 690 | cpu_files = get_operator_backend_files(filelist, cpu_ops_to_build, 'cpu', simd, attrs) |
| 691 | |
| 692 | # Shared among ALL CPU files |
| 693 | lib_files += cpu_files.get('common', []) |
| 694 | |
| 695 | # Arm® Neon™ specific files |
| 696 | lib_files += cpu_files.get('neon', []) |
| 697 | |
| 698 | lib_files_sve = cpu_files.get('sve', []) |
| 699 | |
| 700 | lib_files_sve2 = cpu_files.get('sve2', []) |
Georgios Pinitas | 13ef176 | 2021-07-14 17:14:43 +0100 | [diff] [blame] | 701 | |
| 702 | graph_files += Glob('src/graph/backends/NEON/*.cpp') |
Georgios Pinitas | 70eb53b | 2021-01-06 19:42:21 +0000 | [diff] [blame] | 703 | |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 704 | # Restrict from building graph API if a reduced operator list has been provided |
Freddie Liardet | 487d390 | 2021-09-21 12:36:43 +0100 | [diff] [blame] | 705 | if use_custom_ops: |
| 706 | print("WARNING: Graph library requires all operators to be built") |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 707 | graph_files = [] |
| 708 | |
| 709 | # Build bootcode in case of bare-metal |
Michalis Spyrou | 748a7c8 | 2019-10-07 13:00:44 +0100 | [diff] [blame] | 710 | bootcode_o = [] |
| 711 | if env['os'] == 'bare_metal': |
| 712 | bootcode_files = Glob('bootcode/*.s') |
| 713 | bootcode_o = build_bootcode_objs(bootcode_files) |
| 714 | Export('bootcode_o') |
| 715 | |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 716 | |
Motti Gondabi | 6f3a9f5 | 2021-11-09 15:47:17 +0200 | [diff] [blame] | 717 | if (env['multi_isa']): |
Pablo Marquez Tello | 9f7aca9 | 2023-08-16 15:21:44 +0100 | [diff] [blame] | 718 | lib_static_objs, lib_shared_objs = build_multiisa_lib_objects() |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 719 | |
| 720 | |
| 721 | # STATIC library build. |
| 722 | if (env['multi_isa']): |
| 723 | arm_compute_a = build_library('arm_compute-static', arm_compute_env, lib_static_objs, static=True) |
| 724 | else: |
| 725 | if 'sve2' in env['arch']: |
| 726 | lib_files += lib_files_sve |
| 727 | lib_files += lib_files_sve2 |
| 728 | elif 'sve' in env['arch']: |
| 729 | lib_files += lib_files_sve |
Motti Gondabi | 6f3a9f5 | 2021-11-09 15:47:17 +0200 | [diff] [blame] | 730 | |
Motti Gondabi | f76a502 | 2021-12-21 13:19:29 +0200 | [diff] [blame] | 731 | arm_compute_a = build_library('arm_compute-static', arm_compute_env, lib_files, static=True) |
Motti Gondabi | f76a502 | 2021-12-21 13:19:29 +0200 | [diff] [blame] | 732 | |
Michalis Spyrou | 62c2ad6 | 2021-06-21 17:40:09 +0100 | [diff] [blame] | 733 | Export('arm_compute_a') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 734 | |
Motti Gondabi | f76a502 | 2021-12-21 13:19:29 +0200 | [diff] [blame] | 735 | # SHARED library build. |
Pablo Tello | c6cb35a | 2017-06-21 15:39:47 +0100 | [diff] [blame] | 736 | if env['os'] != 'bare_metal' and not env['standalone']: |
Motti Gondabi | 6f3a9f5 | 2021-11-09 15:47:17 +0200 | [diff] [blame] | 737 | if (env['multi_isa']): |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 738 | |
| 739 | arm_compute_so = build_library('arm_compute', arm_compute_env, lib_shared_objs, static=False) |
Georgios Pinitas | bdcdc39 | 2021-04-22 16:42:03 +0100 | [diff] [blame] | 740 | else: |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 741 | arm_compute_so = build_library('arm_compute', arm_compute_env, lib_files, static=False) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 742 | |
Michalis Spyrou | 62c2ad6 | 2021-06-21 17:40:09 +0100 | [diff] [blame] | 743 | Export('arm_compute_so') |
| 744 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 745 | |
Sang-Hoon Park | 18fbb92 | 2021-01-14 14:50:25 +0000 | [diff] [blame] | 746 | arm_compute_graph_env = arm_compute_env.Clone() |
| 747 | |
Georgios Pinitas | b6af482 | 2021-09-14 12:33:34 +0100 | [diff] [blame] | 748 | # Build graph libraries |
Sang-Hoon Park | 18fbb92 | 2021-01-14 14:50:25 +0000 | [diff] [blame] | 749 | arm_compute_graph_env.Append(CXXFLAGS = ['-Wno-redundant-move', '-Wno-pessimizing-move']) |
| 750 | |
Jakub Sujak | e86f992 | 2023-07-05 17:30:02 +0100 | [diff] [blame] | 751 | arm_compute_graph_a = build_library('arm_compute_graph-static', arm_compute_graph_env, graph_files, static=True) |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 752 | Export('arm_compute_graph_a') |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 753 | |
| 754 | if env['os'] != 'bare_metal' and not env['standalone']: |
Michalis Spyrou | 62c2ad6 | 2021-06-21 17:40:09 +0100 | [diff] [blame] | 755 | arm_compute_graph_so = build_library('arm_compute_graph', arm_compute_graph_env, graph_files, static=False, libs = [ "arm_compute" ]) |
Georgios Pinitas | 9873ea3 | 2017-12-05 15:28:55 +0000 | [diff] [blame] | 756 | Depends(arm_compute_graph_so, arm_compute_so) |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 757 | Export('arm_compute_graph_so') |
| 758 | |
Pablo Tello | c6cb35a | 2017-06-21 15:39:47 +0100 | [diff] [blame] | 759 | if env['standalone']: |
Motti Gondabi | 9d9ad33 | 2022-01-23 12:42:24 +0200 | [diff] [blame] | 760 | alias = arm_compute_env.Alias("arm_compute", [arm_compute_a]) |
Pablo Tello | c6cb35a | 2017-06-21 15:39:47 +0100 | [diff] [blame] | 761 | else: |
| 762 | alias = arm_compute_env.Alias("arm_compute", [arm_compute_a, arm_compute_so]) |
| 763 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 764 | Default(alias) |
| 765 | |
Pablo Tello | c6cb35a | 2017-06-21 15:39:47 +0100 | [diff] [blame] | 766 | if env['standalone']: |
Michalis Spyrou | 62c2ad6 | 2021-06-21 17:40:09 +0100 | [diff] [blame] | 767 | Depends([alias], generate_embed) |
Pablo Tello | c6cb35a | 2017-06-21 15:39:47 +0100 | [diff] [blame] | 768 | else: |
Michalis Spyrou | 62c2ad6 | 2021-06-21 17:40:09 +0100 | [diff] [blame] | 769 | Depends([alias], generate_embed) |