Skip to content

Commit

Permalink
build(bazel): compile in compression when --//:with_compression
Browse files Browse the repository at this point in the history
Conditionally compile in support for compressed tensors when the option
--//:with_compression is given.
  • Loading branch information
rkuester committed Oct 17, 2024
1 parent a1d459b commit 884a234
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
15 changes: 12 additions & 3 deletions tensorflow/lite/micro/build_def.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,30 @@ def tflm_copts():
"-DFLATBUFFERS_LOCALE_INDEPENDENT=0",
]

def tflm_cc_binary(copts = tflm_copts(), **kwargs):
def tflm_defines():
return select({
"//:with_compression_enabled": ["USE_TFLM_COMPRESSION=1"],
"//conditions:default": [],
})

def tflm_cc_binary(copts = tflm_copts(), defines = tflm_defines(), **kwargs):
native.cc_binary(
copts = copts,
defines = defines,
**kwargs
)

def tflm_cc_library(copts = tflm_copts(), **kwargs):
def tflm_cc_library(copts = tflm_copts(), defines = tflm_defines(), **kwargs):
native.cc_library(
copts = copts,
defines = defines,
**kwargs
)

def tflm_cc_test(copts = tflm_copts(), **kwargs):
def tflm_cc_test(copts = tflm_copts(), defines = tflm_defines(), **kwargs):
native.cc_test(
copts = copts,
defines = defines,
**kwargs
)

Expand Down
3 changes: 2 additions & 1 deletion tensorflow/lite/micro/tools/benchmarking/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load("//tensorflow/lite/micro:build_def.bzl",
"tflm_cc_binary",
"tflm_cc_library",
"tflm_defines",
)

tflm_cc_library(
Expand All @@ -26,7 +27,7 @@ tflm_cc_library(
name = "generic_benchmark_lib",
srcs = ["generic_model_benchmark.cc"],
hdrs = ["show_meta_data.h"],
defines = ["GENERIC_BENCHMARK_NO_META_DATA"],
defines = tflm_defines() + ["GENERIC_BENCHMARK_NO_META_DATA"],
deps = [
":metrics",
":op_resolver",
Expand Down

0 comments on commit 884a234

Please sign in to comment.