Skip to content

Commit

Permalink
Adds a xla_bzl_visibility macro for declaring the visibility of a bzl…
Browse files Browse the repository at this point in the history
… file.

PiperOrigin-RevId: 728376113
  • Loading branch information
Google-ML-Automation committed Feb 19, 2025
1 parent aa0835e commit 3e2e6ee
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions xla/tsl/framework/contraction/build_defs.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
"""Defines the cc_binary_disable_onednn build rule to disable oneDNN."""

load("//xla/tsl:tsl.bzl", "xla_bzl_visibility")

visibility(xla_bzl_visibility([
"platforms/xla/...",
"third_party/tensorflow/...",
# The following are legacy users of this .bzl file. DO NOT ADD NEW USERS.
# go/keep-sorted start
"tech/internal/env/extension",
# go/keep-sorted end
]))

def _disable_onednn_transition_impl(settings, attr):
_ignore = (settings, attr) # @unused
return {"//xla/tsl/framework/contraction:disable_onednn_contraction_kernel": True}
Expand Down
13 changes: 13 additions & 0 deletions xla/tsl/tsl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,19 @@ def internal_visibility(internal_targets):
"""
return if_google(internal_targets, ["//visibility:public"])

def _make_abs_targets(targets):
return ["//" + target for target in targets]

def xla_bzl_visibility(targets):
"""To be used in a .bzl file's visibility declaration:
visibility(xla_bzl_visibility(targets))
expands to visibility(targets) inside Google, but visibility("public") in OSS.
"""

return if_google(_make_abs_targets(targets), "public")

# TODO(jakeharmon): Use this to replace if_static
# TODO(b/356020232): remove completely after migration is done
def if_tsl_link_protobuf(if_true, if_false = []):
Expand Down

0 comments on commit 3e2e6ee

Please sign in to comment.