Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame^] | 1 | load("//tools:platforms.bzl", "platforms") |
| 2 | load("//tools/build_rules:select.bzl", "cpu_select") |
| 3 | |
Brian Silverman | 3fec648 | 2020-01-19 17:56:20 -0800 | [diff] [blame] | 4 | def fast_gaussian(sigmas, sizes): |
Austin Schuh | a4f69d6 | 2020-02-28 13:58:14 -0800 | [diff] [blame] | 5 | 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 Silverman | 3fec648 | 2020-01-19 17:56:20 -0800 | [diff] [blame] | 12 | for cols, rows in sizes: |
Austin Schuh | a4f69d6 | 2020-02-28 13:58:14 -0800 | [diff] [blame] | 13 | files.append("fast_subtract_%dx%d" % (cols, rows)) |
Brian Silverman | 3fec648 | 2020-01-19 17:56:20 -0800 | [diff] [blame] | 14 | |
Austin Schuh | a4f69d6 | 2020-02-28 13:58:14 -0800 | [diff] [blame] | 15 | params = struct( |
| 16 | sigmas = sigmas, |
| 17 | sizes = sizes, |
| 18 | ) |
Brian Silverman | 3fec648 | 2020-01-19 17:56:20 -0800 | [diff] [blame] | 19 | |
Austin Schuh | a4f69d6 | 2020-02-28 13:58:14 -0800 | [diff] [blame] | 20 | 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 Silverman | 3fec648 | 2020-01-19 17:56:20 -0800 | [diff] [blame] | 27 | |
Austin Schuh | a4f69d6 | 2020-02-28 13:58:14 -0800 | [diff] [blame] | 28 | native.genrule( |
| 29 | name = "generate_fast_gaussian", |
| 30 | tools = [ |
| 31 | ":fast_gaussian_runner", |
| 32 | ], |
| 33 | cmd = " ".join([ |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame^] | 34 | "$(location :fast_gaussian_runner)", |
Austin Schuh | a4f69d6 | 2020-02-28 13:58:14 -0800 | [diff] [blame] | 35 | "'" + params.to_json() + "'", |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame^] | 36 | "$(RULEDIR)", |
| 37 | ]) + " " + cpu_select({ |
| 38 | "amd64": "k8", |
| 39 | "roborio": "roborio", |
| 40 | "armhf": "armhf-debian", |
| 41 | "cortex-m": "cortex-m", |
| 42 | }), |
Austin Schuh | a4f69d6 | 2020-02-28 13:58:14 -0800 | [diff] [blame] | 43 | outs = headers + objects + htmls, |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame^] | 44 | # 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 Schuh | a4f69d6 | 2020-02-28 13:58:14 -0800 | [diff] [blame] | 50 | ) |
Brian Silverman | 3fec648 | 2020-01-19 17:56:20 -0800 | [diff] [blame] | 51 | |
Austin Schuh | a4f69d6 | 2020-02-28 13:58:14 -0800 | [diff] [blame] | 52 | 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 Schuh | a4f69d6 | 2020-02-28 13:58:14 -0800 | [diff] [blame] | 59 | ) |