diff --git a/.bazelrc b/.bazelrc index 15d46120642..5ea8048d5d9 100644 --- a/.bazelrc +++ b/.bazelrc @@ -200,6 +200,8 @@ build:nogcp --define=no_gcp_support=true build:nohdfs --define=no_hdfs_support=true build:nonccl --define=no_nccl_support=true +build:stackdriver_support --define=stackdriver_support=true + build --define=use_fast_cpp_protos=true build --define=allow_oversize_protos=true diff --git a/tensorflow/BUILD b/tensorflow/BUILD index ce759634232..bd0619b0c05 100644 --- a/tensorflow/BUILD +++ b/tensorflow/BUILD @@ -298,6 +298,13 @@ config_setting( visibility = ["//visibility:public"], ) +# Experimental features +config_setting( + name = "stackdriver_support", + define_values = {"stackdriver_support": "true"}, + visibility = ["//visibility:public"], +) + # Crosses between platforms and file system libraries not supported on those # platforms due to limitations in nested select() statements. config_setting( diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD index 2b16801f6ed..50f1f2527a5 100644 --- a/tensorflow/core/BUILD +++ b/tensorflow/core/BUILD @@ -100,7 +100,7 @@ load("//tensorflow:tensorflow.bzl", "tf_cc_test_gpu") load("//tensorflow:tensorflow.bzl", "tf_cc_tests_gpu") # buildifier: disable=same-origin-load -load("//tensorflow:tensorflow.bzl", "tf_monitoring_deps") +load("//tensorflow:tensorflow.bzl", "tf_monitoring_framework_deps") # For platform specific build config load( @@ -1950,7 +1950,7 @@ cc_library( "@zlib", "@double_conversion//:double-conversion", "@com_google_protobuf//:protobuf", - ] + tf_protos_all_impl() + tf_protos_grappler_impl() + tf_protos_profiler_impl() + tf_monitoring_deps(), + ] + tf_protos_all_impl() + tf_protos_grappler_impl() + tf_protos_profiler_impl() + tf_monitoring_framework_deps(), # Alwayslink causes a cc_binary to "always link" in the # srcs for a given cc_library, even if they are unreferenced, see: # https://docs.bazel.build/versions/master/be/c-cpp.html#cc_library.alwayslink diff --git a/tensorflow/python/BUILD b/tensorflow/python/BUILD index a7338772589..87048ba9d40 100644 --- a/tensorflow/python/BUILD +++ b/tensorflow/python/BUILD @@ -5,6 +5,9 @@ load("//tensorflow:tensorflow.bzl", "py_strict_library") load("//tensorflow:tensorflow.bzl", "cc_header_only_library", "if_mlir", "if_not_windows", "if_xla_available", "py_test", "py_tests", "tf_cc_shared_object", "tf_cuda_library", "tf_gen_op_wrapper_py") +# buildifier: disable=same-origin-load +load("//tensorflow:tensorflow.bzl", "tf_monitoring_python_deps") + # buildifier: disable=same-origin-load load("//tensorflow:tensorflow.bzl", "tf_python_pybind_extension") @@ -6048,6 +6051,7 @@ pywrap_tensorflow_macro( "//tensorflow/core/util/tensor_bundle", "//tensorflow/compiler/mlir/python:mlir", ] + (tf_additional_lib_deps() + + tf_monitoring_python_deps() + tf_additional_plugin_deps() + tf_additional_profiler_deps()) + if_ngraph([ "@ngraph_tf//:ngraph_tf", diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl index 2609f5a42cf..f97363a919e 100644 --- a/tensorflow/tensorflow.bzl +++ b/tensorflow/tensorflow.bzl @@ -2864,8 +2864,31 @@ def if_cuda_or_rocm(if_true, if_false = []): "//conditions:default": if_false, }) -def tf_monitoring_deps(): - return [] +def tf_monitoring_framework_deps(link_to_tensorflow_framework = True): + """Get the monitoring libs that will be linked to the tensorflow framework. + + Currently in OSS, the protos must be statically linked to the tensorflow + framework, whereas the grpc should not be linked here. + """ + return select({ + "//tensorflow:stackdriver_support": [ + "@com_github_googlecloudplatform_tensorflow_gcp_tools//monitoring:stackdriver_exporter_protos", + ], + "//conditions:default": [], + }) + +def tf_monitoring_python_deps(): + """Get the monitoring libs that will be linked to the python wrapper. + + Currently in OSS, the grpc must be statically linked to the python wrapper + whereas the protos should not be linked here. + """ + return select({ + "//tensorflow:stackdriver_support": [ + "@com_github_googlecloudplatform_tensorflow_gcp_tools//monitoring:stackdriver_exporter", + ], + "//conditions:default": [], + }) def tf_jit_compilation_passes_extra_deps(): return [] diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl index 6b0143e397f..60fef8c0cb9 100755 --- a/tensorflow/workspace.bzl +++ b/tensorflow/workspace.bzl @@ -351,6 +351,16 @@ def tf_repositories(path_prefix = "", tf_repo_name = ""): ], ) + tf_http_archive( + name = "com_github_googlecloudplatform_tensorflow_gcp_tools", + sha256 = "5e9ebe17eaa2895eb7f77fefbf52deeda7c4b63f5a616916b823eb74f3a0c542", + strip_prefix = "tensorflow-gcp-tools-2643d8caeba6ca2a6a0b46bb123953cb95b7e7d5", + urls = [ + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/GoogleCloudPlatform/tensorflow-gcp-tools/archive/2643d8caeba6ca2a6a0b46bb123953cb95b7e7d5.tar.gz", + "https://github.com/GoogleCloudPlatform/tensorflow-gcp-tools/archive/2643d8caeba6ca2a6a0b46bb123953cb95b7e7d5.tar.gz", + ], + ) + tf_http_archive( name = "com_google_googleapis", build_file = clean_dep("//third_party/googleapis:googleapis.BUILD"),