blob: c9a56ede766e49ad215af86555dde65abc1db608 [file] [log] [blame]
Motti Gondabi9d9ad332022-01-23 12:42:24 +02001#!/usr/bin/python
2# -*- coding: utf-8 -*-
3
Pablo Tellofbbfa532023-01-26 16:24:04 +00004# Copyright (c) 2016-2023 Arm Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01005#
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 Gondabi6f3a9f52021-11-09 15:47:17 +020025
Anthony Barbier6ff3b192017-09-04 18:44:23 +010026import collections
27import os.path
28import re
29import subprocess
Georgios Pinitasea857272021-01-22 05:47:37 +000030import zlib
Georgios Pinitasbdcdc392021-04-22 16:42:03 +010031import json
Adnan AlSinan39aebd12021-08-06 12:44:51 +010032import codecs
Anthony Barbier6ff3b192017-09-04 18:44:23 +010033
Jakub Sujak59b9ff02023-06-11 21:35:11 +010034print("DEPRECATION NOTICE: Legacy libarm_compute_core has been deprecated. Link your application only to "
35 "libarm_compute for core library functionality")
36
Anthony Barbier6ff3b192017-09-04 18:44:23 +010037VERSION = "v0.0-unreleased"
Omar Al Khatib4494b552023-05-09 15:24:16 +010038LIBRARY_VERSION_MAJOR = 31
Sang-Hoon Park6d0b3842020-08-14 14:48:08 +010039LIBRARY_VERSION_MINOR = 0
ramy.elgammal@arm.comcdb1ee02023-06-28 16:04:04 +010040LIBRARY_VERSION_PATCH = 1
Georgios Pinitas35fcc432020-03-26 18:47:46 +000041SONAME_VERSION = str(LIBRARY_VERSION_MAJOR) + "." + str(LIBRARY_VERSION_MINOR) + "." + str(LIBRARY_VERSION_PATCH)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010042
43Import('env')
44Import('vars')
Anthony Barbier01bbd5f2018-11-01 15:10:51 +000045Import('install_lib')
Anthony Barbier6ff3b192017-09-04 18:44:23 +010046
Michalis Spyrou748a7c82019-10-07 13:00:44 +010047def build_bootcode_objs(sources):
Michalis Spyrou748a7c82019-10-07 13:00:44 +010048 arm_compute_env.Append(ASFLAGS = "-I bootcode/")
49 obj = arm_compute_env.Object(sources)
50 obj = install_lib(obj)
51 Default(obj)
52 return obj
53
Motti Gondabi9d9ad332022-01-23 12:42:24 +020054
55
56
57# @brief Create a list of object from a given file list.
Motti Gondabi6f3a9f52021-11-09 15:47:17 +020058#
Motti Gondabi9d9ad332022-01-23 12:42:24 +020059# @param arch_info A dictionary represents the architecture info such as the
60# compiler flags and defines (filedefs.json).
61#
62# @param sources A list of files to build
Motti Gondabi6f3a9f52021-11-09 15:47:17 +020063#
64# @return A list of objects for the corresponding architecture.
Michalis Spyrou20fca522021-06-07 14:23:57 +010065
Motti Gondabi9d9ad332022-01-23 12:42:24 +020066def build_obj_list(arch_info, sources, static=False):
Motti Gondabi6f3a9f52021-11-09 15:47:17 +020067
Motti Gondabi9d9ad332022-01-23 12:42:24 +020068 # Clone environment
Georgios Pinitasbdcdc392021-04-22 16:42:03 +010069 tmp_env = arm_compute_env.Clone()
Motti Gondabi6f3a9f52021-11-09 15:47:17 +020070
Motti Gondabi9d9ad332022-01-23 12:42:24 +020071 # Append architecture spec
72 if 'cxxflags' in arch_info and len(arch_info['cxxflags']) > 0:
73 tmp_env.Append(CXXFLAGS = arch_info['cxxflags'])
Motti Gondabi6f3a9f52021-11-09 15:47:17 +020074
Motti Gondabi9d9ad332022-01-23 12:42:24 +020075 # Build and return objects
76 if static:
77 objs = tmp_env.StaticObject(sources)
Motti Gondabi6f3a9f52021-11-09 15:47:17 +020078 else:
Motti Gondabi9d9ad332022-01-23 12:42:24 +020079 objs = tmp_env.SharedObject(sources)
Giorgio Arena892b70a2022-03-30 12:23:10 +010080
Motti Gondabif76a5022021-12-21 13:19:29 +020081 tmp_env.Default(objs)
82 return objs
Georgios Pinitasbdcdc392021-04-22 16:42:03 +010083
Motti Gondabi9d9ad332022-01-23 12:42:24 +020084# @brief Build multi-ISA files with the respective architecture.
85#
86# @return Two distinct lists:
87# A list of static objects
88# A list of shared objects
Michalis Spyrou20fca522021-06-07 14:23:57 +010089
Motti Gondabi9d9ad332022-01-23 12:42:24 +020090def build_lib_objects():
91 lib_static_objs = [] # static objects
92 lib_shared_objs = [] # shared objects
93
94 arm_compute_env.Append(CPPDEFINES = ['ENABLE_NEON', 'ARM_COMPUTE_ENABLE_NEON',
95 'ENABLE_SVE', 'ARM_COMPUTE_ENABLE_SVE',
96 'ARM_COMPUTE_ENABLE_FP16', 'ARM_COMPUTE_ENABLE_BF16',
97 'ARM_COMPUTE_ENABLE_I8MM', 'ARM_COMPUTE_ENABLE_SVEF32MM'])
98
99 # Build all the common files for the base architecture
Sunita Nadampalli911d5722023-05-02 14:05:39 +0000100 if env['arch'] == 'armv8a':
101 lib_static_objs += build_obj_list(filedefs["armv8-a"], lib_files, static=True)
102 lib_shared_objs += build_obj_list(filedefs["armv8-a"], lib_files, static=False)
103 else:
104 lib_static_objs += build_obj_list(filedefs["armv8.2-a"], lib_files, static=True)
105 lib_shared_objs += build_obj_list(filedefs["armv8.2-a"], lib_files, static=False)
Giorgio Arena892b70a2022-03-30 12:23:10 +0100106
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200107 # Build the SVE specific files
108 lib_static_objs += build_obj_list(filedefs["armv8.2-a-sve"], lib_files_sve, static=True)
109 lib_shared_objs += build_obj_list(filedefs["armv8.2-a-sve"], lib_files_sve, static=False)
110
111 # Build the SVE2 specific files
112 arm_compute_env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_SVE2'])
113 lib_static_objs += build_obj_list(filedefs["armv8.6-a-sve2"], lib_files_sve2, static=True)
114 lib_shared_objs += build_obj_list(filedefs["armv8.6-a-sve2"], lib_files_sve2, static=False)
115
116 return lib_static_objs, lib_shared_objs
117
Michalis Spyrou20fca522021-06-07 14:23:57 +0100118
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100119
Georgios Pinitas4d9687e2020-10-21 18:33:36 +0100120def build_library(name, build_env, sources, static=False, libs=[]):
Mohammed Suhail Munshide60ed92021-12-21 11:07:27 +0000121 cloned_build_env = build_env.Clone()
Motti Gondabif76a5022021-12-21 13:19:29 +0200122 if env['os'] == 'android' and static == False:
Mohammed Suhail Munshide60ed92021-12-21 11:07:27 +0000123 cloned_build_env["LINKFLAGS"].remove('-pie')
124 cloned_build_env["LINKFLAGS"].remove('-static-libstdc++')
125
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100126 if static:
Mohammed Suhail Munshide60ed92021-12-21 11:07:27 +0000127 obj = cloned_build_env.StaticLibrary(name, source=sources, LIBS = arm_compute_env["LIBS"] + libs)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100128 else:
129 if env['set_soname']:
Mohammed Suhail Munshide60ed92021-12-21 11:07:27 +0000130 obj = cloned_build_env.SharedLibrary(name, source=sources, SHLIBVERSION = SONAME_VERSION, LIBS = arm_compute_env["LIBS"] + libs)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100131 else:
Mohammed Suhail Munshide60ed92021-12-21 11:07:27 +0000132 obj = cloned_build_env.SharedLibrary(name, source=sources, LIBS = arm_compute_env["LIBS"] + libs)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100133
Pablo Marquez Tello299d3a12022-10-12 14:58:24 +0100134 if env['mapfile']:
Pablo Marquez Telloa4f88702022-10-21 10:24:23 +0100135 if not 'windows' in env['os'] and not 'macos' in env['os']:
136 cloned_build_env['LINKFLAGS'].append('"-Wl,-Map='+ name + '.map"')
137 else:
138 cloned_build_env['LINKFLAGS'].append('-Wl,-map,' + name + '.map')
Pablo Marquez Tello299d3a12022-10-12 14:58:24 +0100139
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000140 obj = install_lib(obj)
Motti Gondabif76a5022021-12-21 13:19:29 +0200141 build_env.Default(obj)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100142 return obj
143
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100144
Georgios Pinitasf605bd22020-11-26 11:55:09 +0000145def remove_incode_comments(code):
146 def replace_with_empty(match):
147 s = match.group(0)
148 if s.startswith('/'):
149 return " "
150 else:
151 return s
152
153 comment_regex = re.compile(r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"', re.DOTALL | re.MULTILINE)
154 return re.sub(comment_regex, replace_with_empty, code)
155
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100156
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100157def resolve_includes(target, source, env):
158 # File collection
159 FileEntry = collections.namedtuple('FileEntry', 'target_name file_contents')
160
161 # Include pattern
162 pattern = re.compile("#include \"(.*)\"")
163
164 # Get file contents
165 files = []
166 for i in range(len(source)):
167 src = source[i]
168 dst = target[i]
Georgios Pinitasf605bd22020-11-26 11:55:09 +0000169 contents = src.get_contents().decode('utf-8')
170 contents = remove_incode_comments(contents).splitlines()
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100171 entry = FileEntry(target_name=dst, file_contents=contents)
172 files.append((os.path.basename(src.get_path()),entry))
173
174 # Create dictionary of tupled list
175 files_dict = dict(files)
176
177 # Check for includes (can only be files in the same folder)
178 final_files = []
179 for file in files:
180 done = False
181 tmp_file = file[1].file_contents
182 while not done:
183 file_count = 0
184 updated_file = []
185 for line in tmp_file:
186 found = pattern.search(line)
187 if found:
Giorgio Arena09adcc42022-03-08 11:12:27 +0000188 # Only get the header file name and discard the relative path.
189 # E.g. "common/experimental/gemm_fused_post_ops/fp_mixed_precision_helpers.h" -> "fp_mixed_precision_helpers.h"
Giorgio Arena232c4522022-03-03 10:09:01 +0000190 include_file = found.group(1).split('/')[-1]
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100191 data = files_dict[include_file].file_contents
192 updated_file.extend(data)
193 else:
194 updated_file.append(line)
195 file_count += 1
196
197 # Check if all include are replaced.
198 if file_count == len(tmp_file):
199 done = True
200
201 # Update temp file
202 tmp_file = updated_file
203
204 # Append and prepend string literal identifiers and add expanded file to final list
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100205 entry = FileEntry(target_name=file[1].target_name, file_contents=tmp_file)
206 final_files.append((file[0], entry))
207
208 # Write output files
209 for file in final_files:
210 with open(file[1].target_name.get_path(), 'w+') as out_file:
Georgios Pinitasea857272021-01-22 05:47:37 +0000211 file_to_write = "\n".join( file[1].file_contents )
212 if env['compress_kernels']:
Adnan AlSinan39aebd12021-08-06 12:44:51 +0100213 file_to_write = zlib.compress(file_to_write.encode('utf-8'), 9)
214 file_to_write = codecs.encode(file_to_write, "base64").decode('utf-8').replace("\n", "")
Georgios Pinitasea857272021-01-22 05:47:37 +0000215 file_to_write = "R\"(" + file_to_write + ")\""
216 out_file.write(file_to_write)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100217
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100218
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100219def create_version_file(target, source, env):
220# Generate string with build options library version to embed in the library:
221 try:
222 git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"])
223 except (OSError, subprocess.CalledProcessError):
224 git_hash="unknown"
225
Matthew Benthamdd8d7f42023-06-15 11:50:57 +0000226 build_options = str(vars.args).replace('"', '\\"')
227 build_info = "\"arm_compute_version=%s Build options: %s Git hash=%s\"" % (VERSION,build_options, git_hash.strip())
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100228 with open(target[0].get_path(), "w") as fd:
229 fd.write(build_info)
230
Michalis Spyrou20fca522021-06-07 14:23:57 +0100231
Freddie Liardet487d3902021-09-21 12:36:43 +0100232def get_attrs_list(env, data_types, data_layouts):
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100233 attrs = []
Michalis Spyrou20fca522021-06-07 14:23:57 +0100234
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100235 # Manage data-types
Freddie Liardet487d3902021-09-21 12:36:43 +0100236 if 'all' in data_types:
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100237 attrs += ['fp16', 'fp32', 'integer', 'qasymm8', 'qasymm8_signed', 'qsymm16']
238 else:
Freddie Liardet487d3902021-09-21 12:36:43 +0100239 if 'fp16' in data_types: attrs += ['fp16']
240 if 'fp32' in data_types: attrs += ['fp32']
241 if 'integer' in data_types: attrs += ['integer']
242 if 'qasymm8' in data_types: attrs += ['qasymm8']
243 if 'qasymm8_signed' in data_types: attrs += ['qasymm8_signed']
244 if 'qsymm16' in data_types: attrs += ['qsymm16']
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100245 # Manage data-layouts
Freddie Liardet487d3902021-09-21 12:36:43 +0100246 if 'all' in data_layouts:
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100247 attrs += ['nhwc', 'nchw']
248 else:
Freddie Liardet487d3902021-09-21 12:36:43 +0100249 if 'nhwc' in data_layouts: attrs += ['nhwc']
250 if 'nchw' in data_layouts: attrs += ['nchw']
Michalis Spyrou20fca522021-06-07 14:23:57 +0100251
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100252 # Manage execution state
Freddie Liardet487d3902021-09-21 12:36:43 +0100253 attrs += ['estate32' if (env['estate'] == 'auto' and 'v7a' in env['arch']) or '32' in env['estate'] else 'estate64']
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200254
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100255 return attrs
Michalis Spyrou20fca522021-06-07 14:23:57 +0100256
Michalis Spyrou20fca522021-06-07 14:23:57 +0100257
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100258def get_operator_backend_files(filelist, operators, backend='', techs=[], attrs=[]):
259 files = { "common" : [] }
Michalis Spyrou20fca522021-06-07 14:23:57 +0100260
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100261 # Early return if filelist is empty
262 if backend not in filelist:
263 return files
Michalis Spyrou20fca522021-06-07 14:23:57 +0100264
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100265 # Iterate over operators and create the file lists to compiler
266 for operator in operators:
267 if operator in filelist[backend]['operators']:
268 files['common'] += filelist[backend]['operators'][operator]["files"]["common"]
269 for tech in techs:
270 if tech in filelist[backend]['operators'][operator]["files"]:
271 # Add tech as a key to dictionary if not there
272 if tech not in files:
273 files[tech] = []
Michalis Spyrou20fca522021-06-07 14:23:57 +0100274
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100275 # Add tech files to the tech file list
276 tech_files = filelist[backend]['operators'][operator]["files"][tech]
277 files[tech] += tech_files.get('common', [])
278 for attr in attrs:
279 files[tech] += tech_files.get(attr, [])
280
281 # Remove duplicates if they exist
282 return {k: list(set(v)) for k,v in files.items()}
283
284def collect_operators(filelist, operators, backend=''):
285 ops = set()
286 for operator in operators:
287 if operator in filelist[backend]['operators']:
288 ops.add(operator)
289 if 'deps' in filelist[backend]['operators'][operator]:
290 ops.update(filelist[backend]['operators'][operator]['deps'])
291 else:
292 print("Operator {0} is unsupported on {1} backend!".format(operator, backend))
293
294 return ops
295
296
297def resolve_operator_dependencies(filelist, operators, backend=''):
298 resolved_operators = collect_operators(filelist, operators, backend)
299
300 are_ops_resolved = False
301 while not are_ops_resolved:
302 resolution_pass = collect_operators(filelist, resolved_operators, backend)
303 if len(resolution_pass) != len(resolved_operators):
304 resolved_operators.update(resolution_pass)
305 else:
306 are_ops_resolved = True
307
308 return resolved_operators
309
Freddie Liardet487d3902021-09-21 12:36:43 +0100310def read_build_config_json(build_config):
311 build_config_contents = {}
312 custom_operators = []
313 custom_types = []
314 custom_layouts = []
315 if os.path.isfile(build_config):
316 with open(build_config) as f:
317 try:
318 build_config_contents = json.load(f)
319 except:
320 print("Warning: Build configuration file is of invalid JSON format!")
321 else:
322 try:
323 build_config_contents = json.loads(build_config)
324 except:
325 print("Warning: Build configuration string is of invalid JSON format!")
326 if build_config_contents:
327 custom_operators = build_config_contents.get("operators", [])
328 custom_types = build_config_contents.get("data_types", [])
329 custom_layouts = build_config_contents.get("data_layouts", [])
330 return custom_operators, custom_types, custom_layouts
Michalis Spyrou20fca522021-06-07 14:23:57 +0100331
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100332arm_compute_env = env.Clone()
Anthony Barbier0e72c692018-08-24 11:22:08 +0100333version_file = arm_compute_env.Command("src/core/arm_compute_version.embed", "", action=create_version_file)
334arm_compute_env.AlwaysBuild(version_file)
Anthony Barbier6a3daf12018-02-19 17:24:27 +0000335
Kevin Lo7195f712022-01-07 15:46:02 +0800336default_cpp_compiler = 'g++' if env['os'] not in ['android', 'macos', 'openbsd'] else 'clang++'
Georgios Pinitas4d9687e2020-10-21 18:33:36 +0100337cpp_compiler = os.environ.get('CXX', default_cpp_compiler)
338
Anthony Barbier6a3daf12018-02-19 17:24:27 +0000339# Generate embed files
Anthony Barbier0e72c692018-08-24 11:22:08 +0100340generate_embed = [ version_file ]
Anthony Barbier6a3daf12018-02-19 17:24:27 +0000341if env['opencl'] and env['embed_kernels']:
Giorgio Arena892b70a2022-03-30 12:23:10 +0100342
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100343 # Header files
344 cl_helper_files = [ 'src/core/CL/cl_kernels/activation_float_helpers.h',
345 'src/core/CL/cl_kernels/activation_quant_helpers.h',
346 'src/core/CL/cl_kernels/gemm_helpers.h',
347 'src/core/CL/cl_kernels/helpers_asymm.h',
348 'src/core/CL/cl_kernels/helpers.h',
349 'src/core/CL/cl_kernels/load_store_utility.h',
350 'src/core/CL/cl_kernels/repeat.h',
351 'src/core/CL/cl_kernels/tile_helpers.h',
352 'src/core/CL/cl_kernels/types.h',
SiCongLi1af54162021-10-06 15:25:57 +0100353 'src/core/CL/cl_kernels/warp_helpers.h',
354 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/act_eltwise_op_act/fp_post_ops_act_eltwise_op_act.h',
355 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/fp_mixed_precision_helpers.h',
356 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/fp_elementwise_op_helpers.h',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100357 ]
Anthony Barbier6a3daf12018-02-19 17:24:27 +0000358
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100359 # Common kernels
360 cl_files_common = ['src/core/CL/cl_kernels/common/activation_layer.cl',
361 'src/core/CL/cl_kernels/common/activation_layer_quant.cl',
362 'src/core/CL/cl_kernels/common/arg_min_max.cl',
363 'src/core/CL/cl_kernels/common/batchnormalization_layer.cl',
364 'src/core/CL/cl_kernels/common/bounding_box_transform.cl',
365 'src/core/CL/cl_kernels/common/bounding_box_transform_quantized.cl',
366 'src/core/CL/cl_kernels/common/bitwise_op.cl',
367 'src/core/CL/cl_kernels/common/cast.cl',
368 'src/core/CL/cl_kernels/common/comparisons.cl',
369 'src/core/CL/cl_kernels/common/concatenate.cl',
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +0000370 'src/core/CL/cl_kernels/common/convolution_layer.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100371 'src/core/CL/cl_kernels/common/col2im.cl',
372 'src/core/CL/cl_kernels/common/convert_fc_weights.cl',
373 'src/core/CL/cl_kernels/common/copy_tensor.cl',
374 'src/core/CL/cl_kernels/common/crop_tensor.cl',
375 'src/core/CL/cl_kernels/common/deconvolution_layer.cl',
376 'src/core/CL/cl_kernels/common/dequantization_layer.cl',
377 'src/core/CL/cl_kernels/common/elementwise_operation.cl',
378 'src/core/CL/cl_kernels/common/elementwise_operation_quantized.cl',
379 'src/core/CL/cl_kernels/common/elementwise_unary.cl',
Ramy Elgammal14d7b532023-01-30 04:56:47 +0000380 'src/core/CL/cl_kernels/common/elementwise_unary_quantized.cl',
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +0000381 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/act_eltwise_op_act/gemm_mm_native.cl',
382 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/act_eltwise_op_act/gemm_mm_reshaped.cl',
383 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/act_eltwise_op_act/gemm_mm_reshaped_only_rhs.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100384 'src/core/CL/cl_kernels/common/fft_digit_reverse.cl',
385 'src/core/CL/cl_kernels/common/fft.cl',
386 'src/core/CL/cl_kernels/common/fft_scale.cl',
387 'src/core/CL/cl_kernels/common/fill_border.cl',
388 'src/core/CL/cl_kernels/common/floor.cl',
389 'src/core/CL/cl_kernels/common/gather.cl',
390 'src/core/CL/cl_kernels/common/gemm.cl',
Gunes Bayir4bfc70e2021-12-10 16:17:56 +0000391 'src/core/CL/cl_kernels/common/gemm_reshaped_only_rhs_mmul.cl',
ramelg019cca5922021-11-11 10:05:00 +0000392 'src/core/CL/cl_kernels/common/gemm_utils.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100393 'src/core/CL/cl_kernels/common/gemmlowp.cl',
Freddie Liardete572dff2022-05-16 14:09:10 +0100394 'src/core/CL/cl_kernels/common/gemmlowp_reshaped_only_rhs_mmul.cl',
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +0000395 'src/core/CL/cl_kernels/common/gemv.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100396 'src/core/CL/cl_kernels/common/generate_proposals.cl',
397 'src/core/CL/cl_kernels/common/generate_proposals_quantized.cl',
398 'src/core/CL/cl_kernels/common/instance_normalization.cl',
399 'src/core/CL/cl_kernels/common/l2_normalize.cl',
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +0000400 'src/core/CL/cl_kernels/common/mat_mul.cl',
SiCong Lia8d80582023-05-19 14:23:37 +0100401 'src/core/CL/cl_kernels/common/mat_mul_mmul.cl',
Gunes Bayir9d0c4de2023-04-13 18:22:58 +0100402 'src/core/CL/cl_kernels/common/mat_mul_quantized.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100403 'src/core/CL/cl_kernels/common/mean_stddev_normalization.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100404 'src/core/CL/cl_kernels/common/memset.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100405 'src/core/CL/cl_kernels/common/minmax_layer.cl',
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +0000406 'src/core/CL/cl_kernels/common/nonmax.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100407 'src/core/CL/cl_kernels/common/pad_layer.cl',
408 'src/core/CL/cl_kernels/common/permute.cl',
409 'src/core/CL/cl_kernels/common/pixelwise_mul_float.cl',
410 'src/core/CL/cl_kernels/common/pixelwise_mul_int.cl',
411 'src/core/CL/cl_kernels/common/qlstm_layer_normalization.cl',
412 'src/core/CL/cl_kernels/common/quantization_layer.cl',
413 'src/core/CL/cl_kernels/common/range.cl',
414 'src/core/CL/cl_kernels/common/reduction_operation.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100415 'src/core/CL/cl_kernels/common/reshape_layer.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100416 'src/core/CL/cl_kernels/common/reverse.cl',
417 'src/core/CL/cl_kernels/common/roi_align_layer.cl',
418 'src/core/CL/cl_kernels/common/roi_align_layer_quantized.cl',
419 'src/core/CL/cl_kernels/common/roi_pooling_layer.cl',
420 'src/core/CL/cl_kernels/common/select.cl',
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +0000421 'src/core/CL/cl_kernels/common/slice_ops.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100422 'src/core/CL/cl_kernels/common/softmax_layer.cl',
423 'src/core/CL/cl_kernels/common/softmax_layer_quantized.cl',
424 'src/core/CL/cl_kernels/common/stack_layer.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100425 'src/core/CL/cl_kernels/common/tile.cl',
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +0000426 'src/core/CL/cl_kernels/common/transpose.cl',
427 'src/core/CL/cl_kernels/common/unpooling_layer.cl'
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100428 ]
429
430 # NCHW kernels
431 cl_files_nchw = ['src/core/CL/cl_kernels/nchw/batch_to_space.cl',
432 'src/core/CL/cl_kernels/nchw/batchnormalization_layer.cl',
433 'src/core/CL/cl_kernels/nchw/channel_shuffle.cl',
434 'src/core/CL/cl_kernels/nchw/depth_to_space.cl',
Adnan AlSinan30124352021-12-02 19:12:20 +0000435 'src/core/CL/cl_kernels/nchw/direct_convolution.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100436 'src/core/CL/cl_kernels/nchw/dequantization_layer.cl',
437 'src/core/CL/cl_kernels/nchw/im2col.cl',
438 'src/core/CL/cl_kernels/nchw/normalization_layer.cl',
439 'src/core/CL/cl_kernels/nchw/normalize_planar_yuv_layer.cl',
440 'src/core/CL/cl_kernels/nchw/normalize_planar_yuv_layer_quantized.cl',
441 'src/core/CL/cl_kernels/nchw/pooling_layer.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100442 'src/core/CL/cl_kernels/nchw/prior_box_layer.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100443 'src/core/CL/cl_kernels/nchw/reorg_layer.cl',
444 'src/core/CL/cl_kernels/nchw/scale.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100445 'src/core/CL/cl_kernels/nchw/space_to_batch.cl',
446 'src/core/CL/cl_kernels/nchw/space_to_depth.cl',
447 'src/core/CL/cl_kernels/nchw/upsample_layer.cl',
448 'src/core/CL/cl_kernels/nchw/winograd_filter_transform.cl',
449 'src/core/CL/cl_kernels/nchw/winograd_input_transform.cl',
450 'src/core/CL/cl_kernels/nchw/winograd_output_transform.cl'
451 ]
452
453 # NHWC kernels
454 cl_files_nhwc = ['src/core/CL/cl_kernels/nhwc/batch_to_space.cl',
455 'src/core/CL/cl_kernels/nhwc/batchnormalization_layer.cl',
456 'src/core/CL/cl_kernels/nhwc/channel_shuffle.cl',
457 'src/core/CL/cl_kernels/nhwc/direct_convolution.cl',
Giorgio Arena945ae9e2021-10-13 11:13:04 +0100458 'src/core/CL/cl_kernels/nhwc/direct_convolution3d.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100459 'src/core/CL/cl_kernels/nhwc/depth_to_space.cl',
460 'src/core/CL/cl_kernels/nhwc/dequantization_layer.cl',
461 'src/core/CL/cl_kernels/nhwc/dwc_native_fp_nhwc.cl',
462 'src/core/CL/cl_kernels/nhwc/dwc_native_quantized_nhwc.cl',
463 'src/core/CL/cl_kernels/nhwc/im2col.cl',
Gian Marco Iodice5d016812022-11-17 11:03:39 +0000464 'src/core/CL/cl_kernels/nhwc/indirect_convolution.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100465 'src/core/CL/cl_kernels/nhwc/normalization_layer.cl',
466 'src/core/CL/cl_kernels/nhwc/normalize_planar_yuv_layer.cl',
467 'src/core/CL/cl_kernels/nhwc/normalize_planar_yuv_layer_quantized.cl',
468 'src/core/CL/cl_kernels/nhwc/pooling_layer.cl',
ramelg0137515692022-02-26 22:06:20 +0000469 'src/core/CL/cl_kernels/nhwc/pooling_3d_layer.cl',
Mohammed Suhail Munshi5e549fa2022-03-16 11:14:06 +0000470 'src/core/CL/cl_kernels/nhwc/pooling_3d_layer_quantized.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100471 'src/core/CL/cl_kernels/nhwc/pooling_layer_quantized.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100472 'src/core/CL/cl_kernels/nhwc/reorg_layer.cl',
473 'src/core/CL/cl_kernels/nhwc/scale.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100474 'src/core/CL/cl_kernels/nhwc/space_to_batch.cl',
475 'src/core/CL/cl_kernels/nhwc/space_to_depth.cl',
Gunes Bayirec0113d2022-11-09 09:26:27 +0000476 'src/core/CL/cl_kernels/nhwc/transposed_convolution.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100477 'src/core/CL/cl_kernels/nhwc/upsample_layer.cl',
478 'src/core/CL/cl_kernels/nhwc/winograd_filter_transform.cl',
479 'src/core/CL/cl_kernels/nhwc/winograd_input_transform.cl',
480 'src/core/CL/cl_kernels/nhwc/winograd_output_transform.cl'
481 ]
482
483 cl_files = cl_helper_files + cl_files_common + cl_files_nchw + cl_files_nhwc
484
485 embed_files = [ f+"embed" for f in cl_files ]
Anthony Barbier6a3daf12018-02-19 17:24:27 +0000486 arm_compute_env.Append(CPPPATH =[Dir("./src/core/CL/").path] )
487
488 generate_embed.append(arm_compute_env.Command(embed_files, cl_files, action=resolve_includes))
489
Anthony Barbier6a3daf12018-02-19 17:24:27 +0000490Default(generate_embed)
491if env["build"] == "embed_only":
492 Return()
493
Georgios Pinitas35fcc432020-03-26 18:47:46 +0000494# Append version defines for semantic versioning
495arm_compute_env.Append(CPPDEFINES = [('ARM_COMPUTE_VERSION_MAJOR', LIBRARY_VERSION_MAJOR),
496 ('ARM_COMPUTE_VERSION_MINOR', LIBRARY_VERSION_MINOR),
497 ('ARM_COMPUTE_VERSION_PATCH', LIBRARY_VERSION_PATCH)])
498
Isabella Gottardib28f29d2017-11-09 17:05:07 +0000499# Don't allow undefined references in the libraries:
Georgios Pinitas45514032020-12-30 00:03:09 +0000500undefined_flag = '-Wl,-undefined,error' if 'macos' in arm_compute_env["os"] else '-Wl,--no-undefined'
501arm_compute_env.Append(LINKFLAGS=[undefined_flag])
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100502arm_compute_env.Append(CPPPATH =[Dir("./src/core/").path] )
503
Kevin Lo7195f712022-01-07 15:46:02 +0800504if env['os'] != 'openbsd':
Pablo Tellofbbfa532023-01-26 16:24:04 +0000505 if env['os'] == 'windows':
506 arm_compute_env.Append(LIBS = [])
507 else:
508 arm_compute_env.Append(LIBS = ['dl'])
509
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100510
Motti Gondabi6f3a9f52021-11-09 15:47:17 +0200511# Load build definitions file
512with (open(Dir('#').path + '/filedefs.json')) as fd:
513 filedefs = json.load(fd)
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200514 filedefs = filedefs['cpu']['arch']
Motti Gondabi6f3a9f52021-11-09 15:47:17 +0200515
516
Georgios Pinitasbdcdc392021-04-22 16:42:03 +0100517with (open(Dir('#').path + '/filelist.json')) as fp:
518 filelist = json.load(fp)
519
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100520# Common backend files
521lib_files = filelist['common']
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100522
Nathan John Sircombed7113e42023-04-26 15:02:43 +0100523# Fixed format GEMM kernels.
524if env['fixed_format_kernels']:
525 arm_compute_env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS'])
526
Giorgio Arena232c4522022-03-03 10:09:01 +0000527# Experimental files
528# Dynamic fusion
529if env['experimental_dynamic_fusion']:
Giorgio Arena892b70a2022-03-30 12:23:10 +0100530 lib_files += filelist['experimental']['dynamic_fusion']
Giorgio Arena232c4522022-03-03 10:09:01 +0000531
Jakub Sujak8c49f162023-06-16 09:52:50 +0100532# Compute Kernel Writer integration files
533if env['ckw']:
534 if env['opencl']:
535 lib_files += filelist['experimental']['ckw']['cl']
536
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100537# Logging files
538if env["logging"]:
539 lib_files += filelist['logging']
Georgios Pinitas8795ffb2017-12-01 16:13:40 +0000540
Georgios Pinitasc3c352e2021-03-18 10:59:40 +0000541# C API files
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100542lib_files += filelist['c_api']['common']
543lib_files += filelist['c_api']['operators']
Georgios Pinitasbdcdc392021-04-22 16:42:03 +0100544
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100545# Scheduler infrastructure
546lib_files += filelist['scheduler']['single']
547if env['cppthreads']:
548 lib_files += filelist['scheduler']['threads']
549if env['openmp']:
550 lib_files += filelist['scheduler']['omp']
Georgios Pinitas8a5146f2021-01-12 15:51:07 +0000551
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100552# Graph files
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100553graph_files = Glob('src/graph/*.cpp')
554graph_files += Glob('src/graph/*/*.cpp')
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000555
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100556# Specify user-defined priority operators
Freddie Liardet487d3902021-09-21 12:36:43 +0100557custom_operators = []
558custom_types = []
559custom_layouts = []
560
561use_custom_ops = env['high_priority'] or env['build_config'];
562
563if env['high_priority']:
564 custom_operators = filelist['high_priority']
565 custom_types = ['all']
566 custom_layouts = ['all']
567
568if env['build_config']:
569 custom_operators, custom_types, custom_layouts = read_build_config_json(env['build_config'])
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100570
571if env['opencl']:
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100572 lib_files += filelist['c_api']['gpu']
573 lib_files += filelist['gpu']['common']
Michele Di Giorgio760c7832021-08-05 10:54:13 +0100574
Freddie Liardet487d3902021-09-21 12:36:43 +0100575 cl_operators = custom_operators if use_custom_ops else filelist['gpu']['operators'].keys()
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100576 cl_ops_to_build = resolve_operator_dependencies(filelist, cl_operators, 'gpu')
577 lib_files += get_operator_backend_files(filelist, cl_ops_to_build, 'gpu')['common']
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000578
Georgios Pinitas13ef1762021-07-14 17:14:43 +0100579 graph_files += Glob('src/graph/backends/CL/*.cpp')
580
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200581
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100582lib_files_sve = []
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200583lib_files_sve2 = []
Motti Gondabi6f3a9f52021-11-09 15:47:17 +0200584
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100585if env['neon']:
Georgios Pinitas30271c72019-06-24 14:56:34 +0100586 # build winograd/depthwise sources for either v7a / v8a
Michael Tyler74921ee2023-04-12 17:43:17 +0100587 arm_compute_env.Append(CPPPATH = ["src/core/NEON/kernels/arm_gemm",
588 "src/core/NEON/kernels/convolution/common/",
Michele Di Giorgio6ad60af2020-06-09 14:52:15 +0100589 "src/core/NEON/kernels/convolution/winograd/",
ramelg01c827e992022-04-08 03:52:28 +0100590 "src/core/NEON/kernels/arm_conv/depthwise/",
591 "src/core/NEON/kernels/arm_conv/pooling/",
ramelg018a164882022-04-07 02:42:52 +0100592 "src/core/NEON/kernels/arm_conv/",
Sang-Hoon Park68dd25f2020-10-19 16:00:11 +0100593 "src/core/NEON/kernels/assembly/",
Sang-Hoon Park4f7693d2021-05-12 13:59:10 +0100594 "arm_compute/core/NEON/kernels/assembly/",
Motti Gondabi6f3a9f52021-11-09 15:47:17 +0200595 "src/cpu/kernels/assembly/"])
Pablo Tello9ceebbe2018-01-10 16:44:13 +0000596
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100597 lib_files += filelist['cpu']['common']
Georgios Pinitasff4fca02020-10-02 21:00:00 +0100598
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100599 # Setup SIMD file list to include
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200600 simd = ['neon']
601 if env['multi_isa']:
602 simd += ['sve', 'sve2']
603 else:
604 if 'sve' in env['arch']: simd += ['sve']
605 if 'sve2' in env['arch']: simd += ['sve2']
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100606
607 # Get attributes
Freddie Liardet487d3902021-09-21 12:36:43 +0100608 if(use_custom_ops):
609 attrs = get_attrs_list(env, custom_types, custom_layouts)
610 else:
611 attrs = get_attrs_list(env, env['data_type_support'], env['data_layout_support'])
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100612
Nathan John Sircombed7113e42023-04-26 15:02:43 +0100613
614 if env['fixed_format_kernels']:
615 attrs.append("fixed_format_kernels")
Francesco.Petrogalli@arm.com5fcf22d2022-04-05 10:31:08 +0000616
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100617 # Setup data-type and data-layout files to include
Freddie Liardet487d3902021-09-21 12:36:43 +0100618 cpu_operators = custom_operators if use_custom_ops else filelist['cpu']['operators'].keys()
619 cpu_ops_to_build = resolve_operator_dependencies(filelist, cpu_operators, 'cpu')
620
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100621 cpu_files = get_operator_backend_files(filelist, cpu_ops_to_build, 'cpu', simd, attrs)
Motti Gondabi6f3a9f52021-11-09 15:47:17 +0200622
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200623 # Shared among ALL CPU files
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100624 lib_files += cpu_files.get('common', [])
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200625
626 # Arm® Neon™ specific files
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100627 lib_files += cpu_files.get('neon', [])
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200628
629 # SVE files only
630 lib_files_sve = cpu_files.get('sve', [])
631
632 # SVE2 files only
633 lib_files_sve2 = cpu_files.get('sve2', [])
Georgios Pinitas13ef1762021-07-14 17:14:43 +0100634
635 graph_files += Glob('src/graph/backends/NEON/*.cpp')
Georgios Pinitas70eb53b2021-01-06 19:42:21 +0000636
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100637# Restrict from building graph API if a reduced operator list has been provided
Freddie Liardet487d3902021-09-21 12:36:43 +0100638if use_custom_ops:
639 print("WARNING: Graph library requires all operators to be built")
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100640 graph_files = []
641
642# Build bootcode in case of bare-metal
Michalis Spyrou748a7c82019-10-07 13:00:44 +0100643bootcode_o = []
644if env['os'] == 'bare_metal':
645 bootcode_files = Glob('bootcode/*.s')
646 bootcode_o = build_bootcode_objs(bootcode_files)
647Export('bootcode_o')
648
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200649
Motti Gondabi6f3a9f52021-11-09 15:47:17 +0200650if (env['multi_isa']):
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200651 lib_static_objs, lib_shared_objs = build_lib_objects()
652
653
654# STATIC library build.
655if (env['multi_isa']):
656 arm_compute_a = build_library('arm_compute-static', arm_compute_env, lib_static_objs, static=True)
657else:
658 if 'sve2' in env['arch']:
659 lib_files += lib_files_sve
660 lib_files += lib_files_sve2
661 elif 'sve' in env['arch']:
662 lib_files += lib_files_sve
Motti Gondabi6f3a9f52021-11-09 15:47:17 +0200663
Motti Gondabif76a5022021-12-21 13:19:29 +0200664 arm_compute_a = build_library('arm_compute-static', arm_compute_env, lib_files, static=True)
Motti Gondabif76a5022021-12-21 13:19:29 +0200665
Michalis Spyrou62c2ad62021-06-21 17:40:09 +0100666Export('arm_compute_a')
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100667
Motti Gondabif76a5022021-12-21 13:19:29 +0200668# SHARED library build.
Pablo Telloc6cb35a2017-06-21 15:39:47 +0100669if env['os'] != 'bare_metal' and not env['standalone']:
Motti Gondabi6f3a9f52021-11-09 15:47:17 +0200670 if (env['multi_isa']):
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200671
672 arm_compute_so = build_library('arm_compute', arm_compute_env, lib_shared_objs, static=False)
Georgios Pinitasbdcdc392021-04-22 16:42:03 +0100673 else:
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200674 arm_compute_so = build_library('arm_compute', arm_compute_env, lib_files, static=False)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100675
Michalis Spyrou62c2ad62021-06-21 17:40:09 +0100676 Export('arm_compute_so')
677
Michalis Spyrou62c2ad62021-06-21 17:40:09 +0100678# Generate dummy core lib for backwards compatibility
Pablo Marquez Tello48f26152021-11-18 10:15:23 +0000679if env['os'] == 'macos':
680 # macos static library archiver fails if given an empty list of files
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200681 arm_compute_core_a = build_library('arm_compute_core-static', arm_compute_env, lib_files, static=True)
Pablo Marquez Tello48f26152021-11-18 10:15:23 +0000682else:
683 arm_compute_core_a = build_library('arm_compute_core-static', arm_compute_env, [], static=True)
684
Michalis Spyrou62c2ad62021-06-21 17:40:09 +0100685Export('arm_compute_core_a')
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100686
Pablo Telloc6cb35a2017-06-21 15:39:47 +0100687if env['os'] != 'bare_metal' and not env['standalone']:
Michalis Spyrou62c2ad62021-06-21 17:40:09 +0100688 arm_compute_core_a_so = build_library('arm_compute_core', arm_compute_env, [], static=False)
689 Export('arm_compute_core_a_so')
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100690
Sang-Hoon Park18fbb922021-01-14 14:50:25 +0000691arm_compute_graph_env = arm_compute_env.Clone()
692
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100693# Build graph libraries
Sang-Hoon Park18fbb922021-01-14 14:50:25 +0000694arm_compute_graph_env.Append(CXXFLAGS = ['-Wno-redundant-move', '-Wno-pessimizing-move'])
695
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200696arm_compute_graph_a = build_library('arm_compute_graph-static', arm_compute_graph_env, graph_files, static=True, libs = [ arm_compute_a ])
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100697Export('arm_compute_graph_a')
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000698
699if env['os'] != 'bare_metal' and not env['standalone']:
Michalis Spyrou62c2ad62021-06-21 17:40:09 +0100700 arm_compute_graph_so = build_library('arm_compute_graph', arm_compute_graph_env, graph_files, static=False, libs = [ "arm_compute" ])
Georgios Pinitas9873ea32017-12-05 15:28:55 +0000701 Depends(arm_compute_graph_so, arm_compute_so)
Anthony Barbier2a07e182017-08-04 18:20:27 +0100702 Export('arm_compute_graph_so')
703
Pablo Telloc6cb35a2017-06-21 15:39:47 +0100704if env['standalone']:
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200705 alias = arm_compute_env.Alias("arm_compute", [arm_compute_a])
Pablo Telloc6cb35a2017-06-21 15:39:47 +0100706else:
707 alias = arm_compute_env.Alias("arm_compute", [arm_compute_a, arm_compute_so])
708
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100709Default(alias)
710
Pablo Telloc6cb35a2017-06-21 15:39:47 +0100711if env['standalone']:
Michalis Spyrou62c2ad62021-06-21 17:40:09 +0100712 Depends([alias], generate_embed)
Pablo Telloc6cb35a2017-06-21 15:39:47 +0100713else:
Michalis Spyrou62c2ad62021-06-21 17:40:09 +0100714 Depends([alias], generate_embed)