blob: 83c5a7da8481c7076e264c201df88a34b70dbe01 [file] [log] [blame]
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01001# Copyright (c) 2016, 2017 Arm Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002#
3# SPDX-License-Identifier: MIT
4#
5# Permission is hereby granted, free of charge, to any person obtaining a copy
6# of this software and associated documentation files (the "Software"), to
7# deal in the Software without restriction, including without limitation the
8# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9# sell copies of the Software, and to permit persons to whom the Software is
10# furnished to do so, subject to the following conditions:
11#
12# The above copyright notice and this permission notice shall be included in all
13# copies or substantial portions of the Software.
14#
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21# SOFTWARE.
22import collections
23import os.path
24import re
25import subprocess
Georgios Pinitasea857272021-01-22 05:47:37 +000026import zlib
27import base64
28import string
Anthony Barbier6ff3b192017-09-04 18:44:23 +010029
30VERSION = "v0.0-unreleased"
Sheri Zhang5b114252021-05-06 09:49:05 +010031LIBRARY_VERSION_MAJOR = 23
Sang-Hoon Park6d0b3842020-08-14 14:48:08 +010032LIBRARY_VERSION_MINOR = 0
Georgios Pinitas35fcc432020-03-26 18:47:46 +000033LIBRARY_VERSION_PATCH = 0
34SONAME_VERSION = str(LIBRARY_VERSION_MAJOR) + "." + str(LIBRARY_VERSION_MINOR) + "." + str(LIBRARY_VERSION_PATCH)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010035
36Import('env')
37Import('vars')
Anthony Barbier01bbd5f2018-11-01 15:10:51 +000038Import('install_lib')
Anthony Barbier6ff3b192017-09-04 18:44:23 +010039
Michalis Spyrou748a7c82019-10-07 13:00:44 +010040def build_bootcode_objs(sources):
41
42 arm_compute_env.Append(ASFLAGS = "-I bootcode/")
43 obj = arm_compute_env.Object(sources)
44 obj = install_lib(obj)
45 Default(obj)
46 return obj
47
Georgios Pinitas4d9687e2020-10-21 18:33:36 +010048def build_library(name, build_env, sources, static=False, libs=[]):
Anthony Barbier6ff3b192017-09-04 18:44:23 +010049 if static:
Georgios Pinitas4d9687e2020-10-21 18:33:36 +010050 obj = build_env.StaticLibrary(name, source=sources, LIBS = arm_compute_env["LIBS"] + libs)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010051 else:
52 if env['set_soname']:
Georgios Pinitas4d9687e2020-10-21 18:33:36 +010053 obj = build_env.SharedLibrary(name, source=sources, SHLIBVERSION = SONAME_VERSION, LIBS = arm_compute_env["LIBS"] + libs)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010054 else:
Georgios Pinitas4d9687e2020-10-21 18:33:36 +010055 obj = build_env.SharedLibrary(name, source=sources, LIBS = arm_compute_env["LIBS"] + libs)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010056
Anthony Barbier01bbd5f2018-11-01 15:10:51 +000057 obj = install_lib(obj)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010058 Default(obj)
59 return obj
60
Georgios Pinitasf605bd22020-11-26 11:55:09 +000061def remove_incode_comments(code):
62 def replace_with_empty(match):
63 s = match.group(0)
64 if s.startswith('/'):
65 return " "
66 else:
67 return s
68
69 comment_regex = re.compile(r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"', re.DOTALL | re.MULTILINE)
70 return re.sub(comment_regex, replace_with_empty, code)
71
Anthony Barbier6ff3b192017-09-04 18:44:23 +010072def resolve_includes(target, source, env):
73 # File collection
74 FileEntry = collections.namedtuple('FileEntry', 'target_name file_contents')
75
76 # Include pattern
77 pattern = re.compile("#include \"(.*)\"")
78
79 # Get file contents
80 files = []
81 for i in range(len(source)):
82 src = source[i]
83 dst = target[i]
Georgios Pinitasf605bd22020-11-26 11:55:09 +000084 contents = src.get_contents().decode('utf-8')
85 contents = remove_incode_comments(contents).splitlines()
Anthony Barbier6ff3b192017-09-04 18:44:23 +010086 entry = FileEntry(target_name=dst, file_contents=contents)
87 files.append((os.path.basename(src.get_path()),entry))
88
89 # Create dictionary of tupled list
90 files_dict = dict(files)
91
92 # Check for includes (can only be files in the same folder)
93 final_files = []
94 for file in files:
95 done = False
96 tmp_file = file[1].file_contents
97 while not done:
98 file_count = 0
99 updated_file = []
100 for line in tmp_file:
101 found = pattern.search(line)
102 if found:
103 include_file = found.group(1)
104 data = files_dict[include_file].file_contents
105 updated_file.extend(data)
106 else:
107 updated_file.append(line)
108 file_count += 1
109
110 # Check if all include are replaced.
111 if file_count == len(tmp_file):
112 done = True
113
114 # Update temp file
115 tmp_file = updated_file
116
117 # Append and prepend string literal identifiers and add expanded file to final list
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100118 entry = FileEntry(target_name=file[1].target_name, file_contents=tmp_file)
119 final_files.append((file[0], entry))
120
121 # Write output files
122 for file in final_files:
123 with open(file[1].target_name.get_path(), 'w+') as out_file:
Georgios Pinitasea857272021-01-22 05:47:37 +0000124 file_to_write = "\n".join( file[1].file_contents )
125 if env['compress_kernels']:
126 file_to_write = zlib.compress(file_to_write, 9).encode("base64").replace("\n", "")
127 file_to_write = "R\"(" + file_to_write + ")\""
128 out_file.write(file_to_write)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100129
130def create_version_file(target, source, env):
131# Generate string with build options library version to embed in the library:
132 try:
133 git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"])
134 except (OSError, subprocess.CalledProcessError):
135 git_hash="unknown"
136
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100137 build_info = "\"arm_compute_version=%s Build options: %s Git hash=%s\"" % (VERSION, vars.args, git_hash.strip())
138 with open(target[0].get_path(), "w") as fd:
139 fd.write(build_info)
140
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100141arm_compute_env = env.Clone()
Anthony Barbier0e72c692018-08-24 11:22:08 +0100142version_file = arm_compute_env.Command("src/core/arm_compute_version.embed", "", action=create_version_file)
143arm_compute_env.AlwaysBuild(version_file)
Anthony Barbier6a3daf12018-02-19 17:24:27 +0000144
Georgios Pinitas45514032020-12-30 00:03:09 +0000145default_cpp_compiler = 'g++' if env['os'] not in ['android', 'macos'] else 'clang++'
Georgios Pinitas4d9687e2020-10-21 18:33:36 +0100146cpp_compiler = os.environ.get('CXX', default_cpp_compiler)
147
Anthony Barbier6a3daf12018-02-19 17:24:27 +0000148# Generate embed files
Anthony Barbier0e72c692018-08-24 11:22:08 +0100149generate_embed = [ version_file ]
Anthony Barbier6a3daf12018-02-19 17:24:27 +0000150if env['opencl'] and env['embed_kernels']:
151 cl_files = Glob('src/core/CL/cl_kernels/*.cl')
152 cl_files += Glob('src/core/CL/cl_kernels/*.h')
153
154 embed_files = [ f.get_path()+"embed" for f in cl_files ]
155 arm_compute_env.Append(CPPPATH =[Dir("./src/core/CL/").path] )
156
157 generate_embed.append(arm_compute_env.Command(embed_files, cl_files, action=resolve_includes))
158
Anthony Barbier6a3daf12018-02-19 17:24:27 +0000159Default(generate_embed)
160if env["build"] == "embed_only":
161 Return()
162
Georgios Pinitas35fcc432020-03-26 18:47:46 +0000163# Append version defines for semantic versioning
164arm_compute_env.Append(CPPDEFINES = [('ARM_COMPUTE_VERSION_MAJOR', LIBRARY_VERSION_MAJOR),
165 ('ARM_COMPUTE_VERSION_MINOR', LIBRARY_VERSION_MINOR),
166 ('ARM_COMPUTE_VERSION_PATCH', LIBRARY_VERSION_PATCH)])
167
Isabella Gottardib28f29d2017-11-09 17:05:07 +0000168# Don't allow undefined references in the libraries:
Georgios Pinitas45514032020-12-30 00:03:09 +0000169undefined_flag = '-Wl,-undefined,error' if 'macos' in arm_compute_env["os"] else '-Wl,--no-undefined'
170arm_compute_env.Append(LINKFLAGS=[undefined_flag])
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100171arm_compute_env.Append(CPPPATH =[Dir("./src/core/").path] )
172
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100173arm_compute_env.Append(LIBS = ['dl'])
174
175core_files = Glob('src/core/*.cpp')
176core_files += Glob('src/core/CPP/*.cpp')
177core_files += Glob('src/core/CPP/kernels/*.cpp')
Sang-Hoon Park68dd25f2020-10-19 16:00:11 +0100178core_files += Glob('src/core/helpers/*.cpp')
Sang-Hoon Park3687ee12020-06-24 13:34:04 +0100179core_files += Glob('src/core/utils/*.cpp')
Michalis Spyrou7043d362018-12-03 13:58:32 +0000180core_files += Glob('src/core/utils/helpers/*.cpp')
181core_files += Glob('src/core/utils/io/*.cpp')
182core_files += Glob('src/core/utils/quantization/*.cpp')
Georgios Pinitasb8d5b952019-05-16 14:13:03 +0100183core_files += Glob('src/core/utils/misc/*.cpp')
Michalis Spyrou7043d362018-12-03 13:58:32 +0000184if env["logging"]:
185 core_files += Glob('src/core/utils/logging/*.cpp')
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100186
Anthony Barbier8e6faf12017-08-01 17:03:19 +0100187runtime_files = Glob('src/runtime/*.cpp')
Georgios Pinitas8795ffb2017-12-01 16:13:40 +0000188runtime_files += Glob('src/runtime/CPP/ICPPSimpleFunction.cpp')
189runtime_files += Glob('src/runtime/CPP/functions/*.cpp')
190
Georgios Pinitasc3c352e2021-03-18 10:59:40 +0000191# C API files
192c_api_files = ['src/c/AclContext.cpp',
193 'src/c/AclQueue.cpp',
194 'src/c/AclTensor.cpp',
195 'src/c/AclTensorPack.cpp',
196 'src/c/AclVersion.cpp',
197 ]
198if env['opencl']:
199 c_api_files += ['src/c/cl/AclOpenClExt.cpp']
Georgios Pinitas8a5146f2021-01-12 15:51:07 +0000200
Georgios Pinitasc3c352e2021-03-18 10:59:40 +0000201# Common backend files
202common_backend_files = ['src/common/utils/LegacySupport.cpp',
203 'src/common/AllocatorWrapper.cpp',
204 'src/common/ITensorV2.cpp',
205 'src/common/TensorPack.cpp',
206 ]
207
208core_files += common_backend_files
209runtime_files += c_api_files
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100210# CLHarrisCorners uses the Scheduler to run CPP kernels
Anthony Barbier8e6faf12017-08-01 17:03:19 +0100211runtime_files += Glob('src/runtime/CPP/SingleThreadScheduler.cpp')
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100212
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100213graph_files = Glob('src/graph/*.cpp')
214graph_files += Glob('src/graph/*/*.cpp')
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000215
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100216if env['cppthreads']:
Anthony Barbier8e6faf12017-08-01 17:03:19 +0100217 runtime_files += Glob('src/runtime/CPP/CPPScheduler.cpp')
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100218
219if env['openmp']:
Anthony Barbier8e6faf12017-08-01 17:03:19 +0100220 runtime_files += Glob('src/runtime/OMP/OMPScheduler.cpp')
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100221
222if env['opencl']:
223 core_files += Glob('src/core/CL/*.cpp')
224 core_files += Glob('src/core/CL/kernels/*.cpp')
Gian Marco Iodice926afe12019-03-19 11:44:13 +0000225 core_files += Glob('src/core/CL/gemm/*.cpp')
Gian Marco Iodice06be6f82019-06-24 17:47:51 +0100226 core_files += Glob('src/core/CL/gemm/native/*.cpp')
Gian Marco Iodice926afe12019-03-19 11:44:13 +0000227 core_files += Glob('src/core/CL/gemm/reshaped/*.cpp')
228 core_files += Glob('src/core/CL/gemm/reshaped_only_rhs/*.cpp')
Michele Di Giorgio7d61ff02021-01-18 21:15:59 +0000229 core_files += Glob('src/core/gpu/cl/*.cpp')
230 core_files += Glob('src/core/gpu/cl/kernels/*.cpp')
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100231
Anthony Barbier8e6faf12017-08-01 17:03:19 +0100232 runtime_files += Glob('src/runtime/CL/*.cpp')
233 runtime_files += Glob('src/runtime/CL/functions/*.cpp')
Gian Marco Iodice5a4fe192020-03-16 12:22:37 +0000234 runtime_files += Glob('src/runtime/CL/gemm/*.cpp')
Georgios Pinitasc0d1c862018-03-23 15:13:15 +0000235 runtime_files += Glob('src/runtime/CL/tuners/*.cpp')
Michele Di Giorgio7d61ff02021-01-18 21:15:59 +0000236 runtime_files += Glob('src/runtime/gpu/cl/*.cpp')
237 runtime_files += Glob('src/runtime/gpu/cl/operators/*.cpp')
SiCong Li7061eb22021-01-08 15:16:02 +0000238 runtime_files += Glob('src/runtime/CL/mlgo/*.cpp')
SiCong Libd8b1e22021-02-04 13:07:09 +0000239 runtime_files += Glob('src/runtime/CL/gemm_auto_heuristics/*.cpp')
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100240
Georgios Pinitas8a5146f2021-01-12 15:51:07 +0000241 runtime_files += Glob('src/gpu/cl/*.cpp')
Georgios Pinitas8a5146f2021-01-12 15:51:07 +0000242
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100243 graph_files += Glob('src/graph/backends/CL/*.cpp')
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000244
245
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100246if env['neon']:
247 core_files += Glob('src/core/NEON/*.cpp')
248 core_files += Glob('src/core/NEON/kernels/*.cpp')
Anthony Barbierc8e84b52018-07-17 16:48:42 +0100249 core_files += Glob('src/core/NEON/kernels/assembly/*.cpp')
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100250
Pablo Telloeb82fd22018-02-23 13:43:50 +0000251 core_files += Glob('src/core/NEON/kernels/arm_gemm/*.cpp')
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +0000252 core_files += Glob('src/core/NEON/kernels/arm_conv/*.cpp')
253 core_files += Glob('src/core/NEON/kernels/arm_conv/pooling/*.cpp')
254 core_files += Glob('src/core/NEON/kernels/arm_conv/pooling/kernels/cpp_*/*.cpp')
Pablo Telloeb82fd22018-02-23 13:43:50 +0000255
Georgios Pinitas30271c72019-06-24 14:56:34 +0100256 # build winograd/depthwise sources for either v7a / v8a
Georgios Pinitas4074c992018-01-30 18:13:46 +0000257 core_files += Glob('src/core/NEON/kernels/convolution/*/*.cpp')
258 core_files += Glob('src/core/NEON/kernels/convolution/winograd/*/*.cpp')
Sang-Hoon Park68dd25f2020-10-19 16:00:11 +0100259 arm_compute_env.Append(CPPPATH = ["src/core/NEON/kernels/convolution/common/",
Michele Di Giorgio6ad60af2020-06-09 14:52:15 +0100260 "src/core/NEON/kernels/convolution/winograd/",
Sang-Hoon Park68dd25f2020-10-19 16:00:11 +0100261 "src/core/NEON/kernels/convolution/depthwise/",
262 "src/core/NEON/kernels/assembly/",
Sang-Hoon Park4f7693d2021-05-12 13:59:10 +0100263 "arm_compute/core/NEON/kernels/assembly/",
264 "src/core/cpu/kernels/assembly/",])
Pablo Tello9ceebbe2018-01-10 16:44:13 +0000265
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100266 graph_files += Glob('src/graph/backends/NEON/*.cpp')
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000267
Georgios Pinitasf2cdce32019-12-09 18:35:57 +0000268 if env['estate'] == '32':
Pablo Telloeb82fd22018-02-23 13:43:50 +0000269 core_files += Glob('src/core/NEON/kernels/arm_gemm/kernels/a32_*/*.cpp')
270
Georgios Pinitasf2cdce32019-12-09 18:35:57 +0000271 if env['estate'] == '64':
Pablo Telloeb82fd22018-02-23 13:43:50 +0000272 core_files += Glob('src/core/NEON/kernels/arm_gemm/kernels/a64_*/*.cpp')
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +0000273 core_files += Glob('src/core/NEON/kernels/arm_conv/pooling/kernels/a64_*/*.cpp')
Georgios Pinitas421405b2018-10-26 19:05:32 +0100274 if "sve" in env['arch']:
275 core_files += Glob('src/core/NEON/kernels/arm_gemm/kernels/sve_*/*.cpp')
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +0000276 core_files += Glob('src/core/NEON/kernels/arm_conv/pooling/kernels/sve_*/*.cpp')
Moritz Pflanzerbeabe3b2017-08-31 14:56:32 +0100277
Georgios Pinitasff4fca02020-10-02 21:00:00 +0100278 if any(i in env['data_type_support'] for i in ['all', 'fp16']):
Michalis Spyrouaa51a5b2020-11-22 00:49:42 +0000279 core_files += Glob('src/core/NEON/kernels/*/impl/*/fp16.cpp')
Georgios Pinitasff4fca02020-10-02 21:00:00 +0100280 if any(i in env['data_type_support'] for i in ['all', 'fp32']):
Michalis Spyrouaa51a5b2020-11-22 00:49:42 +0000281 core_files += Glob('src/core/NEON/kernels/*/impl/*/fp32.cpp')
Michalis Spyrouc4d45552020-10-19 12:41:30 +0100282 if any(i in env['data_type_support'] for i in ['all', 'qasymm8']):
Michalis Spyrouaa51a5b2020-11-22 00:49:42 +0000283 core_files += Glob('src/core/NEON/kernels/*/impl/*/qasymm8.cpp')
Michalis Spyrouc4d45552020-10-19 12:41:30 +0100284 if any(i in env['data_type_support'] for i in ['all', 'qasymm8_signed']):
Michalis Spyrouaa51a5b2020-11-22 00:49:42 +0000285 core_files += Glob('src/core/NEON/kernels/*/impl/*/qasymm8_signed.cpp')
Michalis Spyrouc4d45552020-10-19 12:41:30 +0100286 if any(i in env['data_type_support'] for i in ['all', 'qsymm16']):
Michalis Spyrouaa51a5b2020-11-22 00:49:42 +0000287 core_files += Glob('src/core/NEON/kernels/*/impl/*/qsymm16.cpp')
Michalis Spyroua3c9a3b2020-12-08 21:02:16 +0000288 if any(i in env['data_type_support'] for i in ['all', 'integer']):
289 core_files += Glob('src/core/NEON/kernels/*/impl/*/integer.cpp')
Georgios Pinitasff4fca02020-10-02 21:00:00 +0100290
Anthony Barbier8e6faf12017-08-01 17:03:19 +0100291 runtime_files += Glob('src/runtime/NEON/*.cpp')
292 runtime_files += Glob('src/runtime/NEON/functions/*.cpp')
Anthony Barbierc8e84b52018-07-17 16:48:42 +0100293 runtime_files += Glob('src/runtime/NEON/functions/assembly/*.cpp')
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100294
Georgios Pinitasc3c352e2021-03-18 10:59:40 +0000295 cpu_kernel_hp_files = ['src/core/cpu/kernels/CpuActivationKernel.cpp',
296 'src/core/cpu/kernels/CpuDepthwiseConvolutionNativeKernel.cpp',
297 'src/core/cpu/kernels/CpuDirectConvolutionKernel.cpp',
298 'src/core/cpu/kernels/CpuDirectConvolutionOutputStageKernel.cpp',
299 'src/core/cpu/kernels/CpuPermuteKernel.cpp',
300 'src/core/cpu/kernels/CpuPoolingAssemblyWrapperKernel.cpp',
301 'src/core/cpu/kernels/CpuPoolingKernel.cpp',
302 'src/core/cpu/kernels/CpuReshapeKernel.cpp',
303 ]
304 cpu_kernel_files = ['src/core/cpu/kernels/CpuAddKernel.cpp',
305 'src/core/cpu/kernels/CpuConcatenateBatchKernel.cpp',
306 'src/core/cpu/kernels/CpuConcatenateDepthKernel.cpp',
307 'src/core/cpu/kernels/CpuConcatenateHeightKernel.cpp',
308 'src/core/cpu/kernels/CpuConcatenateWidthKernel.cpp',
309 'src/core/cpu/kernels/CpuConvertFullyConnectedWeightsKernel.cpp',
310 'src/core/cpu/kernels/CpuCopyKernel.cpp',
Georgios Pinitasef516e82021-04-30 14:46:05 +0100311 'src/core/cpu/kernels/CpuDequantizeKernel.cpp',
Georgios Pinitasc3c352e2021-03-18 10:59:40 +0000312 'src/core/cpu/kernels/CpuElementwiseKernel.cpp',
313 'src/core/cpu/kernels/CpuElementwiseUnaryKernel.cpp',
314 'src/core/cpu/kernels/CpuFillKernel.cpp',
315 'src/core/cpu/kernels/CpuFloorKernel.cpp',
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +0100316 'src/core/cpu/kernels/CpuMulKernel.cpp',
Georgios Pinitasef516e82021-04-30 14:46:05 +0100317 'src/core/cpu/kernels/CpuQuantizeKernel.cpp',
Georgios Pinitasc3c352e2021-03-18 10:59:40 +0000318 'src/core/cpu/kernels/CpuScaleKernel.cpp',
319 'src/core/cpu/kernels/CpuSoftmaxKernel.cpp',
320 'src/core/cpu/kernels/CpuSubKernel.cpp',
321 'src/core/cpu/kernels/CpuTransposeKernel.cpp',
322 ]
323 core_files += [cpu_kernel_hp_files, cpu_kernel_files]
324
Georgios Pinitas70eb53b2021-01-06 19:42:21 +0000325 core_files += Glob('src/core/cpu/kernels/*/*.cpp')
326 if any(i in env['data_type_support'] for i in ['all', 'fp16']):
Georgios Pinitasf8f04422021-01-08 17:25:55 +0000327 core_files += Glob('src/core/cpu/kernels/*/*/fp16.cpp')
Georgios Pinitas70eb53b2021-01-06 19:42:21 +0000328 if any(i in env['data_type_support'] for i in ['all', 'fp32']):
Georgios Pinitasf8f04422021-01-08 17:25:55 +0000329 core_files += Glob('src/core/cpu/kernels/*/*/fp32.cpp')
Georgios Pinitas70eb53b2021-01-06 19:42:21 +0000330 if any(i in env['data_type_support'] for i in ['all', 'qasymm8']):
Georgios Pinitasf8f04422021-01-08 17:25:55 +0000331 core_files += Glob('src/core/cpu/kernels/*/*/qasymm8.cpp')
Georgios Pinitas70eb53b2021-01-06 19:42:21 +0000332 if any(i in env['data_type_support'] for i in ['all', 'qasymm8_signed']):
Georgios Pinitasf8f04422021-01-08 17:25:55 +0000333 core_files += Glob('src/core/cpu/kernels/*/*/qasymm8_signed.cpp')
Georgios Pinitas70eb53b2021-01-06 19:42:21 +0000334 if any(i in env['data_type_support'] for i in ['all', 'qsymm16']):
Georgios Pinitasf8f04422021-01-08 17:25:55 +0000335 core_files += Glob('src/core/cpu/kernels/*/*/qsymm16.cpp')
Sheri Zhang61243902021-01-12 18:25:16 +0000336 if any(i in env['data_type_support'] for i in ['all', 'integer']):
337 core_files += Glob('src/core/cpu/kernels/*/*/integer.cpp')
Georgios Pinitasc3c352e2021-03-18 10:59:40 +0000338
Sheri Zhang79144a62021-02-08 17:43:04 +0000339 if any(i in env['data_layout_support'] for i in ['all', 'nchw']):
340 core_files += Glob('src/core/cpu/kernels/*/*/nchw/all.cpp')
Georgios Pinitas70eb53b2021-01-06 19:42:21 +0000341
Georgios Pinitasc3c352e2021-03-18 10:59:40 +0000342 cpu_rt_files = ['src/cpu/CpuContext.cpp',
343 'src/cpu/CpuQueue.cpp',
344 'src/cpu/CpuTensor.cpp'
345 ]
346 cpu_operator_hp_files = ['src/runtime/cpu/operators/CpuActivation.cpp',
347 'src/runtime/cpu/operators/CpuDepthwiseConvolution.cpp',
348 'src/runtime/cpu/operators/CpuDepthwiseConvolutionAssemblyDispatch.cpp',
349 'src/runtime/cpu/operators/CpuDirectConvolution.cpp',
350 'src/runtime/cpu/operators/CpuPermute.cpp',
351 'src/runtime/cpu/operators/CpuPooling.cpp',
352 'src/runtime/cpu/operators/CpuPoolingAssemblyDispatch.cpp',
353 ]
354 cpu_operator_files = ['src/runtime/cpu/operators/CpuAdd.cpp',
355 'src/runtime/cpu/operators/CpuConcatenate.cpp',
356 'src/runtime/cpu/operators/CpuConvertFullyConnectedWeights.cpp',
357 'src/runtime/cpu/operators/CpuCopy.cpp',
Georgios Pinitasef516e82021-04-30 14:46:05 +0100358 'src/runtime/cpu/operators/CpuDequantize.cpp',
Georgios Pinitasc3c352e2021-03-18 10:59:40 +0000359 'src/runtime/cpu/operators/CpuElementwise.cpp',
360 'src/runtime/cpu/operators/CpuElementwiseUnary.cpp',
361 'src/runtime/cpu/operators/CpuFill.cpp',
362 'src/runtime/cpu/operators/CpuFloor.cpp',
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +0100363 'src/runtime/cpu/operators/CpuMul.cpp',
Georgios Pinitasef516e82021-04-30 14:46:05 +0100364 'src/runtime/cpu/operators/CpuQuantize.cpp',
Georgios Pinitasc3c352e2021-03-18 10:59:40 +0000365 'src/runtime/cpu/operators/CpuReshape.cpp',
366 'src/runtime/cpu/operators/CpuScale.cpp',
367 'src/runtime/cpu/operators/CpuSoftmax.cpp',
368 'src/runtime/cpu/operators/CpuSub.cpp',
369 'src/runtime/cpu/operators/CpuTranspose.cpp',
370 ]
Sang-Hoon Park4f7693d2021-05-12 13:59:10 +0100371 cpu_internal_operator_files = ['src/runtime/cpu/operators/internal/CpuGemmAssemblyDispatch.cpp',]
372 runtime_files += [ cpu_rt_files, cpu_operator_hp_files, cpu_operator_files, cpu_internal_operator_files ]
Georgios Pinitas70eb53b2021-01-06 19:42:21 +0000373
Michalis Spyrou748a7c82019-10-07 13:00:44 +0100374bootcode_o = []
375if env['os'] == 'bare_metal':
376 bootcode_files = Glob('bootcode/*.s')
377 bootcode_o = build_bootcode_objs(bootcode_files)
378Export('bootcode_o')
379
Georgios Pinitas4d9687e2020-10-21 18:33:36 +0100380arm_compute_core_a = build_library('arm_compute_core-static', arm_compute_env, core_files, static=True)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100381Export('arm_compute_core_a')
382
Pablo Telloc6cb35a2017-06-21 15:39:47 +0100383if env['os'] != 'bare_metal' and not env['standalone']:
Georgios Pinitas4d9687e2020-10-21 18:33:36 +0100384 arm_compute_core_so = build_library('arm_compute_core', arm_compute_env, core_files, static=False)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100385 Export('arm_compute_core_so')
386
Georgios Pinitas4d9687e2020-10-21 18:33:36 +0100387arm_compute_a = build_library('arm_compute-static', arm_compute_env, runtime_files, static=True, libs = [ arm_compute_core_a ])
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100388Export('arm_compute_a')
389
Pablo Telloc6cb35a2017-06-21 15:39:47 +0100390if env['os'] != 'bare_metal' and not env['standalone']:
Georgios Pinitas4d9687e2020-10-21 18:33:36 +0100391 arm_compute_so = build_library('arm_compute', arm_compute_env, runtime_files, static=False, libs = [ "arm_compute_core" ])
Anthony Barbierb2881fc2017-09-29 17:12:12 +0100392 Depends(arm_compute_so, arm_compute_core_so)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100393 Export('arm_compute_so')
394
Sang-Hoon Park18fbb922021-01-14 14:50:25 +0000395arm_compute_graph_env = arm_compute_env.Clone()
396
397arm_compute_graph_env.Append(CXXFLAGS = ['-Wno-redundant-move', '-Wno-pessimizing-move'])
398
Georgios Pinitas4d9687e2020-10-21 18:33:36 +0100399arm_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 +0100400Export('arm_compute_graph_a')
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000401
402if env['os'] != 'bare_metal' and not env['standalone']:
Georgios Pinitas4d9687e2020-10-21 18:33:36 +0100403 arm_compute_graph_so = build_library('arm_compute_graph', arm_compute_graph_env, graph_files, static=False, libs = [ "arm_compute" , "arm_compute_core"])
Georgios Pinitas9873ea32017-12-05 15:28:55 +0000404 Depends(arm_compute_graph_so, arm_compute_so)
Anthony Barbier2a07e182017-08-04 18:20:27 +0100405 Export('arm_compute_graph_so')
406
Pablo Telloc6cb35a2017-06-21 15:39:47 +0100407if env['standalone']:
408 alias = arm_compute_env.Alias("arm_compute", [arm_compute_a])
409else:
410 alias = arm_compute_env.Alias("arm_compute", [arm_compute_a, arm_compute_so])
411
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100412Default(alias)
413
Pablo Telloc6cb35a2017-06-21 15:39:47 +0100414if env['standalone']:
415 Depends([alias,arm_compute_core_a], generate_embed)
416else:
417 Depends([alias,arm_compute_core_so, arm_compute_core_a], generate_embed)