blob: 205764b9a7ad0b5f5ef0412c954f9bf6b58e7e3c [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
34VERSION = "v0.0-unreleased"
Jakub Sujak83ac7f12023-02-04 22:52:49 +000035LIBRARY_VERSION_MAJOR = 30
Sang-Hoon Park6d0b3842020-08-14 14:48:08 +010036LIBRARY_VERSION_MINOR = 0
Jakub Sujak217ba112023-03-13 17:21:48 +000037LIBRARY_VERSION_PATCH = 1
Georgios Pinitas35fcc432020-03-26 18:47:46 +000038SONAME_VERSION = str(LIBRARY_VERSION_MAJOR) + "." + str(LIBRARY_VERSION_MINOR) + "." + str(LIBRARY_VERSION_PATCH)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010039
40Import('env')
41Import('vars')
Anthony Barbier01bbd5f2018-11-01 15:10:51 +000042Import('install_lib')
Anthony Barbier6ff3b192017-09-04 18:44:23 +010043
Michalis Spyrou748a7c82019-10-07 13:00:44 +010044def build_bootcode_objs(sources):
Michalis Spyrou748a7c82019-10-07 13:00:44 +010045 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 Gondabi9d9ad332022-01-23 12:42:24 +020051
52
53
54# @brief Create a list of object from a given file list.
Motti Gondabi6f3a9f52021-11-09 15:47:17 +020055#
Motti Gondabi9d9ad332022-01-23 12:42:24 +020056# @param arch_info A dictionary represents the architecture info such as the
57# compiler flags and defines (filedefs.json).
58#
59# @param sources A list of files to build
Motti Gondabi6f3a9f52021-11-09 15:47:17 +020060#
61# @return A list of objects for the corresponding architecture.
Michalis Spyrou20fca522021-06-07 14:23:57 +010062
Motti Gondabi9d9ad332022-01-23 12:42:24 +020063def build_obj_list(arch_info, sources, static=False):
Motti Gondabi6f3a9f52021-11-09 15:47:17 +020064
Motti Gondabi9d9ad332022-01-23 12:42:24 +020065 # Clone environment
Georgios Pinitasbdcdc392021-04-22 16:42:03 +010066 tmp_env = arm_compute_env.Clone()
Motti Gondabi6f3a9f52021-11-09 15:47:17 +020067
Motti Gondabi9d9ad332022-01-23 12:42:24 +020068 # Append architecture spec
69 if 'cxxflags' in arch_info and len(arch_info['cxxflags']) > 0:
70 tmp_env.Append(CXXFLAGS = arch_info['cxxflags'])
Motti Gondabi6f3a9f52021-11-09 15:47:17 +020071
Motti Gondabi9d9ad332022-01-23 12:42:24 +020072 # Build and return objects
73 if static:
74 objs = tmp_env.StaticObject(sources)
Motti Gondabi6f3a9f52021-11-09 15:47:17 +020075 else:
Motti Gondabi9d9ad332022-01-23 12:42:24 +020076 objs = tmp_env.SharedObject(sources)
Giorgio Arena892b70a2022-03-30 12:23:10 +010077
Motti Gondabif76a5022021-12-21 13:19:29 +020078 tmp_env.Default(objs)
79 return objs
Georgios Pinitasbdcdc392021-04-22 16:42:03 +010080
Motti Gondabi9d9ad332022-01-23 12:42:24 +020081# @brief Build multi-ISA files with the respective architecture.
82#
83# @return Two distinct lists:
84# A list of static objects
85# A list of shared objects
Michalis Spyrou20fca522021-06-07 14:23:57 +010086
Motti Gondabi9d9ad332022-01-23 12:42:24 +020087def build_lib_objects():
88 lib_static_objs = [] # static objects
89 lib_shared_objs = [] # shared objects
90
91 arm_compute_env.Append(CPPDEFINES = ['ENABLE_NEON', 'ARM_COMPUTE_ENABLE_NEON',
92 'ENABLE_SVE', 'ARM_COMPUTE_ENABLE_SVE',
93 'ARM_COMPUTE_ENABLE_FP16', 'ARM_COMPUTE_ENABLE_BF16',
94 'ARM_COMPUTE_ENABLE_I8MM', 'ARM_COMPUTE_ENABLE_SVEF32MM'])
95
96 # Build all the common files for the base architecture
97 lib_static_objs += build_obj_list(filedefs["armv8.2-a"], lib_files, static=True)
98 lib_shared_objs += build_obj_list(filedefs["armv8.2-a"], lib_files, static=False)
Giorgio Arena892b70a2022-03-30 12:23:10 +010099
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200100 # Build the SVE specific files
101 lib_static_objs += build_obj_list(filedefs["armv8.2-a-sve"], lib_files_sve, static=True)
102 lib_shared_objs += build_obj_list(filedefs["armv8.2-a-sve"], lib_files_sve, static=False)
103
104 # Build the SVE2 specific files
105 arm_compute_env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_SVE2'])
106 lib_static_objs += build_obj_list(filedefs["armv8.6-a-sve2"], lib_files_sve2, static=True)
107 lib_shared_objs += build_obj_list(filedefs["armv8.6-a-sve2"], lib_files_sve2, static=False)
108
109 return lib_static_objs, lib_shared_objs
110
Michalis Spyrou20fca522021-06-07 14:23:57 +0100111
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100112
Georgios Pinitas4d9687e2020-10-21 18:33:36 +0100113def build_library(name, build_env, sources, static=False, libs=[]):
Mohammed Suhail Munshide60ed92021-12-21 11:07:27 +0000114 cloned_build_env = build_env.Clone()
Motti Gondabif76a5022021-12-21 13:19:29 +0200115 if env['os'] == 'android' and static == False:
Mohammed Suhail Munshide60ed92021-12-21 11:07:27 +0000116 cloned_build_env["LINKFLAGS"].remove('-pie')
117 cloned_build_env["LINKFLAGS"].remove('-static-libstdc++')
118
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100119 if static:
Mohammed Suhail Munshide60ed92021-12-21 11:07:27 +0000120 obj = cloned_build_env.StaticLibrary(name, source=sources, LIBS = arm_compute_env["LIBS"] + libs)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100121 else:
122 if env['set_soname']:
Mohammed Suhail Munshide60ed92021-12-21 11:07:27 +0000123 obj = cloned_build_env.SharedLibrary(name, source=sources, SHLIBVERSION = SONAME_VERSION, LIBS = arm_compute_env["LIBS"] + libs)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100124 else:
Mohammed Suhail Munshide60ed92021-12-21 11:07:27 +0000125 obj = cloned_build_env.SharedLibrary(name, source=sources, LIBS = arm_compute_env["LIBS"] + libs)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100126
Pablo Marquez Tello299d3a12022-10-12 14:58:24 +0100127 if env['mapfile']:
Pablo Marquez Telloa4f88702022-10-21 10:24:23 +0100128 if not 'windows' in env['os'] and not 'macos' in env['os']:
129 cloned_build_env['LINKFLAGS'].append('"-Wl,-Map='+ name + '.map"')
130 else:
131 cloned_build_env['LINKFLAGS'].append('-Wl,-map,' + name + '.map')
Pablo Marquez Tello299d3a12022-10-12 14:58:24 +0100132
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000133 obj = install_lib(obj)
Motti Gondabif76a5022021-12-21 13:19:29 +0200134 build_env.Default(obj)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100135 return obj
136
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100137
Georgios Pinitasf605bd22020-11-26 11:55:09 +0000138def remove_incode_comments(code):
139 def replace_with_empty(match):
140 s = match.group(0)
141 if s.startswith('/'):
142 return " "
143 else:
144 return s
145
146 comment_regex = re.compile(r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"', re.DOTALL | re.MULTILINE)
147 return re.sub(comment_regex, replace_with_empty, code)
148
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100149
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100150def resolve_includes(target, source, env):
151 # File collection
152 FileEntry = collections.namedtuple('FileEntry', 'target_name file_contents')
153
154 # Include pattern
155 pattern = re.compile("#include \"(.*)\"")
156
157 # Get file contents
158 files = []
159 for i in range(len(source)):
160 src = source[i]
161 dst = target[i]
Georgios Pinitasf605bd22020-11-26 11:55:09 +0000162 contents = src.get_contents().decode('utf-8')
163 contents = remove_incode_comments(contents).splitlines()
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100164 entry = FileEntry(target_name=dst, file_contents=contents)
165 files.append((os.path.basename(src.get_path()),entry))
166
167 # Create dictionary of tupled list
168 files_dict = dict(files)
169
170 # Check for includes (can only be files in the same folder)
171 final_files = []
172 for file in files:
173 done = False
174 tmp_file = file[1].file_contents
175 while not done:
176 file_count = 0
177 updated_file = []
178 for line in tmp_file:
179 found = pattern.search(line)
180 if found:
Giorgio Arena09adcc42022-03-08 11:12:27 +0000181 # Only get the header file name and discard the relative path.
182 # E.g. "common/experimental/gemm_fused_post_ops/fp_mixed_precision_helpers.h" -> "fp_mixed_precision_helpers.h"
Giorgio Arena232c4522022-03-03 10:09:01 +0000183 include_file = found.group(1).split('/')[-1]
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100184 data = files_dict[include_file].file_contents
185 updated_file.extend(data)
186 else:
187 updated_file.append(line)
188 file_count += 1
189
190 # Check if all include are replaced.
191 if file_count == len(tmp_file):
192 done = True
193
194 # Update temp file
195 tmp_file = updated_file
196
197 # Append and prepend string literal identifiers and add expanded file to final list
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100198 entry = FileEntry(target_name=file[1].target_name, file_contents=tmp_file)
199 final_files.append((file[0], entry))
200
201 # Write output files
202 for file in final_files:
203 with open(file[1].target_name.get_path(), 'w+') as out_file:
Georgios Pinitasea857272021-01-22 05:47:37 +0000204 file_to_write = "\n".join( file[1].file_contents )
205 if env['compress_kernels']:
Adnan AlSinan39aebd12021-08-06 12:44:51 +0100206 file_to_write = zlib.compress(file_to_write.encode('utf-8'), 9)
207 file_to_write = codecs.encode(file_to_write, "base64").decode('utf-8').replace("\n", "")
Georgios Pinitasea857272021-01-22 05:47:37 +0000208 file_to_write = "R\"(" + file_to_write + ")\""
209 out_file.write(file_to_write)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100210
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100211
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100212def create_version_file(target, source, env):
213# Generate string with build options library version to embed in the library:
214 try:
215 git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"])
216 except (OSError, subprocess.CalledProcessError):
217 git_hash="unknown"
218
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100219 build_info = "\"arm_compute_version=%s Build options: %s Git hash=%s\"" % (VERSION, vars.args, git_hash.strip())
220 with open(target[0].get_path(), "w") as fd:
221 fd.write(build_info)
222
Michalis Spyrou20fca522021-06-07 14:23:57 +0100223
Freddie Liardet487d3902021-09-21 12:36:43 +0100224def get_attrs_list(env, data_types, data_layouts):
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100225 attrs = []
Michalis Spyrou20fca522021-06-07 14:23:57 +0100226
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100227 # Manage data-types
Freddie Liardet487d3902021-09-21 12:36:43 +0100228 if 'all' in data_types:
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100229 attrs += ['fp16', 'fp32', 'integer', 'qasymm8', 'qasymm8_signed', 'qsymm16']
230 else:
Freddie Liardet487d3902021-09-21 12:36:43 +0100231 if 'fp16' in data_types: attrs += ['fp16']
232 if 'fp32' in data_types: attrs += ['fp32']
233 if 'integer' in data_types: attrs += ['integer']
234 if 'qasymm8' in data_types: attrs += ['qasymm8']
235 if 'qasymm8_signed' in data_types: attrs += ['qasymm8_signed']
236 if 'qsymm16' in data_types: attrs += ['qsymm16']
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100237 # Manage data-layouts
Freddie Liardet487d3902021-09-21 12:36:43 +0100238 if 'all' in data_layouts:
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100239 attrs += ['nhwc', 'nchw']
240 else:
Freddie Liardet487d3902021-09-21 12:36:43 +0100241 if 'nhwc' in data_layouts: attrs += ['nhwc']
242 if 'nchw' in data_layouts: attrs += ['nchw']
Michalis Spyrou20fca522021-06-07 14:23:57 +0100243
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100244 # Manage execution state
Freddie Liardet487d3902021-09-21 12:36:43 +0100245 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 +0200246
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100247 return attrs
Michalis Spyrou20fca522021-06-07 14:23:57 +0100248
Michalis Spyrou20fca522021-06-07 14:23:57 +0100249
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100250def get_operator_backend_files(filelist, operators, backend='', techs=[], attrs=[]):
251 files = { "common" : [] }
Michalis Spyrou20fca522021-06-07 14:23:57 +0100252
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100253 # Early return if filelist is empty
254 if backend not in filelist:
255 return files
Michalis Spyrou20fca522021-06-07 14:23:57 +0100256
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100257 # Iterate over operators and create the file lists to compiler
258 for operator in operators:
259 if operator in filelist[backend]['operators']:
260 files['common'] += filelist[backend]['operators'][operator]["files"]["common"]
261 for tech in techs:
262 if tech in filelist[backend]['operators'][operator]["files"]:
263 # Add tech as a key to dictionary if not there
264 if tech not in files:
265 files[tech] = []
Michalis Spyrou20fca522021-06-07 14:23:57 +0100266
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100267 # Add tech files to the tech file list
268 tech_files = filelist[backend]['operators'][operator]["files"][tech]
269 files[tech] += tech_files.get('common', [])
270 for attr in attrs:
271 files[tech] += tech_files.get(attr, [])
272
273 # Remove duplicates if they exist
274 return {k: list(set(v)) for k,v in files.items()}
275
276def collect_operators(filelist, operators, backend=''):
277 ops = set()
278 for operator in operators:
279 if operator in filelist[backend]['operators']:
280 ops.add(operator)
281 if 'deps' in filelist[backend]['operators'][operator]:
282 ops.update(filelist[backend]['operators'][operator]['deps'])
283 else:
284 print("Operator {0} is unsupported on {1} backend!".format(operator, backend))
285
286 return ops
287
288
289def resolve_operator_dependencies(filelist, operators, backend=''):
290 resolved_operators = collect_operators(filelist, operators, backend)
291
292 are_ops_resolved = False
293 while not are_ops_resolved:
294 resolution_pass = collect_operators(filelist, resolved_operators, backend)
295 if len(resolution_pass) != len(resolved_operators):
296 resolved_operators.update(resolution_pass)
297 else:
298 are_ops_resolved = True
299
300 return resolved_operators
301
Freddie Liardet487d3902021-09-21 12:36:43 +0100302def read_build_config_json(build_config):
303 build_config_contents = {}
304 custom_operators = []
305 custom_types = []
306 custom_layouts = []
307 if os.path.isfile(build_config):
308 with open(build_config) as f:
309 try:
310 build_config_contents = json.load(f)
311 except:
312 print("Warning: Build configuration file is of invalid JSON format!")
313 else:
314 try:
315 build_config_contents = json.loads(build_config)
316 except:
317 print("Warning: Build configuration string is of invalid JSON format!")
318 if build_config_contents:
319 custom_operators = build_config_contents.get("operators", [])
320 custom_types = build_config_contents.get("data_types", [])
321 custom_layouts = build_config_contents.get("data_layouts", [])
322 return custom_operators, custom_types, custom_layouts
Michalis Spyrou20fca522021-06-07 14:23:57 +0100323
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100324arm_compute_env = env.Clone()
Anthony Barbier0e72c692018-08-24 11:22:08 +0100325version_file = arm_compute_env.Command("src/core/arm_compute_version.embed", "", action=create_version_file)
326arm_compute_env.AlwaysBuild(version_file)
Anthony Barbier6a3daf12018-02-19 17:24:27 +0000327
Kevin Lo7195f712022-01-07 15:46:02 +0800328default_cpp_compiler = 'g++' if env['os'] not in ['android', 'macos', 'openbsd'] else 'clang++'
Georgios Pinitas4d9687e2020-10-21 18:33:36 +0100329cpp_compiler = os.environ.get('CXX', default_cpp_compiler)
330
Anthony Barbier6a3daf12018-02-19 17:24:27 +0000331# Generate embed files
Anthony Barbier0e72c692018-08-24 11:22:08 +0100332generate_embed = [ version_file ]
Anthony Barbier6a3daf12018-02-19 17:24:27 +0000333if env['opencl'] and env['embed_kernels']:
Giorgio Arena892b70a2022-03-30 12:23:10 +0100334
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100335 # Header files
336 cl_helper_files = [ 'src/core/CL/cl_kernels/activation_float_helpers.h',
337 'src/core/CL/cl_kernels/activation_quant_helpers.h',
338 'src/core/CL/cl_kernels/gemm_helpers.h',
339 'src/core/CL/cl_kernels/helpers_asymm.h',
340 'src/core/CL/cl_kernels/helpers.h',
341 'src/core/CL/cl_kernels/load_store_utility.h',
342 'src/core/CL/cl_kernels/repeat.h',
343 'src/core/CL/cl_kernels/tile_helpers.h',
344 'src/core/CL/cl_kernels/types.h',
SiCongLi1af54162021-10-06 15:25:57 +0100345 'src/core/CL/cl_kernels/warp_helpers.h',
346 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/act_eltwise_op_act/fp_post_ops_act_eltwise_op_act.h',
347 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/fp_mixed_precision_helpers.h',
348 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/fp_elementwise_op_helpers.h',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100349 ]
Anthony Barbier6a3daf12018-02-19 17:24:27 +0000350
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100351 # Common kernels
352 cl_files_common = ['src/core/CL/cl_kernels/common/activation_layer.cl',
353 'src/core/CL/cl_kernels/common/activation_layer_quant.cl',
354 'src/core/CL/cl_kernels/common/arg_min_max.cl',
355 'src/core/CL/cl_kernels/common/batchnormalization_layer.cl',
356 'src/core/CL/cl_kernels/common/bounding_box_transform.cl',
357 'src/core/CL/cl_kernels/common/bounding_box_transform_quantized.cl',
358 'src/core/CL/cl_kernels/common/bitwise_op.cl',
359 'src/core/CL/cl_kernels/common/cast.cl',
360 'src/core/CL/cl_kernels/common/comparisons.cl',
361 'src/core/CL/cl_kernels/common/concatenate.cl',
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +0000362 'src/core/CL/cl_kernels/common/convolution_layer.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100363 'src/core/CL/cl_kernels/common/col2im.cl',
364 'src/core/CL/cl_kernels/common/convert_fc_weights.cl',
365 'src/core/CL/cl_kernels/common/copy_tensor.cl',
366 'src/core/CL/cl_kernels/common/crop_tensor.cl',
367 'src/core/CL/cl_kernels/common/deconvolution_layer.cl',
368 'src/core/CL/cl_kernels/common/dequantization_layer.cl',
369 'src/core/CL/cl_kernels/common/elementwise_operation.cl',
370 'src/core/CL/cl_kernels/common/elementwise_operation_quantized.cl',
371 'src/core/CL/cl_kernels/common/elementwise_unary.cl',
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +0000372 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/act_eltwise_op_act/gemm_mm_native.cl',
373 'src/core/CL/cl_kernels/common/experimental/gemm_fused_post_ops/act_eltwise_op_act/gemm_mm_reshaped.cl',
374 '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 +0100375 'src/core/CL/cl_kernels/common/fft_digit_reverse.cl',
376 'src/core/CL/cl_kernels/common/fft.cl',
377 'src/core/CL/cl_kernels/common/fft_scale.cl',
378 'src/core/CL/cl_kernels/common/fill_border.cl',
379 'src/core/CL/cl_kernels/common/floor.cl',
380 'src/core/CL/cl_kernels/common/gather.cl',
381 'src/core/CL/cl_kernels/common/gemm.cl',
Gunes Bayir4bfc70e2021-12-10 16:17:56 +0000382 'src/core/CL/cl_kernels/common/gemm_reshaped_only_rhs_mmul.cl',
ramelg019cca5922021-11-11 10:05:00 +0000383 'src/core/CL/cl_kernels/common/gemm_utils.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100384 'src/core/CL/cl_kernels/common/gemmlowp.cl',
Freddie Liardete572dff2022-05-16 14:09:10 +0100385 'src/core/CL/cl_kernels/common/gemmlowp_reshaped_only_rhs_mmul.cl',
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +0000386 'src/core/CL/cl_kernels/common/gemv.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100387 'src/core/CL/cl_kernels/common/generate_proposals.cl',
388 'src/core/CL/cl_kernels/common/generate_proposals_quantized.cl',
389 'src/core/CL/cl_kernels/common/instance_normalization.cl',
390 'src/core/CL/cl_kernels/common/l2_normalize.cl',
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +0000391 'src/core/CL/cl_kernels/common/mat_mul.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100392 'src/core/CL/cl_kernels/common/mean_stddev_normalization.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100393 'src/core/CL/cl_kernels/common/memset.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100394 'src/core/CL/cl_kernels/common/minmax_layer.cl',
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +0000395 'src/core/CL/cl_kernels/common/nonmax.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100396 'src/core/CL/cl_kernels/common/pad_layer.cl',
397 'src/core/CL/cl_kernels/common/permute.cl',
398 'src/core/CL/cl_kernels/common/pixelwise_mul_float.cl',
399 'src/core/CL/cl_kernels/common/pixelwise_mul_int.cl',
400 'src/core/CL/cl_kernels/common/qlstm_layer_normalization.cl',
401 'src/core/CL/cl_kernels/common/quantization_layer.cl',
402 'src/core/CL/cl_kernels/common/range.cl',
403 'src/core/CL/cl_kernels/common/reduction_operation.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100404 'src/core/CL/cl_kernels/common/reshape_layer.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100405 'src/core/CL/cl_kernels/common/reverse.cl',
406 'src/core/CL/cl_kernels/common/roi_align_layer.cl',
407 'src/core/CL/cl_kernels/common/roi_align_layer_quantized.cl',
408 'src/core/CL/cl_kernels/common/roi_pooling_layer.cl',
409 'src/core/CL/cl_kernels/common/select.cl',
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +0000410 'src/core/CL/cl_kernels/common/slice_ops.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100411 'src/core/CL/cl_kernels/common/softmax_layer.cl',
412 'src/core/CL/cl_kernels/common/softmax_layer_quantized.cl',
413 'src/core/CL/cl_kernels/common/stack_layer.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100414 'src/core/CL/cl_kernels/common/tile.cl',
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +0000415 'src/core/CL/cl_kernels/common/transpose.cl',
416 'src/core/CL/cl_kernels/common/unpooling_layer.cl'
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100417 ]
418
419 # NCHW kernels
420 cl_files_nchw = ['src/core/CL/cl_kernels/nchw/batch_to_space.cl',
421 'src/core/CL/cl_kernels/nchw/batchnormalization_layer.cl',
422 'src/core/CL/cl_kernels/nchw/channel_shuffle.cl',
423 'src/core/CL/cl_kernels/nchw/depth_to_space.cl',
Adnan AlSinan30124352021-12-02 19:12:20 +0000424 'src/core/CL/cl_kernels/nchw/direct_convolution.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100425 'src/core/CL/cl_kernels/nchw/dequantization_layer.cl',
426 'src/core/CL/cl_kernels/nchw/im2col.cl',
427 'src/core/CL/cl_kernels/nchw/normalization_layer.cl',
428 'src/core/CL/cl_kernels/nchw/normalize_planar_yuv_layer.cl',
429 'src/core/CL/cl_kernels/nchw/normalize_planar_yuv_layer_quantized.cl',
430 'src/core/CL/cl_kernels/nchw/pooling_layer.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100431 'src/core/CL/cl_kernels/nchw/prior_box_layer.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100432 'src/core/CL/cl_kernels/nchw/reorg_layer.cl',
433 'src/core/CL/cl_kernels/nchw/scale.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100434 'src/core/CL/cl_kernels/nchw/space_to_batch.cl',
435 'src/core/CL/cl_kernels/nchw/space_to_depth.cl',
436 'src/core/CL/cl_kernels/nchw/upsample_layer.cl',
437 'src/core/CL/cl_kernels/nchw/winograd_filter_transform.cl',
438 'src/core/CL/cl_kernels/nchw/winograd_input_transform.cl',
439 'src/core/CL/cl_kernels/nchw/winograd_output_transform.cl'
440 ]
441
442 # NHWC kernels
443 cl_files_nhwc = ['src/core/CL/cl_kernels/nhwc/batch_to_space.cl',
444 'src/core/CL/cl_kernels/nhwc/batchnormalization_layer.cl',
445 'src/core/CL/cl_kernels/nhwc/channel_shuffle.cl',
446 'src/core/CL/cl_kernels/nhwc/direct_convolution.cl',
Giorgio Arena945ae9e2021-10-13 11:13:04 +0100447 'src/core/CL/cl_kernels/nhwc/direct_convolution3d.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100448 'src/core/CL/cl_kernels/nhwc/depth_to_space.cl',
449 'src/core/CL/cl_kernels/nhwc/dequantization_layer.cl',
450 'src/core/CL/cl_kernels/nhwc/dwc_native_fp_nhwc.cl',
451 'src/core/CL/cl_kernels/nhwc/dwc_native_quantized_nhwc.cl',
452 'src/core/CL/cl_kernels/nhwc/im2col.cl',
Gian Marco Iodice5d016812022-11-17 11:03:39 +0000453 'src/core/CL/cl_kernels/nhwc/indirect_convolution.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100454 'src/core/CL/cl_kernels/nhwc/normalization_layer.cl',
455 'src/core/CL/cl_kernels/nhwc/normalize_planar_yuv_layer.cl',
456 'src/core/CL/cl_kernels/nhwc/normalize_planar_yuv_layer_quantized.cl',
457 'src/core/CL/cl_kernels/nhwc/pooling_layer.cl',
ramelg0137515692022-02-26 22:06:20 +0000458 'src/core/CL/cl_kernels/nhwc/pooling_3d_layer.cl',
Mohammed Suhail Munshi5e549fa2022-03-16 11:14:06 +0000459 'src/core/CL/cl_kernels/nhwc/pooling_3d_layer_quantized.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100460 'src/core/CL/cl_kernels/nhwc/pooling_layer_quantized.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100461 'src/core/CL/cl_kernels/nhwc/reorg_layer.cl',
462 'src/core/CL/cl_kernels/nhwc/scale.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100463 'src/core/CL/cl_kernels/nhwc/space_to_batch.cl',
464 'src/core/CL/cl_kernels/nhwc/space_to_depth.cl',
Gunes Bayirec0113d2022-11-09 09:26:27 +0000465 'src/core/CL/cl_kernels/nhwc/transposed_convolution.cl',
Adnan AlSinan7075fe22021-07-05 13:12:52 +0100466 'src/core/CL/cl_kernels/nhwc/upsample_layer.cl',
467 'src/core/CL/cl_kernels/nhwc/winograd_filter_transform.cl',
468 'src/core/CL/cl_kernels/nhwc/winograd_input_transform.cl',
469 'src/core/CL/cl_kernels/nhwc/winograd_output_transform.cl'
470 ]
471
472 cl_files = cl_helper_files + cl_files_common + cl_files_nchw + cl_files_nhwc
473
474 embed_files = [ f+"embed" for f in cl_files ]
Anthony Barbier6a3daf12018-02-19 17:24:27 +0000475 arm_compute_env.Append(CPPPATH =[Dir("./src/core/CL/").path] )
476
477 generate_embed.append(arm_compute_env.Command(embed_files, cl_files, action=resolve_includes))
478
Anthony Barbier6a3daf12018-02-19 17:24:27 +0000479Default(generate_embed)
480if env["build"] == "embed_only":
481 Return()
482
Georgios Pinitas35fcc432020-03-26 18:47:46 +0000483# Append version defines for semantic versioning
484arm_compute_env.Append(CPPDEFINES = [('ARM_COMPUTE_VERSION_MAJOR', LIBRARY_VERSION_MAJOR),
485 ('ARM_COMPUTE_VERSION_MINOR', LIBRARY_VERSION_MINOR),
486 ('ARM_COMPUTE_VERSION_PATCH', LIBRARY_VERSION_PATCH)])
487
Isabella Gottardib28f29d2017-11-09 17:05:07 +0000488# Don't allow undefined references in the libraries:
Georgios Pinitas45514032020-12-30 00:03:09 +0000489undefined_flag = '-Wl,-undefined,error' if 'macos' in arm_compute_env["os"] else '-Wl,--no-undefined'
490arm_compute_env.Append(LINKFLAGS=[undefined_flag])
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100491arm_compute_env.Append(CPPPATH =[Dir("./src/core/").path] )
492
Kevin Lo7195f712022-01-07 15:46:02 +0800493if env['os'] != 'openbsd':
Pablo Tellofbbfa532023-01-26 16:24:04 +0000494 if env['os'] == 'windows':
495 arm_compute_env.Append(LIBS = [])
496 else:
497 arm_compute_env.Append(LIBS = ['dl'])
498
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100499
Motti Gondabi6f3a9f52021-11-09 15:47:17 +0200500# Load build definitions file
501with (open(Dir('#').path + '/filedefs.json')) as fd:
502 filedefs = json.load(fd)
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200503 filedefs = filedefs['cpu']['arch']
Motti Gondabi6f3a9f52021-11-09 15:47:17 +0200504
505
Georgios Pinitasbdcdc392021-04-22 16:42:03 +0100506with (open(Dir('#').path + '/filelist.json')) as fp:
507 filelist = json.load(fp)
508
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100509# Common backend files
510lib_files = filelist['common']
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100511
Giorgio Arena232c4522022-03-03 10:09:01 +0000512# Experimental files
513# Dynamic fusion
514if env['experimental_dynamic_fusion']:
Giorgio Arena892b70a2022-03-30 12:23:10 +0100515 lib_files += filelist['experimental']['dynamic_fusion']
Giorgio Arena232c4522022-03-03 10:09:01 +0000516
Francesco.Petrogalli@arm.com5fcf22d2022-04-05 10:31:08 +0000517# Fixed format GEMM kernels.
518if env['experimental_fixed_format_kernels']:
Francesco Petrogalli553f6952022-06-30 10:22:01 +0000519 arm_compute_env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS'])
Francesco.Petrogalli@arm.com5fcf22d2022-04-05 10:31:08 +0000520
Giorgio Arena232c4522022-03-03 10:09:01 +0000521
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100522# Logging files
523if env["logging"]:
524 lib_files += filelist['logging']
Georgios Pinitas8795ffb2017-12-01 16:13:40 +0000525
Georgios Pinitasc3c352e2021-03-18 10:59:40 +0000526# C API files
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100527lib_files += filelist['c_api']['common']
528lib_files += filelist['c_api']['operators']
Georgios Pinitasbdcdc392021-04-22 16:42:03 +0100529
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100530# Scheduler infrastructure
531lib_files += filelist['scheduler']['single']
532if env['cppthreads']:
533 lib_files += filelist['scheduler']['threads']
534if env['openmp']:
535 lib_files += filelist['scheduler']['omp']
Georgios Pinitas8a5146f2021-01-12 15:51:07 +0000536
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100537# Graph files
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100538graph_files = Glob('src/graph/*.cpp')
539graph_files += Glob('src/graph/*/*.cpp')
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000540
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100541# Specify user-defined priority operators
Freddie Liardet487d3902021-09-21 12:36:43 +0100542custom_operators = []
543custom_types = []
544custom_layouts = []
545
546use_custom_ops = env['high_priority'] or env['build_config'];
547
548if env['high_priority']:
549 custom_operators = filelist['high_priority']
550 custom_types = ['all']
551 custom_layouts = ['all']
552
553if env['build_config']:
554 custom_operators, custom_types, custom_layouts = read_build_config_json(env['build_config'])
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100555
556if env['opencl']:
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100557 lib_files += filelist['c_api']['gpu']
558 lib_files += filelist['gpu']['common']
Michele Di Giorgio760c7832021-08-05 10:54:13 +0100559
Freddie Liardet487d3902021-09-21 12:36:43 +0100560 cl_operators = custom_operators if use_custom_ops else filelist['gpu']['operators'].keys()
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100561 cl_ops_to_build = resolve_operator_dependencies(filelist, cl_operators, 'gpu')
562 lib_files += get_operator_backend_files(filelist, cl_ops_to_build, 'gpu')['common']
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000563
Georgios Pinitas13ef1762021-07-14 17:14:43 +0100564 graph_files += Glob('src/graph/backends/CL/*.cpp')
565
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200566
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100567lib_files_sve = []
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200568lib_files_sve2 = []
Motti Gondabi6f3a9f52021-11-09 15:47:17 +0200569
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100570if env['neon']:
Georgios Pinitas30271c72019-06-24 14:56:34 +0100571 # build winograd/depthwise sources for either v7a / v8a
Sang-Hoon Park68dd25f2020-10-19 16:00:11 +0100572 arm_compute_env.Append(CPPPATH = ["src/core/NEON/kernels/convolution/common/",
Michele Di Giorgio6ad60af2020-06-09 14:52:15 +0100573 "src/core/NEON/kernels/convolution/winograd/",
ramelg01c827e992022-04-08 03:52:28 +0100574 "src/core/NEON/kernels/arm_conv/depthwise/",
575 "src/core/NEON/kernels/arm_conv/pooling/",
ramelg018a164882022-04-07 02:42:52 +0100576 "src/core/NEON/kernels/arm_conv/",
Sang-Hoon Park68dd25f2020-10-19 16:00:11 +0100577 "src/core/NEON/kernels/assembly/",
Sang-Hoon Park4f7693d2021-05-12 13:59:10 +0100578 "arm_compute/core/NEON/kernels/assembly/",
Motti Gondabi6f3a9f52021-11-09 15:47:17 +0200579 "src/cpu/kernels/assembly/"])
Pablo Tello9ceebbe2018-01-10 16:44:13 +0000580
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100581 lib_files += filelist['cpu']['common']
Georgios Pinitasff4fca02020-10-02 21:00:00 +0100582
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100583 # Setup SIMD file list to include
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200584 simd = ['neon']
585 if env['multi_isa']:
586 simd += ['sve', 'sve2']
587 else:
588 if 'sve' in env['arch']: simd += ['sve']
589 if 'sve2' in env['arch']: simd += ['sve2']
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100590
591 # Get attributes
Freddie Liardet487d3902021-09-21 12:36:43 +0100592 if(use_custom_ops):
593 attrs = get_attrs_list(env, custom_types, custom_layouts)
594 else:
595 attrs = get_attrs_list(env, env['data_type_support'], env['data_layout_support'])
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100596
Francesco.Petrogalli@arm.com5fcf22d2022-04-05 10:31:08 +0000597 if env['experimental_fixed_format_kernels']:
598 attrs.append("experimental_fixed_format_kernels")
599
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100600 # Setup data-type and data-layout files to include
Freddie Liardet487d3902021-09-21 12:36:43 +0100601 cpu_operators = custom_operators if use_custom_ops else filelist['cpu']['operators'].keys()
602 cpu_ops_to_build = resolve_operator_dependencies(filelist, cpu_operators, 'cpu')
603
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100604 cpu_files = get_operator_backend_files(filelist, cpu_ops_to_build, 'cpu', simd, attrs)
Motti Gondabi6f3a9f52021-11-09 15:47:17 +0200605
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200606 # Shared among ALL CPU files
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100607 lib_files += cpu_files.get('common', [])
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200608
609 # Arm® Neon™ specific files
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100610 lib_files += cpu_files.get('neon', [])
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200611
612 # SVE files only
613 lib_files_sve = cpu_files.get('sve', [])
614
615 # SVE2 files only
616 lib_files_sve2 = cpu_files.get('sve2', [])
Georgios Pinitas13ef1762021-07-14 17:14:43 +0100617
618 graph_files += Glob('src/graph/backends/NEON/*.cpp')
Georgios Pinitas70eb53b2021-01-06 19:42:21 +0000619
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100620# Restrict from building graph API if a reduced operator list has been provided
Freddie Liardet487d3902021-09-21 12:36:43 +0100621if use_custom_ops:
622 print("WARNING: Graph library requires all operators to be built")
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100623 graph_files = []
624
625# Build bootcode in case of bare-metal
Michalis Spyrou748a7c82019-10-07 13:00:44 +0100626bootcode_o = []
627if env['os'] == 'bare_metal':
628 bootcode_files = Glob('bootcode/*.s')
629 bootcode_o = build_bootcode_objs(bootcode_files)
630Export('bootcode_o')
631
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200632
Motti Gondabi6f3a9f52021-11-09 15:47:17 +0200633if (env['multi_isa']):
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200634 lib_static_objs, lib_shared_objs = build_lib_objects()
635
636
637# STATIC library build.
638if (env['multi_isa']):
639 arm_compute_a = build_library('arm_compute-static', arm_compute_env, lib_static_objs, static=True)
640else:
641 if 'sve2' in env['arch']:
642 lib_files += lib_files_sve
643 lib_files += lib_files_sve2
644 elif 'sve' in env['arch']:
645 lib_files += lib_files_sve
Motti Gondabi6f3a9f52021-11-09 15:47:17 +0200646
Motti Gondabif76a5022021-12-21 13:19:29 +0200647 arm_compute_a = build_library('arm_compute-static', arm_compute_env, lib_files, static=True)
Motti Gondabif76a5022021-12-21 13:19:29 +0200648
Michalis Spyrou62c2ad62021-06-21 17:40:09 +0100649Export('arm_compute_a')
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100650
Motti Gondabif76a5022021-12-21 13:19:29 +0200651# SHARED library build.
Pablo Telloc6cb35a2017-06-21 15:39:47 +0100652if env['os'] != 'bare_metal' and not env['standalone']:
Motti Gondabi6f3a9f52021-11-09 15:47:17 +0200653 if (env['multi_isa']):
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200654
655 arm_compute_so = build_library('arm_compute', arm_compute_env, lib_shared_objs, static=False)
Georgios Pinitasbdcdc392021-04-22 16:42:03 +0100656 else:
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200657 arm_compute_so = build_library('arm_compute', arm_compute_env, lib_files, static=False)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100658
Michalis Spyrou62c2ad62021-06-21 17:40:09 +0100659 Export('arm_compute_so')
660
Michalis Spyrou62c2ad62021-06-21 17:40:09 +0100661# Generate dummy core lib for backwards compatibility
Pablo Marquez Tello48f26152021-11-18 10:15:23 +0000662if env['os'] == 'macos':
663 # macos static library archiver fails if given an empty list of files
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200664 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 +0000665else:
666 arm_compute_core_a = build_library('arm_compute_core-static', arm_compute_env, [], static=True)
667
Michalis Spyrou62c2ad62021-06-21 17:40:09 +0100668Export('arm_compute_core_a')
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100669
Pablo Telloc6cb35a2017-06-21 15:39:47 +0100670if env['os'] != 'bare_metal' and not env['standalone']:
Michalis Spyrou62c2ad62021-06-21 17:40:09 +0100671 arm_compute_core_a_so = build_library('arm_compute_core', arm_compute_env, [], static=False)
672 Export('arm_compute_core_a_so')
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100673
Sang-Hoon Park18fbb922021-01-14 14:50:25 +0000674arm_compute_graph_env = arm_compute_env.Clone()
675
Georgios Pinitasb6af4822021-09-14 12:33:34 +0100676# Build graph libraries
Sang-Hoon Park18fbb922021-01-14 14:50:25 +0000677arm_compute_graph_env.Append(CXXFLAGS = ['-Wno-redundant-move', '-Wno-pessimizing-move'])
678
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200679arm_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 +0100680Export('arm_compute_graph_a')
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000681
682if env['os'] != 'bare_metal' and not env['standalone']:
Michalis Spyrou62c2ad62021-06-21 17:40:09 +0100683 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 +0000684 Depends(arm_compute_graph_so, arm_compute_so)
Anthony Barbier2a07e182017-08-04 18:20:27 +0100685 Export('arm_compute_graph_so')
686
Pablo Telloc6cb35a2017-06-21 15:39:47 +0100687if env['standalone']:
Motti Gondabi9d9ad332022-01-23 12:42:24 +0200688 alias = arm_compute_env.Alias("arm_compute", [arm_compute_a])
Pablo Telloc6cb35a2017-06-21 15:39:47 +0100689else:
690 alias = arm_compute_env.Alias("arm_compute", [arm_compute_a, arm_compute_so])
691
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100692Default(alias)
693
Pablo Telloc6cb35a2017-06-21 15:39:47 +0100694if env['standalone']:
Michalis Spyrou62c2ad62021-06-21 17:40:09 +0100695 Depends([alias], generate_embed)
Pablo Telloc6cb35a2017-06-21 15:39:47 +0100696else:
Michalis Spyrou62c2ad62021-06-21 17:40:09 +0100697 Depends([alias], generate_embed)