提交 c7b20bf9 编辑于 作者: Michael Reneer's avatar Michael Reneer 提交者: tensorflow-copybara
浏览文件

Add C++ BUILD files.

* Added BUILD files.
* Updated WORKSPACE.
* Updated bazelrc.
* Added TF patch.

PiperOrigin-RevId: 394259252
上级 629aa528
......@@ -30,6 +30,10 @@ build --copt=-march=native
build --host_copt=-march=native
build --copt=-O3
# C++ compiler options.
build --cxxopt=-std=c++17
build:linux --copt=-Wno-stringop-truncation
# gRPC on MacOS requires this define, see
# https://github.com/bazelbuild/bazel/issues/4341#issuecomment-572050759 for
# more information.
......@@ -48,3 +52,10 @@ build:remote --remote_cache=grpcs://remotebuildexecution.googleapis.com
# Project configuration.
build:remote --remote_instance_name=projects/tensorflow-federated/instances/default_instance
build:remote --project_id=tensorflow-federated
#
# Required to build Tensorflow.
#
# Enable remote execution capabilities.
common --experimental_repo_remote_exec
......@@ -8,6 +8,38 @@ git_repository(
tag = "0.2.0",
)
git_repository(
name = "pybind11_bazel",
remote = "https://github.com/pybind/pybind11_bazel.git",
commit = "26973c0ff320cb4b39e45bc3e4297b82bc3a6c09",
)
new_git_repository(
name = "pybind11",
remote = "https://github.com/pybind/pybind11.git",
build_file = "@pybind11_bazel//:pybind11.BUILD",
tag = "v2.7.1",
)
git_repository(
name = "org_tensorflow",
remote = "https://github.com/tensorflow/tensorflow.git",
tag = "v2.6.0",
patches = ["//third_party/tensorflow:internal_visibility.patch"],
)
load("@org_tensorflow//tensorflow:workspace3.bzl", "tf_workspace3")
tf_workspace3()
load("@org_tensorflow//tensorflow:workspace2.bzl", "tf_workspace2")
tf_workspace2()
load("@org_tensorflow//tensorflow:workspace1.bzl", "tf_workspace1")
tf_workspace1()
load("@org_tensorflow//tensorflow:workspace0.bzl", "tf_workspace0")
tf_workspace0()
git_repository(
name = "com_google_protobuf",
remote = "https://github.com/protocolbuffers/protobuf.git",
......@@ -29,10 +61,28 @@ grpc_deps()
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
grpc_extra_deps()
# git_repository(
# name = "bazel_skylib",
# remote = "https://github.com/bazelbuild/bazel-skylib.git",
# tag = "1.0.3",
# )
git_repository(
name = "com_google_absl",
remote = "https://github.com/abseil/abseil-cpp.git",
tag = "20210324.2",
)
git_repository(
name = "bazel_skylib",
remote = "https://github.com/bazelbuild/bazel-skylib.git",
tag = "1.0.3",
name = "absl_py",
remote = "https://github.com/abseil/abseil-py.git",
tag = "pypi-v0.9.0",
)
git_repository(
name = "com_google_googletest",
remote = "https://github.com/google/googletest.git",
tag = "release-1.11.0",
)
git_repository(
......@@ -42,17 +92,10 @@ git_repository(
)
git_repository(
name = "pybind11_bazel",
remote = "https://github.com/pybind/pybind11_bazel.git",
commit = "26973c0ff320cb4b39e45bc3e4297b82bc3a6c09",
)
new_git_repository(
name = "pybind11",
remote = "https://github.com/pybind/pybind11.git",
build_file = "@pybind11_bazel//:pybind11.BUILD",
tag = "v2.6.2",
name = "pybind11_protobuf",
remote = "https://github.com/pybind/pybind11_protobuf.git",
commit = "b2e7ae2294b8520f01842e4da8e6d030d58c4a27",
)
load("@pybind11_bazel//:python_configure.bzl", "python_configure")
python_configure(name = "local_config_python")
# load("@pybind11_bazel//:python_configure.bzl", "python_configure")
# python_configure(name = "local_config_python")
package(default_visibility = ["//visibility:private"])
package_group(
name = "impl_packages",
packages = [
"//tensorflow_federated/cc/core/impl/...",
"//tensorflow_federated/python/core/impl/...",
],
)
package_group(name = "impl_visibility")
licenses(["notice"])
load("@pybind11_bazel//:build_defs.bzl", "pybind_extension")
package(default_visibility = [
":executor_stacks_packages",
"//tensorflow_federated/cc/core/impl:impl_visibility",
])
package_group(
name = "executor_stacks_packages",
packages = [
"//tensorflow_federated/cc/core/impl/executor_stacks/...",
"//tensorflow_federated/python/core/impl/executor_stacks/...",
],
)
licenses(["notice"])
pybind_extension(
name = "executor_stack_bindings",
srcs = ["executor_stack_bindings.cc"],
tags = ["nokokoro"],
deps = [
":remote_stacks",
"//third_party/grpc:grpc++",
"@com_google_absl//absl/types:span",
"@pybind11_abseil//pybind11_abseil:absl_casters",
"@pybind11_abseil//pybind11_abseil:status_casters",
"@pybind11_protobuf//pybind11_protobuf:proto_casters",
],
)
cc_library(
name = "local_stacks",
srcs = ["local_stacks.cc"],
hdrs = ["local_stacks.h"],
tags = ["nokokoro"],
deps = [
"//tensorflow_federated/cc/core/impl/executors:cardinalities",
"//tensorflow_federated/cc/core/impl/executors:executor",
"//tensorflow_federated/cc/core/impl/executors:federating_executor",
"//tensorflow_federated/cc/core/impl/executors:reference_resolving_executor",
"//tensorflow_federated/cc/core/impl/executors:tensorflow_executor",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
],
)
cc_test(
name = "local_stacks_test",
srcs = ["local_stacks_test.cc"],
tags = ["nokokoro"],
deps = [
":local_stacks",
"//tensorflow_federated/cc/core/impl/executors:mock_executor",
"@com_google_googletest//:gtest_main",
],
)
cc_library(
name = "remote_stacks",
srcs = ["remote_stacks.cc"],
hdrs = ["remote_stacks.h"],
tags = ["nokokoro"],
deps = [
"//tensorflow_federated/cc/core/impl/executors:cardinalities",
"//tensorflow_federated/cc/core/impl/executors:composing_executor",
"//tensorflow_federated/cc/core/impl/executors:executor",
"//tensorflow_federated/cc/core/impl/executors:federating_executor",
"//tensorflow_federated/cc/core/impl/executors:reference_resolving_executor",
"//tensorflow_federated/cc/core/impl/executors:remote_executor",
"//tensorflow_federated/cc/core/impl/executors:tensorflow_executor",
"//tensorflow_federated/cc/core/impl/executors:threading",
"//third_party/grpc:grpc++",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/time",
],
)
cc_test(
name = "remote_stacks_test",
srcs = ["remote_stacks_test.cc"],
tags = ["nokokoro"],
deps = [
":remote_stacks",
"//tensorflow_federated/cc/core/impl/executors:cardinalities",
"//tensorflow_federated/cc/core/impl/executors:executor",
"//tensorflow_federated/cc/core/impl/executors:mock_executor",
"//tensorflow_federated/cc/core/impl/executors:tensorflow_executor",
"//third_party/grpc:grpc++",
"@com_google_googletest//:gtest_main",
],
)
load("//tensorflow_federated/tools:build_defs.bzl", "cc_cpu_gpu_test")
load("@pybind11_bazel//:build_defs.bzl", "pybind_extension")
package(default_visibility = [
":executors_packages",
"//tensorflow_federated/cc/core/impl:impl_visibility",
"//tensorflow_federated/cc/core/impl/executor_stacks:executor_stacks_packages",
])
package_group(
name = "executors_packages",
packages = [
"//tensorflow_federated/cc/core/impl/executors/...",
"//tensorflow_federated/python/core/impl/executors/...",
],
)
licenses(["notice"])
cc_library(
name = "cardinalities",
srcs = ["cardinalities.cc"],
hdrs = ["cardinalities.h"],
tags = ["nokokoro"],
deps = [
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
],
)
cc_library(
name = "composing_executor",
srcs = ["composing_executor.cc"],
hdrs = ["composing_executor.h"],
tags = ["nokokoro"],
deps = [
":cardinalities",
":computations",
":executor",
":federated_intrinsics",
":status_macros",
":threading",
":value_validation",
"@com_google_absl//absl/status",
"@com_google_absl//absl/synchronization",
"@com_google_protobuf//:protobuf",
],
)
cc_test(
name = "composing_executor_test",
srcs = ["composing_executor_test.cc"],
tags = ["nokokoro"],
deps = [
":composing_executor",
":computations",
":executor_test_base",
":federated_intrinsics",
":mock_executor",
":value_test_utils",
"//tensorflow_federated/proto/v0:executor_cc_proto",
"@com_google_googletest//:gtest_main",
],
)
cc_library(
name = "computations",
hdrs = ["computations.h"],
tags = ["nokokoro"],
deps = ["//tensorflow_federated/proto/v0:computation_cc_proto"],
)
pybind_extension(
name = "executor_bindings",
srcs = ["executor_bindings.cc"],
tags = ["nokokoro"],
deps = [
":composing_executor",
":executor",
":federating_executor",
":reference_resolving_executor",
":remote_executor",
":tensorflow_executor",
"//tensorflow_federated/proto/v0:computation_cc_proto",
"//tensorflow_federated/proto/v0:executor_cc_proto",
"//third_party/grpc:grpc++",
"@pybind11_abseil//pybind11_abseil:absl_casters",
"@pybind11_abseil//pybind11_abseil:status_casters",
"@pybind11_protobuf//pybind11_protobuf:proto_casters",
],
)
cc_library(
name = "executor",
srcs = ["executor.cc"],
hdrs = ["executor.h"],
tags = ["nokokoro"],
deps = [
":status_macros",
"//tensorflow_federated/proto/v0:computation_cc_proto",
"//tensorflow_federated/proto/v0:executor_cc_proto",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/synchronization",
"@com_google_absl//absl/types:span",
"@org_tensorflow//tensorflow/core/profiler/lib:traceme",
],
)
cc_library(
name = "executor_service",
srcs = ["executor_service.cc"],
hdrs = ["executor_service.h"],
tags = ["nokokoro"],
deps = [
":cardinalities",
":executor",
":status_macros",
"//tensorflow_federated/proto/v0:computation_cc_proto",
"//tensorflow_federated/proto/v0:executor_cc_grpc_proto",
"//tensorflow_federated/proto/v0:executor_cc_proto",
"//third_party/grpc:grpc++",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/synchronization",
],
)
cc_test(
name = "executor_service_test",
srcs = ["executor_service_test.cc"],
tags = ["nokokoro"],
deps = [
":executor",
":executor_service",
":mock_executor",
":value_test_utils",
"//tensorflow_federated/proto/v0:computation_cc_proto",
"//tensorflow_federated/proto/v0:executor_cc_proto",
"//third_party/grpc:grpc++",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/status",
"@com_google_googletest//:gtest_main",
"@org_tensorflow//tensorflow/core:framework",
"@org_tensorflow//tensorflow/core:protos_all_cc",
],
)
cc_library(
name = "executor_test_base",
testonly = True,
srcs = [],
hdrs = ["executor_test_base.h"],
tags = ["nokokoro"],
deps = [
":mock_executor",
"//tensorflow_federated/proto/v0:executor_cc_proto",
"@com_google_googletest//:gtest",
],
)
cc_library(
name = "federated_intrinsics",
srcs = ["federated_intrinsics.cc"],
hdrs = ["federated_intrinsics.h"],
tags = ["nokokoro"],
deps = ["@com_google_absl//absl/status:statusor"],
)
cc_library(
name = "federating_executor",
srcs = ["federating_executor.cc"],
hdrs = ["federating_executor.h"],
tags = ["nokokoro"],
deps = [
":cardinalities",
":executor",
":federated_intrinsics",
":status_macros",
":threading",
":value_validation",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
],
)
cc_test(
name = "federating_executor_test",
srcs = ["federating_executor_test.cc"],
tags = ["nokokoro"],
deps = [
":executor_test_base",
":federating_executor",
":mock_executor",
":value_test_utils",
"//tensorflow_federated/proto/v0:executor_cc_proto",
"@com_google_googletest//:gtest_main",
],
)
cc_library(
name = "mock_executor",
testonly = True,
hdrs = ["mock_executor.h"],
tags = ["nokokoro"],
deps = [
":executor",
"@com_google_absl//absl/status",
"@com_google_googletest//:gtest",
],
)
cc_library(
name = "mock_grpc",
testonly = True,
hdrs = ["mock_grpc.h"],
tags = ["nokokoro"],
deps = [
"//tensorflow_federated/proto/v0:executor_cc_grpc_proto",
"//tensorflow_federated/proto/v0:executor_cc_proto",
"//third_party/grpc:grpc++",
"@com_google_googletest//:gtest",
],
)
cc_library(
name = "reference_resolving_executor",
srcs = ["reference_resolving_executor.cc"],
hdrs = ["reference_resolving_executor.h"],
tags = ["nokokoro"],
deps = [
":executor",
":status_macros",
"//tensorflow_federated/proto/v0:computation_cc_proto",
"@com_google_absl//absl/status",
"@org_tensorflow//tensorflow/core:tensorflow",
"@org_tensorflow//tensorflow/core/platform:tstring",
],
)
cc_test(
name = "reference_resolving_executor_test",
timeout = "short",
srcs = ["reference_resolving_executor_test.cc"],
tags = ["nokokoro"],
deps = [
":executor",
":executor_test_base",
":mock_executor",
":reference_resolving_executor",
":value_test_utils",
"//tensorflow_federated/proto/v0:computation_cc_proto",
"//tensorflow_federated/proto/v0:executor_cc_proto",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/status",
"@com_google_googletest//:gtest_main",
"@org_tensorflow//tensorflow/cc:array_ops",
"@org_tensorflow//tensorflow/cc:math_ops",
"@org_tensorflow//tensorflow/cc:ops",
"@org_tensorflow//tensorflow/cc:scope",
"@org_tensorflow//tensorflow/core:framework",
"@org_tensorflow//tensorflow/core:protos_all_cc",
],
)
cc_library(
name = "remote_executor",
srcs = ["remote_executor.cc"],
hdrs = ["remote_executor.h"],
tags = ["nokokoro"],
deps = [
":cardinalities",
":executor",
":status_macros",
":threading",
"//tensorflow_federated/proto/v0:computation_cc_proto",
"//tensorflow_federated/proto/v0:executor_cc_grpc_proto",
"//tensorflow_federated/proto/v0:executor_cc_proto",
"//third_party/grpc:grpc++",
"@com_google_absl//absl/status",
"@com_google_absl//absl/synchronization",
],
)
cc_test(
name = "remote_executor_test",
timeout = "short",
srcs = ["remote_executor_test.cc"],
tags = ["nokokoro"],
deps = [
":executor",
":mock_grpc",
":remote_executor",
":value_test_utils",
"//tensorflow_federated/proto/v0:executor_cc_proto",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings",
"@com_google_googletest//:gtest_main",
"@org_tensorflow//tensorflow/cc:array_ops",
"@org_tensorflow//tensorflow/cc:math_ops",
],
)
pybind_extension(
name = "serialization_bindings",
srcs = ["serialization_bindings.cc"],
tags = ["nokokoro"],
deps = [
":status_macros",
":tensor_serialization",
"//tensorflow_federated/proto/v0:executor_cc_proto",
"@org_tensorflow//tensorflow/c:c_api",
"@org_tensorflow//tensorflow/c/eager:c_api",
"@org_tensorflow//tensorflow/core:framework",
"@org_tensorflow//tensorflow/core/common_runtime/eager:tensor_handle",
"@org_tensorflow//tensorflow/python/eager:pywrap_tfe_lib",
"@org_tensorflow//tensorflow/python/lib/core:ndarray_tensor_headers",
"@org_tensorflow//tensorflow/python/lib/core:safe_ptr",
"@pybind11_abseil//pybind11_abseil:absl_casters",
"@pybind11_abseil//pybind11_abseil:status_casters",
"@pybind11_protobuf//pybind11_protobuf:proto_casters",
],
)
cc_library(
name = "status_macros",
hdrs = ["status_macros.h"],
tags = ["nokokoro"],
deps = [
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
],
)
cc_library(
name = "tensor_serialization",
srcs = ["tensor_serialization.cc"],
hdrs = ["tensor_serialization.h"],
tags = ["nokokoro"],
deps = [
":status_macros",
"//tensorflow_federated/proto/v0:executor_cc_proto",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@org_tensorflow//tensorflow/core:framework",
"@org_tensorflow//tensorflow/core:protos_all_cc",
],
)
cc_library(
name = "tensorflow_executor",
srcs = ["tensorflow_executor.cc"],
hdrs = ["tensorflow_executor.h"],
tags = ["nokokoro"],
deps = [
":executor",
":status_macros",
":tensor_serialization",
":threading",
"//tensorflow_federated/proto/v0:computation_cc_proto",
"//tensorflow_federated/proto/v0:executor_cc_proto",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/synchronization",
"@com_google_absl//absl/types:span",
"@org_tensorflow//tensorflow/cc:array_ops",
"@org_tensorflow//tensorflow/cc:client_session",
"@org_tensorflow//tensorflow/cc:dataset_ops_internal",
"@org_tensorflow//tensorflow/cc:scope",
"@org_tensorflow//tensorflow/core:core_cpu",
"@org_tensorflow//tensorflow/core:framework",
"@org_tensorflow//tensorflow/core:protos_all_cc",
"@org_tensorflow//tensorflow/core:tensorflow_opensource",
"@org_tensorflow//tensorflow/core/platform:errors",
"@org_tensorflow//tensorflow/core/platform:tstring",
],
)
cc_cpu_gpu_test(