Add rule to build halide generators and add a CrCv generator
This lets us pack images from 2 planes on the ORIN into one plane.
Change-Id: Id6fe6a9a0a267e167f8433c2f7cb26b39c330f60
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/frc971/halide.bzl b/frc971/halide.bzl
new file mode 100644
index 0000000..452716b
--- /dev/null
+++ b/frc971/halide.bzl
@@ -0,0 +1,51 @@
+def halide_library(name, src, function, args, visibility = None):
+ native.genrule(
+ name = name + "_build_generator",
+ outs = [
+ name + "_generator",
+ ],
+ srcs = [
+ src,
+ ],
+ cmd = "$(location //frc971:halide_generator_compile_script) $(OUTS) $(location " + src + ")",
+ tools = [
+ "//frc971:halide_generator_compile_script",
+ ],
+ )
+ native.genrule(
+ name = "generate_" + name,
+ srcs = [
+ ":" + name + "_generator",
+ ],
+ outs = [
+ name + ".h",
+ name + ".o",
+ name + ".stmt.html",
+ ],
+ # TODO(austin): Upgrade halide...
+ cmd = "$(location :" + name + "_generator) -g '" + function + "' -o $(RULEDIR) -f " + name + " -e 'o,h,html' " + select({
+ "@platforms//cpu:x86_64": "target=host ",
+ "@platforms//cpu:aarch64": "target=arm-64-linux-sve2-arm_dot_prod-arm_fp16-armv81a ",
+ "//conditions:default": "",
+ }) + args,
+ target_compatible_with = select({
+ "@platforms//cpu:x86_64": [],
+ "@platforms//cpu:arm64": [],
+ "//conditions:default": ["@platforms//:incompatible"],
+ }) + ["@platforms//os:linux"],
+ )
+
+ native.cc_library(
+ name = name,
+ srcs = [name + ".o"],
+ hdrs = [name + ".h"],
+ visibility = visibility,
+ target_compatible_with = select({
+ "@platforms//cpu:x86_64": [],
+ "@platforms//cpu:arm64": [],
+ "//conditions:default": ["@platforms//:incompatible"],
+ }) + ["@platforms//os:linux"],
+ deps = [
+ "//third_party:halide_runtime",
+ ],
+ )