diff --git a/tensorflow/lite/micro/build_def.bzl b/tensorflow/lite/micro/build_def.bzl index 2e966c1ef8c..355283f1910 100644 --- a/tensorflow/lite/micro/build_def.bzl +++ b/tensorflow/lite/micro/build_def.bzl @@ -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 ) diff --git a/tensorflow/lite/micro/tools/benchmarking/BUILD b/tensorflow/lite/micro/tools/benchmarking/BUILD index 3bc3268c2ea..06e09df8a94 100644 --- a/tensorflow/lite/micro/tools/benchmarking/BUILD +++ b/tensorflow/lite/micro/tools/benchmarking/BUILD @@ -1,6 +1,7 @@ load("//tensorflow/lite/micro:build_def.bzl", "tflm_cc_binary", "tflm_cc_library", + "tflm_defines", ) tflm_cc_library( @@ -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",