blob: 5eaa4bfe34ca5bdfbaa7b4ddb635265b3fa249ac [file] [log] [blame]
Philipp Schraderdada1072020-11-24 11:34:46 -08001load("//tools:platforms.bzl", "platforms")
2load("//tools/build_rules:select.bzl", "cpu_select")
3
Brian Silverman3fec6482020-01-19 17:56:20 -08004def fast_gaussian(sigmas, sizes):
Austin Schuha4f69d62020-02-28 13:58:14 -08005 files = []
6 for _, sigma_name, _ in sigmas:
7 for cols, rows in sizes:
8 files.append("fast_gaussian_%dx%d_%s" % (cols, rows, sigma_name))
9 for _, sigma_name, _ in sigmas:
10 for cols, rows in sizes:
11 files.append("fast_gaussian_subtract_%dx%d_%s" % (cols, rows, sigma_name))
Brian Silverman3fec6482020-01-19 17:56:20 -080012 for cols, rows in sizes:
Austin Schuha4f69d62020-02-28 13:58:14 -080013 files.append("fast_subtract_%dx%d" % (cols, rows))
Brian Silverman3fec6482020-01-19 17:56:20 -080014
Austin Schuha4f69d62020-02-28 13:58:14 -080015 params = struct(
16 sigmas = sigmas,
17 sizes = sizes,
18 )
Brian Silverman3fec6482020-01-19 17:56:20 -080019
Austin Schuha4f69d62020-02-28 13:58:14 -080020 headers = [f + ".h" for f in files] + [
21 "fast_gaussian_all.h",
22 ]
23 objects = [f + ".o" for f in files] + [
24 "fast_gaussian_runtime.o",
25 ]
26 htmls = [f + ".html" for f in files]
Brian Silverman3fec6482020-01-19 17:56:20 -080027
Austin Schuha4f69d62020-02-28 13:58:14 -080028 native.genrule(
29 name = "generate_fast_gaussian",
30 tools = [
31 ":fast_gaussian_runner",
32 ],
33 cmd = " ".join([
Philipp Schraderdada1072020-11-24 11:34:46 -080034 "$(location :fast_gaussian_runner)",
Austin Schuha4f69d62020-02-28 13:58:14 -080035 "'" + params.to_json() + "'",
Philipp Schraderdada1072020-11-24 11:34:46 -080036 "$(RULEDIR)",
37 ]) + " " + cpu_select({
38 "amd64": "k8",
39 "roborio": "roborio",
40 "armhf": "armhf-debian",
41 "cortex-m": "cortex-m",
42 }),
Austin Schuha4f69d62020-02-28 13:58:14 -080043 outs = headers + objects + htmls,
Philipp Schraderdada1072020-11-24 11:34:46 -080044 # The tool doesn't support anything other than k8 and armhf-debian
45 # right now.
46 target_compatible_with = platforms.any_of([
47 "@platforms//cpu:x86_64",
48 "//tools/platforms/hardware:raspberry_pi",
49 ]),
Austin Schuha4f69d62020-02-28 13:58:14 -080050 )
Brian Silverman3fec6482020-01-19 17:56:20 -080051
Austin Schuha4f69d62020-02-28 13:58:14 -080052 native.cc_library(
53 name = "fast_gaussian_all",
54 hdrs = ["fast_gaussian_all.h"],
55 srcs = headers + objects,
56 deps = [
57 "//third_party:halide_runtime",
58 ],
Austin Schuha4f69d62020-02-28 13:58:14 -080059 )