Polishing touches to workspace macros.

PiperOrigin-RevId: 360217268
Change-Id: I8d47c8e34e116f16011c48181f0487db48f86da8
This commit is contained in:
Christian Sigg 2021-03-01 10:09:20 -08:00 committed by TensorFlower Gardener
parent 27fadcdbde
commit d53a69801a
8 changed files with 34 additions and 63 deletions

View File

@ -1,5 +1,6 @@
"""TensorFlow workspace initialization. Consult the WORKSPACE on how to use it.""" """TensorFlow workspace initialization. Consult the WORKSPACE on how to use it."""
# Import third party config rules.
load("//tensorflow:version_check.bzl", "check_bazel_version_at_least") load("//tensorflow:version_check.bzl", "check_bazel_version_at_least")
load("//third_party/gpus:cuda_configure.bzl", "cuda_configure") load("//third_party/gpus:cuda_configure.bzl", "cuda_configure")
load("//third_party/gpus:rocm_configure.bzl", "rocm_configure") load("//third_party/gpus:rocm_configure.bzl", "rocm_configure")
@ -15,6 +16,8 @@ load("//third_party/toolchains/embedded/arm-linux:arm_linux_toolchain_configure.
load("//third_party:repo.bzl", "tf_http_archive") load("//third_party:repo.bzl", "tf_http_archive")
load("//third_party/clang_toolchain:cc_configure_clang.bzl", "cc_download_clang_toolchain") load("//third_party/clang_toolchain:cc_configure_clang.bzl", "cc_download_clang_toolchain")
load("//tensorflow/tools/def_file_filter:def_file_filter_configure.bzl", "def_file_filter_configure") load("//tensorflow/tools/def_file_filter:def_file_filter_configure.bzl", "def_file_filter_configure")
# Import third party repository rules. See go/tfbr-thirdparty.
load("//third_party/FP16:workspace.bzl", FP16 = "repo") load("//third_party/FP16:workspace.bzl", FP16 = "repo")
load("//third_party/absl:workspace.bzl", absl = "repo") load("//third_party/absl:workspace.bzl", absl = "repo")
load("//third_party/aws:workspace.bzl", aws = "repo") load("//third_party/aws:workspace.bzl", aws = "repo")
@ -39,6 +42,8 @@ load("//third_party/psimd:workspace.bzl", psimd = "repo")
load("//third_party/ruy:workspace.bzl", ruy = "repo") load("//third_party/ruy:workspace.bzl", ruy = "repo")
load("//third_party/sobol_data:workspace.bzl", sobol_data = "repo") load("//third_party/sobol_data:workspace.bzl", sobol_data = "repo")
load("//third_party/vulkan_headers:workspace.bzl", vulkan_headers = "repo") load("//third_party/vulkan_headers:workspace.bzl", vulkan_headers = "repo")
# Import external repository rules.
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
load("@bazel_tools//tools/build_defs/repo:java.bzl", "java_import_external") load("@bazel_tools//tools/build_defs/repo:java.bzl", "java_import_external")
load("@io_bazel_rules_closure//closure:defs.bzl", "filegroup_external") load("@io_bazel_rules_closure//closure:defs.bzl", "filegroup_external")
@ -47,42 +52,34 @@ load("@tf_toolchains//toolchains/remote_config:configs.bzl", "initialize_rbe_con
def _initialize_third_party(): def _initialize_third_party():
""" Load third party repositories. See above load() statements. """ """ Load third party repositories. See above load() statements. """
FP16() FP16()
absl()
aws() aws()
clog() clog()
cpuinfo() cpuinfo()
dlpack() dlpack()
eigen3()
farmhash()
flatbuffers() flatbuffers()
gemmlowp()
hexagon_nn() hexagon_nn()
highwayhash() highwayhash()
hwloc() hwloc()
icu() icu()
kissfft()
jpeg() jpeg()
kissfft()
nasm() nasm()
opencl_headers() opencl_headers()
pasta() pasta()
psimd() psimd()
ruy()
sobol_data() sobol_data()
vulkan_headers() vulkan_headers()
ruy()
# Sanitize a dependency so that it works correctly from code that includes
# TensorFlow as a submodule.
def _clean_dep(dep):
return str(Label(dep))
# Toolchains & platforms required by Tensorflow to build. # Toolchains & platforms required by Tensorflow to build.
def _tf_toolchains(): def _tf_toolchains():
native.register_execution_platforms("@local_execution_config_platform//:platform") native.register_execution_platforms("@local_execution_config_platform//:platform")
native.register_toolchains("@local_execution_config_python//:py_toolchain") native.register_toolchains("@local_execution_config_python//:py_toolchain")
# Define all external repositories required by TensorFlow
def _tf_repositories():
"""All external dependencies for TF builds."""
# Initialize toolchains and platforms.
_tf_toolchains()
# Loads all external repos to configure RBE builds. # Loads all external repos to configure RBE builds.
initialize_rbe_configs() initialize_rbe_configs()
@ -98,8 +95,6 @@ def _tf_repositories():
rocm_configure(name = "local_config_rocm") rocm_configure(name = "local_config_rocm")
remote_execution_configure(name = "local_config_remote_execution") remote_execution_configure(name = "local_config_remote_execution")
_initialize_third_party()
# For windows bazel build # For windows bazel build
# TODO: Remove def file filter when TensorFlow can export symbols properly on Windows. # TODO: Remove def file filter when TensorFlow can export symbols properly on Windows.
def_file_filter_configure(name = "local_config_def_file_filter") def_file_filter_configure(name = "local_config_def_file_filter")
@ -120,6 +115,10 @@ def _tf_repositories():
armhf_repo = "../armhf_linux_toolchain", armhf_repo = "../armhf_linux_toolchain",
) )
# Define all external repositories required by TensorFlow
def _tf_repositories():
"""All external dependencies for TF builds."""
# To update any of the dependencies bellow: # To update any of the dependencies bellow:
# a) update URL and strip_prefix to the new git commit hash # a) update URL and strip_prefix to the new git commit hash
# b) get the sha256 hash of the commit by running: # b) get the sha256 hash of the commit by running:
@ -177,10 +176,6 @@ def _tf_repositories():
], ],
) )
absl("com_google_absl")
eigen3(name = "eigen_archive")
tf_http_archive( tf_http_archive(
name = "arm_compiler", name = "arm_compiler",
build_file = "//:arm_compiler.BUILD", build_file = "//:arm_compiler.BUILD",
@ -300,10 +295,6 @@ def _tf_repositories():
], ],
) )
gemmlowp("gemmlowp")
farmhash("farmhash_archive")
tf_http_archive( tf_http_archive(
name = "png", name = "png",
build_file = "//third_party:png.BUILD", build_file = "//third_party:png.BUILD",
@ -1078,8 +1069,17 @@ def workspace():
# those rules rely on the version we require here. # those rules rely on the version we require here.
check_bazel_version_at_least("1.0.0") check_bazel_version_at_least("1.0.0")
# Load tf_repositories() before loading dependencies for other repository so # Initialize toolchains and platforms.
# that dependencies like com_google_protobuf won't be overridden. _tf_toolchains()
# Import third party repositories according to go/tfbr-thirdparty.
_initialize_third_party()
# Import all other repositories. This should happen before initializing
# any external repositories, because those come with their own
# dependencies. Those recursive dependencies will only be imported if they
# don't already exist (at least if the external repository macros were
# written according to common practice to query native.existing_rule()).
_tf_repositories() _tf_repositories()
# Alias so it can be loaded without assigning to a different symbol to prevent # Alias so it can be loaded without assigning to a different symbol to prevent

View File

@ -2,7 +2,7 @@
load("//third_party:repo.bzl", "tf_http_archive") load("//third_party:repo.bzl", "tf_http_archive")
def repo(name): def repo():
"""Imports absl.""" """Imports absl."""
# Attention: tools parse and update these lines. # Attention: tools parse and update these lines.
@ -10,7 +10,7 @@ def repo(name):
ABSL_SHA256 = "f368a8476f4e2e0eccf8a7318b98dafbe30b2600f4e3cf52636e5eb145aba06a" ABSL_SHA256 = "f368a8476f4e2e0eccf8a7318b98dafbe30b2600f4e3cf52636e5eb145aba06a"
tf_http_archive( tf_http_archive(
name = name, name = "com_google_absl",
sha256 = ABSL_SHA256, sha256 = ABSL_SHA256,
build_file = "//third_party/absl:com_google_absl.BUILD", build_file = "//third_party/absl:com_google_absl.BUILD",
# TODO: Remove the patch when https://github.com/abseil/abseil-cpp/issues/326 is resolved # TODO: Remove the patch when https://github.com/abseil/abseil-cpp/issues/326 is resolved

View File

@ -2,7 +2,7 @@
load("//third_party:repo.bzl", "tf_http_archive") load("//third_party:repo.bzl", "tf_http_archive")
def repo(name): def repo():
"""Imports Eigen.""" """Imports Eigen."""
# Attention: tools parse and update these lines. # Attention: tools parse and update these lines.
@ -10,7 +10,7 @@ def repo(name):
EIGEN_SHA256 = "6ae281a5a32d0f4185856e790c06f58858ffc16594483281621746ffb74d88a2" EIGEN_SHA256 = "6ae281a5a32d0f4185856e790c06f58858ffc16594483281621746ffb74d88a2"
tf_http_archive( tf_http_archive(
name = name, name = "eigen_archive",
build_file = "//third_party/eigen3:eigen_archive.BUILD", build_file = "//third_party/eigen3:eigen_archive.BUILD",
sha256 = EIGEN_SHA256, sha256 = EIGEN_SHA256,
strip_prefix = "eigen-{commit}".format(commit = EIGEN_COMMIT), strip_prefix = "eigen-{commit}".format(commit = EIGEN_COMMIT),

View File

@ -2,7 +2,7 @@
load("//third_party:repo.bzl", "tf_http_archive") load("//third_party:repo.bzl", "tf_http_archive")
def repo(name): def repo():
"""Imports farmhash.""" """Imports farmhash."""
# Attention: tools parse and update these lines. # Attention: tools parse and update these lines.
@ -10,7 +10,7 @@ def repo(name):
FARMHASH_SHA256 = "6560547c63e4af82b0f202cb710ceabb3f21347a4b996db565a411da5b17aba0" FARMHASH_SHA256 = "6560547c63e4af82b0f202cb710ceabb3f21347a4b996db565a411da5b17aba0"
tf_http_archive( tf_http_archive(
name = name, name = "farmhash_archive",
build_file = "//third_party/farmhash:farmhash.BUILD", build_file = "//third_party/farmhash:farmhash.BUILD",
sha256 = FARMHASH_SHA256, sha256 = FARMHASH_SHA256,
strip_prefix = "farmhash-{commit}".format(commit = FARMHASH_COMMIT), strip_prefix = "farmhash-{commit}".format(commit = FARMHASH_COMMIT),

View File

@ -2,7 +2,7 @@
load("//third_party:repo.bzl", "tf_http_archive") load("//third_party:repo.bzl", "tf_http_archive")
def repo(name): def repo():
"""Imports gemmlowp.""" """Imports gemmlowp."""
# Attention: tools parse and update these lines. # Attention: tools parse and update these lines.
@ -10,7 +10,7 @@ def repo(name):
GEMMLOWP_SHA256 = "43146e6f56cb5218a8caaab6b5d1601a083f1f31c06ff474a4378a7d35be9cfb" GEMMLOWP_SHA256 = "43146e6f56cb5218a8caaab6b5d1601a083f1f31c06ff474a4378a7d35be9cfb"
tf_http_archive( tf_http_archive(
name = name, name = "gemmlowp",
sha256 = GEMMLOWP_SHA256, sha256 = GEMMLOWP_SHA256,
strip_prefix = "gemmlowp-{commit}".format(commit = GEMMLOWP_COMMIT), strip_prefix = "gemmlowp-{commit}".format(commit = GEMMLOWP_COMMIT),
urls = [ urls = [

View File

@ -1 +0,0 @@
# Dummy BUILD file to make this directory a package.

View File

@ -1,13 +0,0 @@
# Google's software suite for combinatorial optimization
licenses(["notice"]) # Apache2 license
exports_files(["LICENSE-2.0.txt"])
native.cc_library(
name = "linear_solver_glop",
deps = [
"@ortools_archive//linear_solver:linear_solver_glop",
],
visibility = ["//visibility:public"],
)

View File

@ -1,15 +0,0 @@
"""loads the aws library, used by TF."""
load("//third_party:repo.bzl", "tf_http_archive")
def repo():
tf_http_archive(
name = "ortools_archive",
urls = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/google/or-tools/archive/v6.7.2.tar.gz",
"https://github.com/google/or-tools/archive/v6.7.2.tar.gz",
],
sha256 = "d025a95f78b5fc5eaa4da5f395f23d11c23cf7dbd5069f1f627f002de87b86b9",
strip_prefix = "or-tools-6.7.2/src",
build_file = "//third_party/ortools:BUILD.bazel",
)