1# Experimental extensions to the C API for eager execution of kernels. 2 3load("//tensorflow/core/platform:rules_cc.bzl", "cc_library") 4load( 5 "//tensorflow:tensorflow.bzl", 6 "if_libtpu", 7 "tf_cc_test", 8 "tf_copts", 9 "tf_cuda_cc_test", 10 "tf_cuda_library", 11) 12 13# buildifier: disable=same-origin-load 14load("//tensorflow:tensorflow.bzl", "cc_header_only_library") 15 16# buildifier: disable=same-origin-load 17load("//tensorflow:tensorflow.bzl", "filegroup") 18 19# buildifier: disable=same-origin-load 20load("//tensorflow:tensorflow.bzl", "internal_tfrt_deps") 21load( 22 "//tensorflow/core/platform:build_config.bzl", 23 "tf_kernel_tests_linkstatic", 24) 25load( 26 "//tensorflow/core/platform:build_config_root.bzl", 27 "tf_cuda_tests_tags", 28) 29 30package( 31 licenses = ["notice"], # Apache 2.0 32) 33 34tf_cuda_library( 35 name = "c_api", 36 srcs = [ 37 "c_api.cc", 38 "c_api_debug.cc", 39 "c_api_experimental.h", 40 "c_api_internal.h", 41 "c_api_unified_experimental.h", 42 ], 43 hdrs = ["c_api.h"], 44 copts = tf_copts(), 45 visibility = ["//visibility:public"], 46 deps = select({ 47 "//tensorflow:android": [ 48 "//tensorflow/core:portable_tensorflow_lib_lite", 49 ], 50 "//conditions:default": [ 51 ":immediate_execution_context", 52 ":immediate_execution_operation", 53 ":immediate_execution_tensor_handle", 54 ":immediate_execution_distributed_manager", 55 ":tfe_context_internal", 56 ":tfe_cancellation_manager_internal", 57 ":tfe_executor_internal", 58 ":tfe_monitoring_internal", 59 ":tfe_op_attrs_internal", 60 ":tfe_op_internal", 61 ":tfe_tensor_debug_info_internal", 62 ":tfe_tensorhandle_internal", 63 "@com_google_absl//absl/algorithm:container", 64 "@com_google_absl//absl/types:span", 65 "@com_google_absl//absl/types:variant", 66 "//tensorflow/c:c_api", 67 "//tensorflow/c:c_api_internal", 68 "//tensorflow/c:tf_status_internal", 69 "//tensorflow/c:tf_tensor_internal", 70 "//tensorflow/core:core_cpu", 71 "//tensorflow/core/common_runtime/eager:attr_builder", 72 "//tensorflow/core/common_runtime/eager:context", 73 "//tensorflow/core/common_runtime/eager:context_distributed_manager", 74 "//tensorflow/core/common_runtime/eager:core", 75 "//tensorflow/core/common_runtime/eager:custom_device", 76 "//tensorflow/core/common_runtime/eager:custom_device_op_handler", 77 "//tensorflow/core/common_runtime/eager:eager_executor", 78 "//tensorflow/core/common_runtime/eager:execute", 79 "//tensorflow/core/common_runtime/eager:tensor_handle", 80 "//tensorflow/core/common_runtime/eager:placement_utils", 81 "//tensorflow/core:core_cpu_internal", 82 "//tensorflow/core:framework", 83 "//tensorflow/core:framework_internal", 84 "//tensorflow/core:lib", 85 "//tensorflow/core:lib_internal", 86 "//tensorflow/core:protos_all_cc", 87 "//tensorflow/core/profiler/lib:traceme", 88 ], 89 }) + [ 90 "@com_google_absl//absl/memory", 91 ":abstract_tensor_handle", 92 "//tensorflow/core/common_runtime/eager:eager_operation", 93 "//tensorflow/core/distributed_runtime/eager:remote_mgr", 94 "//tensorflow/core/distributed_runtime/eager:cluster_function_library_runtime", 95 "//tensorflow/core/distributed_runtime/eager:eager_client", 96 "//tensorflow/core/distributed_runtime/rpc/eager:grpc_eager_client", 97 "//tensorflow/core/distributed_runtime/rpc:grpc_channel", 98 "//tensorflow/core/distributed_runtime/rpc:grpc_server_lib", 99 "//tensorflow/core/distributed_runtime/rpc:grpc_worker_cache", 100 "//tensorflow/core/distributed_runtime/rpc:grpc_worker_service", 101 "//tensorflow/core/distributed_runtime/rpc:rpc_rendezvous_mgr", 102 "//tensorflow/core/distributed_runtime:remote_device", 103 "//tensorflow/core/distributed_runtime:server_lib", 104 "//tensorflow/core/distributed_runtime:worker_env", 105 "//tensorflow/core/distributed_runtime:worker_interface", 106 "//tensorflow/core:gpu_runtime", 107 ] + internal_tfrt_deps(), 108 alwayslink = 1, 109) 110 111filegroup( 112 name = "pywrap_required_hdrs", 113 srcs = [ 114 "abstract_context.h", 115 "abstract_function.h", 116 "abstract_op_attrs.h", 117 "abstract_operation.h", 118 "abstract_tensor_handle.h", 119 "c_api.h", 120 "c_api_experimental.h", 121 "c_api_internal.h", 122 "c_api_unified_experimental.h", 123 "c_api_unified_experimental_internal.h", 124 "dlpack.h", 125 "gradients.h", 126 "gradients_internal.h", 127 "immediate_execution_context.h", 128 "immediate_execution_distributed_manager.h", 129 "immediate_execution_operation.h", 130 "immediate_execution_tensor_handle.h", 131 "tape.h", 132 "tfe_cancellation_manager_internal.h", 133 "tfe_context_internal.h", 134 "tfe_executor_internal.h", 135 "tfe_monitoring_internal.h", 136 "tfe_op_attrs_internal.h", 137 "tfe_tensor_debug_info_internal.h", 138 "tfe_tensorhandle_internal.h", 139 ], 140 visibility = [ 141 "//tensorflow/core:__pkg__", 142 "//tensorflow/python:__pkg__", 143 ], 144) 145 146cc_library( 147 name = "c_api_internal", 148 hdrs = [ 149 "c_api_experimental.h", 150 "c_api_internal.h", 151 ], 152 visibility = ["//tensorflow:internal"], 153 deps = [ 154 ":c_api", 155 ":tfe_cancellation_manager_internal", 156 ":tfe_context_internal", 157 ":tfe_executor_internal", 158 ":tfe_monitoring_internal", 159 ":tfe_op_attrs_internal", 160 ":tfe_op_internal", 161 ":tfe_tensor_debug_info_internal", 162 ":tfe_tensorhandle_internal", 163 "//tensorflow/c:c_api_internal", 164 ], 165) 166 167cc_library( 168 name = "c_api_unified_internal", 169 hdrs = [ 170 "c_api_unified_experimental_internal.h", 171 ], 172 visibility = [ 173 "//tensorflow:internal", 174 ], 175 deps = [ 176 ":abstract_context", 177 ":abstract_operation", 178 ":abstract_tensor_handle", 179 ":c_api", 180 ":c_api_experimental", 181 "//tensorflow/c:c_api_internal", 182 "//tensorflow/c:conversion_macros", 183 "//tensorflow/c:tf_status", 184 "//tensorflow/core:framework", 185 "//tensorflow/core/platform:casts", 186 "//tensorflow/core/platform:types", 187 ], 188) 189 190cc_library( 191 name = "tracing_utils", 192 srcs = ["tracing_utils.cc"], 193 hdrs = [ 194 "tracing_utils.h", 195 ], 196 visibility = [ 197 "//tensorflow:internal", 198 ], 199 deps = [ 200 ":abstract_operation", 201 ":c_api_unified_internal", 202 "//tensorflow/c/experimental/gradients/tape:tape_operation", 203 "//tensorflow/core/lib/llvm_rtti", 204 "//tensorflow/core/platform:errors", 205 ], 206) 207 208cc_library( 209 name = "gradients_internal", 210 srcs = [ 211 "gradients.cc", 212 ], 213 hdrs = [ 214 "gradients.h", 215 "gradients_internal.h", 216 ], 217 visibility = [ 218 "//tensorflow:internal", 219 ], 220 deps = [ 221 ":abstract_context", 222 ":abstract_tensor_handle", 223 ":c_api_unified_internal", 224 ":tape", 225 "//tensorflow/core/common_runtime/eager:attr_builder", 226 "//tensorflow/core/lib/llvm_rtti", 227 "//tensorflow/core/platform:errors", 228 "@com_google_absl//absl/container:flat_hash_map", 229 "@com_google_absl//absl/strings", 230 ], 231) 232 233cc_library( 234 name = "unified_api_testutil", 235 testonly = 1, 236 srcs = [ 237 "unified_api_testutil.cc", 238 ], 239 hdrs = [ 240 "unified_api_testutil.h", 241 ], 242 visibility = [ 243 "//tensorflow:internal", 244 ], 245 deps = [ 246 ":abstract_context", 247 ":abstract_tensor_handle", 248 ":c_api_experimental", 249 ":c_api_test_util", 250 ":c_api_unified_internal", 251 "//tensorflow/c:tf_status", 252 "//tensorflow/c:tf_status_helper", 253 "//tensorflow/c:tf_tensor", 254 "//tensorflow/core:framework", 255 "//tensorflow/core/lib/llvm_rtti", 256 "//tensorflow/core/platform:errors", 257 "//tensorflow/core/platform:status", 258 "@com_google_absl//absl/container:flat_hash_set", 259 ], 260) 261 262tf_cuda_cc_test( 263 name = "gradients_test", 264 size = "small", 265 srcs = [ 266 "gradients_test.cc", 267 ], 268 args = ["--heap_check=local"], 269 linkstatic = tf_kernel_tests_linkstatic(), 270 tags = tf_cuda_tests_tags() + ["nomac"], 271 deps = [ 272 ":abstract_context", 273 ":abstract_tensor_handle", 274 ":c_api_experimental", 275 ":c_api_test_util", 276 ":c_api_unified_internal", 277 ":gradients_internal", 278 ":unified_api_testutil", 279 "//tensorflow/c:c_api", 280 "//tensorflow/c:c_test_util", 281 "//tensorflow/c:tf_status_helper", 282 "//tensorflow/c/experimental/gradients:array_grad", 283 "//tensorflow/c/experimental/gradients:math_grad", 284 "//tensorflow/c/experimental/gradients:not_differentiable", 285 "//tensorflow/c/experimental/gradients/tape:tape_context", 286 "//tensorflow/c/experimental/ops", 287 "//tensorflow/cc/profiler", 288 "//tensorflow/compiler/mlir/tensorflow/c:mlir_c_api_registration", 289 "//tensorflow/core:lib", 290 "//tensorflow/core:protos_all_cc", 291 "//tensorflow/core:test", 292 "//tensorflow/core:test_main", 293 "//tensorflow/core/lib/llvm_rtti", 294 "@com_google_absl//absl/container:flat_hash_set", 295 "@com_google_absl//absl/strings", 296 "@com_google_absl//absl/types:span", 297 ], 298) 299 300tf_cuda_cc_test( 301 name = "unified_api_test", 302 size = "small", 303 srcs = [ 304 "unified_api_test.cc", 305 ], 306 args = ["--heap_check=local"], 307 linkstatic = tf_kernel_tests_linkstatic(), 308 tags = tf_cuda_tests_tags() + ["no_cuda_asan"], # b/173654156 309 deps = [ 310 ":c_api_experimental", 311 ":c_api_unified_internal", 312 ":unified_api_testutil", 313 "//tensorflow/c:tf_status_helper", 314 "//tensorflow/compiler/mlir/tensorflow/c:mlir_c_api_registration", 315 "//tensorflow/core:framework", 316 "//tensorflow/core:test", 317 "//tensorflow/core:test_main", 318 "//tensorflow/core/lib/llvm_rtti", 319 "//tensorflow/core/platform:errors", 320 ], 321) 322 323cc_library( 324 name = "gradients_util", 325 srcs = [ 326 "gradients_util.cc", 327 ], 328 hdrs = [ 329 "gradients_util.h", 330 ], 331 visibility = [ 332 "//tensorflow:internal", 333 ], 334 deps = [ 335 ":abstract_context", 336 ":abstract_operation", 337 ":abstract_tensor_handle", 338 ":c_api", 339 ":c_api_experimental", 340 ":c_api_unified_internal", 341 ":gradients_internal", 342 ":tape", 343 "@com_google_absl//absl/container:flat_hash_map", 344 "@com_google_absl//absl/container:flat_hash_set", 345 "@com_google_absl//absl/strings", 346 "@com_google_absl//absl/types:span", 347 "//tensorflow/c:c_api", 348 "//tensorflow/c:tf_status_helper", 349 "//tensorflow/c/experimental/ops:array_ops", 350 "//tensorflow/c/experimental/ops:math_ops", 351 "//tensorflow/c/experimental/ops:nn_ops", 352 "//tensorflow/cc/profiler", 353 "//tensorflow/core:framework", 354 "//tensorflow/core:lib", 355 "//tensorflow/core:protos_all_cc", 356 "//tensorflow/core/lib/llvm_rtti", 357 ] + if_libtpu( 358 if_false = ["//tensorflow/compiler/mlir/tensorflow/c:mlir_c_api_registration"], 359 if_true = [], 360 ), 361) 362 363cc_library( 364 name = "mnist_gradients_testutil", 365 srcs = [ 366 "mnist_gradients_testutil.cc", 367 ], 368 hdrs = [ 369 "mnist_gradients_testutil.h", 370 ], 371 visibility = [ 372 "//tensorflow:internal", 373 ], 374 deps = [ 375 ":abstract_tensor_handle", 376 ":c_api_experimental", 377 ":c_api_unified_internal", 378 ":gradients_internal", 379 ":gradients_util", 380 ":tape", 381 "//tensorflow/c/experimental/gradients/tape:tape_context", 382 "//tensorflow/c/experimental/ops:array_ops", 383 "//tensorflow/c/experimental/ops:math_ops", 384 "//tensorflow/c/experimental/ops:nn_ops", 385 "//tensorflow/core/lib/llvm_rtti", 386 "//tensorflow/core/platform:status", 387 "@com_google_absl//absl/container:flat_hash_set", 388 "@com_google_absl//absl/types:span", 389 ], 390) 391 392cc_library( 393 name = "gradient_checker", 394 testonly = 1, 395 srcs = [ 396 "gradient_checker.cc", 397 ], 398 hdrs = [ 399 "gradient_checker.h", 400 ], 401 visibility = [ 402 "//tensorflow:internal", 403 ], 404 deps = [ 405 ":abstract_tensor_handle", 406 ":unified_api_testutil", 407 "//tensorflow/c:tf_tensor_internal", 408 "//tensorflow/c/experimental/ops:math_ops", 409 "@com_google_absl//absl/types:span", 410 ], 411) 412 413tf_cuda_cc_test( 414 name = "gradient_checker_test", 415 size = "small", 416 srcs = [ 417 "gradient_checker_test.cc", 418 ], 419 args = ["--heap_check=local"], 420 linkstatic = tf_kernel_tests_linkstatic(), 421 tags = tf_cuda_tests_tags() + [ 422 "no_cuda_asan", # b/175330074 423 ], 424 deps = [ 425 ":abstract_tensor_handle", 426 ":c_api_experimental", 427 ":gradient_checker", 428 ":unified_api_testutil", 429 "//tensorflow/c:tf_status_helper", 430 "//tensorflow/c:tf_tensor_internal", 431 "//tensorflow/c/experimental/ops", 432 "//tensorflow/core:test", 433 "//tensorflow/core:test_main", 434 "//tensorflow/core/platform:tensor_float_32_utils", 435 "@com_google_absl//absl/types:span", 436 ], 437) 438 439tf_cuda_cc_test( 440 name = "mnist_gradients_test", 441 size = "small", 442 srcs = [ 443 "mnist_gradients_test.cc", 444 ], 445 args = ["--heap_check=local"], 446 linkstatic = tf_kernel_tests_linkstatic(), 447 tags = tf_cuda_tests_tags() + [ 448 "no_cuda_asan", # b/173825513 449 ], 450 deps = [ 451 ":abstract_tensor_handle", 452 ":c_api_experimental", 453 ":c_api_unified_internal", 454 ":gradients_internal", 455 ":gradients_util", 456 ":mnist_gradients_testutil", 457 "//tensorflow/c:c_api", 458 "//tensorflow/c:c_test_util", 459 "//tensorflow/c:tf_status_helper", 460 "//tensorflow/c/experimental/gradients:math_grad", 461 "//tensorflow/c/experimental/gradients:nn_grad", 462 "//tensorflow/c/experimental/ops:array_ops", 463 "//tensorflow/c/experimental/ops:math_ops", 464 "//tensorflow/c/experimental/ops:nn_ops", 465 "//tensorflow/cc/profiler", 466 "//tensorflow/compiler/mlir/tensorflow/c:mlir_c_api_registration", 467 "//tensorflow/core:lib", 468 "//tensorflow/core:protos_all_cc", 469 "//tensorflow/core:test", 470 "//tensorflow/core:test_main", 471 "//tensorflow/core/lib/llvm_rtti", 472 "//tensorflow/core/platform:tensor_float_32_utils", 473 "@com_google_absl//absl/container:flat_hash_set", 474 "@com_google_absl//absl/strings", 475 "@com_google_absl//absl/types:span", 476 ], 477) 478 479cc_library( 480 name = "abstract_tensor_handle", 481 srcs = ["abstract_tensor_handle.cc"], 482 hdrs = ["abstract_tensor_handle.h"], 483 visibility = [ 484 "//tensorflow:internal", 485 ], 486 deps = select({ 487 "//tensorflow:android": [ 488 "//tensorflow/core:portable_tensorflow_lib_lite", 489 ], 490 "//conditions:default": [ 491 "//tensorflow/core:framework", 492 "//tensorflow/core:protos_all_cc", 493 "//tensorflow/core/platform:refcount", 494 "//tensorflow/core/platform:status", 495 ], 496 }), 497) 498 499cc_library( 500 name = "immediate_execution_tensor_handle", 501 hdrs = ["immediate_execution_tensor_handle.h"], 502 visibility = [ 503 "//tensorflow:internal", 504 ], 505 deps = [ 506 ":abstract_tensor_handle", 507 "//tensorflow/c:tensor_interface", 508 "//tensorflow/core:framework", 509 "//tensorflow/core:lib", 510 "//tensorflow/core:protos_all_cc", 511 ], 512) 513 514cc_library( 515 name = "abstract_op_attrs", 516 hdrs = ["abstract_op_attrs.h"], 517 visibility = [ 518 "//tensorflow:internal", 519 ], 520 deps = [ 521 "//tensorflow/c:tensor_interface", 522 "//tensorflow/core:framework", 523 "//tensorflow/core:lib", 524 "//tensorflow/core:protos_all_cc", 525 "@com_google_absl//absl/types:span", 526 ], 527) 528 529cc_library( 530 name = "abstract_operation", 531 hdrs = ["abstract_operation.h"], 532 visibility = [ 533 "//tensorflow:internal", 534 ], 535 deps = [ 536 ":abstract_tensor_handle", 537 "//tensorflow/c:tensor_interface", 538 "//tensorflow/core:framework", 539 "//tensorflow/core:lib", 540 "//tensorflow/core:protos_all_cc", 541 "@com_google_absl//absl/types:span", 542 ], 543) 544 545cc_library( 546 name = "immediate_execution_operation", 547 hdrs = ["immediate_execution_operation.h"], 548 visibility = [ 549 "//tensorflow:internal", 550 ], 551 deps = [ 552 ":abstract_operation", 553 ":abstract_tensor_handle", 554 ":immediate_execution_tensor_handle", 555 "//tensorflow/c:tensor_interface", 556 "//tensorflow/core:framework", 557 "//tensorflow/core:lib", 558 "//tensorflow/core:protos_all_cc", 559 "//tensorflow/core/util:managed_stack_trace", 560 "@com_google_absl//absl/types:optional", 561 "@com_google_absl//absl/types:span", 562 ], 563) 564 565cc_library( 566 name = "abstract_context", 567 hdrs = ["abstract_context.h"], 568 visibility = [ 569 "//tensorflow:internal", 570 ], 571 deps = [ 572 ":abstract_function", 573 ":abstract_operation", 574 ], 575) 576 577cc_library( 578 name = "abstract_function", 579 hdrs = ["abstract_function.h"], 580 visibility = [ 581 "//tensorflow:internal", 582 ], 583 deps = [ 584 "//tensorflow/core:protos_all_cc", 585 "//tensorflow/core/platform:status", 586 ], 587) 588 589cc_library( 590 name = "immediate_execution_distributed_manager", 591 hdrs = ["immediate_execution_distributed_manager.h"], 592 visibility = [ 593 "//tensorflow:internal", 594 ], 595 deps = [ 596 "//tensorflow/core:framework", 597 "//tensorflow/core:lib", 598 "//tensorflow/core:protos_all_cc", 599 ], 600) 601 602cc_library( 603 name = "immediate_execution_context", 604 hdrs = ["immediate_execution_context.h"], 605 visibility = [ 606 "//tensorflow:internal", 607 ], 608 deps = [ 609 ":abstract_context", 610 ":immediate_execution_distributed_manager", 611 ":immediate_execution_operation", 612 ":immediate_execution_tensor_handle", 613 "//tensorflow/c:tensor_interface", 614 "//tensorflow/core:framework", 615 "//tensorflow/core:lib", 616 "//tensorflow/core:protos_all_cc", 617 "//tensorflow/core/platform", 618 "@com_google_absl//absl/types:optional", 619 "@com_google_absl//absl/types:span", 620 ], 621) 622 623cc_library( 624 name = "tfe_context_internal", 625 hdrs = ["tfe_context_internal.h"], 626 visibility = [ 627 "//tensorflow:internal", 628 ], 629 deps = [ 630 ":immediate_execution_context", 631 "//tensorflow/c:conversion_macros", 632 ], 633) 634 635cc_library( 636 name = "tfe_cancellation_manager_internal", 637 hdrs = ["tfe_cancellation_manager_internal.h"], 638 visibility = [ 639 "//tensorflow:internal", 640 ], 641 deps = [ 642 "//tensorflow/c:conversion_macros", 643 "//tensorflow/core:framework", 644 ], 645) 646 647cc_library( 648 name = "tfe_executor_internal", 649 hdrs = ["tfe_executor_internal.h"], 650 visibility = [ 651 "//tensorflow:internal", 652 ], 653 deps = [ 654 "//tensorflow/core/common_runtime/eager:eager_executor", 655 ], 656) 657 658cc_library( 659 name = "tfe_monitoring_internal", 660 hdrs = ["tfe_monitoring_internal.h"], 661 visibility = [ 662 "//tensorflow:internal", 663 ], 664 deps = [ 665 "//tensorflow/core:lib", 666 "@com_google_absl//absl/memory", 667 ], 668) 669 670cc_library( 671 name = "tfe_op_attrs_internal", 672 hdrs = ["tfe_op_attrs_internal.h"], 673 visibility = [ 674 "//tensorflow:internal", 675 ], 676 deps = [ 677 ":abstract_op_attrs", 678 "//tensorflow/c:conversion_macros", 679 "//tensorflow/c:tf_status", 680 "//tensorflow/core:protos_all_cc", 681 ], 682) 683 684cc_library( 685 name = "tfe_op_internal", 686 hdrs = ["tfe_op_internal.h"], 687 visibility = [ 688 "//tensorflow:internal", 689 ], 690 deps = [ 691 ":immediate_execution_operation", 692 "//tensorflow/c:conversion_macros", 693 ], 694) 695 696cc_library( 697 name = "tfe_tensor_debug_info_internal", 698 hdrs = ["tfe_tensor_debug_info_internal.h"], 699 visibility = [ 700 "//tensorflow:internal", 701 ], 702 deps = [ 703 "//tensorflow/core:lib", 704 ], 705) 706 707cc_library( 708 name = "tfe_tensorhandle_internal", 709 hdrs = ["tfe_tensorhandle_internal.h"], 710 visibility = [ 711 "//tensorflow:internal", 712 ], 713 deps = [ 714 ":immediate_execution_tensor_handle", 715 "//tensorflow/c:conversion_macros", 716 ], 717) 718 719cc_header_only_library( 720 name = "tfe_tensorhandle_internal_hdrs_only", 721 extra_deps = [ 722 "@com_google_absl//absl/strings", 723 ], 724 visibility = [ 725 "//tensorflow:internal", 726 ], 727 deps = [ 728 ":tfe_tensorhandle_internal", 729 ], 730) 731 732cc_header_only_library( 733 name = "tfe_cancellationmanager_internal_hdrs_only", 734 extra_deps = [ 735 "@com_google_absl//absl/strings", 736 ], 737 visibility = [ 738 "//tensorflow:internal", 739 ], 740 deps = [ 741 ":tfe_cancellation_manager_internal", 742 ], 743) 744 745tf_cuda_library( 746 name = "c_api_test_util", 747 testonly = 1, 748 srcs = ["c_api_test_util.cc"], 749 hdrs = ["c_api_test_util.h"], 750 visibility = [ 751 "//learning/brain:__subpackages__", 752 "//tensorflow:__subpackages__", 753 ], 754 deps = [ 755 ":c_api", 756 ":c_api_experimental", 757 "//tensorflow/c:c_test_util", 758 "//tensorflow/c:tf_datatype", 759 "//tensorflow/c:tf_tensor", 760 "//tensorflow/core:framework", 761 "//tensorflow/core:lib", 762 "//tensorflow/core:protos_all_cc", 763 "//tensorflow/core:test", 764 ], 765) 766 767tf_cuda_cc_test( 768 name = "c_api_test", 769 size = "small", 770 srcs = [ 771 "c_api_debug_test.cc", 772 "c_api_test.cc", 773 ], 774 tags = [ 775 "guitar", 776 "multi_gpu", 777 ], 778 deps = [ 779 ":c_api", 780 ":c_api_experimental", 781 ":c_api_internal", 782 ":c_api_test_util", 783 ":tfe_op_internal", 784 ":tfe_tensorhandle_internal", 785 "//tensorflow/c:c_test_util", 786 "//tensorflow/core:lib", 787 "//tensorflow/core:lib_internal", 788 "//tensorflow/core:protos_all_cc", 789 "//tensorflow/core:test", 790 "//tensorflow/core:test_main", 791 "//tensorflow/core/common_runtime/eager:eager_operation", 792 "//tensorflow/core/common_runtime/eager:tensor_handle", 793 "@com_google_absl//absl/strings", 794 ], 795) 796 797tf_cuda_library( 798 name = "c_api_remote_test_util", 799 testonly = 1, 800 srcs = ["c_api_remote_test_util.cc"], 801 hdrs = ["c_api_remote_test_util.h"], 802 visibility = ["//tensorflow:__subpackages__"], 803 deps = [ 804 ":c_api", 805 ":c_api_internal", 806 ":c_api_test_util", 807 ":tfe_tensorhandle_internal", 808 "//tensorflow/core:framework", 809 "//tensorflow/core:lib", 810 "//tensorflow/core:protos_all_cc", 811 "//tensorflow/core:test", 812 "//tensorflow/core/common_runtime/eager:tensor_handle", 813 "//tensorflow/core/distributed_runtime/rpc:grpc_server_lib", 814 "@com_google_absl//absl/strings", 815 ], 816) 817 818tf_cuda_cc_test( 819 name = "c_api_remote_test", 820 size = "small", 821 srcs = [ 822 "c_api_remote_test.cc", 823 ], 824 # TODO(b/136478427): Figure out how to correctly shut the server down 825 args = ["--heap_check=local"], 826 tags = [ 827 "no_windows", 828 ], 829 deps = [ 830 ":c_api", 831 ":c_api_experimental", 832 ":c_api_internal", 833 ":c_api_remote_test_util", 834 ":c_api_test_util", 835 ":tfe_tensorhandle_internal", 836 "//tensorflow/c:c_test_util", 837 "//tensorflow/core:framework", 838 "//tensorflow/core:graph", 839 "//tensorflow/core:lib", 840 "//tensorflow/core:protos_all_cc", 841 "//tensorflow/core:test", 842 "//tensorflow/core:test_main", 843 "//tensorflow/core/common_runtime:function_optimization_registry", 844 "//tensorflow/core/common_runtime/eager:eager_operation", 845 "//tensorflow/core/distributed_runtime/rpc:grpc_server_lib", 846 "@com_google_absl//absl/strings", 847 ], 848) 849 850tf_cuda_cc_test( 851 name = "c_api_remote_function_test", 852 size = "small", 853 srcs = [ 854 "c_api_remote_function_test.cc", 855 ], 856 # TODO(b/136478427): Figure out how to correctly shut the server down 857 args = ["--heap_check=local"], 858 tags = [ 859 "no_windows", 860 ], 861 deps = [ 862 ":c_api_remote_test_util", 863 "//tensorflow/core:test", 864 "//tensorflow/core:test_main", 865 ], 866) 867 868tf_cuda_cc_test( 869 name = "c_api_distributed_test", 870 size = "small", 871 srcs = [ 872 "c_api_distributed_test.cc", 873 ], 874 # TODO(b/136478427): Figure out how to correctly shut the server down 875 args = ["--heap_check=local"], 876 tags = [ 877 "no_windows", 878 "noasan", # leaks gRPC server instances 879 ], 880 deps = [ 881 ":c_api", 882 ":c_api_experimental", 883 ":c_api_internal", 884 ":c_api_test_util", 885 ":tfe_tensorhandle_internal", 886 "//tensorflow/c:c_test_util", 887 "//tensorflow/core:framework", 888 "//tensorflow/core:graph", 889 "//tensorflow/core:lib", 890 "//tensorflow/core:protos_all_cc", 891 "//tensorflow/core:test", 892 "//tensorflow/core:test_main", 893 "//tensorflow/core/common_runtime:function_optimization_registry", 894 "//tensorflow/core/common_runtime:optimization_registry", 895 "//tensorflow/core/common_runtime/eager:eager_operation", 896 "//tensorflow/core/distributed_runtime/rpc:grpc_server_lib", 897 "@com_google_absl//absl/strings", 898 ], 899) 900 901tf_cuda_cc_test( 902 name = "c_api_cluster_test", 903 size = "small", 904 srcs = [ 905 "c_api_cluster_test.cc", 906 ], 907 # TODO(b/136478427): Figure out how to correctly shut the server down 908 args = ["--heap_check=local"], 909 tags = [ 910 "no_windows", 911 ], 912 deps = [ 913 ":c_api", 914 ":c_api_experimental", 915 ":c_api_internal", 916 ":c_api_test_util", 917 ":tfe_tensorhandle_internal", 918 "//tensorflow/c:c_test_util", 919 "//tensorflow/core:lib", 920 "//tensorflow/core:protos_all_cc", 921 "//tensorflow/core:test", 922 "//tensorflow/core:test_main", 923 "//tensorflow/core/common_runtime/eager:eager_operation", 924 "//tensorflow/core/distributed_runtime/rpc:grpc_server_lib", 925 "//tensorflow/core/platform:env", 926 "@com_google_absl//absl/strings", 927 ], 928) 929 930tf_cuda_library( 931 name = "c_api_experimental", 932 srcs = [ 933 "c_api_experimental.cc", 934 "c_api_unified_experimental.cc", 935 "c_api_unified_experimental_eager.cc", 936 "c_api_unified_experimental_graph.cc", 937 "c_api_unified_experimental_internal.h", 938 ], 939 hdrs = [ 940 "c_api_experimental.h", 941 "c_api_unified_experimental.h", 942 ], 943 copts = tf_copts(), 944 visibility = ["//visibility:public"], 945 deps = select({ 946 "//tensorflow:android": [ 947 "//tensorflow/core:portable_tensorflow_lib_lite", 948 ], 949 "//conditions:default": [ 950 ":c_api", 951 ":c_api_internal", 952 ":tfe_context_internal", 953 ":tfe_op_internal", 954 ":tfe_tensorhandle_internal", 955 ":abstract_operation", 956 ":abstract_context", 957 ":abstract_tensor_handle", 958 ":immediate_execution_tensor_handle", 959 ":immediate_execution_context", 960 "//tensorflow/core/lib/llvm_rtti", 961 "//tensorflow/c:c_api", 962 "//tensorflow/c:c_api_internal", 963 "//tensorflow/core:core_cpu", 964 "//tensorflow/core/common_runtime/eager:attr_builder", 965 "//tensorflow/core/common_runtime/eager:context", 966 "//tensorflow/core/common_runtime/eager:eager_executor", 967 "//tensorflow/core/common_runtime/eager:eager_operation", 968 "//tensorflow/core/common_runtime/eager:execute", 969 "//tensorflow/core/common_runtime/eager:kernel_and_device", 970 "//tensorflow/core/common_runtime/eager:tensor_handle", 971 "//tensorflow/core/common_runtime/eager:copy_to_device_node", 972 "//tensorflow/core:core_cpu_internal", 973 "//tensorflow/core:framework", 974 "//tensorflow/core:framework_internal", 975 "//tensorflow/core:lib", 976 "//tensorflow/core:lib_internal", 977 "//tensorflow/core:protos_all_cc", 978 "@com_google_absl//absl/types:variant", 979 "//tensorflow/c:conversion_macros", 980 ], 981 }) + select({ 982 "//tensorflow:with_xla_support": [ 983 "//tensorflow/compiler/tf2xla:xla_compiler", 984 "//tensorflow/compiler/jit", 985 "//tensorflow/compiler/jit:xla_device", 986 ], 987 "//conditions:default": [], 988 }) + [ 989 "@com_google_absl//absl/memory", 990 "@com_google_absl//absl/strings", 991 "@com_google_absl//absl/container:flat_hash_map", 992 "//tensorflow/c:tf_status_helper", 993 "//tensorflow/core/distributed_runtime/eager:eager_client", 994 "//tensorflow/core/distributed_runtime/rpc/eager:grpc_eager_client", 995 "//tensorflow/core/distributed_runtime/rpc:grpc_channel", 996 "//tensorflow/core/distributed_runtime/rpc:grpc_server_lib", 997 "//tensorflow/core/distributed_runtime/rpc:grpc_worker_cache", 998 "//tensorflow/core/distributed_runtime/rpc:grpc_worker_service", 999 "//tensorflow/core/distributed_runtime/rpc:rpc_rendezvous_mgr", 1000 "//tensorflow/core/distributed_runtime:remote_device", 1001 "//tensorflow/core/distributed_runtime:server_lib", 1002 "//tensorflow/core/distributed_runtime:worker_env", 1003 "//tensorflow/core:gpu_runtime", 1004 ], 1005 alwayslink = 1, 1006) 1007 1008tf_cuda_cc_test( 1009 name = "c_api_experimental_test", 1010 size = "small", 1011 srcs = [ 1012 "c_api_experimental_test.cc", 1013 ], 1014 args = ["--heap_check=local"], 1015 linkstatic = tf_kernel_tests_linkstatic(), 1016 tags = tf_cuda_tests_tags() + ["nomac"], 1017 deps = [ 1018 ":c_api", 1019 ":c_api_experimental", 1020 ":c_api_test_util", 1021 "//tensorflow/c:c_test_util", 1022 "//tensorflow/cc/profiler", 1023 "//tensorflow/core:lib", 1024 "//tensorflow/core:protos_all_cc", 1025 "//tensorflow/core:test", 1026 "//tensorflow/core:test_main", 1027 "//tensorflow/core/platform:status", 1028 "@com_google_absl//absl/strings", 1029 ], 1030) 1031 1032tf_cuda_cc_test( 1033 name = "c_api_unified_experimental_test", 1034 size = "small", 1035 srcs = [ 1036 "c_api_unified_experimental_test.cc", 1037 ], 1038 args = ["--heap_check=local"], 1039 linkstatic = tf_kernel_tests_linkstatic(), 1040 tags = tf_cuda_tests_tags() + ["nomac"], 1041 deps = [ 1042 ":c_api", 1043 ":c_api_experimental", 1044 ":c_api_test_util", 1045 "//tensorflow/c:c_api", 1046 "//tensorflow/c:c_test_util", 1047 "//tensorflow/c:tf_status_helper", 1048 "//tensorflow/cc/profiler", 1049 "//tensorflow/compiler/mlir/tensorflow/c:mlir_c_api_registration", 1050 "//tensorflow/core:lib", 1051 "//tensorflow/core:protos_all_cc", 1052 "//tensorflow/core:test", 1053 "//tensorflow/core:test_main", 1054 "@com_google_absl//absl/strings", 1055 ], 1056) 1057 1058cc_library( 1059 name = "custom_device_testutil", 1060 testonly = True, 1061 srcs = ["custom_device_testutil.cc"], 1062 hdrs = ["custom_device_testutil.h"], 1063 visibility = ["//tensorflow:internal"], 1064 deps = [ 1065 ":c_api", 1066 ":c_api_experimental", 1067 ":c_api_test_util", 1068 "//tensorflow/c:c_api", 1069 "//tensorflow/core:lib", 1070 "//tensorflow/core:test", 1071 ], 1072) 1073 1074tf_cc_test( 1075 name = "custom_device_test", 1076 size = "small", 1077 srcs = [ 1078 "custom_device_test.cc", 1079 ], 1080 deps = [ 1081 ":c_api", 1082 ":c_api_experimental", 1083 ":c_api_test_util", 1084 ":custom_device_testutil", 1085 "//tensorflow/c:c_api", 1086 "//tensorflow/c:c_test_util", 1087 "//tensorflow/cc/profiler", 1088 "//tensorflow/core:lib", 1089 "//tensorflow/core:protos_all_cc", 1090 "//tensorflow/core:test", 1091 "//tensorflow/core:test_main", 1092 "@com_google_absl//absl/strings", 1093 ], 1094) 1095 1096cc_library( 1097 name = "tape", 1098 hdrs = ["tape.h"], 1099 visibility = ["//tensorflow:internal"], 1100 deps = [ 1101 "//tensorflow/core:framework", 1102 "//tensorflow/core:lib", 1103 ], 1104) 1105 1106filegroup( 1107 name = "headers", 1108 srcs = [ 1109 "c_api.h", 1110 "c_api_experimental.h", 1111 "dlpack.h", 1112 ], 1113 visibility = ["//tensorflow:__subpackages__"], 1114) 1115 1116cc_library( 1117 name = "dlpack", 1118 srcs = ["dlpack.cc"], 1119 hdrs = ["dlpack.h"], 1120 copts = [ 1121 "-fexceptions", 1122 "-fno-strict-aliasing", 1123 ], 1124 features = ["-use_header_modules"], 1125 visibility = ["//tensorflow:__subpackages__"], 1126 deps = [ 1127 ":c_api", 1128 ":c_api_experimental", 1129 ":tfe_tensorhandle_internal", 1130 "//tensorflow/c:tf_status_helper", 1131 "//tensorflow/c:tf_status_internal", 1132 "//tensorflow/core:framework", 1133 "//tensorflow/core:framework_internal", 1134 "//tensorflow/core:lib", 1135 "//tensorflow/core/common_runtime/eager:tensor_handle", 1136 "@dlpack", 1137 ], 1138 alwayslink = 1, 1139) 1140 1141# TODO(karllessard): only used by //tensorflow/core:mobile_srcs_only_runtime 1142# right now, remove this public rule when no longer needed (it should be 1143# replaced by TF Lite) 1144filegroup( 1145 name = "srcs", 1146 srcs = glob( 1147 [ 1148 "*.cc", 1149 "*.h", 1150 ], 1151 exclude = [ 1152 "c_api_experimental.cc", 1153 "c_api_unified_experimental.cc", 1154 "c_api_unified_experimental_eager.cc", 1155 "c_api_unified_experimental_graph.cc", 1156 "c_api_unified_experimental_internal.h", 1157 "gradient_checker.cc", 1158 "gradient_checker.h", 1159 "gradients.cc", # Uses RTTI. 1160 "gradients_util.cc", 1161 "gradients_util.h", 1162 "tracing_utils.h", 1163 "tracing_utils.cc", 1164 "*test*", 1165 "*dlpack*", 1166 ], 1167 ), 1168 visibility = ["//visibility:public"], 1169) 1170