Skip to content

Commit

Permalink
Documents when to use xla_test/xla_cc_test/tsl_cc_test.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 726140197
  • Loading branch information
Google-ML-Automation committed Feb 12, 2025
1 parent eabe200 commit a40dbd6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions xla/tests/build_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ def xla_test(
for. This tag is of the form "xla_${BACKEND}" (eg, "xla_cpu"). These
tags can be used to gather tests for a particular backend into a test_suite.
Use xla_test instead of cc_test or xla_cc_test in all tests that need to run
on specific XLA backends. Do not use xla_test in .../tsl/... directories,
where tsl_cc_test should be used instead.
Examples:
# Generates the targets: foo_test_cpu and foo_test_gpu.
Expand Down
5 changes: 5 additions & 0 deletions xla/tsl/platform/default/build_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,11 @@ def tsl_cc_test(
name,
deps = [],
**kwargs):
"""A wrapper around cc_test that adds protobuf deps if needed.
Use tsl_cc_test instead of cc_test in all .../tsl/... directories.
"""

native.cc_test(
name = name,
deps = deps + if_tsl_link_protobuf(
Expand Down
6 changes: 6 additions & 0 deletions xla/xla.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ def xla_cc_binary(deps = [], copts = tsl_copts(), **kwargs):
native.cc_binary(deps = deps + _XLA_SHARED_OBJECT_SENSITIVE_DEPS, copts = copts, **kwargs)

def xla_cc_test(name, deps = [], **kwargs):
"""A wrapper around cc_test that adds XLA-specific dependencies.
Use xla_cc_test or xla_test instead of cc_test in all .../xla/... directories except .../tsl/...,
where tsl_cc_test should be used.
"""

native.cc_test(
name = name,
deps = deps + _XLA_SHARED_OBJECT_SENSITIVE_DEPS,
Expand Down

0 comments on commit a40dbd6

Please sign in to comment.