Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(bazel): introduce tflm_cc_* macros, refactoring away micro_copts #2765

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions codegen/build_def.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
""" Build rule for generating ML inference code from TFLite model. """

load("//tensorflow/lite/micro:build_def.bzl", "micro_copts")
load("//tensorflow/lite/micro:build_def.bzl", "tflm_cc_library")

def tflm_inference_library(
name,
Expand Down Expand Up @@ -39,7 +39,7 @@ def tflm_inference_library(
visibility = ["//visibility:private"],
)

native.cc_library(
tflm_cc_library(
name = name,
hdrs = [name + ".h"],
srcs = [name + ".cc"],
Expand All @@ -53,6 +53,5 @@ def tflm_inference_library(
"//tensorflow/lite/micro:micro_common",
"//tensorflow/lite/micro:micro_context",
],
copts = micro_copts(),
visibility = visibility,
)
5 changes: 2 additions & 3 deletions codegen/runtime/BUILD
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
load("//tensorflow/lite/micro:build_def.bzl", "micro_copts")
load("//tensorflow/lite/micro:build_def.bzl", "tflm_cc_library")

package(default_visibility = ["//visibility:public"])

cc_library(
tflm_cc_library(
name = "micro_codegen_context",
srcs = ["micro_codegen_context.cc"],
hdrs = ["micro_codegen_context.h"],
copts = micro_copts(),
deps = [
"//tensorflow/lite/c:common",
"//tensorflow/lite/kernels:op_macros",
Expand Down
5 changes: 2 additions & 3 deletions python/tflite_micro/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ load("@rules_python//python:packaging.bzl", "py_package", "py_wheel")
load("@tflm_pip_deps//:requirements.bzl", "requirement")
load(
"//tensorflow/lite/micro:build_def.bzl",
"micro_copts",
"tflm_cc_library",
)
load(
"//tensorflow:extra_rules.bzl",
Expand All @@ -24,15 +24,14 @@ package_group(
packages = tflm_python_op_resolver_friends(),
)

cc_library(
tflm_cc_library(
name = "python_ops_resolver",
srcs = [
"python_ops_resolver.cc",
],
hdrs = [
"python_ops_resolver.h",
],
copts = micro_copts(),
visibility = [
":op_resolver_friends",
"//tensorflow/lite/micro/integration_tests:__subpackages__",
Expand Down
5 changes: 2 additions & 3 deletions signal/micro/kernels/BUILD
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
load(
"//tensorflow/lite/micro:build_def.bzl",
"micro_copts",
"tflm_cc_library",
)

package(licenses = ["notice"])

cc_library(
tflm_cc_library(
name = "register_signal_ops",
srcs = [
"delay.cc",
Expand All @@ -31,7 +31,6 @@ cc_library(
"irfft.h",
"rfft.h",
],
copts = micro_copts(),
visibility = [
"//tensorflow/lite/micro",
],
Expand Down
10 changes: 7 additions & 3 deletions tensorflow/compiler/mlir/lite/core/api/BUILD
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
load("//tensorflow/lite:build_def.bzl", "tflite_copts")
load("//tensorflow/lite/micro:build_def.bzl", "micro_copts")
load(
"//tensorflow/lite/micro:build_def.bzl",
"tflm_cc_library",
"tflm_copts",
)

package(
default_visibility = ["//visibility:public"],
licenses = ["notice"],
)

cc_library(
tflm_cc_library(
name = "error_reporter",
srcs = ["error_reporter.cc"],
hdrs = ["error_reporter.h"],
copts = tflite_copts() + micro_copts(),
copts = tflm_copts() + tflite_copts(),
deps = [],
)
14 changes: 9 additions & 5 deletions tensorflow/lite/core/api/BUILD
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
load("//tensorflow/lite:build_def.bzl", "tflite_copts")
load("//tensorflow/lite/micro:build_def.bzl", "micro_copts")
load(
"//tensorflow/lite/micro:build_def.bzl",
"tflm_cc_library",
"tflm_copts",
)

package(
default_visibility = ["//visibility:private"],
licenses = ["notice"],
)

cc_library(
tflm_cc_library(
name = "api",
srcs = [
"flatbuffer_conversions.cc",
Expand All @@ -17,7 +21,7 @@ cc_library(
"flatbuffer_conversions.h",
"tensor_utils.h",
],
copts = tflite_copts() + micro_copts(),
copts = tflm_copts() + tflite_copts(),
visibility = ["//visibility:public"],
deps = [
":error_reporter",
Expand All @@ -33,13 +37,13 @@ cc_library(
# also exported by the "api" target, so that targets which only want to depend
# on these small abstract base class modules can express more fine-grained
# dependencies without pulling in tensor_utils and flatbuffer_conversions.
cc_library(
tflm_cc_library(
name = "error_reporter",
hdrs = [
"error_reporter.h",
"//tensorflow/compiler/mlir/lite/core/api:error_reporter.h",
],
copts = tflite_copts() + micro_copts(),
copts = tflm_copts() + tflite_copts(),
visibility = [
"//visibility:public",
],
Expand Down
12 changes: 6 additions & 6 deletions tensorflow/lite/experimental/microfrontend/lib/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ cc_test(
name = "filterbank_test",
srcs = ["filterbank_test.cc"],
# Setting copts for experimental code to [], but this code should be fixed
# to build with the default copts (micro_copts())
# to build with the default copts
copts = [],
deps = [
":filterbank",
Expand All @@ -156,7 +156,7 @@ cc_test(
name = "frontend_test",
srcs = ["frontend_test.cc"],
# Setting copts for experimental code to [], but this code should be fixed
# to build with the default copts (micro_copts())
# to build with the default copts
copts = [],
deps = [
":frontend",
Expand All @@ -168,7 +168,7 @@ cc_test(
name = "log_scale_test",
srcs = ["log_scale_test.cc"],
# Setting copts for experimental code to [], but this code should be fixed
# to build with the default copts (micro_copts())
# to build with the default copts
copts = [],
deps = [
":log_scale",
Expand All @@ -180,7 +180,7 @@ cc_test(
name = "noise_reduction_test",
srcs = ["noise_reduction_test.cc"],
# Setting copts for experimental code to [], but this code should be fixed
# to build with the default copts (micro_copts())
# to build with the default copts
copts = [],
deps = [
":noise_reduction",
Expand All @@ -192,7 +192,7 @@ cc_test(
name = "pcan_gain_control_test",
srcs = ["pcan_gain_control_test.cc"],
# Setting copts for experimental code to [], but this code should be fixed
# to build with the default copts (micro_copts())
# to build with the default copts
copts = [],
deps = [
":pcan_gain_control",
Expand All @@ -204,7 +204,7 @@ cc_test(
name = "window_test",
srcs = ["window_test.cc"],
# Setting copts for experimental code to [], but this code should be fixed
# to build with the default copts (micro_copts())
# to build with the default copts
copts = [],
deps = [
":window",
Expand Down
10 changes: 7 additions & 3 deletions tensorflow/lite/kernels/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
load("//tensorflow/lite:build_def.bzl", "tflite_copts")
load("//tensorflow/lite/micro:build_def.bzl", "micro_copts")
load(
"//tensorflow/lite/micro:build_def.bzl",
"tflm_cc_library",
"tflm_copts",
)

package(
default_visibility = [
Expand All @@ -17,15 +21,15 @@ cc_library(
deps = ["//tensorflow/lite/micro:micro_log"],
)

cc_library(
tflm_cc_library(
name = "kernel_util",
srcs = [
"kernel_util.cc",
],
hdrs = [
"kernel_util.h",
],
copts = tflite_copts() + micro_copts(),
copts = tflm_copts() + tflite_copts(),
deps = [
"//tensorflow/lite:array",
"//tensorflow/lite:kernel_api",
Expand Down
10 changes: 7 additions & 3 deletions tensorflow/lite/kernels/internal/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
load("//tensorflow/lite:build_def.bzl", "tflite_copts")
load("//tensorflow/lite/micro:build_def.bzl", "micro_copts")
load(
"//tensorflow/lite/micro:build_def.bzl",
"tflm_cc_library",
"tflm_copts",
)

package(
default_visibility = [
Expand Down Expand Up @@ -44,11 +48,11 @@ cc_library(
copts = tflite_copts(),
)

cc_library(
tflm_cc_library(
name = "quantization_util",
srcs = ["quantization_util.cc"],
hdrs = ["quantization_util.h"],
copts = tflite_copts() + micro_copts(),
copts = tflm_copts() + tflite_copts(),
deps = [
":compatibility",
":cppmath",
Expand Down
Loading
Loading