8000 Introduce a config setting to selectively disable the hexagon delegate. · IBMZ-Linux-OSS-Python/tensorflow@60fc34b · GitHub
[go: up one dir, main page]

Skip to content

Commit 60fc34b

Browse files
Introduce a config setting to selectively disable the hexagon delegate.
Useful for building TfLite runtime tools without dependencies on hexagon(enabled by default). To disable hexagon dependencies, simply add `--define EXPLICIT_DISABLE_HEXAGON=1` or `--//tensorflow/lite/delegates/hexagon:explicit_disable_hexagon=true` to your build command. PiperOrigin-RevId: 673099424
1 parent d3bd57f commit 60fc34b

File tree

1 file changed

+55
-11
lines changed
  • tensorflow/lite/delegates/hexagon

1 file changed

+55
-11
lines changed

tensorflow/lite/delegates/hexagon/BUILD

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
# limitations under the License.
1414
# ==============================================================================
1515

16+
load("@bazel_skylib//lib:selects.bzl", "selects")
17+
load(
18+
"@bazel_skylib//rules:common_settings.bzl",
19+
"bool_flag",
20+
)
1621
load("//tensorflow/lite:build_def.bzl", "tflite_copts", "tflite_linkopts")
1722

1823
package(
@@ -23,6 +28,35 @@ package(
2328
licenses = ["notice"],
2429
)
2530

31+
# If --define EXPLICIT_DISABLE_HEXAGON=1 is passed, the Hexagon delegate will be disabled.
32+
config_setting(
33+
name = "explicit_disable_hexagon_define",
34+
define_values = {
35+
"EXPLICIT_DISABLE_HEXAGON": "1",
36+
},
37+
)
38+
39+
bool_flag(
40+
name = "explicit_disable_hexagon",
41+
build_setting_default = False,
42+
)
43+
44+
config_setting(
45+
name = "explicit_disable_hexagon_flag",
46+
flag_values = {
47+
":explicit_disable_hexagon": "True",
48+
},
49+
)
50+
51+
# Set if either the explicit_disable_hexagon define or the flag is set.
52+
selects.config_setting_group(
53+
name = "explicit_disable_hexagon_setting",
54+
match_any = [
55+
":explicit_disable_hexagon_define",
56+
":explicit_disable_hexagon_flag",
57+
],
58+
)
59+
2660
cc_library(
2761
name = "hexagon_implementation",
2862
srcs = ["hexagon_implementation.cc"],
@@ -77,21 +111,31 @@ cc_library(
77111

78112
cc_library(
79113
name = "hexagon_delegate",
80-
srcs = ["hexagon_delegate.cc"],
81-
hdrs = ["hexagon_delegate.h"],
114+
srcs = select({
115+
":explicit_disable_hexagon_setting": [],
116+
"//conditions:default": ["hexagon_delegate.cc"],
117+
}),
118+
hdrs = select({
119+
":explicit_disable_hexagon_setting": [],
120+
"//conditions:default": ["hexagon_delegate.h"],
121+
}),
82122
tags = [
83123
"manual",
84124
"nobuilder",
85125
],
86-
deps = [
87-
":hexagon_delegate_kernel",
88-
":hexagon_implementation",
89-
":utils",
90-
"//tensorflow/lite:kernel_api",
91-
"//tensorflow/lite:minimal_logging",
92-
"//tensorflow/lite/core/c:common",
93-
"//tensorflow/lite/delegates/utils:simple_delegate",
94-
] + select({
126+
deps = select({
127+
":explicit_disable_hexagon_setting": [],
128+
"//conditions:default": [
129+
":hexagon_delegate_kernel",
130+
":hexagon_implementation",
131+
":utils",
132+
"//tensorflow/lite:kernel_api",
133+
"//tensorflow/lite:minimal_logging",
134+
"//tensorflow/lite/core/c:common",
135+
"//tensorflow/lite/delegates/utils:simple_delegate",
136+
],
137+
}) + select({
138+
":explicit_disable_hexagon_setting": [],
95139
"//tensorflow:ios": [],
96140
"//tensorflow:ios_x86_64": [],
97141
"//tensorflow:macos": [],

0 commit comments

Comments
 (0)
0