1# Description: 2# C API for TensorFlow, for use by client language bindings. 3 4load("@bazel_skylib//lib:selects.bzl", "selects") 5load("//tensorflow/core/platform:rules_cc.bzl", "cc_library") 6load( 7 "//tensorflow:tensorflow.bzl", 8 "check_deps", 9 "if_google", 10 "if_not_mobile", 11 "tf_cc_test", 12 "tf_copts", 13 "tf_cuda_library", 14 "tf_custom_op_library", 15 "tf_kernel_library", 16) 17load("@local_config_tensorrt//:build_defs.bzl", "if_tensorrt") 18 19# buildifier: disable=same-origin-load 20load("//tensorflow:tensorflow.bzl", "filegroup") 21 22# buildifier: disable=same-origin-load 23load("//tensorflow:tensorflow.bzl", "tf_cuda_cc_test") 24 25package( 26 licenses = ["notice"], 27) 28 29# ----------------------------------------------------------------------------- 30# Public targets 31 32filegroup( 33 name = "headers", 34 srcs = [ 35 "c_api.h", 36 "c_api_experimental.h", 37 "c_api_macros.h", 38 "tensor_interface.h", 39 "tf_attrtype.h", 40 "tf_buffer.h", 41 "tf_datatype.h", 42 "tf_file_statistics.h", 43 "tf_status.h", 44 "tf_tensor.h", 45 "tf_tstring.h", 46 "//tensorflow/core/platform:ctstring", 47 ] + if_tensorrt([ 48 "//tensorflow/compiler/tf2tensorrt:headers", 49 ]), 50 visibility = ["//tensorflow:__subpackages__"], 51) 52 53filegroup( 54 name = "srcs", 55 srcs = glob( 56 [ 57 "*.cc", 58 "*.h", 59 ], 60 exclude = [ 61 "c_api_experimental.cc", 62 "c_api_experimental.h", 63 "python_api.cc", 64 "python_api.h", 65 "*test*", 66 ], 67 ) + [ 68 "//tensorflow/core/platform:ctstring", 69 "//tensorflow/cc:srcs_no_runtime", 70 "//tensorflow/core/distributed_runtime:server_lib.h", 71 ], 72 visibility = ["//visibility:public"], 73) 74 75cc_library( 76 name = "pywrap_required_hdrs", 77 textual_hdrs = [ 78 "c_api_internal.h", 79 "c_api_macros.h", 80 "conversion_macros.h", 81 "python_api.h", 82 "tensor_interface.h", 83 "tf_status_helper.h", 84 "tf_buffer_internal.h", 85 "tf_status_internal.h", 86 "tf_tensor_internal.h", 87 ], 88 visibility = [ 89 "//tensorflow/core:__pkg__", 90 "//tensorflow/python:__subpackages__", 91 ], 92) 93 94tf_cuda_library( 95 name = "c_api_internal", 96 hdrs = [ 97 "c_api.h", 98 "c_api_internal.h", 99 "c_api_macros.h", 100 "tf_buffer.h", 101 "tf_datatype.h", 102 "tf_tensor.h", 103 "tf_tstring.h", 104 ], 105 visibility = [ 106 "//tensorflow:internal", 107 "//tensorflow/c:__subpackages__", 108 ], 109 deps = selects.with_or({ 110 "//tensorflow:android": [ 111 "//tensorflow/core:portable_tensorflow_lib_lite", 112 ], 113 ("//tensorflow:chromiumos", "//tensorflow:fuchsia"): [ 114 ":tf_attrtype", 115 "//tensorflow/core:core_cpu", 116 "//tensorflow/core:framework", 117 "//tensorflow/core:lib", 118 "//tensorflow/core/platform:platform", 119 ], 120 "//conditions:default": [ 121 ":tf_attrtype", 122 "//tensorflow/core:core_cpu", 123 "//tensorflow/core:framework", 124 "//tensorflow/core:lib", 125 "//tensorflow/core/platform:platform", 126 "//tensorflow/core:op_gen_lib", 127 "//tensorflow/core/distributed_runtime:server_lib", 128 ], 129 }) + [ 130 ":tf_buffer_internal", 131 ":tf_status_internal", 132 ":tf_tensor_internal", 133 ], 134) 135 136filegroup( 137 name = "pywrap_tf_session_hdrs", 138 srcs = [ 139 "python_api.h", 140 ], 141 visibility = [ 142 "//tensorflow/core:__pkg__", 143 "//tensorflow/python:__pkg__", 144 ], 145) 146 147cc_library( 148 name = "tf_attrtype", 149 hdrs = ["tf_attrtype.h"], 150 visibility = ["//visibility:public"], 151) 152 153cc_library( 154 name = "c_api_macros", 155 hdrs = [ 156 "c_api_macros.h", 157 "c_api_macros_internal.h", 158 ], 159 copts = tf_copts(), 160 visibility = ["//visibility:public"], 161 deps = [ 162 ":tf_status", 163 "//tensorflow/core:lib", 164 "//tensorflow/core:lib_internal", 165 ], 166) 167 168tf_cuda_library( 169 name = "c_api", 170 hdrs = [ 171 "c_api.h", 172 "tf_attrtype.h", 173 "tf_buffer.h", 174 "tf_datatype.h", 175 "tf_file_statistics.h", 176 "tf_status.h", 177 "tf_tensor.h", 178 "tf_tstring.h", 179 ], 180 copts = tf_copts(), 181 visibility = ["//visibility:public"], 182 deps = [ 183 ":c_api_no_xla", 184 ":c_api_internal", 185 ":tf_attrtype", 186 ":tf_buffer", 187 ":tf_file_statistics", 188 ":tf_status_internal", 189 ":tf_tensor_internal", 190 ":tf_tstring", 191 "//tensorflow/core/platform:tstring", 192 ] + select({ 193 "//tensorflow:with_xla_support": [ 194 "//tensorflow/compiler/tf2xla:xla_compiler", 195 "//tensorflow/compiler/jit", 196 ], 197 "//conditions:default": [], 198 }) + if_tensorrt([ 199 "//tensorflow/compiler/tf2tensorrt:trt_convert_api", 200 ]), 201) 202 203# Check that c_api_no_xla does not depend on xla. 204check_deps( 205 name = "c_api_no_xla_check_deps", 206 disallowed_deps = ["//tensorflow/compiler/jit:xla_kernel_creator"], 207 deps = [":c_api_no_xla"], 208) 209 210tf_cuda_library( 211 name = "c_api_no_xla", 212 srcs = [ 213 "c_api.cc", 214 "c_api_function.cc", 215 ], 216 hdrs = [ 217 "c_api.h", 218 ], 219 copts = tf_copts(), 220 visibility = [ 221 "//tensorflow/c:__subpackages__", 222 "//tensorflow/python:__subpackages__", 223 ], 224 deps = [ 225 ":c_api_internal", 226 ":tf_attrtype", 227 ":tf_datatype", 228 ":tf_buffer", 229 ":tf_buffer_internal", 230 ":tf_status_internal", 231 ] + select({ 232 "//tensorflow:android": [ 233 "//tensorflow/core:portable_tensorflow_lib_lite", 234 ], 235 "//conditions:default": [ 236 ":env", 237 ":logging", 238 ":tf_status", 239 ":tf_tensor", 240 "@com_google_absl//absl/strings", 241 "//tensorflow/c/experimental/filesystem:modular_filesystem", 242 "//tensorflow/cc/saved_model:loader_lite", 243 "//tensorflow/cc:gradients", 244 "//tensorflow/cc:ops", 245 "//tensorflow/cc:grad_ops", 246 "//tensorflow/cc:scope_internal", 247 "//tensorflow/cc:while_loop", 248 "//tensorflow/core:core_cpu", 249 "//tensorflow/core:core_cpu_internal", 250 "//tensorflow/core:framework", 251 "//tensorflow/core:op_gen_lib", 252 "//tensorflow/core:protos_all_cc", 253 "//tensorflow/core:lib", 254 "//tensorflow/core:lib_internal", 255 "//tensorflow/core/distributed_runtime:server_lib", 256 "//tensorflow/core/kernels:logging_ops", 257 "//tensorflow/compiler/mlir/tfr:node_expansion_pass", 258 "//tensorflow/compiler/mlir/tfr:graph_decompose_pass", 259 ], 260 }), 261 alwayslink = 1, 262) 263 264cc_library( 265 name = "logging", 266 srcs = ["logging.cc"], 267 hdrs = ["logging.h"], 268 visibility = ["//visibility:public"], 269 deps = [ 270 ":c_api_macros", 271 "//tensorflow/core/platform:logging", 272 "//tensorflow/core/platform:stringprintf", 273 ], 274) 275 276tf_cuda_library( 277 name = "tf_status_internal", 278 hdrs = [ 279 "tf_status.h", 280 "tf_status_internal.h", 281 ], 282 visibility = [ 283 "//tensorflow/c:__subpackages__", 284 "//tensorflow/cc/experimental/libtf:__pkg__", 285 "//tensorflow/cc/experimental/libtf:__subpackages__", 286 # copybara:uncomment_begin(google-only) 287 # "//tensorflow/cc/experimental/tf2:__pkg__", 288 # "//tensorflow/cc/experimental/tf2:__subpackages__", 289 # copybara:uncomment_end 290 "//tensorflow/compiler/mlir/tensorflow/c:__subpackages__", 291 "//tensorflow/core/transforms:__subpackages__", 292 ], 293 deps = select({ 294 "//tensorflow:android": [ 295 "//tensorflow/core:portable_tensorflow_lib_lite", # TODO(annarev): exclude runtime srcs 296 ], 297 "//conditions:default": [ 298 "//tensorflow/core:lib", 299 ], 300 }), 301) 302 303filegroup( 304 name = "tf_status_internal_headers", 305 srcs = ["tf_status_internal.h"], 306 visibility = [ 307 "//tensorflow/python:__subpackages__", 308 ], 309) 310 311cc_library( 312 name = "tf_shape", 313 srcs = ["tf_shape.cc"], 314 hdrs = ["tf_shape.h"], 315 copts = tf_copts(), 316 visibility = ["//visibility:public"], 317 deps = [ 318 ":c_api_macros", 319 ":tf_shape_internal", 320 "//tensorflow/core:framework", 321 ], 322) 323 324cc_library( 325 name = "tf_shape_internal", 326 hdrs = ["tf_shape_internal.h"], 327 copts = tf_copts(), 328 visibility = ["//tensorflow:internal"], 329 deps = [ 330 ":conversion_macros", 331 "//tensorflow/core:framework", 332 ], 333) 334 335cc_library( 336 name = "tf_status", 337 srcs = ["tf_status.cc"], 338 hdrs = ["tf_status.h"], 339 visibility = ["//visibility:public"], 340 deps = [ 341 ":tf_status_internal", 342 ] + select({ 343 "//tensorflow:android": [ 344 "//tensorflow/core:portable_tensorflow_lib_lite", # TODO(annarev): exclude runtime srcs 345 ], 346 "//conditions:default": [ 347 "//tensorflow/core:lib", 348 ], 349 }), 350) 351 352tf_cc_test( 353 name = "tf_status_test", 354 srcs = ["tf_status_test.cc"], 355 deps = [ 356 ":tf_status", 357 ":tf_status_internal", 358 "//tensorflow/core:lib", 359 "//tensorflow/core:test", 360 "//tensorflow/core:test_main", 361 ], 362) 363 364cc_library( 365 name = "tf_status_headers", 366 hdrs = ["tf_status.h"], 367 visibility = ["//visibility:public"], 368) 369 370cc_library( 371 name = "tf_tstring", 372 srcs = [ 373 "tf_tstring.cc", 374 ], 375 hdrs = [ 376 "c_api_macros.h", 377 "tf_datatype.h", 378 "tf_status.h", 379 "tf_tensor.h", 380 "tf_tstring.h", 381 ], 382 visibility = ["//visibility:public"], 383 deps = [ 384 "//tensorflow/core/platform:status", 385 "//tensorflow/core/platform:tstring", 386 ], 387) 388 389cc_library( 390 name = "tf_file_statistics", 391 hdrs = ["tf_file_statistics.h"], 392 visibility = ["//visibility:public"], 393) 394 395cc_library( 396 name = "tensor_interface", 397 hdrs = ["tensor_interface.h"], 398 visibility = ["//tensorflow:internal"], 399 deps = select({ 400 "//tensorflow:android": [ 401 "//tensorflow/core:portable_tensorflow_lib_lite", # TODO(annarev): exclude runtime srcs 402 ], 403 "//conditions:default": [ 404 "//tensorflow/core:lib", 405 "//tensorflow/core:protos_all_cc", 406 ], 407 }), 408) 409 410cc_library( 411 name = "tf_datatype", 412 srcs = ["tf_datatype.cc"], 413 hdrs = ["tf_datatype.h"], 414 visibility = ["//visibility:public"], 415 deps = select({ 416 "//tensorflow:android": [ 417 "//tensorflow/core:portable_tensorflow_lib_lite", # TODO(annarev): exclude runtime srcs 418 ], 419 "//conditions:default": [ 420 "//tensorflow/core:framework", 421 ], 422 }), 423 alwayslink = 1, 424) 425 426cc_library( 427 name = "tf_tensor", 428 srcs = ["tf_tensor.cc"], 429 hdrs = ["tf_tensor.h"], 430 visibility = ["//visibility:public"], 431 deps = [ 432 ":c_api_macros", 433 ":tensor_interface", 434 ":tf_datatype", 435 ":tf_status", 436 ":tf_status_helper", 437 ":tf_tensor_internal", 438 ] + select({ 439 "//tensorflow:android": [ 440 "//tensorflow/core:portable_tensorflow_lib_lite", # TODO(annarev): exclude runtime srcs 441 ], 442 "//conditions:default": [ 443 "//tensorflow/core:framework", 444 "//tensorflow/core:lib", 445 "//tensorflow/core:protos_all_cc", 446 "//tensorflow/core/platform:casts", 447 ], 448 }), 449) 450 451tf_cuda_library( 452 name = "tf_tensor_internal", 453 hdrs = [ 454 "tf_tensor.h", 455 "tf_tensor_internal.h", 456 ], 457 visibility = ["//tensorflow:internal"], 458 deps = [ 459 ":c_api_macros", 460 ":tensor_interface", 461 ":tf_datatype", 462 ":tf_status", 463 ] + select({ 464 "//tensorflow:android": [ 465 "//tensorflow/core:portable_tensorflow_lib_lite", # TODO(annarev): exclude runtime srcs 466 ], 467 "//conditions:default": [ 468 "//tensorflow/core:framework", 469 "//tensorflow/core:protos_all_cc", 470 "//tensorflow/core/platform:casts", 471 ], 472 }), 473) 474 475cc_library( 476 name = "tf_buffer", 477 srcs = [ 478 "tf_buffer.cc", 479 ], 480 hdrs = [ 481 "tf_buffer.h", 482 ], 483 visibility = ["//visibility:public"], 484 deps = [ 485 ":tf_buffer_internal", 486 ":tf_status", 487 ":tf_tensor_internal", 488 "//tensorflow/core/platform:errors", 489 "//tensorflow/core/platform:platform_port", 490 "//tensorflow/core/platform:protobuf", 491 "//tensorflow/core/platform:status", 492 ], 493) 494 495tf_cuda_library( 496 name = "tf_buffer_internal", 497 hdrs = [ 498 "tf_buffer.h", 499 "tf_buffer_internal.h", 500 ], 501 visibility = [ 502 "//tensorflow:internal", 503 "//tensorflow/c:__subpackages__", 504 ], 505 deps = [ 506 ":tf_status", 507 ":tf_tensor_internal", 508 "//tensorflow/core/platform:protobuf", 509 "//tensorflow/core/platform:status", 510 ], 511) 512 513tf_cuda_library( 514 name = "c_api_experimental", 515 srcs = [ 516 "c_api_experimental.cc", 517 ], 518 hdrs = [ 519 "c_api_experimental.h", 520 ], 521 copts = tf_copts(), 522 visibility = ["//visibility:public"], 523 deps = [ 524 ":c_api", 525 ":c_api_internal", 526 ":checkpoint_reader", 527 ":tf_buffer", 528 ":tf_buffer_internal", 529 "//tensorflow/c/eager:c_api", 530 "//tensorflow/c/eager:c_api_internal", 531 "//tensorflow/c/eager:tfe_context_internal", 532 "//tensorflow/c/eager:tfe_op_internal", 533 "//tensorflow/c/eager:tfe_tensorhandle_internal", 534 "//tensorflow/compiler/jit:flags", 535 "//tensorflow/compiler/jit:get_compiler_ir", 536 "//tensorflow/core:core_cpu", 537 "//tensorflow/core:framework", 538 "//tensorflow/core:lib", 539 "//tensorflow/core:protos_all_cc", 540 "//tensorflow/core/common_runtime/eager:attr_builder", 541 "//tensorflow/core/common_runtime/eager:context", 542 "//tensorflow/core/common_runtime/eager:core", 543 "//tensorflow/core/common_runtime/eager:eager_operation", 544 "//tensorflow/core/common_runtime/pluggable_device:pluggable_device_plugin_init", 545 "//tensorflow/core/distributed_runtime/rpc:grpc_server_lib", 546 "//tensorflow/core/platform", 547 "//tensorflow/core/platform:blocking_counter", 548 "@com_google_absl//absl/strings", 549 ], 550 alwayslink = 1, 551) 552 553exports_files( 554 [ 555 "version_script.lds", 556 "exported_symbols.lds", 557 ], 558 visibility = ["//visibility:public"], 559) 560 561filegroup( 562 name = "checkpoint_reader_hdrs", 563 srcs = [ 564 "checkpoint_reader.h", 565 "tf_status_helper.h", 566 ], 567 visibility = ["//tensorflow:__subpackages__"], 568) 569 570tf_cuda_library( 571 name = "tf_status_helper", 572 srcs = ["tf_status_helper.cc"], 573 hdrs = ["tf_status_helper.h"], 574 visibility = ["//visibility:public"], 575 deps = [ 576 ":tf_status", 577 ":tf_status_internal", 578 ] + select({ 579 "//tensorflow:android": [ 580 "//tensorflow/core:portable_tensorflow_lib_lite", # TODO(annarev): exclude runtime srcs 581 ], 582 "//conditions:default": [ 583 "//tensorflow/core:lib", 584 ], 585 }), 586) 587 588tf_cc_test( 589 name = "tf_status_helper_test", 590 srcs = ["tf_status_helper_test.cc"], 591 deps = [ 592 ":tf_status_helper", 593 "//tensorflow/core:lib", 594 "//tensorflow/core:test", 595 "//tensorflow/core:test_main", 596 ], 597) 598 599tf_cuda_library( 600 name = "checkpoint_reader", 601 srcs = ["checkpoint_reader.cc"], 602 hdrs = ["checkpoint_reader.h"], 603 visibility = ["//visibility:public"], 604 deps = [ 605 ":tf_status_helper", 606 "//tensorflow/core:framework", 607 "//tensorflow/core:lib", 608 "//tensorflow/core/util/tensor_bundle", 609 ], 610) 611 612tf_cuda_library( 613 name = "env", 614 srcs = [ 615 "env.cc", 616 ], 617 hdrs = [ 618 "env.h", 619 ], 620 copts = tf_copts(), 621 visibility = ["//visibility:public"], 622 deps = select({ 623 "//tensorflow:android": [ 624 "//tensorflow/core:portable_tensorflow_lib_lite", 625 ], 626 "//conditions:default": [ 627 "//tensorflow/core:framework", 628 ], 629 }) + [ 630 ":c_api_macros", 631 ":tf_status", 632 ":tf_status_helper", 633 ":tf_file_statistics", 634 "//tensorflow/core/platform:env", 635 "//tensorflow/core/platform:path", 636 "//tensorflow/core/platform:types", 637 ], 638) 639 640cc_library( 641 name = "kernels_hdrs", 642 hdrs = [ 643 "kernels.h", 644 "kernels_experimental.h", 645 ], 646 visibility = ["//tensorflow:internal"], 647 deps = [ 648 ":c_api_internal", 649 ":tf_datatype", 650 ":tf_status", 651 ":tf_tensor", 652 "//tensorflow/c/experimental/stream_executor:stream_executor_hdrs", 653 ], 654) 655 656tf_cuda_library( 657 name = "kernels", 658 srcs = [ 659 "kernels.cc", 660 ], 661 hdrs = [ 662 "kernels.h", 663 ], 664 copts = tf_copts(), 665 visibility = ["//visibility:public"], 666 deps = [ 667 ":tf_buffer", 668 ":tf_buffer_internal", 669 ":tf_status", 670 ":tf_status_helper", 671 ":tf_tensor_internal", 672 ] + select({ 673 "//tensorflow:android": [ 674 ":c_api_internal", 675 "//tensorflow/c/experimental/stream_executor:stream_executor_hdrs", 676 "//tensorflow/core:portable_tensorflow_lib_lite", 677 ], 678 "//conditions:default": [ 679 ":c_api_internal", 680 ":tf_tensor", 681 "//tensorflow/stream_executor:stream", 682 "//tensorflow/core:framework", 683 "//tensorflow/core:framework_lite", 684 "//tensorflow/core:protos_all_cc", 685 "//tensorflow/c/experimental/stream_executor:stream_executor", 686 "//tensorflow/c/experimental/stream_executor:stream_executor_internal", 687 ], 688 }), 689) 690 691cc_library( 692 name = "kernels_experimental_hdrs", 693 hdrs = ["kernels_experimental.h"], 694 visibility = ["//tensorflow:internal"], 695 deps = [":kernels_hdrs"], 696) 697 698tf_cuda_library( 699 name = "kernels_experimental", 700 srcs = ["kernels_experimental.cc"], 701 hdrs = ["kernels_experimental.h"], 702 copts = tf_copts(), 703 visibility = ["//visibility:public"], 704 deps = [ 705 ":kernels", 706 ":tf_status_helper", 707 ":tf_status_internal", 708 ":tf_tensor_internal", 709 "//tensorflow/core:framework", 710 "//tensorflow/core:framework_internal_impl", 711 "//tensorflow/core/platform:errors", 712 "//tensorflow/core/platform:mutex", 713 "//tensorflow/core/platform:refcount", 714 ] + if_not_mobile([ 715 "//tensorflow/core/kernels:tensor_list", 716 "//tensorflow/core/kernels:tensor_list_util", 717 "//tensorflow/core/kernels:variant_ops_util", 718 "//tensorflow/core/kernels/data:optional_ops_util", 719 "//tensorflow/core/platform:abi", 720 ]), 721) 722 723tf_cuda_library( 724 name = "ops", 725 srcs = [ 726 "ops.cc", 727 ], 728 hdrs = [ 729 "ops.h", 730 ], 731 copts = tf_copts(), 732 visibility = ["//visibility:public"], 733 deps = [ 734 ":tf_datatype", 735 ":tf_status", 736 ":tf_status_helper", 737 ] + select({ 738 "//tensorflow:android": [ 739 "//tensorflow/core:portable_tensorflow_lib_lite", 740 ], 741 "//conditions:default": [ 742 "//tensorflow/core:framework", 743 ], 744 }), 745 alwayslink = 1, 746) 747 748cc_library( 749 name = "ops_hdrs", 750 hdrs = ["ops.h"], 751 visibility = ["//tensorflow:internal"], 752 deps = [ 753 ":tf_datatype", 754 ":tf_status", 755 ], 756) 757 758# ----------------------------------------------------------------------------- 759# Tests 760 761tf_cuda_library( 762 name = "c_test_util", 763 testonly = 1, 764 srcs = ["c_test_util.cc"], 765 hdrs = ["c_test_util.h"], 766 visibility = [ 767 "//learning/brain:__subpackages__", 768 "//tensorflow:__subpackages__", 769 ], 770 deps = [ 771 ":c_api", 772 ":c_api_experimental", 773 "//tensorflow/core:lib", 774 "//tensorflow/core:protos_all_cc", 775 "//tensorflow/core:session_options", 776 "//tensorflow/core:test", 777 ], 778) 779 780tf_cc_test( 781 name = "c_test", 782 srcs = ["c_test.c"], 783 extra_copts = ["-std=c11"], 784 deps = [ 785 ":c_api", 786 ":c_api_experimental", 787 ":env", 788 ":kernels", 789 ], 790) 791 792tf_cuda_cc_test( 793 name = "c_api_test", 794 size = "small", 795 srcs = ["c_api_test.cc"], 796 data = [ 797 ":test_op1.so", 798 "//tensorflow/cc/saved_model:saved_model_half_plus_two", 799 ], 800 linkopts = select({ 801 "//tensorflow:macos": ["-headerpad_max_install_names"], 802 "//conditions:default": [], 803 }), 804 tags = [ 805 "no_cuda_asan", # TODO(b/181771536) 806 "no_windows", # TODO(b/155444728) 807 "noasan", 808 ], 809 # We must ensure that the dependencies can be dynamically linked since 810 # the shared library must be able to use core:framework. 811 # linkstatic = tf_kernel_tests_linkstatic(), 812 deps = [ 813 ":c_api", 814 ":c_api_internal", 815 ":c_test_util", 816 ":test_op_kernel", 817 ":tf_buffer", 818 ":tf_buffer_internal", 819 "//tensorflow/cc:cc_ops", 820 "//tensorflow/cc:grad_ops", 821 "//tensorflow/cc/saved_model:signature_constants", 822 "//tensorflow/cc/saved_model:tag_constants", 823 "//tensorflow/compiler/jit", 824 "//tensorflow/core:array_ops_op_lib", 825 "//tensorflow/core:bitwise_ops_op_lib", 826 "//tensorflow/core:control_flow_ops_op_lib", 827 "//tensorflow/core:core_cpu_internal", 828 "//tensorflow/core:direct_session", 829 "//tensorflow/core:framework", 830 "//tensorflow/core:framework_internal", 831 "//tensorflow/core:functional_ops_op_lib", 832 "//tensorflow/core:lib", 833 "//tensorflow/core:math_ops_op_lib", 834 "//tensorflow/core:nn_ops_op_lib", 835 "//tensorflow/core:no_op_op_lib", 836 "//tensorflow/core:protos_all_cc", 837 "//tensorflow/core:sendrecv_ops_op_lib", 838 "//tensorflow/core:spectral_ops_op_lib", 839 "//tensorflow/core:state_ops_op_lib", 840 "//tensorflow/core:test", 841 "//tensorflow/core:test_main", 842 "//tensorflow/core/kernels:array", 843 "//tensorflow/core/kernels:control_flow_ops", 844 "//tensorflow/core/kernels:math", 845 "//tensorflow/core/platform:resource_loader", 846 ], 847) 848 849tf_cc_test( 850 name = "c_api_experimental_test", 851 size = "medium", 852 srcs = ["c_api_experimental_test.cc"], 853 data = [ 854 "testdata/tf_record", 855 "//tensorflow/c/experimental/stream_executor/test:test_pluggable_device.so", 856 ], 857 extra_copts = if_google(["-DTENSORFLOW_NO_SHARED_OBJECTS=1"]), 858 linkopts = select({ 859 "//tensorflow:macos": ["-headerpad_max_install_names"], 860 "//conditions:default": [], 861 }), 862 tags = [ 863 "nomsan", # b/149031034 864 "notsan", # b/149031034 865 ], 866 # We must ensure that the dependencies can be dynamically linked since 867 # the shared library must be able to use core:framework. 868 # linkstatic = tf_kernel_tests_linkstatic(), 869 deps = [ 870 ":c_api", 871 ":c_api_experimental", 872 ":c_api_internal", 873 ":c_test_util", 874 "//tensorflow/c/eager:c_api", 875 "//tensorflow/c/eager:c_api_test_util", 876 "//tensorflow/core:lib", 877 "//tensorflow/core:protos_all_cc", 878 "//tensorflow/core:test", 879 "//tensorflow/core:test_main", 880 "//tensorflow/core/platform:resource_loader", 881 "@com_google_absl//absl/types:optional", 882 ], 883) 884 885tf_cc_test( 886 name = "c_api_function_test", 887 size = "small", 888 srcs = ["c_api_function_test.cc"], 889 deps = [ 890 ":c_api", 891 ":c_api_internal", 892 ":c_test_util", 893 "//tensorflow/core:framework", 894 "//tensorflow/core:lib", 895 "//tensorflow/core:lib_internal", 896 "//tensorflow/core:protos_all_cc", 897 "//tensorflow/core:test", 898 "//tensorflow/core:test_main", 899 ], 900) 901 902tf_cc_test( 903 name = "while_loop_test", 904 size = "small", 905 srcs = ["while_loop_test.cc"], 906 deps = [ 907 ":c_api", 908 ":c_test_util", 909 "//tensorflow/core:lib", 910 "//tensorflow/core:test", 911 "//tensorflow/core:test_main", 912 ], 913) 914 915tf_custom_op_library( 916 name = "test_op1.so", 917 srcs = ["test_op1.cc"], 918) 919 920tf_kernel_library( 921 name = "test_op_kernel", 922 srcs = ["test_op.cc"], 923 deps = [ 924 "//tensorflow/core:framework", 925 "//tensorflow/core:lib", 926 ], 927 alwayslink = 1, 928) 929 930tf_cuda_cc_test( 931 name = "env_test", 932 size = "small", 933 srcs = ["env_test.cc"], 934 linkopts = select({ 935 "//tensorflow:macos": ["-headerpad_max_install_names"], 936 "//conditions:default": [], 937 }), 938 tags = ["noasan"], 939 # We must ensure that the dependencies can be dynamically linked since 940 # the shared library must be able to use core:framework. 941 # linkstatic = tf_kernel_tests_linkstatic(), 942 deps = [ 943 ":c_api", 944 ":env", 945 "//tensorflow/core:lib", 946 "//tensorflow/core:test", 947 "//tensorflow/core:test_main", 948 ], 949) 950 951tf_cuda_cc_test( 952 name = "kernels_test", 953 size = "small", 954 srcs = ["kernels_test.cc"], 955 linkopts = select({ 956 "//tensorflow:macos": ["-headerpad_max_install_names"], 957 "//conditions:default": [], 958 }), 959 tags = ["no_cuda_on_cpu_tap"], 960 # We must ensure that the dependencies can be dynamically linked since 961 # the shared library must be able to use core:framework. 962 # linkstatic = tf_kernel_tests_linkstatic(), 963 deps = [ 964 ":c_api", 965 ":kernels", 966 "//tensorflow/core:core_cpu", 967 "//tensorflow/core:framework", 968 "//tensorflow/core:lib", 969 "//tensorflow/core:protos_all_cc", 970 "//tensorflow/core:test", 971 "//tensorflow/core:test_main", 972 "//tensorflow/core/kernels:ops_testutil", 973 "//third_party/eigen3", 974 "@com_google_absl//absl/container:inlined_vector", 975 "@com_google_absl//absl/strings:str_format", 976 ], 977) 978 979tf_cc_test( 980 name = "ops_test", 981 size = "small", 982 srcs = ["ops_test.cc"], 983 linkopts = select({ 984 "//conditions:default": [], 985 }), 986 tags = ["noasan"], 987 # We must ensure that the dependencies can be dynamically linked since 988 # the shared library must be able to use core:framework. 989 # linkstatic = tf_kernel_tests_linkstatic(), 990 deps = [ 991 ":c_api", 992 ":ops", 993 "//tensorflow/core:framework", 994 "//tensorflow/core:lib", 995 "//tensorflow/core:protos_all_cc", 996 "//tensorflow/core:test", 997 "//tensorflow/core:test_main", 998 "//tensorflow/core:testlib", 999 "@com_google_absl//absl/strings", 1000 ], 1001) 1002 1003# ----------------------------------------------------------------------------- 1004# Python API target 1005 1006tf_cuda_library( 1007 name = "python_api", 1008 srcs = ["python_api.cc"], 1009 hdrs = ["python_api.h"], 1010 visibility = ["//tensorflow/python:__pkg__"], 1011 deps = [ 1012 ":c_api", 1013 ":c_api_internal", 1014 "//tensorflow/core:protos_all_cc", 1015 # TODO(b/74620627): remove when _USE_C_SHAPES is removed 1016 "//tensorflow/python/framework:cpp_shape_inference_proto_cc", 1017 ], 1018 alwayslink = 1, 1019) 1020 1021cc_library( 1022 name = "conversion_macros", 1023 hdrs = [ 1024 "conversion_macros.h", 1025 ], 1026 visibility = ["//tensorflow:__subpackages__"], 1027) 1028 1029cc_library( 1030 name = "c_op_requires", 1031 hdrs = ["c_op_requires.h"], 1032 visibility = ["//visibility:public"], 1033 deps = ["//tensorflow/core/platform:macros"], 1034) 1035