Skip to content

Commit 3555e03

Browse files
penpornkGoogle-ML-Automation
authored andcommitted
[xla:cpu:ynn] Add build macros for YNNPACK integration.
We won't build XLA with YNNPACK on Windows yet. PiperOrigin-RevId: 820744698
1 parent 4f8ff0b commit 3555e03

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

xla/tsl/xnnpack/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# copybara:uncomment package(default_applicable_licenses = ["//tensorflow:license"])

xla/tsl/xnnpack/build_defs.bzl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""Macros for XNNPACK and YNNPACK."""
2+
3+
load("//xla:xla.default.bzl", "xla_cc_test")
4+
load("//xla/tsl:package_groups.bzl", "DEFAULT_LOAD_VISIBILITY")
5+
6+
visibility(DEFAULT_LOAD_VISIBILITY)
7+
8+
def if_ynnpack(if_true, if_false = []):
9+
"""Selection based on whether we are building XLA with YNNPACK integration.
10+
11+
Args:
12+
if_true: Expression to evaluate if building with YNNPACK.
13+
if_false: Expression to evaluate if building without YNNPACK.
14+
15+
Returns:
16+
A select evaluating to either if_true or if_false as appropriate.
17+
"""
18+
return select({
19+
# YNNPACK is not tested on Windows.
20+
"//xla/tsl:windows": if_false,
21+
"//conditions:default": if_true,
22+
})
23+
24+
def ynn_cc_test(
25+
srcs = [],
26+
deps = [],
27+
**kwargs):
28+
"""xla_cc_test rule with empty src and deps if not building with YNNPACK."""
29+
xla_cc_test(
30+
# CC_TEST_OK=Just defining `xla_cc_test` rule to be used in XLA.
31+
srcs = if_ynnpack(srcs),
32+
deps = if_ynnpack(if_true = deps, if_false = ["@com_google_googletest//:gtest_main"]),
33+
# If not building with YNNPACK, we don't have any tests linked.
34+
fail_if_no_test_linked = False,
35+
# If not building with YNNPACK, we don't have any tests defined either.
36+
fail_if_no_test_selected = False,
37+
**kwargs
38+
)

0 commit comments

Comments
 (0)