1# Description: 2# CUDA-platform specific StreamExecutor support code. 3 4load("//tensorflow:tensorflow.bzl", "check_deps", "tf_copts") 5load( 6 "//tensorflow/stream_executor:build_defs.bzl", 7 "stream_executor_friends", 8 "tf_additional_cudnn_plugin_copts", 9) 10load( 11 "//tensorflow/tsl/platform/default:cuda_build_defs.bzl", 12 "if_cuda_is_configured", 13) 14load( 15 "//tensorflow/core/platform:build_config_root.bzl", 16 "if_static", 17) 18load( 19 "//tensorflow/core/platform:rules_cc.bzl", 20 "cc_library", 21) 22 23package( 24 default_visibility = [":friends"], 25 features = ["-layering_check"], 26 licenses = ["notice"], 27) 28 29package_group( 30 name = "friends", 31 packages = stream_executor_friends(), 32) 33 34cc_library( 35 name = "cuda_platform_id", 36 hdrs = ["cuda_platform_id.h"], 37 deps = ["//tensorflow/compiler/xla/stream_executor/cuda:cuda_platform_id"], 38) 39 40cc_library( 41 name = "cuda_platform", 42 hdrs = if_cuda_is_configured(["cuda_platform.h"]), 43 visibility = ["//visibility:public"], 44 deps = [ 45 ":cuda_activation", 46 "//tensorflow/compiler/xla/stream_executor/cuda:cuda_platform", 47 ], 48 alwayslink = True, # Registers itself with the MultiPlatformManager. 49) 50 51cc_library( 52 name = "cuda_diagnostics", 53 hdrs = if_cuda_is_configured(["cuda_diagnostics.h"]), 54 deps = [ 55 "//tensorflow/compiler/xla/stream_executor/cuda:cuda_diagnostics", 56 ], 57) 58 59cc_library( 60 name = "cuda_stub", 61 deps = [ 62 "//tensorflow/compiler/xla/stream_executor/cuda:cuda_stub", 63 ], 64) 65 66# Buildozer can not remove dependencies inside select guards, so we have to use 67# an intermediate target. 68cc_library(name = "ptxas_wrapper") 69 70# Buildozer can not remove dependencies inside select guards, so we have to use 71# an intermediate target. 72cc_library(name = "fatbinary_wrapper") 73 74cc_library( 75 name = "cuda_driver", 76 hdrs = if_cuda_is_configured(["cuda_driver.h"]), 77 deps = [ 78 "//tensorflow/compiler/xla/stream_executor/cuda:cuda_driver", 79 ], 80) 81 82cc_library( 83 name = "cudart_stub", 84 visibility = ["//visibility:public"], 85 deps = [ 86 "//tensorflow/compiler/xla/stream_executor/cuda:cudart_stub", 87 ], 88) 89 90# The activation library is tightly coupled to the executor library. 91# TODO(leary) split up cuda_gpu_executor.cc so that this can stand alone. 92cc_library( 93 name = "cuda_activation_header", 94 hdrs = ["cuda_activation.h"], 95 visibility = ["//visibility:public"], 96 deps = [ 97 "//tensorflow/compiler/xla/stream_executor/cuda:cuda_activation_header", 98 ], 99) 100 101cc_library( 102 name = "cuda_activation", 103 hdrs = if_cuda_is_configured(["cuda_activation.h"]), 104 deps = [ 105 "//tensorflow/compiler/xla/stream_executor/cuda:cuda_activation", 106 ], 107) 108 109cc_library( 110 name = "cuda_gpu_executor_header", 111 textual_hdrs = if_cuda_is_configured(["cuda_gpu_executor.h"]), 112 visibility = ["//visibility:public"], 113 deps = [ 114 "//tensorflow/compiler/xla/stream_executor/cuda:cuda_gpu_executor_header", 115 ], 116) 117 118cc_library( 119 name = "cublas_stub", 120 deps = [ 121 "//tensorflow/compiler/xla/stream_executor/cuda:cublas_stub", 122 ], 123) 124 125alias( 126 name = "cublas_lib", 127 actual = select({ 128 "//tensorflow:oss": ":cublas_stub", 129 "//conditions:default": "//third_party/gpus/cuda:cublas_static", 130 }), 131 visibility = ["//visibility:public"], 132) 133 134cc_library( 135 name = "cublas_lt_header", 136 hdrs = if_cuda_is_configured([ 137 "cuda_blas_lt.h", 138 "cuda_blas_utils.h", 139 ]), 140 visibility = ["//visibility:public"], 141 deps = [ 142 "//tensorflow/compiler/xla/stream_executor/cuda:cublas_lt_header", 143 ], 144) 145 146cc_library( 147 name = "cublas_lt_stub", 148 deps = [ 149 "//tensorflow/compiler/xla/stream_executor/cuda:cublas_lt_stub", 150 ], 151) 152 153alias( 154 name = "cublas_lt_lib", 155 actual = select({ 156 "//tensorflow:oss": ":cublas_lt_stub", 157 "//conditions:default": "//third_party/gpus/cuda:cublas_lt_static", 158 }), 159 visibility = ["//visibility:public"], 160) 161 162cc_library( 163 name = "cublas_plugin", 164 hdrs = if_cuda_is_configured([ 165 "cuda_blas.h", 166 "cuda_blas_lt.h", 167 ]), 168 visibility = ["//visibility:public"], 169 deps = [ 170 "//tensorflow/compiler/xla/stream_executor/cuda:cublas_plugin", 171 ], 172 alwayslink = True, 173) 174 175cc_library( 176 name = "cuda_blas_utils", 177 hdrs = if_cuda_is_configured(["cuda_blas_utils.h"]), 178 deps = [ 179 "//tensorflow/compiler/xla/stream_executor/cuda:cuda_blas_utils", 180 ], 181) 182 183cc_library( 184 name = "cufft_stub", 185 deps = [ 186 "//tensorflow/compiler/xla/stream_executor/cuda:cufft_stub", 187 ], 188) 189 190alias( 191 name = "cufft_lib", 192 actual = select({ 193 "//tensorflow:oss": ":cufft_stub", 194 "//conditions:default": "//third_party/gpus/cuda:cufft_static", 195 }), 196 visibility = ["//visibility:public"], 197) 198 199cc_library( 200 name = "cufft_plugin", 201 hdrs = if_cuda_is_configured(["cuda_fft.h"]), 202 visibility = ["//visibility:public"], 203 deps = [ 204 "//tensorflow/compiler/xla/stream_executor/cuda:cufft_plugin", 205 ], 206 alwayslink = True, 207) 208 209cc_library( 210 name = "cudnn_stub", 211 deps = [ 212 "//tensorflow/compiler/xla/stream_executor/cuda:cudnn_stub", 213 ], 214) 215 216alias( 217 name = "cudnn_lib", 218 actual = select({ 219 "//tensorflow:oss": ":cudnn_stub", 220 "//conditions:default": "//third_party/gpus/cudnn:cudnn", 221 }), 222 visibility = ["//visibility:public"], 223) 224 225cc_library( 226 name = "cuda_dnn_headers", 227 textual_hdrs = ["cuda_dnn.h"], 228 deps = [ 229 "//tensorflow/compiler/xla/stream_executor/cuda:cuda_dnn_headers", 230 ], 231) 232 233cc_library( 234 name = "cudnn_plugin", 235 hdrs = if_cuda_is_configured(["cuda_dnn.h"]), 236 copts = tf_additional_cudnn_plugin_copts(), 237 visibility = ["//visibility:public"], 238 deps = [ 239 "//tensorflow/compiler/xla/stream_executor/cuda:cudnn_plugin", 240 ], 241 alwayslink = True, 242) 243 244cc_library( 245 name = "curand_stub", 246 deps = [ 247 "//tensorflow/compiler/xla/stream_executor/cuda:curand_stub", 248 ], 249) 250 251alias( 252 name = "curand_lib", 253 actual = select({ 254 "//tensorflow:oss": ":curand_stub", 255 "//conditions:default": "//third_party/gpus/cuda:curand_static", 256 }), 257 visibility = ["//visibility:public"], 258) 259 260cc_library( 261 name = "curand_plugin", 262 hdrs = if_cuda_is_configured(["cuda_rng.h"]), 263 deps = [ 264 "//tensorflow/compiler/xla/stream_executor/cuda:curand_plugin", 265 ], 266 alwayslink = True, 267) 268 269cc_library( 270 name = "cupti_stub", 271 deps = [ 272 "//tensorflow/compiler/xla/stream_executor/cuda:cupti_stub", 273 ], 274) 275 276cc_library( 277 name = "cusolver_stub", 278 deps = [ 279 "//tensorflow/compiler/xla/stream_executor/cuda:cusolver_stub", 280 ], 281) 282 283alias( 284 name = "cusolver_lib", 285 actual = select({ 286 "//tensorflow:oss": ":cusolver_stub", 287 "//conditions:default": "//third_party/gpus/cuda:cusolver_static", 288 }), 289 visibility = ["//visibility:public"], 290) 291 292cc_library( 293 name = "cusparse_stub", 294 deps = [ 295 "//tensorflow/compiler/xla/stream_executor/cuda:cusparse_stub", 296 ], 297) 298 299alias( 300 name = "cusparse_lib", 301 actual = select({ 302 "//tensorflow:oss": ":cusparse_stub", 303 "//conditions:default": "//third_party/gpus/cuda:cusparse_static", 304 }), 305 visibility = ["//visibility:public"], 306) 307 308cc_library( 309 name = "cuda_kernel", 310 deps = [ 311 "//tensorflow/compiler/xla/stream_executor/cuda:cuda_kernel", 312 ], 313) 314 315# TODO(leary) we likely need to canonicalize/eliminate this. 316cc_library( 317 name = "cuda_helpers", 318 textual_hdrs = if_cuda_is_configured(["cuda_helpers.h"]), 319 deps = [ 320 "//tensorflow/compiler/xla/stream_executor/cuda:cuda_helpers", 321 ], 322) 323 324cc_library( 325 name = "cuda_event", 326 hdrs = if_cuda_is_configured(["cuda_event.h"]), 327 deps = [ 328 "//tensorflow/compiler/xla/stream_executor/cuda:cuda_event", 329 ], 330) 331 332cc_library( 333 name = "cuda_stream", 334 hdrs = if_cuda_is_configured(["cuda_stream.h"]), 335 deps = [ 336 "//tensorflow/compiler/xla/stream_executor/cuda:cuda_stream", 337 ], 338) 339 340cc_library( 341 name = "cuda_timer", 342 hdrs = if_cuda_is_configured(["cuda_timer.h"]), 343 deps = [ 344 "//tensorflow/compiler/xla/stream_executor/cuda:cuda_timer", 345 ], 346) 347 348cc_library( 349 name = "cuda_asm_compiler", 350 deps = [ 351 "//tensorflow/compiler/xla/stream_executor/cuda:cuda_asm_compiler", 352 ], 353) 354 355cc_library( 356 name = "cuda_gpu_executor", 357 hdrs = if_cuda_is_configured(["cuda_gpu_executor.h"]), 358 deps = [ 359 "//tensorflow/compiler/xla/stream_executor/cuda:cuda_gpu_executor", 360 ], 361 alwayslink = True, 362) 363 364cc_library( 365 name = "cudnn_version", 366 hdrs = ["cudnn_version.h"], 367 deps = [ 368 "//tensorflow/compiler/xla/stream_executor/cuda:cudnn_version", 369 ], 370) 371 372cc_library( 373 name = "all_runtime", 374 copts = tf_copts(), 375 visibility = ["//visibility:public"], 376 deps = [ 377 "//tensorflow/compiler/xla/stream_executor/cuda:all_runtime", 378 ], 379 alwayslink = 1, 380) 381 382# To avoid duplication, check that the C++ or python library does not depend on 383# the stream executor cuda plugins. Targets that want to use cuda APIs should 384# instead depend on the dummy plugins in //tensorflow/tsl/platform/default/build_config 385# and use header only targets. 386check_deps( 387 name = "cuda_plugins_check_deps", 388 disallowed_deps = if_static( 389 [], 390 otherwise = [ 391 ":all_runtime", 392 ":cuda_driver", 393 ":cuda_platform", 394 ":cudnn_plugin", 395 ":cufft_plugin", 396 ":curand_plugin", 397 "//tensorflow/stream_executor:cuda_platform", 398 ], 399 ), 400 deps = [ 401 "//tensorflow:tensorflow_cc", 402 "//tensorflow/python:pywrap_tensorflow_internal", 403 ], 404) 405