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