Implement a build_defs.bzl
shim to simplify new platform porting.
This shim accepts a flag, `build_for_embedded`, which enables additional rules besides `native.cc_library` to build the sources specified in the TFLM build graph. PiperOrigin-RevId: 285291476 Change-Id: Ie65a81cff5083b32c5c3f84845c26b02060b481f
This commit is contained in:
parent
13088cc7ba
commit
1be7afb1c6
tensorflow
@ -1,5 +1,6 @@
|
||||
load("//tensorflow:tensorflow.bzl", "if_not_windows", "tf_cc_test")
|
||||
load("//tensorflow/lite:build_def.bzl", "tflite_cc_shared_object", "tflite_copts")
|
||||
load("//tensorflow/lite/micro:build_def.bzl", "cc_library")
|
||||
load("//tensorflow/lite:special_rules.bzl", "tflite_portable_test_suite")
|
||||
|
||||
package(
|
||||
@ -150,6 +151,7 @@ cc_library(
|
||||
hdrs = [
|
||||
"string_type.h",
|
||||
],
|
||||
build_for_embedded = True,
|
||||
copts = TFLITE_DEFAULT_COPTS,
|
||||
)
|
||||
|
||||
@ -233,6 +235,7 @@ cc_library(
|
||||
name = "string_util",
|
||||
srcs = ["string_util.cc"],
|
||||
hdrs = ["string_util.h"],
|
||||
build_for_embedded = True,
|
||||
copts = TFLITE_DEFAULT_COPTS,
|
||||
deps = [
|
||||
":string",
|
||||
@ -437,6 +440,7 @@ cc_library(
|
||||
cc_library(
|
||||
name = "type_to_tflitetype",
|
||||
hdrs = ["type_to_tflitetype.h"],
|
||||
build_for_embedded = True,
|
||||
deps = ["//tensorflow/lite/c:common"],
|
||||
)
|
||||
|
||||
|
@ -3,6 +3,10 @@ load(
|
||||
"tflite_cc_shared_object",
|
||||
"tflite_copts",
|
||||
)
|
||||
load(
|
||||
"//tensorflow/lite/micro:build_def.bzl",
|
||||
"cc_library",
|
||||
)
|
||||
|
||||
package(
|
||||
default_visibility = [":experimental"],
|
||||
@ -130,6 +134,7 @@ cc_library(
|
||||
"builtin_op_data.h",
|
||||
"common.h",
|
||||
],
|
||||
build_for_embedded = True,
|
||||
visibility = [
|
||||
"//tensorflow/lite:__subpackages__",
|
||||
],
|
||||
|
@ -1,4 +1,5 @@
|
||||
load("//tensorflow/lite:build_def.bzl", "tflite_copts")
|
||||
load("//tensorflow/lite/micro:build_def.bzl", "cc_library")
|
||||
|
||||
package(
|
||||
default_visibility = ["//visibility:public"],
|
||||
@ -20,6 +21,7 @@ cc_library(
|
||||
"profiler.h",
|
||||
"tensor_utils.h",
|
||||
],
|
||||
build_for_embedded = True,
|
||||
copts = tflite_copts(),
|
||||
deps = [
|
||||
"//tensorflow/lite/c:common",
|
||||
|
@ -1,4 +1,5 @@
|
||||
load("//tensorflow/lite:build_def.bzl", "tflite_copts")
|
||||
load("//tensorflow/lite/micro:build_def.bzl", "cc_library")
|
||||
load("//tensorflow/lite:special_rules.bzl", "tflite_portable_test_suite_combined")
|
||||
load("//tensorflow:tensorflow.bzl", "tf_opts_nortti_if_android")
|
||||
|
||||
@ -359,6 +360,7 @@ cc_library(
|
||||
hdrs = [
|
||||
"op_macros.h",
|
||||
],
|
||||
build_for_embedded = True,
|
||||
copts = tflite_copts(),
|
||||
)
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
load("//tensorflow:tensorflow.bzl", "transitive_hdrs")
|
||||
load("//tensorflow/lite:build_def.bzl", "tflite_copts")
|
||||
load("//tensorflow/lite/micro:build_def.bzl", "cc_library")
|
||||
load("//tensorflow/lite:special_rules.bzl", "tflite_portable_test_suite_combined")
|
||||
|
||||
package(
|
||||
@ -41,6 +42,7 @@ NEON_FLAGS_IF_APPLICABLE = select({
|
||||
cc_library(
|
||||
name = "compatibility",
|
||||
hdrs = ["compatibility.h"],
|
||||
build_for_embedded = True,
|
||||
copts = tflite_copts(),
|
||||
deps = [
|
||||
"//tensorflow/lite/kernels:op_macros",
|
||||
@ -60,6 +62,7 @@ cc_library(
|
||||
cc_library(
|
||||
name = "types",
|
||||
hdrs = ["types.h"],
|
||||
build_for_embedded = True,
|
||||
copts = tflite_copts(),
|
||||
deps = [
|
||||
":compatibility",
|
||||
@ -546,6 +549,7 @@ cc_library(
|
||||
"tensor.h",
|
||||
"tensor_ctypes.h",
|
||||
],
|
||||
build_for_embedded = True,
|
||||
copts = tflite_copts(),
|
||||
deps = [
|
||||
":types",
|
||||
|
@ -2,6 +2,10 @@ load(
|
||||
"//tensorflow/lite/micro/testing:micro_test.bzl",
|
||||
"tflite_micro_cc_test",
|
||||
)
|
||||
load(
|
||||
"//tensorflow/lite/micro:build_def.bzl",
|
||||
"cc_library",
|
||||
)
|
||||
|
||||
package(
|
||||
default_visibility = ["//visibility:public"],
|
||||
@ -35,6 +39,7 @@ cc_library(
|
||||
"simple_memory_allocator.h",
|
||||
"test_helpers.h",
|
||||
],
|
||||
build_for_embedded = True,
|
||||
copts = [
|
||||
"-Werror",
|
||||
"-Wdouble-promotion",
|
||||
@ -59,6 +64,7 @@ cc_library(
|
||||
hdrs = [
|
||||
"micro_utils.h",
|
||||
],
|
||||
build_for_embedded = True,
|
||||
deps = [
|
||||
"//tensorflow/lite/c:common",
|
||||
"//tensorflow/lite/kernels:op_macros",
|
||||
|
16
tensorflow/lite/micro/build_def.bzl
Normal file
16
tensorflow/lite/micro/build_def.bzl
Normal file
@ -0,0 +1,16 @@
|
||||
load(
|
||||
"@rules_cc//cc:defs.bzl",
|
||||
_cc_library = "cc_library",
|
||||
)
|
||||
load(
|
||||
"@flatbuffers//:build_defs.bzl",
|
||||
_flatbuffer_cc_library = "flatbuffer_cc_library",
|
||||
)
|
||||
|
||||
def cc_library(**kwargs):
|
||||
kwargs.pop("build_for_embedded", False)
|
||||
_cc_library(**kwargs)
|
||||
|
||||
def flatbuffer_cc_library(**kwargs):
|
||||
kwargs.pop("build_for_embedded", False)
|
||||
_flatbuffer_cc_library(**kwargs)
|
@ -2,6 +2,10 @@ load(
|
||||
"//tensorflow/lite/micro/testing:micro_test.bzl",
|
||||
"tflite_micro_cc_test",
|
||||
)
|
||||
load(
|
||||
"//tensorflow/lite/micro:build_def.bzl",
|
||||
"cc_library",
|
||||
)
|
||||
|
||||
package(
|
||||
default_visibility = ["//visibility:public"],
|
||||
@ -13,6 +17,7 @@ cc_library(
|
||||
hdrs = [
|
||||
"memory_planner.h",
|
||||
],
|
||||
build_for_embedded = True,
|
||||
copts = [
|
||||
"-Werror",
|
||||
"-Wdouble-promotion",
|
||||
@ -54,6 +59,7 @@ cc_library(
|
||||
hdrs = [
|
||||
"greedy_memory_planner.h",
|
||||
],
|
||||
build_for_embedded = True,
|
||||
copts = [
|
||||
"-Werror",
|
||||
"-Wdouble-promotion",
|
||||
|
@ -1,6 +1,6 @@
|
||||
load("//tensorflow:tensorflow.bzl", "py_test")
|
||||
load("//tensorflow/lite:special_rules.bzl", "tflite_portable_test_suite")
|
||||
load("@flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
|
||||
load("//tensorflow/lite/micro:build_def.bzl", "flatbuffer_cc_library")
|
||||
|
||||
package(
|
||||
default_visibility = [
|
||||
@ -61,10 +61,10 @@ exports_files([
|
||||
"schema_v3.fbs",
|
||||
])
|
||||
|
||||
# Generic schema for inference on device.
|
||||
flatbuffer_cc_library(
|
||||
name = "schema_fbs",
|
||||
srcs = ["schema.fbs"],
|
||||
build_for_embedded = True,
|
||||
)
|
||||
|
||||
# Generic schema for flatbuffer converter (but with mutable makes bigger).
|
||||
|
@ -6,6 +6,7 @@ tensorflow/compat_template.__init__.py
|
||||
tensorflow/compat_template_v1.__init__.py
|
||||
tensorflow/compiler/mlir/glob_lit_test.bzl
|
||||
tensorflow/core/public/version.h
|
||||
tensorflow/lite/micro/build_def.bzl
|
||||
tensorflow/python/autograph/core/config.py
|
||||
tensorflow/python/distribute/cluster_resolver/tpu_cluster_resolver.py
|
||||
tensorflow/python/distribute/cluster_resolver/tpu_cluster_resolver_test.py
|
||||
|
Loading…
Reference in New Issue
Block a user