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 | ] |
Austin Schuh | 669068e | 2023-01-04 20:50:34 -0800 | [diff] [blame] | 26 | htmls = [f + ".stmt.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", |
Brian Silverman | 4c7235a | 2021-11-17 19:04:37 -0800 | [diff] [blame] | 40 | "armhf": "armv7", |
Philipp Schrader | f1bbf34 | 2022-02-05 14:30:15 -0800 | [diff] [blame] | 41 | "arm64": "aarch64", |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 42 | "cortex-m": "cortex-m", |
Austin Schuh | 0a96ea3 | 2022-01-01 22:29:30 -0800 | [diff] [blame] | 43 | "cortex-m0plus": "cortex-m0plus", |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 44 | }), |
Austin Schuh | a4f69d6 | 2020-02-28 13:58:14 -0800 | [diff] [blame] | 45 | outs = headers + objects + htmls, |
Philipp Schrader | f1bbf34 | 2022-02-05 14:30:15 -0800 | [diff] [blame] | 46 | # The tool doesn't support everything right now. |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 47 | target_compatible_with = platforms.any_of([ |
Philipp Schrader | f1bbf34 | 2022-02-05 14:30:15 -0800 | [diff] [blame] | 48 | "@platforms//cpu:arm64", |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 49 | "@platforms//cpu:x86_64", |
Philipp Schrader | f1bbf34 | 2022-02-05 14:30:15 -0800 | [diff] [blame] | 50 | "//tools:cpu_armhf", |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 51 | ]), |
Austin Schuh | a4f69d6 | 2020-02-28 13:58:14 -0800 | [diff] [blame] | 52 | ) |
Brian Silverman | 3fec648 | 2020-01-19 17:56:20 -0800 | [diff] [blame] | 53 | |
Austin Schuh | a4f69d6 | 2020-02-28 13:58:14 -0800 | [diff] [blame] | 54 | native.cc_library( |
| 55 | name = "fast_gaussian_all", |
| 56 | hdrs = ["fast_gaussian_all.h"], |
| 57 | srcs = headers + objects, |
| 58 | deps = [ |
| 59 | "//third_party:halide_runtime", |
| 60 | ], |
Austin Schuh | a4f69d6 | 2020-02-28 13:58:14 -0800 | [diff] [blame] | 61 | ) |