1# Description: 2# ROCm-platform specific StreamExecutor support code. 3 4load("//tensorflow/core/platform:rules_cc.bzl", "cc_library") 5load( 6 "//tensorflow/stream_executor:build_defs.bzl", 7 "stream_executor_friends", 8) 9load("//tensorflow:tensorflow.bzl", "tf_copts") 10load("//tensorflow:tensorflow.bzl", "filegroup") 11load("@local_config_rocm//rocm:build_defs.bzl", "if_rocm_is_configured") 12load("//tensorflow/core/platform:build_config_root.bzl", "if_static") 13 14package( 15 default_visibility = [":friends"], 16 licenses = ["notice"], 17) 18 19package_group( 20 name = "friends", 21 packages = stream_executor_friends(), 22) 23 24# Filegroup used to collect source files for the dependency check. 25filegroup( 26 name = "c_srcs", 27 data = glob([ 28 "**/*.cc", 29 "**/*.h", 30 ]), 31) 32 33cc_library( 34 name = "rocm_diagnostics", 35 srcs = if_rocm_is_configured(["rocm_diagnostics.cc"]), 36 hdrs = if_rocm_is_configured(["rocm_diagnostics.h"]), 37 deps = if_rocm_is_configured([ 38 "@com_google_absl//absl/container:inlined_vector", 39 "@com_google_absl//absl/strings", 40 "@com_google_absl//absl/strings:str_format", 41 "//tensorflow/stream_executor/gpu:gpu_diagnostics_header", 42 "//tensorflow/stream_executor/lib", 43 "//tensorflow/stream_executor/platform", 44 ]), 45) 46 47cc_library( 48 name = "rocm_driver", 49 srcs = if_rocm_is_configured(["rocm_driver.cc"]), 50 hdrs = if_rocm_is_configured(["rocm_driver_wrapper.h"]), 51 deps = if_rocm_is_configured([ 52 ":rocm_diagnostics", 53 "@com_google_absl//absl/base", 54 "@com_google_absl//absl/container:inlined_vector", 55 "@com_google_absl//absl/strings", 56 "//tensorflow/stream_executor:device_options", 57 "//tensorflow/stream_executor/gpu:gpu_driver_header", 58 "//tensorflow/stream_executor/lib", 59 "//tensorflow/stream_executor/platform", 60 "//tensorflow/stream_executor/platform:dso_loader", 61 "@local_config_rocm//rocm:rocm_headers", 62 ]), 63) 64 65cc_library( 66 name = "rocm_activation", 67 srcs = [], 68 hdrs = if_rocm_is_configured(["rocm_activation.h"]), 69 deps = if_rocm_is_configured([ 70 ":rocm_driver", 71 "@local_config_rocm//rocm:rocm_headers", 72 "//tensorflow/stream_executor", 73 "//tensorflow/stream_executor:stream_executor_internal", 74 "//tensorflow/stream_executor/gpu:gpu_activation", 75 "//tensorflow/stream_executor/platform", 76 ]), 77) 78 79cc_library( 80 name = "rocm_event", 81 srcs = if_rocm_is_configured(["rocm_event.cc"]), 82 hdrs = [], 83 deps = if_rocm_is_configured([ 84 ":rocm_driver", 85 "//tensorflow/stream_executor:stream_executor_headers", 86 "//tensorflow/stream_executor/gpu:gpu_event_header", 87 "//tensorflow/stream_executor/gpu:gpu_executor_header", 88 "//tensorflow/stream_executor/gpu:gpu_stream_header", 89 "//tensorflow/stream_executor/lib", 90 ]), 91) 92 93cc_library( 94 name = "rocm_gpu_executor", 95 srcs = if_rocm_is_configured(["rocm_gpu_executor.cc"]), 96 hdrs = [], 97 deps = if_rocm_is_configured([ 98 ":rocm_diagnostics", 99 ":rocm_driver", 100 ":rocm_event", 101 ":rocm_kernel", 102 ":rocm_platform_id", 103 "@com_google_absl//absl/strings", 104 "//tensorflow/stream_executor:event", 105 "//tensorflow/stream_executor:plugin_registry", 106 "//tensorflow/stream_executor:stream_executor_internal", 107 "//tensorflow/stream_executor:stream_executor_pimpl_header", 108 "//tensorflow/stream_executor:timer", 109 "//tensorflow/stream_executor/gpu:gpu_activation_header", 110 "//tensorflow/stream_executor/gpu:gpu_event", 111 "//tensorflow/stream_executor/gpu:gpu_kernel_header", 112 "//tensorflow/stream_executor/gpu:gpu_stream", 113 "//tensorflow/stream_executor/gpu:gpu_timer", 114 "//tensorflow/stream_executor/lib", 115 "//tensorflow/stream_executor/platform", 116 "//tensorflow/stream_executor/platform:dso_loader", 117 ]), 118 alwayslink = True, 119) 120 121cc_library( 122 name = "rocm_kernel", 123 srcs = if_rocm_is_configured(["rocm_kernel.cc"]), 124 hdrs = [], 125 visibility = ["//visibility:public"], 126 deps = if_rocm_is_configured([ 127 "//tensorflow/stream_executor/gpu:gpu_kernel_header", 128 ]), 129 alwayslink = True, 130) 131 132cc_library( 133 name = "rocm_platform", 134 srcs = if_rocm_is_configured(["rocm_platform.cc"]), 135 hdrs = if_rocm_is_configured(["rocm_platform.h"]), 136 visibility = ["//visibility:public"], 137 deps = if_rocm_is_configured([ 138 ":rocm_driver", 139 ":rocm_gpu_executor", 140 ":rocm_platform_id", 141 "@com_google_absl//absl/base", 142 "@com_google_absl//absl/memory", 143 "//tensorflow/core:lib", 144 "//tensorflow/stream_executor", # buildcleaner: keep 145 "//tensorflow/stream_executor:executor_cache", 146 "//tensorflow/stream_executor:multi_platform_manager", 147 "//tensorflow/stream_executor:stream_executor_pimpl_header", 148 "//tensorflow/stream_executor/lib", 149 "//tensorflow/stream_executor/platform", 150 ]), 151 alwayslink = True, # Registers itself with the MultiPlatformManager. 152) 153 154cc_library( 155 name = "rocm_platform_id", 156 srcs = ["rocm_platform_id.cc"], 157 hdrs = ["rocm_platform_id.h"], 158 deps = ["//tensorflow/stream_executor:platform"], 159) 160 161cc_library( 162 name = "rocblas_if_static", 163 deps = if_static([ 164 "@local_config_rocm//rocm:rocblas", 165 ]), 166) 167 168cc_library( 169 name = "rocblas_wrapper", 170 srcs = if_rocm_is_configured(["rocblas_wrapper.h"]), 171 hdrs = if_rocm_is_configured(["rocblas_wrapper.h"]), 172 deps = if_rocm_is_configured([ 173 ":rocblas_if_static", 174 ":rocm_gpu_executor", 175 ":rocm_platform_id", 176 "@local_config_rocm//rocm:rocm_headers", 177 "//tensorflow/stream_executor/lib", 178 "//tensorflow/stream_executor/platform", 179 "//tensorflow/stream_executor/platform:dso_loader", 180 ]), 181 alwayslink = True, 182) 183 184cc_library( 185 name = "rocblas_plugin", 186 srcs = if_rocm_is_configured(["rocm_blas.cc"]), 187 hdrs = if_rocm_is_configured(["rocm_blas.h"]), 188 visibility = ["//visibility:public"], 189 deps = if_rocm_is_configured([ 190 ":rocblas_if_static", 191 ":rocblas_wrapper", 192 ":rocm_gpu_executor", 193 ":rocm_platform_id", 194 "//third_party/eigen3", 195 "//tensorflow/core:lib", 196 "//tensorflow/core:lib_internal", 197 "//tensorflow/stream_executor", 198 "//tensorflow/stream_executor:event", 199 "//tensorflow/stream_executor:host_or_device_scalar", 200 "//tensorflow/stream_executor:plugin_registry", 201 "//tensorflow/stream_executor:scratch_allocator", 202 "//tensorflow/stream_executor:timer", 203 "//tensorflow/stream_executor/gpu:gpu_activation", 204 "//tensorflow/stream_executor/gpu:gpu_helpers_header", 205 "//tensorflow/stream_executor/gpu:gpu_stream_header", 206 "//tensorflow/stream_executor/gpu:gpu_timer_header", 207 "//tensorflow/stream_executor/lib", 208 "//tensorflow/stream_executor/platform", 209 "//tensorflow/stream_executor/platform:dso_loader", 210 "@com_google_absl//absl/strings", 211 "@local_config_rocm//rocm:rocm_headers", 212 ]), 213 alwayslink = True, 214) 215 216cc_library( 217 name = "hipfft_if_static", 218 deps = if_static([ 219 "@local_config_rocm//rocm:hipfft", 220 ]), 221) 222 223cc_library( 224 name = "hipfft_plugin", 225 srcs = if_rocm_is_configured(["rocm_fft.cc"]), 226 hdrs = if_rocm_is_configured(["rocm_fft.h"]), 227 visibility = ["//visibility:public"], 228 deps = if_rocm_is_configured([ 229 ":hipfft_if_static", 230 ":rocm_platform_id", 231 "//tensorflow/stream_executor:event", 232 "//tensorflow/stream_executor:fft", 233 "//tensorflow/stream_executor:plugin_registry", 234 "//tensorflow/stream_executor:scratch_allocator", 235 "//tensorflow/stream_executor/gpu:gpu_activation", 236 "//tensorflow/stream_executor/gpu:gpu_helpers_header", 237 "//tensorflow/stream_executor/gpu:gpu_executor_header", 238 "//tensorflow/stream_executor/gpu:gpu_stream_header", 239 "//tensorflow/stream_executor/gpu:gpu_kernel_header", 240 "//tensorflow/stream_executor/lib", 241 "//tensorflow/stream_executor/platform", 242 "//tensorflow/stream_executor/platform:dso_loader", 243 "@local_config_rocm//rocm:rocm_headers", 244 ]), 245 alwayslink = True, 246) 247 248cc_library( 249 name = "miopen_if_static", 250 deps = if_static([ 251 "@local_config_rocm//rocm:miopen", 252 ]), 253) 254 255cc_library( 256 name = "miopen_plugin", 257 srcs = if_rocm_is_configured(["rocm_dnn.cc"]), 258 hdrs = if_rocm_is_configured(["rocm_dnn.h"]), 259 copts = [ 260 # STREAM_EXECUTOR_CUDNN_WRAP would fail on Clang with the default 261 # setting of template depth 256 262 "-ftemplate-depth-512", 263 ], 264 visibility = ["//visibility:public"], 265 deps = if_rocm_is_configured([ 266 ":miopen_if_static", 267 ":rocm_diagnostics", 268 ":rocm_driver", 269 ":rocm_gpu_executor", 270 ":rocm_platform_id", 271 "//third_party/eigen3", 272 "//tensorflow/core:lib", 273 "//tensorflow/core:lib_internal", 274 "//tensorflow/stream_executor:dnn", 275 "//tensorflow/stream_executor:event", 276 "//tensorflow/stream_executor:plugin_registry", 277 "//tensorflow/stream_executor:scratch_allocator", 278 "//tensorflow/stream_executor:stream_executor_pimpl_header", 279 "//tensorflow/stream_executor:temporary_device_memory", 280 "//tensorflow/stream_executor/gpu:gpu_activation_header", 281 "//tensorflow/stream_executor/gpu:gpu_stream_header", 282 "//tensorflow/stream_executor/gpu:gpu_timer_header", 283 "//tensorflow/stream_executor/lib", 284 "//tensorflow/stream_executor/platform", 285 "//tensorflow/stream_executor/platform:dso_loader", 286 "@com_google_absl//absl/algorithm:container", 287 "@com_google_absl//absl/strings", 288 "@local_config_rocm//rocm:rocm_headers", 289 ]), 290 alwayslink = True, 291) 292 293cc_library( 294 name = "hiprand_if_static", 295 deps = if_static([ 296 "@local_config_rocm//rocm:hiprand", 297 ]), 298) 299 300cc_library( 301 name = "rocrand_plugin", 302 srcs = if_rocm_is_configured(["rocm_rng.cc"]), 303 hdrs = if_rocm_is_configured([]), 304 deps = if_rocm_is_configured([ 305 ":hiprand_if_static", 306 ":rocm_gpu_executor", 307 ":rocm_platform_id", 308 "@local_config_rocm//rocm:rocm_headers", 309 "//tensorflow/stream_executor:event", 310 "//tensorflow/stream_executor:plugin_registry", 311 "//tensorflow/stream_executor:rng", 312 "//tensorflow/stream_executor/gpu:gpu_activation_header", 313 "//tensorflow/stream_executor/gpu:gpu_helpers_header", 314 "//tensorflow/stream_executor/gpu:gpu_executor_header", 315 "//tensorflow/stream_executor/gpu:gpu_rng_header", 316 "//tensorflow/stream_executor/gpu:gpu_stream_header", 317 "//tensorflow/stream_executor/lib", 318 "//tensorflow/stream_executor/platform", 319 "//tensorflow/stream_executor/platform:dso_loader", 320 ]), 321 alwayslink = True, 322) 323 324cc_library( 325 name = "hipsparse_if_static", 326 deps = if_static([ 327 "@local_config_rocm//rocm:hipsparse", 328 ]), 329) 330 331cc_library( 332 name = "hipsparse_wrapper", 333 srcs = if_rocm_is_configured(["hipsparse_wrapper.h"]), 334 hdrs = if_rocm_is_configured(["hipsparse_wrapper.h"]), 335 deps = if_rocm_is_configured([ 336 ":hipsparse_if_static", 337 ":rocm_gpu_executor", 338 ":rocm_platform_id", 339 "@local_config_rocm//rocm:rocm_headers", 340 "//tensorflow/stream_executor/lib", 341 "//tensorflow/stream_executor/platform", 342 "//tensorflow/stream_executor/platform:dso_loader", 343 ]), 344 alwayslink = True, 345) 346 347cc_library( 348 name = "rocsolver_if_static", 349 deps = if_static([ 350 "@local_config_rocm//rocm:rocsolver", 351 ]), 352) 353 354cc_library( 355 name = "rocsolver_wrapper", 356 srcs = if_rocm_is_configured(["rocsolver_wrapper.h"]), 357 hdrs = if_rocm_is_configured(["rocsolver_wrapper.h"]), 358 deps = if_rocm_is_configured([ 359 ":rocm_gpu_executor", 360 ":rocm_platform_id", 361 ":rocsolver_if_static", 362 "@local_config_rocm//rocm:rocm_headers", 363 "//tensorflow/stream_executor/lib", 364 "//tensorflow/stream_executor/platform", 365 "//tensorflow/stream_executor/platform:dso_loader", 366 ]), 367 alwayslink = True, 368) 369 370cc_library( 371 name = "roctracer_if_static", 372 deps = if_static([ 373 "@local_config_rocm//rocm:roctracer", 374 ]), 375) 376 377cc_library( 378 name = "roctracer_wrapper", 379 srcs = if_rocm_is_configured(["roctracer_wrapper.h"]), 380 hdrs = if_rocm_is_configured(["roctracer_wrapper.h"]), 381 deps = if_rocm_is_configured([ 382 ":rocm_gpu_executor", 383 ":rocm_platform_id", 384 ":roctracer_if_static", 385 "@local_config_rocm//rocm:rocm_headers", 386 "//tensorflow/stream_executor/lib", 387 "//tensorflow/stream_executor/platform", 388 "//tensorflow/stream_executor/platform:dso_loader", 389 ]), 390 alwayslink = True, 391) 392 393cc_library( 394 name = "all_runtime", 395 copts = tf_copts(), 396 visibility = ["//visibility:public"], 397 deps = if_rocm_is_configured([ 398 ":miopen_plugin", 399 ":hipfft_plugin", 400 ":rocblas_plugin", 401 ":rocrand_plugin", 402 ":rocm_driver", 403 ":rocm_platform", 404 ]), 405 alwayslink = 1, 406) 407