From 66b193faeecda4e6bc7e2767c2d927eecd199a34 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Wed, 8 May 2019 05:35:44 -0700 Subject: [PATCH] Return select() statement from if_cuda_is_configured(). PiperOrigin-RevId: 247196015 --- tensorflow/core/BUILD | 2 +- tensorflow/stream_executor/cuda/BUILD | 60 ++++++++++++++----- third_party/gpus/cuda/build_defs.bzl.tpl | 4 +- .../cuda10.0-cudnn7/cuda/build_defs.bzl | 4 +- 4 files changed, 49 insertions(+), 21 deletions(-) diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD index 5774fca765f..2bf9fc9d011 100644 --- a/tensorflow/core/BUILD +++ b/tensorflow/core/BUILD @@ -3326,7 +3326,7 @@ tf_cuda_library( name = "device_tracer", srcs = tf_additional_device_tracer_srcs(), copts = tf_copts(), - cuda_deps = if_cuda_is_configured(tf_additional_cupti_wrapper_deps() + tf_additional_device_tracer_cuda_deps()), + cuda_deps = tf_additional_cupti_wrapper_deps() + tf_additional_device_tracer_cuda_deps(), visibility = [ "//tensorflow:internal", ], diff --git a/tensorflow/stream_executor/cuda/BUILD b/tensorflow/stream_executor/cuda/BUILD index fa456bf76d3..0dee5183641 100644 --- a/tensorflow/stream_executor/cuda/BUILD +++ b/tensorflow/stream_executor/cuda/BUILD @@ -198,12 +198,22 @@ cc_library( ]), ) +alias( + name = "cublas_lib", + actual = if_static( + "@local_config_cuda//cuda:cublas", + ":cublas_stub", + ), + visibility = ["//visibility:private"], +) + cc_library( name = "cublas_plugin", srcs = if_cuda_is_configured(["cuda_blas.cc"]), hdrs = if_cuda_is_configured(["cuda_blas.h"]), visibility = ["//visibility:public"], deps = if_cuda_is_configured([ + ":cublas_lib", ":cuda_activation", ":cuda_gpu_executor", ":cuda_platform_id", @@ -223,10 +233,7 @@ cc_library( "//tensorflow/stream_executor/gpu:gpu_helpers_header", "//tensorflow/stream_executor/lib", "//tensorflow/stream_executor/platform", - ] + if_static( - ["@local_config_cuda//cuda:cublas"], - [":cublas_stub"], - )) + [ + ]) + [ "@com_google_absl//absl/strings:str_format", "@com_google_absl//absl/synchronization", ], @@ -244,6 +251,15 @@ cc_library( ]), ) +alias( + name = "cufft_lib", + actual = if_static( + "@local_config_cuda//cuda:cufft", + ":cufft_stub", + ), + visibility = ["//visibility:private"], +) + cc_library( name = "cufft_plugin", srcs = if_cuda_is_configured(["cuda_fft.cc"]), @@ -255,6 +271,7 @@ cc_library( ":cuda_platform_id", ":cuda_stream", ":cuda_helpers", + ":cufft_lib", "@local_config_cuda//cuda:cuda_headers", "//tensorflow/stream_executor:event", "//tensorflow/stream_executor:fft", @@ -264,10 +281,7 @@ cc_library( "//tensorflow/stream_executor/lib", "//tensorflow/stream_executor/platform", "//tensorflow/stream_executor/platform:dso_loader", - ] + if_static( - ["@local_config_cuda//cuda:cufft"], - [":cufft_stub"], - )), + ]), alwayslink = True, ) @@ -282,6 +296,15 @@ cc_library( ]), ) +alias( + name = "cudnn_lib", + actual = if_static( + "@local_config_cuda//cuda:cudnn", + ":cudnn_stub", + ), + visibility = ["//visibility:private"], +) + cc_library( name = "cudnn_plugin", srcs = if_cuda_is_configured(["cuda_dnn.cc"]), @@ -296,6 +319,7 @@ cc_library( ":cuda_stream", ":cuda_timer", ":cudnn_version", + ":cudnn_lib", "@com_google_absl//absl/strings", "//third_party/eigen3", "@local_config_cuda//cuda:cuda_headers", @@ -309,10 +333,7 @@ cc_library( "//tensorflow/stream_executor:temporary_device_memory", "//tensorflow/stream_executor/lib", "//tensorflow/stream_executor/platform", - ]) + tf_additional_cudnn_plugin_deps() + if_cuda_is_configured(if_static( - ["@local_config_cuda//cuda:cudnn"], - [":cudnn_stub"], - )) + ["@com_google_absl//absl/synchronization"], + ]) + tf_additional_cudnn_plugin_deps() + ["@com_google_absl//absl/synchronization"], alwayslink = True, ) @@ -327,6 +348,15 @@ cc_library( ]), ) +alias( + name = "curand_lib", + actual = if_static( + "@local_config_cuda//cuda:curand", + ":curand_stub", + ), + visibility = ["//visibility:private"], +) + cc_library( name = "curand_plugin", srcs = if_cuda_is_configured(["cuda_rng.cc"]), @@ -337,6 +367,7 @@ cc_library( ":cuda_platform_id", ":cuda_stream", ":cuda_helpers", + ":curand_lib", "@local_config_cuda//cuda:cuda_headers", "//tensorflow/stream_executor:event", "//tensorflow/stream_executor:plugin_registry", @@ -346,10 +377,7 @@ cc_library( "//tensorflow/stream_executor/lib", "//tensorflow/stream_executor/platform", "//tensorflow/stream_executor/platform:dso_loader", - ] + if_static( - ["@local_config_cuda//cuda:curand"], - [":curand_stub"], - )), + ]), alwayslink = True, ) diff --git a/third_party/gpus/cuda/build_defs.bzl.tpl b/third_party/gpus/cuda/build_defs.bzl.tpl index ca8bbc1ee22..69e0bb1ac71 100644 --- a/third_party/gpus/cuda/build_defs.bzl.tpl +++ b/third_party/gpus/cuda/build_defs.bzl.tpl @@ -29,5 +29,5 @@ def if_cuda_is_configured(x): --config=cuda. Used to allow non-CUDA code to depend on CUDA libraries. """ if cuda_is_configured(): - return x - return [] + return select({"//conditions:default": x}) + return select({"//conditions:default": []}) diff --git a/third_party/toolchains/preconfig/ubuntu14.04/cuda10.0-cudnn7/cuda/build_defs.bzl b/third_party/toolchains/preconfig/ubuntu14.04/cuda10.0-cudnn7/cuda/build_defs.bzl index a53c891d8bb..20ef28ffeae 100755 --- a/third_party/toolchains/preconfig/ubuntu14.04/cuda10.0-cudnn7/cuda/build_defs.bzl +++ b/third_party/toolchains/preconfig/ubuntu14.04/cuda10.0-cudnn7/cuda/build_defs.bzl @@ -27,5 +27,5 @@ def if_cuda_is_configured(x): --config=cuda. Used to allow non-CUDA code to depend on CUDA libraries. """ if cuda_is_configured(): - return x - return [] + return select({"//conditions:default": x}) + return select({"//conditions:default": []})