blob: f897a1a6aa234b45c9016ce875ca318bcd48e45e [file] [log] [blame]
David Svantessone0c42ef2022-12-15 16:25:57 +00001# Copyright (c) 2023 Arm Limited.
2#
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.
22
23load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
24load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
25
26#---------------------------------------------------------------------
27# Config setting for Tensorflow build
28config_setting(
29 name = "build_with_acl",
30 define_values = {
31 "build_with_acl": "true",
32 },
33 visibility = ["//visibility:public"],
34)
35
36#---------------------------------------------------------------------
37# Flags for build options. Example: --//:debug=true
38# All flags have aliases in .bazelrc so can use for example --debug=true when building
39bool_flag(
40 name = "debug",
41 build_setting_default = False,
42 visibility = ["//visibility:public"],
43)
44
45bool_flag(
46 name = "Werror",
47 build_setting_default = False,
48 visibility = ["//visibility:public"],
49)
50
51bool_flag(
52 name = "logging",
53 build_setting_default = False,
54 visibility = ["//visibility:public"],
55)
56
57bool_flag(
58 name = "openmp",
59 build_setting_default = True,
60 visibility = ["//visibility:public"],
61)
62
63bool_flag(
64 name = "cppthreads",
65 build_setting_default = False,
66 visibility = ["//visibility:public"],
67)
68
David Svantesson45370892023-02-22 11:08:57 +000069bool_flag(
70 name = "enable_bf16_validation",
71 build_setting_default = False,
72 visibility = ["//visibility:public"],
73)
74
David Svantesson3b162e52023-03-28 14:13:32 +000075bool_flag(
76 name = "enable_sve_validation",
77 build_setting_default = False,
78 visibility = ["//visibility:public"],
79)
80
David Svantessone0c42ef2022-12-15 16:25:57 +000081#---------------------------------------------------------------------
82# Flag variables
83config_setting(
84 name = "debug_flag",
85 flag_values = {
86 ":debug": "true",
87 },
88)
89
90config_setting(
91 name = "Werror_flag",
92 flag_values = {
93 ":Werror": "true",
94 },
95)
96
97config_setting(
98 name = "logging_flag",
99 flag_values = {
100 ":logging": "true",
101 },
102)
103
104config_setting(
105 name = "openmp_flag",
106 flag_values = {
107 ":openmp": "true",
108 },
109)
110
111config_setting(
112 name = "cppthreads_flag",
113 flag_values = {
114 ":cppthreads": "true",
115 },
116)
117
David Svantesson45370892023-02-22 11:08:57 +0000118config_setting(
119 name = "bf16_validation_flag",
120 flag_values = {
121 ":enable_bf16_validation": "true",
122 },
123)
124
David Svantesson3b162e52023-03-28 14:13:32 +0000125config_setting(
126 name = "sve_validation_flag",
127 flag_values = {
128 ":enable_sve_validation": "true",
129 },
130)
131
David Svantesson45370892023-02-22 11:08:57 +0000132
David Svantessone0c42ef2022-12-15 16:25:57 +0000133#---------------------------------------------------------------------
134# Common defines used for all targets
135cc_library(
136 name = "common_defines",
137 defines = [
138 "ENABLE_NEON",
139 "ARM_COMPUTE_CPU_ENABLED",
140 "ARM_COMPUTE_ENABLE_NEON",
141 "ARM_COMPUTE_ENABLE_FP16",
David Svantessone0c42ef2022-12-15 16:25:57 +0000142 "ARM_COMPUTE_ENABLE_I8MM",
143 "ENABLE_FP16_KERNELS",
144 "ENABLE_FP32_KERNELS",
145 "ENABLE_QASYMM8_KERNELS",
146 "ENABLE_QASYMM8_SIGNED_KERNELS",
147 "ENABLE_QSYMM16_KERNELS",
148 "ENABLE_INTEGER_KERNELS",
149 "ENABLE_NHWC_KERNELS",
150 "ENABLE_NCHW_KERNELS",
151 "DARM_COMPUTE_GRAPH_ENABLED",
152 "ARM_COMPUTE_ENABLE_SVEF32MM",
153 "ARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS",
David Svantesson45370892023-02-22 11:08:57 +0000154 "_GLIBCXX_USE_NANOSLEEP"
David Svantessone0c42ef2022-12-15 16:25:57 +0000155 ] + select({
156 "//:debug_flag": [
157 "ARM_COMPUTE_DEBUG_ENABLED",
158 "ARM_COMPUTE_ASSERTS_ENABLED",
159 ],
160 "//conditions:default": [],
161 }) +
162 select({
163 "//:logging_flag": ["ARM_COMPUTE_LOGGING_ENABLED"],
164 "//conditions:default": [],
165 }) +
166 select({
167 "//:cppthreads_flag": ["ARM_COMPUTE_CPP_SCHEDULER"],
168 "//conditions:default": [],
169 }) +
170 select({
171 "//:openmp_flag": ["ARM_COMPUTE_OPENMP_SCHEDULER"],
172 "//conditions:default": [],
173 }),
174 visibility = ["//visibility:public"],
175)
176
177#---------------------------------------------------------------------
178# Rule for creating file "arm_compute_version.embed"
179genrule(
180 name = "create_version_file",
181 srcs = [".git/HEAD"],
182 outs = ["arm_compute_version.embed"],
183 cmd = "$(location //scripts:print_version_file) bazel-build-options `cat $(location :.git/HEAD)` > $@",
184 tools = ["//scripts:print_version_file"],
185 visibility = ["//visibility:public"],
186)
187
188#---------------------------------------------------------------------
189# Graph library
190
191cc_library(
192 name = "arm_compute_graph",
193 srcs = ["//src:arm_compute_graph_srcs"],
194 copts = [
David Svantessonb5d6c282023-04-24 16:47:04 +0000195 "-march=armv8.2-a+fp16",
David Svantessone0c42ef2022-12-15 16:25:57 +0000196 ] + select({
197 "//:debug_flag": [
198 "-O0",
199 "-g",
200 "-gdwarf-2",
201 ],
202 "//conditions:default": ["-O3"],
203 }) +
204 select({
205 "//:openmp_flag": ["-fopenmp"],
206 "//conditions:default": [],
207 }) +
208 select({
209 "//:Werror_flag": ["-Werror"],
210 "//conditions:default": [],
211 }),
212 visibility = ["//visibility:public"],
213 deps = [
David Svantessonb5d6c282023-04-24 16:47:04 +0000214 "arm_compute_core",
David Svantessone0c42ef2022-12-15 16:25:57 +0000215 "//:common_defines",
216 "//arm_compute:graph_headers",
217 ],
218 alwayslink = True,
219)
220
221#---------------------------------------------------------------------
222# SVE2 library
223
224cc_library(
225 name = "arm_compute_sve2",
226 srcs = ["//src:arm_compute_sve2_srcs"],
227 copts = [
David Svantessonb5d6c282023-04-24 16:47:04 +0000228 "-march=armv8.6-a+sve2+fp16+dotprod",
David Svantessone0c42ef2022-12-15 16:25:57 +0000229 ] + select({
230 "//:debug_flag": [
231 "-O0",
232 "-g",
233 "-gdwarf-2",
234 ],
235 "//conditions:default": ["-O3"],
236 }) +
237 select({
238 "//:openmp_flag": ["-fopenmp"],
239 "//conditions:default": [],
240 }) +
241 select({
242 "//:Werror_flag": ["-Werror"],
243 "//conditions:default": [],
244 }),
245 includes = [
246 "src/core/NEON/kernels/arm_conv",
247 "src/core/NEON/kernels/arm_gemm",
248 "src/core/NEON/kernels/assembly",
249 "src/core/cpu/kernels/assembly",
250 "src/cpu/kernels/assembly",
251 ],
252 linkopts = select({
253 "//:openmp_flag": ["-fopenmp"],
254 "//conditions:default": [],
255 }),
256 local_defines = [
David Svantesson3b162e52023-03-28 14:13:32 +0000257 "ENABLE_SVE",
258 "ARM_COMPUTE_ENABLE_SVE",
David Svantessone0c42ef2022-12-15 16:25:57 +0000259 "ARM_COMPUTE_ENABLE_SVE2",
David Svantesson3b162e52023-03-28 14:13:32 +0000260 "ARM_COMPUTE_ENABLE_BF16",
David Svantessone0c42ef2022-12-15 16:25:57 +0000261 ],
262 deps = [
263 "//:common_defines",
264 "//arm_compute:core_headers",
265 "//arm_compute:runtime_headers",
266 "//include",
267 "//support",
268 ],
269 alwayslink = True,
270)
271
272#---------------------------------------------------------------------
273# SVE library
274
275cc_library(
276 name = "arm_compute_sve",
277 srcs = ["//src:arm_compute_sve_srcs"],
278 copts = [
David Svantessonb5d6c282023-04-24 16:47:04 +0000279 "-march=armv8.2-a+sve+fp16+dotprod",
David Svantessone0c42ef2022-12-15 16:25:57 +0000280 ] + select({
281 "//:debug_flag": [
282 "-O0",
283 "-g",
284 "-gdwarf-2",
285 ],
286 "//conditions:default": ["-O3"],
287 }) +
288 select({
289 "//:openmp_flag": ["-fopenmp"],
290 "//conditions:default": [],
291 }) +
292 select({
293 "//:Werror_flag": ["-Werror"],
294 "//conditions:default": [],
295 }),
296 includes = [
297 "src/core/NEON/kernels/arm_conv",
298 "src/core/NEON/kernels/arm_gemm",
299 "src/core/NEON/kernels/assembly",
300 "src/core/cpu/kernels/assembly",
301 "src/cpu/kernels/assembly",
302 ],
303 linkopts = select({
304 "//:openmp_flag": ["-fopenmp"],
305 "//conditions:default": [],
306 }),
307 local_defines = [
David Svantesson3b162e52023-03-28 14:13:32 +0000308 "ENABLE_SVE",
309 "ARM_COMPUTE_ENABLE_SVE",
David Svantesson45370892023-02-22 11:08:57 +0000310 "ARM_COMPUTE_ENABLE_BF16",
David Svantessone0c42ef2022-12-15 16:25:57 +0000311 ],
312 deps = [
313 "//:common_defines",
314 "//arm_compute:core_headers",
315 "//arm_compute:runtime_headers",
316 "//include",
317 "//support",
318 ],
319 alwayslink = True,
320)
321
322#---------------------------------------------------------------------
323# Core and Runtime library
324
325cc_library(
David Svantessonb5d6c282023-04-24 16:47:04 +0000326 name = "arm_compute_core",
327 srcs = ["//src:arm_compute_core_srcs"],
David Svantessone0c42ef2022-12-15 16:25:57 +0000328 hdrs = glob([
329 "core/NEON/kernels/**/*.h",
330 "core/NEON/kernels/**/*.hpp",
331 "**/*.inl",
332 ]) + [
333 "//:create_version_file",
334 ],
335 copts = [
David Svantessonb5d6c282023-04-24 16:47:04 +0000336 "-march=armv8.2-a+fp16",
David Svantessone0c42ef2022-12-15 16:25:57 +0000337 ] + select({
338 "//:debug_flag": [
339 "-O0",
340 "-g",
341 "-gdwarf-2",
342 ],
343 "//conditions:default": ["-O3"],
344 }) +
345 select({
346 "//:openmp_flag": ["-fopenmp"],
347 "//conditions:default": [],
348 }) +
349 select({
350 "//:Werror_flag": ["-Werror"],
351 "//conditions:default": [],
352 }),
353 includes = [
354 "arm_compute/runtime",
355 "src/core/NEON/kernels/assembly",
356 "src/core/NEON/kernels/convolution/common",
357 "src/core/NEON/kernels/convolution/winograd",
358 "src/core/cpu/kernels/assembly",
359 "src/cpu/kernels/assembly",
360 ],
361 linkopts = select({
362 "//:openmp_flag": ["-fopenmp"],
363 "//conditions:default": [],
364 }),
David Svantesson45370892023-02-22 11:08:57 +0000365 local_defines = [
David Svantesson3b162e52023-03-28 14:13:32 +0000366 "ENABLE_SVE",
367 "ARM_COMPUTE_ENABLE_SVE",
David Svantesson45370892023-02-22 11:08:57 +0000368 "ARM_COMPUTE_ENABLE_BF16",
369 ],
David Svantessone0c42ef2022-12-15 16:25:57 +0000370 visibility = ["//visibility:public"],
371 deps = [
372 "//:common_defines",
373 "//arm_compute:core_headers",
374 "//arm_compute:graph_headers",
375 "//arm_compute:runtime_headers",
376 "//include",
377 "//support",
378 "//utils",
David Svantesson45370892023-02-22 11:08:57 +0000379 "//:arm_compute_sve",
380 "//:arm_compute_sve2"
David Svantessone0c42ef2022-12-15 16:25:57 +0000381 ],
382 alwayslink = True,
383)