1load("//tensorflow:tensorflow.bzl", "if_not_windows", "tf_cc_test") 2load("//tensorflow/lite:build_def.bzl", "tflite_cc_shared_object", "tflite_copts", "tflite_copts_warnings") 3load("//tensorflow/lite:special_rules.bzl", "internal_visibility_allowlist", "tflite_portable_test_suite") 4load("//tensorflow:tensorflow.bzl", "get_compatible_with_portable") 5 6package( 7 default_visibility = ["//visibility:public"], 8 licenses = ["notice"], # Apache 2.0 9) 10 11exports_files(glob([ 12 "testdata/*.bin", 13 "testdata/*.pb", 14 "testdata/*.tflite", 15 "testdata/*.csv", 16 "models/testdata/*", 17]) + [ 18 "create_op_resolver.h", 19 "create_op_resolver_with_selected_ops.cc", 20]) 21 22config_setting( 23 name = "gemmlowp_profiling", 24 values = { 25 "copt": "-DGEMMLOWP_PROFILING", 26 }, 27) 28 29config_setting( 30 name = "mips", 31 values = { 32 "cpu": "mips", 33 }, 34) 35 36config_setting( 37 name = "mips64", 38 values = { 39 "cpu": "mips64", 40 }, 41) 42 43# Without "cpu":"k8", when building with --copt=-DTF_LITE_STATIC_MEMORY, we get 44# the following error: 45# Multiple matches are not allowed unless one is unambiguously more specialized. 46# 47# The reason for this is that some of the tflite BUILD files (e.g. 48# kernels/internal/BUILD) have config_settings based on "cpu":"k8" and the 49# tf_lite_static_memory config_setting needs to be more specialized. It may be 50# possible to change the existing config_settings to allow for 51# tf_lite_static_memory to not require "cpu":"k8". We are not attempting that 52# since we currently only using the BUILD files for x86. 53config_setting( 54 name = "tf_lite_static_memory", 55 values = { 56 "copt": "-DTF_LITE_STATIC_MEMORY", 57 "cpu": "k8", 58 }, 59) 60 61FRAMEWORK_LIB_HDRS = [ 62 "allocation.h", 63 "context.h", 64 "context_util.h", 65 "core/macros.h", 66 "core/subgraph.h", 67 "error_reporter.h", 68 "graph_info.h", 69 "interpreter.h", 70 "model.h", 71 "model_builder.h", 72 "interpreter_builder.h", 73 "mutable_op_resolver.h", 74 "op_resolver.h", 75 "optional_debug_tools.h", 76 "stderr_reporter.h", 77] 78 79exports_files( 80 FRAMEWORK_LIB_HDRS, 81 visibility = ["//tensorflow/lite/core/shims:__subpackages__"], 82) 83 84cc_library( 85 name = "version", 86 hdrs = ["version.h"], 87 compatible_with = get_compatible_with_portable(), 88 copts = tflite_copts_warnings(), 89 # Note that we only use the header defines from :version_lib. 90 deps = ["//tensorflow/core:version_lib"], 91) 92 93# TODO(b/128420794): Migrate clients to use :version directly. 94alias( 95 name = "schema_fbs_version", 96 actual = ":version", 97 # avoid_dep tells build_cleaner to not use schema_fbs_version. 98 tags = ["avoid_dep"], 99) 100 101cc_library( 102 name = "arena_planner", 103 srcs = ["arena_planner.cc"], 104 hdrs = ["arena_planner.h"], 105 compatible_with = get_compatible_with_portable(), 106 copts = tflite_copts_warnings(), 107 deps = [ 108 ":graph_info", 109 ":memory_planner", 110 ":simple_memory_arena", 111 ":util", 112 "//tensorflow/lite/c:common", 113 ], 114) 115 116cc_test( 117 name = "arena_planner_test", 118 size = "small", 119 srcs = ["arena_planner_test.cc"], 120 tags = [ 121 "tflite_not_portable_android", 122 ], 123 deps = [ 124 ":arena_planner", 125 ":graph_info", 126 "//tensorflow/core:tflite_portable_logging", 127 "//tensorflow/lite/c:common", 128 "//tensorflow/lite/testing:util", 129 "@com_google_googletest//:gtest", 130 ], 131) 132 133# Main library. No ops are included here. 134# TODO(aselle): Resolve problems preventing C99 usage. 135cc_library( 136 name = "context", 137 hdrs = ["context.h"], 138 compatible_with = get_compatible_with_portable(), 139 copts = tflite_copts_warnings(), 140 deps = ["//tensorflow/lite/c:common"], 141) 142 143cc_library( 144 name = "external_cpu_backend_context", 145 srcs = ["external_cpu_backend_context.cc"], 146 hdrs = ["external_cpu_backend_context.h"], 147 compatible_with = get_compatible_with_portable(), 148 copts = tflite_copts_warnings(), 149 deps = [ 150 "//tensorflow/lite/c:common", 151 ], 152) 153 154cc_library( 155 name = "graph_info", 156 hdrs = ["graph_info.h"], 157 compatible_with = get_compatible_with_portable(), 158 copts = tflite_copts_warnings(), 159 deps = ["//tensorflow/lite/c:common"], 160) 161 162cc_library( 163 name = "memory_planner", 164 hdrs = ["memory_planner.h"], 165 compatible_with = get_compatible_with_portable(), 166 copts = tflite_copts_warnings(), 167 deps = ["//tensorflow/lite/c:common"], 168) 169 170cc_library( 171 name = "simple_memory_arena", 172 srcs = ["simple_memory_arena.cc"], 173 hdrs = ["simple_memory_arena.h"], 174 compatible_with = get_compatible_with_portable(), 175 copts = tflite_copts_warnings(), 176 deps = ["//tensorflow/lite/c:common"], 177) 178 179cc_library( 180 name = "builtin_op_data", 181 hdrs = ["builtin_op_data.h"], 182 deps = ["//tensorflow/lite/c:common"], 183) 184 185cc_library( 186 name = "kernel_api", 187 hdrs = [ 188 "builtin_op_data.h", 189 "builtin_ops.h", 190 "context_util.h", 191 ], 192 compatible_with = get_compatible_with_portable(), 193 deps = ["//tensorflow/lite/c:common"], 194) 195 196cc_library( 197 name = "builtin_ops", 198 hdrs = ["builtin_ops.h"], 199 compatible_with = get_compatible_with_portable(), 200) 201 202exports_files(["builtin_ops.h"]) 203 204cc_library( 205 name = "string", 206 hdrs = [ 207 "string_type.h", 208 ], 209 compatible_with = get_compatible_with_portable(), 210 copts = tflite_copts_warnings(), 211) 212 213cc_library( 214 name = "allocation", 215 srcs = [ 216 "allocation.cc", 217 ] + select({ 218 "//tensorflow:android": [ 219 "mmap_allocation.cc", 220 ], 221 "//tensorflow:windows": [ 222 "mmap_allocation_disabled.cc", 223 ], 224 "//conditions:default": [ 225 "mmap_allocation.cc", 226 ], 227 }), 228 hdrs = [ 229 "allocation.h", 230 ], 231 compatible_with = get_compatible_with_portable(), 232 copts = tflite_copts_warnings(), 233 deps = [ 234 ":string", 235 "//tensorflow/lite/c:common", 236 "//tensorflow/lite/core/api", 237 ], 238) 239 240# The library that implements the full C++ API. 241# See also 'framework' below, which is the corresponding public target. 242cc_library( 243 name = "framework_lib", 244 hdrs = FRAMEWORK_LIB_HDRS, 245 compatible_with = get_compatible_with_portable(), 246 copts = tflite_copts() + tflite_copts_warnings(), 247 visibility = [ 248 "//tensorflow/lite:__subpackages__", 249 ], 250 deps = [ 251 ":allocation", 252 ":cc_api", 253 ":external_cpu_backend_context", 254 ":graph_info", 255 ":kernel_api", 256 ":macros", 257 ":memory_planner", 258 ":mutable_op_resolver", 259 ":optional_debug_tools", 260 ":stderr_reporter", 261 ":string", 262 ":type_to_tflitetype", 263 ":util", 264 "//tensorflow/lite/c:common", 265 "//tensorflow/lite/core/api", 266 "//tensorflow/lite/core/api:verifier", 267 "//tensorflow/lite/experimental/resource", 268 "//tensorflow/lite/schema:schema_fbs", 269 "@flatbuffers//:runtime_cc", 270 ], 271 alwayslink = 1, # Why?? TODO(b/161243354): eliminate this. 272) 273 274# The public target for the full C++ API. 275# The deps listed here, other than ":framework_lib", are the interface dependencies 276# (dependencies required by the header files). 277# TODO(ahentz): investigate dependency on gemm_support requiring usage of tf_copts. 278cc_library( 279 name = "framework", 280 srcs = [], 281 hdrs = FRAMEWORK_LIB_HDRS, 282 compatible_with = get_compatible_with_portable(), 283 copts = tflite_copts() + tflite_copts_warnings(), 284 deps = [ 285 ":allocation", 286 ":cc_api", 287 ":external_cpu_backend_context", 288 ":framework_lib", 289 ":graph_info", 290 ":memory_planner", 291 ":string", 292 ":type_to_tflitetype", 293 ":util", 294 "//tensorflow/lite/c:common", 295 "//tensorflow/lite/core/api", 296 "//tensorflow/lite/core/api:verifier", 297 "//tensorflow/lite/experimental/resource", 298 "//tensorflow/lite/schema:schema_fbs", 299 "@flatbuffers//:runtime_cc", 300 ], 301) 302 303# The key parts of the C++ API. This target defines the TF Lite classes for 304# loading models and interpreting them. 305cc_library( 306 name = "cc_api", 307 srcs = [ 308 "core/subgraph.cc", 309 "graph_info.cc", 310 "interpreter.cc", 311 "interpreter_builder.cc", 312 "model_builder.cc", 313 ], 314 hdrs = [ 315 "core/subgraph.h", 316 "graph_info.h", 317 "interpreter.h", 318 "interpreter_builder.h", 319 "model.h", 320 "model_builder.h", 321 ], 322 compatible_with = get_compatible_with_portable(), 323 copts = tflite_copts() + tflite_copts_warnings(), 324 visibility = [ 325 "//tensorflow/lite/core/shims:__subpackages__", 326 "//tensorflow/lite/kernels:__subpackages__", 327 ], 328 deps = [ 329 ":allocation", 330 ":arena_planner", 331 ":external_cpu_backend_context", 332 ":graph_info", 333 ":kernel_api", 334 ":macros", 335 ":memory_planner", 336 ":minimal_logging", 337 ":mutable_op_resolver", 338 ":shared_library", 339 ":simple_memory_arena", 340 ":stderr_reporter", 341 ":string", 342 ":type_to_tflitetype", 343 ":util", 344 ":version", 345 "//tensorflow/lite/c:common", 346 "//tensorflow/lite/core/api", 347 "//tensorflow/lite/core/api:verifier", 348 "//tensorflow/lite/delegates:telemetry", 349 "//tensorflow/lite/experimental/resource", 350 "//tensorflow/lite/kernels/internal:compatibility", 351 "//tensorflow/lite/profiling:platform_profiler", 352 "//tensorflow/lite/schema:schema_fbs", 353 "//tensorflow/lite/schema:schema_utils", 354 "@flatbuffers//:runtime_cc", 355 ], 356 alwayslink = 1, # Why?? TODO(b/161243354): eliminate this. 357) 358 359cc_library( 360 name = "optional_debug_tools", 361 srcs = [ 362 "optional_debug_tools.cc", 363 ], 364 hdrs = ["optional_debug_tools.h"], 365 compatible_with = get_compatible_with_portable(), 366 copts = tflite_copts() + tflite_copts_warnings(), 367 visibility = [ 368 "//visibility:public", 369 ], 370 deps = [ 371 ":macros", 372 "//tensorflow/lite:cc_api", 373 "//tensorflow/lite/c:common", 374 "//tensorflow/lite/schema:schema_fbs", 375 ], 376) 377 378cc_library( 379 name = "error_reporter", 380 hdrs = ["error_reporter.h"], 381 compatible_with = get_compatible_with_portable(), 382 copts = tflite_copts() + tflite_copts_warnings(), 383 visibility = [ 384 "//visibility:public", 385 ], 386 deps = [ 387 "//tensorflow/lite:stderr_reporter", 388 "//tensorflow/lite/core/api:error_reporter", 389 ], 390) 391 392cc_library( 393 name = "stderr_reporter", 394 srcs = ["stderr_reporter.cc"], 395 hdrs = ["stderr_reporter.h"], 396 compatible_with = get_compatible_with_portable(), 397 copts = tflite_copts() + tflite_copts_warnings(), 398 visibility = [ 399 "//visibility:public", 400 ], 401 deps = [ 402 ":minimal_logging", 403 "//tensorflow/lite/c:common", 404 "//tensorflow/lite/core/api:error_reporter", 405 ], 406) 407 408cc_library( 409 name = "op_resolver", 410 hdrs = ["op_resolver.h"], 411 compatible_with = get_compatible_with_portable(), 412 copts = tflite_copts() + tflite_copts_warnings(), 413 visibility = [ 414 "//visibility:public", 415 ], 416 deps = [ 417 "//tensorflow/lite:mutable_op_resolver", 418 "//tensorflow/lite/core/api:op_resolver", 419 ], 420) 421 422cc_library( 423 name = "mutable_op_resolver", 424 srcs = ["mutable_op_resolver.cc"], 425 hdrs = ["mutable_op_resolver.h"], 426 compatible_with = get_compatible_with_portable(), 427 copts = tflite_copts() + tflite_copts_warnings(), 428 visibility = [ 429 "//visibility:public", 430 ], 431 deps = [ 432 ":util", 433 "//tensorflow/lite/c:common", 434 "//tensorflow/lite/core/api:op_resolver", 435 "//tensorflow/lite/schema:schema_fbs", 436 ], 437) 438 439cc_library( 440 name = "string_util", 441 srcs = ["string_util.cc"], 442 hdrs = ["string_util.h"], 443 compatible_with = get_compatible_with_portable(), 444 copts = tflite_copts_warnings(), 445 deps = [ 446 ":string", 447 "//tensorflow/lite/c:common", 448 ], 449) 450 451# Link this library to inject XNNPACK delegate to TFLite runtime automatically 452# by utilizing the weak symbols if they're supported by the platform. 453cc_library( 454 name = "tflite_with_xnnpack", 455 srcs = ["tflite_with_xnnpack.cc"], 456 copts = tflite_copts() + tflite_copts_warnings(), 457 linkstatic = True, 458 deps = [ 459 "//tensorflow/lite/c:common", 460 "//tensorflow/lite/delegates/xnnpack:xnnpack_delegate", 461 ], 462 alwayslink = 1, 463) 464 465# Enables applying XNNPACK delegate for float models in TFLite runtime. 466# WARNING: This build flag is experimental and subject to change. 467config_setting( 468 name = "tflite_with_xnnpack_explicit_true", 469 define_values = {"tflite_with_xnnpack": "true"}, 470) 471 472config_setting( 473 name = "tflite_with_xnnpack_explicit_false", 474 define_values = {"tflite_with_xnnpack": "false"}, 475) 476 477cc_library( 478 name = "tflite_with_xnnpack_enabled", 479 defines = ["TFLITE_BUILD_WITH_XNNPACK_DELEGATE"], 480 visibility = ["//visibility:private"], 481 deps = [ 482 "//tensorflow/lite/delegates/xnnpack:xnnpack_delegate", 483 ], 484) 485 486cc_library( 487 name = "tflite_with_xnnpack_default", 488 compatible_with = get_compatible_with_portable(), 489 visibility = ["//visibility:private"], 490 # TODO(b/151246885): put ":tflite_with_xnnpack_enabled" to macos/windows 491 # once we have a good testing coverage on these two platforms. 492 deps = select({ 493 "//tensorflow:macos": [], 494 "//tensorflow:windows": [], 495 "//conditions:default": [], 496 }), 497) 498 499cc_library( 500 name = "tflite_with_xnnpack_optional", 501 srcs = ["tflite_with_xnnpack_optional.cc"], 502 hdrs = [ 503 "core/macros.h", 504 "tflite_with_xnnpack_optional.h", 505 ], 506 compatible_with = get_compatible_with_portable(), 507 copts = tflite_copts() + tflite_copts_warnings(), 508 deps = [ 509 "//tensorflow/lite/c:common", 510 ] + select({ 511 ":tflite_with_xnnpack_explicit_true": [ 512 "//tensorflow/lite/delegates/xnnpack:xnnpack_delegate_hdrs_only", 513 ":tflite_with_xnnpack_enabled", 514 ], 515 ":tflite_with_xnnpack_explicit_false": [], 516 "//conditions:default": [ 517 "//tensorflow/lite/delegates/xnnpack:xnnpack_delegate_hdrs_only", 518 ":tflite_with_xnnpack_default", 519 ], 520 }), 521) 522 523cc_test( 524 name = "string_util_test", 525 size = "small", 526 srcs = ["string_util_test.cc"], 527 features = ["-dynamic_link_test_srcs"], # see go/dynamic_link_test_srcs 528 deps = [ 529 ":framework", 530 ":string", 531 ":string_util", 532 "//tensorflow/lite/c:common", 533 "//tensorflow/lite/testing:util", 534 "@com_google_googletest//:gtest", 535 ], 536) 537 538cc_library( 539 name = "interpreter_test_util", 540 testonly = True, 541 hdrs = ["interpreter_test_util.h"], 542 deps = [ 543 ":builtin_op_data", 544 ":external_cpu_backend_context", 545 ":framework", 546 ":string_util", 547 ":version", 548 "//tensorflow/lite/c:common", 549 "//tensorflow/lite/core/api", 550 "//tensorflow/lite/kernels:builtin_ops", 551 "//tensorflow/lite/kernels:cpu_backend_context", 552 "//tensorflow/lite/kernels:kernel_util", 553 "//tensorflow/lite/kernels/internal:compatibility", 554 "//tensorflow/lite/schema:schema_fbs", 555 "//tensorflow/lite/testing:util", 556 "//third_party/eigen3", 557 "@com_google_googletest//:gtest", 558 ], 559) 560 561# Test main interpreter 562cc_test( 563 name = "interpreter_test", 564 size = "small", 565 srcs = [ 566 "interpreter_test.cc", 567 ], 568 features = ["-dynamic_link_test_srcs"], # see go/dynamic_link_test_srcs 569 tags = [ 570 "tflite_not_portable_ios", # TODO(b/173711739) 571 "tflite_smoke_test", 572 ], 573 deps = [ 574 ":external_cpu_backend_context", 575 ":framework", 576 ":interpreter_test_util", 577 ":string", 578 ":string_util", 579 ":util", 580 "//tensorflow/lite/c:common", 581 "//tensorflow/lite/kernels:builtin_ops", 582 "//tensorflow/lite/kernels:kernel_util", 583 "//tensorflow/lite/kernels/internal:compatibility", 584 "//tensorflow/lite/testing:util", 585 "//third_party/eigen3", 586 "@com_google_googletest//:gtest", 587 ], 588) 589 590# Test graph utils 591cc_test( 592 name = "graph_info_test", 593 size = "small", 594 srcs = ["graph_info_test.cc"], 595 features = ["-dynamic_link_test_srcs"], # see go/dynamic_link_test_srcs 596 deps = [ 597 ":framework", 598 "//tensorflow/lite/c:common", 599 "//tensorflow/lite/testing:util", 600 "@com_google_googletest//:gtest", 601 ], 602) 603 604# Test arena allocator 605cc_test( 606 name = "simple_memory_arena_test", 607 size = "small", 608 srcs = ["simple_memory_arena_test.cc"], 609 features = ["-dynamic_link_test_srcs"], # see go/dynamic_link_test_srcs 610 deps = [ 611 ":simple_memory_arena", 612 "//tensorflow/lite/c:common", 613 "//tensorflow/lite/testing:util", 614 "@com_google_googletest//:gtest", 615 ], 616) 617 618# Test model framework. 619cc_test( 620 name = "model_test", 621 size = "small", 622 srcs = ["model_test.cc"], 623 data = [ 624 "testdata/0_subgraphs.bin", 625 "testdata/2_subgraphs.bin", 626 "testdata/2_subgraphs_dont_delegate_name.bin", 627 "testdata/add_shared_tensors.bin", 628 "testdata/empty_model.bin", 629 "testdata/multi_add_flex.bin", 630 "testdata/segment_sum_invalid_buffer.bin", 631 "testdata/sparse_tensor.bin", 632 "testdata/test_min_runtime.bin", 633 "testdata/test_model.bin", 634 "testdata/test_model_broken.bin", 635 "testdata/while_op_with_forwarding_input.bin", 636 ], 637 tags = [ 638 "tflite_not_portable", 639 "tflite_smoke_test", 640 ], 641 deps = [ 642 ":framework", 643 ":interpreter_test_util", 644 ":string", 645 "//tensorflow/lite:string_util", 646 "//tensorflow/lite/core/api", 647 "//tensorflow/lite/core/api:verifier", 648 "//tensorflow/lite/kernels:builtin_ops", 649 "//tensorflow/lite/schema:schema_fbs", 650 "//tensorflow/lite/testing:util", 651 "@com_google_googletest//:gtest", 652 "@flatbuffers//:runtime_cc", 653 ], 654) 655 656# Test model framework with the flex library linked into the target. 657tf_cc_test( 658 name = "model_flex_test", 659 size = "small", 660 srcs = ["model_flex_test.cc"], 661 data = [ 662 "testdata/multi_add_flex.bin", 663 ], 664 tags = [ 665 "no_gpu", # GPU + flex is not officially supported. 666 "no_windows", # TODO(b/116667551): No weak symbols with MSVC. 667 "tflite_not_portable_android", 668 "tflite_not_portable_ios", 669 ], 670 deps = [ 671 ":framework", 672 "//tensorflow/lite/core/api", 673 "//tensorflow/lite/delegates/flex:delegate", 674 "//tensorflow/lite/kernels:builtin_ops", 675 "//tensorflow/lite/testing:util", 676 "@com_google_googletest//:gtest", 677 ], 678) 679 680# Test model framework with the XNNPACK delegate. 681cc_test( 682 name = "model_xnnpack_test", 683 size = "small", 684 srcs = [ 685 "model_xnnpack_test.cc", 686 ], 687 data = [ 688 "testdata/multi_add.bin", 689 ], 690 tags = [ 691 "no_windows", # No weak symbols with MSVC. 692 "tflite_not_portable_android", 693 "tflite_not_portable_ios", 694 "tflite_smoke_test", 695 ], 696 deps = [ 697 ":framework", 698 ":string", 699 ":tflite_with_xnnpack", 700 ":util", 701 "//tensorflow/lite/c:common", 702 "//tensorflow/lite/kernels:builtin_ops", 703 "@com_google_googletest//:gtest_main", 704 ], 705) 706 707# Test OpResolver. 708cc_test( 709 name = "mutable_op_resolver_test", 710 size = "small", 711 srcs = ["mutable_op_resolver_test.cc"], 712 features = ["-dynamic_link_test_srcs"], # see go/dynamic_link_test_srcs 713 deps = [ 714 ":framework", 715 "//tensorflow/lite/c:common", 716 "//tensorflow/lite/schema:schema_fbs", 717 "//tensorflow/lite/testing:util", 718 "@com_google_googletest//:gtest", 719 ], 720) 721 722cc_test( 723 name = "stderr_reporter_test", 724 srcs = ["stderr_reporter_test.cc"], 725 deps = [ 726 ":stderr_reporter", 727 "//tensorflow/lite/core/api:error_reporter", 728 "@com_google_googletest//:gtest_main", 729 ], 730) 731 732cc_library( 733 name = "util", 734 srcs = ["util.cc"], 735 hdrs = ["util.h"], 736 compatible_with = get_compatible_with_portable(), 737 copts = tflite_copts_warnings() + tflite_copts(), 738 deps = [ 739 ":kernel_api", 740 "//tensorflow/lite/c:common", 741 "//tensorflow/lite/schema:schema_fbs", 742 ], 743) 744 745# Defines CreateOpResolver with all builtin ops. 746cc_library( 747 name = "create_op_resolver_with_builtin_ops", 748 srcs = ["create_op_resolver_with_builtin_ops.cc"], 749 hdrs = ["create_op_resolver.h"], 750 copts = tflite_copts(), 751 deps = [ 752 ":mutable_op_resolver", 753 ":op_resolver", 754 "//tensorflow/lite/kernels:builtin_ops", 755 ], 756) 757 758cc_test( 759 name = "util_test", 760 size = "small", 761 srcs = ["util_test.cc"], 762 features = ["-dynamic_link_test_srcs"], # see go/dynamic_link_test_srcs 763 deps = [ 764 ":util", 765 "//tensorflow/lite/c:common", 766 "//tensorflow/lite/schema:schema_fbs", 767 "@com_google_googletest//:gtest", 768 ], 769) 770 771cc_library( 772 name = "minimal_logging", 773 srcs = [ 774 "minimal_logging.cc", 775 ] + select({ 776 "//tensorflow:android": [ 777 "minimal_logging_android.cc", 778 ], 779 "//tensorflow:ios": [ 780 "minimal_logging_ios.cc", 781 ], 782 "//tensorflow:macos": [ 783 "minimal_logging_default.cc", 784 ], 785 "//conditions:default": [ 786 "minimal_logging_default.cc", 787 ], 788 }), 789 hdrs = ["minimal_logging.h"], 790 compatible_with = get_compatible_with_portable(), 791 copts = tflite_copts_warnings() + tflite_copts(), 792 linkopts = select({ 793 "//tensorflow:android": ["-llog"], 794 "//conditions:default": [], 795 }), 796 visibility = internal_visibility_allowlist(), 797) 798 799cc_library( 800 name = "type_to_tflitetype", 801 hdrs = [ 802 "portable_type_to_tflitetype.h", 803 ] + select({ 804 ":tf_lite_static_memory": [], 805 "//conditions:default": [ 806 "type_to_tflitetype.h", 807 ], 808 }), 809 compatible_with = get_compatible_with_portable(), 810 deps = ["//tensorflow/lite/c:common"], 811) 812 813cc_test( 814 name = "type_to_tflitetype_test", 815 size = "small", 816 srcs = ["type_to_tflitetype_test.cc"], 817 deps = [ 818 ":type_to_tflitetype", 819 "//tensorflow/lite/c:c_api_types", 820 "@com_google_googletest//:gtest_main", 821 ], 822) 823 824cc_test( 825 name = "minimal_logging_test", 826 size = "small", 827 srcs = ["minimal_logging_test.cc"], 828 tags = [ 829 "tflite_not_portable_ios", # TODO(b/173711739) 830 ], 831 deps = [ 832 ":minimal_logging", 833 "@com_google_googletest//:gtest", 834 ], 835) 836 837cc_library( 838 name = "shared_library", 839 hdrs = ["shared_library.h"], 840 compatible_with = get_compatible_with_portable(), 841 linkopts = if_not_windows(["-ldl"]), 842) 843 844cc_library( 845 name = "macros", 846 hdrs = ["core/macros.h"], 847 compatible_with = get_compatible_with_portable(), 848) 849 850cc_library( 851 name = "stateful_error_reporter", 852 hdrs = ["stateful_error_reporter.h"], 853 compatible_with = get_compatible_with_portable(), 854 deps = ["//tensorflow/lite/core/api"], 855) 856 857# Shared lib target for convenience, pulls in the core runtime and builtin ops. 858# Note: This target is not yet finalized, and the exact set of exported (C/C++) 859# APIs is subject to change. The output library name is platform dependent: 860# - Linux/Android: `libtensorflowlite.so` 861# - Mac: `libtensorflowlite.dylib` 862# - Windows: `tensorflowlite.dll` 863tflite_cc_shared_object( 864 name = "tensorflowlite", 865 # Until we have more granular symbol export for the C++ API on Windows, 866 # export all symbols. 867 features = ["windows_export_all_symbols"], 868 linkopts = select({ 869 "//tensorflow:macos": [ 870 "-Wl,-exported_symbols_list,$(location //tensorflow/lite:tflite_exported_symbols.lds)", 871 ], 872 "//tensorflow:windows": [], 873 "//conditions:default": [ 874 "-Wl,-z,defs", 875 "-Wl,--version-script,$(location //tensorflow/lite:tflite_version_script.lds)", 876 ], 877 }), 878 per_os_targets = True, 879 deps = [ 880 ":framework", 881 ":tflite_exported_symbols.lds", 882 ":tflite_version_script.lds", 883 "//tensorflow/lite/kernels:builtin_ops_all_linked", 884 ], 885) 886 887tflite_portable_test_suite() 888