1load("@bazel_skylib//lib:selects.bzl", "selects") 2load("//tensorflow:tensorflow.bzl", "transitive_hdrs") 3load("//tensorflow/lite:build_def.bzl", "tflite_copts") 4load("//tensorflow/lite/micro:build_def.bzl", "micro_copts") 5load("//tensorflow/lite:special_rules.bzl", "tflite_portable_test_suite_combined") 6load("//tensorflow:tensorflow.bzl", "get_compatible_with_portable") 7 8package( 9 default_visibility = [ 10 "//visibility:public", 11 ], 12 licenses = ["notice"], # Apache 2.0 13) 14 15tflite_deps_intel = [ 16 "@arm_neon_2_x86_sse", 17] 18 19HARD_FP_FLAGS_IF_APPLICABLE = select({ 20 "//tensorflow:android_arm": ["-mfloat-abi=softfp"], 21 "//tensorflow:android_arm64": ["-mfloat-abi=softfp"], 22 "//tensorflow:android_armeabi": ["-mfloat-abi=softfp"], 23 "//conditions:default": [], 24}) 25 26NEON_FLAGS_IF_APPLICABLE = select({ 27 ":arm": [ 28 "-O3", 29 "-mfpu=neon", 30 ], 31 ":armeabi-v7a": [ 32 "-O3", 33 "-mfpu=neon", 34 ], 35 ":armhf": [ 36 "-O3", 37 "-mfpu=neon", 38 ], 39 ":armv7a": [ 40 "-O3", 41 "-mfpu=neon", 42 ], 43 "//conditions:default": [ 44 "-O3", 45 ], 46}) 47 48cc_library( 49 name = "compatibility", 50 hdrs = ["compatibility.h"], 51 compatible_with = get_compatible_with_portable(), 52 copts = tflite_copts(), 53 deps = [ 54 "//tensorflow/lite/kernels:op_macros", 55 ], 56) 57 58cc_library( 59 name = "types", 60 hdrs = ["types.h"], 61 compatible_with = get_compatible_with_portable(), 62 copts = tflite_copts(), 63 deps = [ 64 ":compatibility", 65 ], 66) 67 68cc_library( 69 name = "legacy_types", 70 hdrs = ["legacy_types.h"], 71 copts = tflite_copts(), 72 deps = [ 73 ":types", 74 ], 75) 76 77config_setting( 78 name = "aarch64", 79 values = { 80 "cpu": "aarch64", 81 }, 82) 83 84config_setting( 85 name = "arm", 86 values = { 87 "cpu": "arm", 88 }, 89) 90 91config_setting( 92 name = "arm64-v8a", 93 values = { 94 "cpu": "arm64-v8a", 95 }, 96) 97 98config_setting( 99 name = "armhf", 100 values = { 101 "cpu": "armhf", 102 }, 103) 104 105config_setting( 106 name = "armv7a", 107 values = { 108 "cpu": "armv7a", 109 }, 110) 111 112config_setting( 113 name = "armeabi-v7a", 114 values = { 115 "cpu": "armeabi-v7a", 116 }, 117) 118 119config_setting( 120 name = "haswell", 121 values = { 122 "cpu": "haswell", 123 }, 124) 125 126config_setting( 127 name = "ios_x86_64", 128 values = { 129 "cpu": "ios_x86_64", 130 }, 131) 132 133config_setting( 134 name = "ios_armv7", 135 values = { 136 "cpu": "ios_armv7", 137 }, 138) 139 140config_setting( 141 name = "ios_arm64", 142 values = { 143 "cpu": "ios_arm64", 144 }, 145) 146 147config_setting( 148 name = "ios_arm64e", 149 values = { 150 "cpu": "ios_arm64e", 151 }, 152) 153 154config_setting( 155 name = "k8", 156 values = { 157 "cpu": "k8", 158 }, 159) 160 161config_setting( 162 name = "x86", 163 values = { 164 "cpu": "x86", 165 }, 166) 167 168config_setting( 169 name = "x86_64", 170 values = { 171 "cpu": "x86_64", 172 }, 173) 174 175config_setting( 176 name = "darwin", 177 values = { 178 "cpu": "darwin", 179 }, 180) 181 182config_setting( 183 name = "darwin_x86_64", 184 values = { 185 "cpu": "darwin_x86_64", 186 }, 187) 188 189config_setting( 190 name = "darwin_arm64", 191 values = { 192 "cpu": "darwin_arm64", 193 }, 194) 195 196config_setting( 197 name = "freebsd", 198 values = { 199 "cpu": "freebsd", 200 }, 201) 202 203config_setting( 204 name = "windows", 205 values = { 206 "cpu": "x64_windows", 207 }, 208) 209 210config_setting( 211 name = "raspberry_pi_with_neon", 212 define_values = { 213 "raspberry_pi_with_neon": "true", 214 }, 215 values = { 216 "cpu": "armeabi", 217 }, 218) 219 220cc_library( 221 name = "common", 222 srcs = [], 223 hdrs = ["common.h"], 224 compatible_with = get_compatible_with_portable(), 225 copts = tflite_copts(), 226 deps = [ 227 ":cppmath", 228 ":cpu_check", 229 ":types", 230 "@gemmlowp//:fixedpoint", 231 ], 232) 233 234cc_library( 235 name = "optimized_base", 236 srcs = [], 237 hdrs = [ 238 "optimized/batch_matmul.h", 239 "optimized/depthwiseconv_3x3_filter_common.h", 240 "optimized/depthwiseconv_float.h", 241 "optimized/depthwiseconv_multithread.h", 242 "optimized/depthwiseconv_uint8.h", 243 "optimized/depthwiseconv_uint8_3x3_filter.h", 244 "optimized/im2col_utils.h", 245 "optimized/integer_ops/add.h", 246 "optimized/integer_ops/conv.h", 247 "optimized/integer_ops/depthwise_conv.h", 248 "optimized/integer_ops/depthwise_conv_3x3_filter.h", 249 "optimized/integer_ops/depthwise_conv_hybrid.h", 250 "optimized/integer_ops/depthwise_conv_hybrid_3x3_filter.h", 251 "optimized/integer_ops/fully_connected.h", 252 "optimized/integer_ops/mean.h", 253 "optimized/integer_ops/mul.h", 254 "optimized/integer_ops/pooling.h", 255 "optimized/integer_ops/transpose_conv.h", 256 "optimized/optimized_ops.h", 257 "optimized/sparse_ops/fully_connected.h", 258 ], 259 compatible_with = get_compatible_with_portable(), 260 copts = tflite_copts(), 261 deps = [ 262 ":common", 263 ":compatibility", 264 ":cpu_check", 265 ":quantization_util", 266 ":strided_slice_logic", 267 ":types", 268 ":reference_base", 269 ":cppmath", 270 ":tensor", 271 ":tensor_utils", 272 ":transpose_utils", 273 "//third_party/eigen3", 274 "@gemmlowp//:fixedpoint", 275 "@ruy//ruy/profiler:instrumentation", 276 "//tensorflow/lite/c:common", 277 "//tensorflow/lite/kernels:cpu_backend_context", 278 "//tensorflow/lite/kernels:cpu_backend_threadpool", 279 "//tensorflow/lite/kernels:cpu_backend_gemm", 280 ] + select({ 281 ":haswell": tflite_deps_intel, 282 ":ios_x86_64": tflite_deps_intel, 283 ":k8": tflite_deps_intel, 284 ":x86": tflite_deps_intel, 285 ":x86_64": tflite_deps_intel, 286 ":darwin": tflite_deps_intel, 287 ":darwin_x86_64": tflite_deps_intel, 288 ":freebsd": tflite_deps_intel, 289 ":windows": tflite_deps_intel, 290 "//conditions:default": [], 291 }), 292) 293 294cc_library( 295 name = "legacy_optimized_base", 296 srcs = [], 297 hdrs = [ 298 "optimized/depthwiseconv_3x3_filter_common.h", 299 "optimized/depthwiseconv_float.h", 300 "optimized/depthwiseconv_uint8.h", 301 "optimized/depthwiseconv_uint8_3x3_filter.h", 302 "optimized/im2col_utils.h", 303 "optimized/legacy_optimized_ops.h", 304 "optimized/optimized_ops.h", 305 ], 306 copts = tflite_copts(), 307 deps = [ 308 ":common", 309 ":compatibility", 310 ":cpu_check", 311 ":optimized_base", 312 ":quantization_util", 313 ":strided_slice_logic", 314 ":tensor", 315 ":tensor_utils", 316 ":transpose_utils", 317 ":types", 318 ":legacy_reference_base", 319 ":cppmath", 320 "//third_party/eigen3", 321 "@gemmlowp", 322 "//tensorflow/lite/c:common", 323 "//tensorflow/lite/kernels:cpu_backend_context", 324 "//tensorflow/lite/kernels:cpu_backend_threadpool", 325 "//tensorflow/lite/kernels:cpu_backend_gemm", 326 "@ruy//ruy/profiler:instrumentation", 327 ] + select({ 328 ":haswell": tflite_deps_intel, 329 ":ios_x86_64": tflite_deps_intel, 330 ":k8": tflite_deps_intel, 331 ":x86": tflite_deps_intel, 332 ":x86_64": tflite_deps_intel, 333 ":darwin": tflite_deps_intel, 334 ":darwin_x86_64": tflite_deps_intel, 335 ":freebsd": tflite_deps_intel, 336 ":windows": tflite_deps_intel, 337 "//conditions:default": [], 338 }), 339) 340 341cc_library( 342 name = "optimized_eigen", 343 hdrs = [ 344 "optimized/eigen_spatial_convolutions.h", 345 "optimized/eigen_tensor_reduced_instantiations_oss.h", 346 "optimized/multithreaded_conv.h", 347 ], 348 compatible_with = get_compatible_with_portable(), 349 copts = tflite_copts(), 350 deps = [ 351 ":common", 352 ":optimized_base", 353 ":types", 354 "//tensorflow/core/kernels:eigen_spatial_convolutions-inl", 355 "//tensorflow/lite/c:common", 356 "//third_party/eigen3", 357 ], 358) 359 360cc_test( 361 name = "tensor_test", 362 srcs = ["tensor_test.cc"], 363 deps = [ 364 ":tensor", 365 "@com_google_googletest//:gtest_main", 366 ], 367) 368 369cc_library( 370 name = "cppmath", 371 srcs = [], 372 hdrs = [ 373 "cppmath.h", 374 "max.h", 375 "min.h", 376 ], 377 compatible_with = get_compatible_with_portable(), 378 copts = tflite_copts(), 379) 380 381cc_library( 382 name = "quantization_util", 383 srcs = ["quantization_util.cc"], 384 hdrs = ["quantization_util.h"], 385 compatible_with = get_compatible_with_portable(), 386 copts = tflite_copts() + micro_copts(), 387 linkopts = select({ 388 "//tensorflow:windows": [], 389 "//conditions:default": ["-lm"], 390 }), 391 deps = [ 392 ":compatibility", 393 ":cppmath", 394 ":types", 395 ], 396) 397 398cc_test( 399 name = "quantization_util_test", 400 srcs = ["quantization_util_test.cc"], 401 deps = [ 402 ":common", 403 ":quantization_util", 404 "@com_google_googletest//:gtest_main", 405 ], 406) 407 408cc_library( 409 name = "transpose_utils", 410 srcs = [ 411 "transpose_utils.cc", 412 ], 413 hdrs = [ 414 "transpose_utils.h", 415 ], 416 compatible_with = get_compatible_with_portable(), 417 copts = tflite_copts(), 418 deps = [ 419 ":types", 420 ], 421) 422 423cc_test( 424 name = "transpose_utils_test", 425 srcs = ["transpose_utils_test.cc"], 426 deps = [ 427 ":transpose_utils", 428 "@com_google_googletest//:gtest", 429 ], 430) 431 432cc_library( 433 name = "strided_slice_logic", 434 srcs = [], 435 hdrs = [ 436 "strided_slice_logic.h", 437 ], 438 compatible_with = get_compatible_with_portable(), 439 copts = tflite_copts(), 440 deps = [ 441 ":compatibility", 442 ":types", 443 ], 444) 445 446cc_library( 447 name = "reference_base", 448 srcs = [], 449 hdrs = [ 450 "reference/add.h", 451 "reference/add_n.h", 452 "reference/arg_min_max.h", 453 "reference/batch_matmul.h", 454 "reference/batch_to_space_nd.h", 455 "reference/binary_function.h", 456 "reference/broadcast_to.h", 457 "reference/cast.h", 458 "reference/ceil.h", 459 "reference/comparisons.h", 460 "reference/concatenation.h", 461 "reference/conv.h", 462 "reference/conv3d.h", 463 "reference/densify.h", 464 "reference/depth_to_space.h", 465 "reference/depthwiseconv_float.h", 466 "reference/depthwiseconv_uint8.h", 467 "reference/dequantize.h", 468 "reference/div.h", 469 "reference/elu.h", 470 "reference/exp.h", 471 "reference/fill.h", 472 "reference/floor.h", 473 "reference/floor_div.h", 474 "reference/floor_mod.h", 475 "reference/fully_connected.h", 476 "reference/gather.h", 477 "reference/hard_swish.h", 478 "reference/integer_ops/add.h", 479 "reference/integer_ops/conv.h", 480 "reference/integer_ops/depthwise_conv.h", 481 "reference/integer_ops/fully_connected.h", 482 "reference/integer_ops/l2normalization.h", 483 "reference/integer_ops/logistic.h", 484 "reference/integer_ops/mean.h", 485 "reference/integer_ops/mul.h", 486 "reference/integer_ops/pooling.h", 487 "reference/integer_ops/tanh.h", 488 "reference/integer_ops/transpose_conv.h", 489 "reference/l2normalization.h", 490 "reference/leaky_relu.h", 491 "reference/logistic.h", 492 "reference/maximum_minimum.h", 493 "reference/mul.h", 494 "reference/neg.h", 495 "reference/non_max_suppression.h", 496 "reference/pad.h", 497 "reference/pooling.h", 498 "reference/prelu.h", 499 "reference/process_broadcast_shapes.h", 500 "reference/quantize.h", 501 "reference/reduce.h", 502 "reference/requantize.h", 503 "reference/resize_nearest_neighbor.h", 504 "reference/round.h", 505 "reference/softmax.h", 506 "reference/space_to_batch_nd.h", 507 "reference/space_to_depth.h", 508 "reference/strided_slice.h", 509 "reference/sub.h", 510 "reference/svdf.h", 511 "reference/tanh.h", 512 "reference/transpose.h", 513 "reference/transpose_conv.h", 514 ] + select({ 515 "//tensorflow/lite:tf_lite_static_memory": [], 516 "//conditions:default": [ 517 "reference/integer_ops/dequantize.h", 518 "reference/integer_ops/log_softmax.h", 519 "reference/reference_ops.h", 520 "reference/string_comparisons.h", 521 "reference/sparse_ops/fully_connected.h", 522 ], 523 }), 524 compatible_with = get_compatible_with_portable(), 525 copts = tflite_copts(), 526 # We are disabling parse_headers for this header-only target so that the 527 # external and internal builds are consistent. The primary issue here is 528 # that parse_headers is not supported with bazel and the TFLM team would 529 # really like to have all build errors in shared Micro/Lite code be 530 # reproducible from the OSS build as well. 531 # 532 # See b/175817116 for more details. 533 features = ["-parse_headers"], 534 deps = [ 535 ":common", 536 ":compatibility", 537 ":cppmath", 538 ":portable_tensor_utils", 539 ":quantization_util", 540 ":strided_slice_logic", 541 ":tensor", 542 ":tensor_utils", 543 ":types", 544 "//third_party/eigen3", 545 "@gemmlowp//:fixedpoint", 546 "@ruy//ruy/profiler:instrumentation", 547 "//tensorflow/lite:string_util", 548 "//tensorflow/lite/c:common", 549 "//tensorflow/lite/kernels:kernel_util", 550 "//tensorflow/lite/kernels:op_macros", 551 "//tensorflow/lite/tools/optimize/sparsity:format_converter", 552 ] + select({ 553 ":haswell": tflite_deps_intel, 554 ":ios_x86_64": tflite_deps_intel, 555 ":k8": tflite_deps_intel, 556 ":x86": tflite_deps_intel, 557 ":x86_64": tflite_deps_intel, 558 ":darwin": tflite_deps_intel, 559 ":darwin_x86_64": tflite_deps_intel, 560 ":freebsd": tflite_deps_intel, 561 ":windows": tflite_deps_intel, 562 "//conditions:default": [], 563 }), 564) 565 566cc_library( 567 name = "legacy_reference_base", 568 srcs = [], 569 hdrs = [ 570 "reference/add.h", 571 "reference/add_n.h", 572 "reference/arg_min_max.h", 573 "reference/batch_matmul.h", 574 "reference/batch_to_space_nd.h", 575 "reference/binary_function.h", 576 "reference/cast.h", 577 "reference/ceil.h", 578 "reference/comparisons.h", 579 "reference/concatenation.h", 580 "reference/conv.h", 581 "reference/conv3d.h", 582 "reference/densify.h", 583 "reference/depth_to_space.h", 584 "reference/depthwiseconv_float.h", 585 "reference/depthwiseconv_uint8.h", 586 "reference/dequantize.h", 587 "reference/div.h", 588 "reference/elu.h", 589 "reference/exp.h", 590 "reference/fill.h", 591 "reference/floor.h", 592 "reference/floor_div.h", 593 "reference/floor_mod.h", 594 "reference/fully_connected.h", 595 "reference/gather.h", 596 "reference/hard_swish.h", 597 "reference/l2normalization.h", 598 "reference/leaky_relu.h", 599 "reference/legacy_reference_ops.h", 600 "reference/logistic.h", 601 "reference/maximum_minimum.h", 602 "reference/mul.h", 603 "reference/neg.h", 604 "reference/pad.h", 605 "reference/pooling.h", 606 "reference/prelu.h", 607 "reference/process_broadcast_shapes.h", 608 "reference/quantize.h", 609 "reference/reduce.h", 610 "reference/reference_ops.h", 611 "reference/requantize.h", 612 "reference/resize_nearest_neighbor.h", 613 "reference/round.h", 614 "reference/softmax.h", 615 "reference/space_to_batch_nd.h", 616 "reference/space_to_depth.h", 617 "reference/strided_slice.h", 618 "reference/string_comparisons.h", 619 "reference/sub.h", 620 "reference/tanh.h", 621 "reference/transpose.h", 622 "reference/transpose_conv.h", 623 ], 624 copts = tflite_copts(), 625 # We are disabling parse_headers for this header-only target so that the 626 # external and internal builds are consistent. The primary issue here is 627 # that parse_headers is not supported with bazel and the TFLM team would 628 # really like to have all build errors in shared Micro/Lite code be 629 # reproducible from the OSS build as well. 630 # 631 # See b/175817116 for more details. 632 features = ["-parse_headers"], 633 deps = [ 634 ":common", 635 ":compatibility", 636 ":quantization_util", 637 ":cppmath", 638 ":strided_slice_logic", 639 ":legacy_types", 640 ":tensor", 641 ":types", 642 "//third_party/eigen3", 643 "@gemmlowp", 644 "//tensorflow/lite/c:common", 645 "//tensorflow/lite/kernels:op_macros", 646 "@ruy//ruy/profiler:instrumentation", 647 "//tensorflow/lite/tools/optimize/sparsity:format_converter", 648 "//tensorflow/lite:string_util", 649 ] + select({ 650 ":haswell": tflite_deps_intel, 651 ":ios_x86_64": tflite_deps_intel, 652 ":k8": tflite_deps_intel, 653 ":x86": tflite_deps_intel, 654 ":x86_64": tflite_deps_intel, 655 ":darwin": tflite_deps_intel, 656 ":darwin_x86_64": tflite_deps_intel, 657 ":freebsd": tflite_deps_intel, 658 ":windows": tflite_deps_intel, 659 "//conditions:default": [], 660 }), 661) 662 663cc_library( 664 name = "tensor", 665 hdrs = [ 666 "portable_tensor.h", 667 "tensor_ctypes.h", 668 ] + select({ 669 "//tensorflow/lite:tf_lite_static_memory": [], 670 "//conditions:default": [ 671 "tensor.h", 672 ], 673 }), 674 compatible_with = get_compatible_with_portable(), 675 copts = tflite_copts(), 676 deps = [ 677 ":types", 678 "//tensorflow/lite:string_util", 679 "//tensorflow/lite/c:common", 680 ], 681) 682 683# Deprecated version of :tensor, kept for backwards compatibility. 684cc_library( 685 name = "reference", 686 hdrs = [ 687 "portable_tensor.h", 688 "tensor_ctypes.h", 689 ] + select({ 690 "//tensorflow/lite:tf_lite_static_memory": [], 691 "//conditions:default": [ 692 "tensor.h", 693 ], 694 }), 695 copts = tflite_copts(), 696 deps = [ 697 ":types", 698 "//tensorflow/lite:string_util", 699 "//tensorflow/lite/c:common", 700 ], 701) 702 703cc_library( 704 name = "portable_tensor_utils", 705 srcs = [ 706 "reference/portable_tensor_utils.cc", 707 ], 708 hdrs = [ 709 "reference/portable_tensor_utils.h", 710 "reference/portable_tensor_utils_impl.h", 711 ], 712 compatible_with = get_compatible_with_portable(), 713 copts = tflite_copts(), 714 deps = [ 715 ":common", 716 ":compatibility", 717 ":cppmath", 718 "@gemmlowp", 719 ], 720) 721 722cc_library( 723 name = "neon_tensor_utils", 724 srcs = [ 725 "optimized/neon_tensor_utils.cc", 726 ], 727 hdrs = [ 728 "optimized/neon_tensor_utils.h", 729 "optimized/neon_tensor_utils_impl.h", 730 ], 731 compatible_with = get_compatible_with_portable(), 732 copts = tflite_copts() + NEON_FLAGS_IF_APPLICABLE + HARD_FP_FLAGS_IF_APPLICABLE, 733 deps = [ 734 ":common", 735 ":compatibility", 736 ":cppmath", 737 ":cpu_check", 738 ":portable_tensor_utils", 739 "//tensorflow/lite/kernels:cpu_backend_context", 740 "//tensorflow/lite/kernels:cpu_backend_gemm", 741 "@ruy//ruy", 742 ], 743) 744 745cc_library( 746 name = "sse_tensor_utils", 747 srcs = [ 748 "compatibility.h", 749 "optimized/sse_tensor_utils.cc", 750 ], 751 hdrs = [ 752 "optimized/sse_tensor_utils.h", 753 "optimized/sse_tensor_utils_impl.h", 754 ], 755 compatible_with = get_compatible_with_portable(), 756 copts = tflite_copts(), 757 deps = [ 758 ":cpu_check", 759 ":neon_tensor_utils", 760 ":portable_tensor_utils", 761 "//tensorflow/lite/c:common", 762 "//tensorflow/lite/kernels:cpu_backend_context", 763 "//tensorflow/lite/kernels:cpu_backend_gemm", 764 "//tensorflow/lite/kernels:op_macros", 765 "@ruy//ruy/profiler:instrumentation", 766 ], 767) 768 769cc_library( 770 name = "kernel_utils", 771 srcs = ["kernel_utils.cc"], 772 hdrs = ["kernel_utils.h"], 773 compatible_with = get_compatible_with_portable(), 774 copts = tflite_copts() + micro_copts(), 775 deps = [ 776 ":tensor_utils", 777 "//tensorflow/lite/c:common", 778 ], 779) 780 781# Audio support classes imported directly from TensorFlow. 782cc_library( 783 name = "audio_utils", 784 srcs = [ 785 "mfcc.cc", 786 "mfcc_dct.cc", 787 "mfcc_mel_filterbank.cc", 788 "spectrogram.cc", 789 ], 790 hdrs = [ 791 "mfcc.h", 792 "mfcc_dct.h", 793 "mfcc_mel_filterbank.h", 794 "spectrogram.h", 795 ], 796 compatible_with = get_compatible_with_portable(), 797 copts = tflite_copts(), 798 deps = [ 799 "//third_party/fft2d:fft2d_headers", 800 "@fft2d", 801 ], 802) 803 804cc_library( 805 name = "tensor_utils", 806 srcs = [ 807 "tensor_utils.cc", 808 ], 809 hdrs = [ 810 "tensor_utils.h", 811 "tensor_utils_common.h", 812 ], 813 compatible_with = get_compatible_with_portable(), 814 copts = tflite_copts() + NEON_FLAGS_IF_APPLICABLE, 815 deps = [ 816 ":cpu_check", 817 "//third_party/eigen3", 818 "//tensorflow/lite/c:common", 819 ] + selects.with_or({ 820 ( 821 ":aarch64", 822 ":arm", 823 ":arm64-v8a", 824 ":armeabi-v7a", 825 ":armhf", 826 ":armv7a", 827 ":ios_armv7", 828 ":ios_arm64", 829 ":ios_arm64e", 830 ":darwin_arm64", 831 ":raspberry_pi_with_neon", 832 ): [":neon_tensor_utils"], 833 ( 834 ":darwin", 835 ":darwin_x86_64", 836 ":freebsd", 837 ":haswell", 838 ":ios_x86_64", 839 ":x86_64", 840 ":x86", 841 ":k8", 842 ":windows", 843 ): [ 844 ":sse_tensor_utils", 845 ], 846 ( 847 "//tensorflow/lite:tf_lite_static_memory", 848 "//conditions:default", 849 ): [":portable_tensor_utils"], 850 }), 851) 852 853cc_library( 854 name = "test_util", 855 srcs = ["test_util.cc"], 856 hdrs = ["test_util.h"], 857 copts = tflite_copts(), 858 linkopts = select({ 859 "//tensorflow:windows": [], 860 "//conditions:default": ["-lm"], 861 }), 862 deps = [ 863 ":types", 864 ], 865) 866 867cc_test( 868 name = "tensor_utils_test", 869 srcs = ["tensor_utils_test.cc"], 870 linkopts = select({ 871 "//tensorflow:android": [ 872 "-fPIE -pie", 873 ], 874 "//conditions:default": [], 875 }), 876 linkstatic = 1, 877 deps = [ 878 ":common", 879 ":quantization_util", 880 ":tensor_utils", 881 "//tensorflow/lite/c:common", 882 "//tensorflow/lite/kernels:cpu_backend_context", 883 "//tensorflow/lite/kernels:test_util", 884 "@com_google_googletest//:gtest_main", 885 ], 886) 887 888cc_test( 889 name = "depthwiseconv_float_test", 890 srcs = ["depthwiseconv_float_test.cc"], 891 deps = [ 892 ":common", 893 ":cpu_check", 894 ":optimized_base", 895 ":reference_base", 896 ":test_util", 897 ":types", 898 "@com_google_googletest//:gtest_main", 899 ], 900) 901 902cc_test( 903 name = "depthwiseconv_quantized_test", 904 srcs = [ 905 "depthwiseconv_quantized_test.cc", 906 "optimized/depthwiseconv_uint8_transitional.h", 907 ], 908 copts = tflite_copts(), 909 shard_count = 2, 910 deps = [ 911 ":compatibility", 912 ":cpu_check", 913 ":optimized_base", 914 ":reference_base", 915 ":test_util", 916 ":types", 917 "//tensorflow/lite/kernels:cpu_backend_context", 918 "@com_google_absl//absl/strings", 919 "@com_google_googletest//:gtest_main", 920 "@ruy//ruy:context", 921 ], 922) 923 924cc_test( 925 name = "depthwiseconv_per_channel_quantized_test", 926 srcs = [ 927 "depthwiseconv_per_channel_quantized_test.cc", 928 ], 929 shard_count = 2, 930 deps = [ 931 ":common", 932 ":optimized_base", 933 ":quantization_util", 934 ":reference_base", 935 ":test_util", 936 ":types", 937 "@com_google_googletest//:gtest_main", 938 ], 939) 940 941cc_test( 942 name = "depthwiseconv_per_channel_quantized_16x8_test", 943 srcs = [ 944 "depthwiseconv_per_channel_quantized_16x8_test.cc", 945 ], 946 shard_count = 2, 947 deps = [ 948 ":common", 949 ":quantization_util", 950 ":reference_base", 951 ":test_util", 952 ":types", 953 "@com_google_googletest//:gtest_main", 954 ], 955) 956 957cc_test( 958 name = "conv_per_channel_quantized_16x8_test", 959 srcs = [ 960 "conv_per_channel_quantized_16x8_test.cc", 961 ], 962 shard_count = 2, 963 deps = [ 964 ":common", 965 ":quantization_util", 966 ":reference_base", 967 ":test_util", 968 ":types", 969 "@com_google_googletest//:gtest_main", 970 ], 971) 972 973cc_test( 974 name = "resize_bilinear_test", 975 srcs = ["resize_bilinear_test.cc"], 976 deps = [ 977 ":optimized_base", 978 ":reference_base", 979 ":test_util", 980 ":types", 981 "@com_google_googletest//:gtest_main", 982 ], 983) 984 985cc_test( 986 name = "resize_nearest_neighbor_test", 987 srcs = ["resize_nearest_neighbor_test.cc"], 988 deps = [ 989 ":optimized_base", 990 ":reference_base", 991 ":test_util", 992 ":types", 993 "@com_google_googletest//:gtest_main", 994 ], 995) 996 997cc_test( 998 name = "softmax_quantized_test", 999 timeout = "long", 1000 srcs = [ 1001 "softmax_quantized_test.cc", 1002 ], 1003 shard_count = 4, 1004 deps = [ 1005 ":optimized_base", 1006 ":quantization_util", 1007 ":reference_base", 1008 ":test_util", 1009 "//tensorflow/lite:string", 1010 "@com_google_googletest//:gtest_main", 1011 ], 1012) 1013 1014cc_test( 1015 name = "strided_slice_logic_test", 1016 timeout = "moderate", 1017 srcs = [ 1018 "strided_slice_logic_test.cc", 1019 ], 1020 shard_count = 4, 1021 deps = [ 1022 ":strided_slice_logic", 1023 "@com_google_googletest//:gtest_main", 1024 ], 1025) 1026 1027cc_test( 1028 name = "logsoftmax_quantized_test", 1029 timeout = "long", 1030 srcs = [ 1031 "logsoftmax_quantized_test.cc", 1032 ], 1033 shard_count = 4, 1034 tags = [ 1035 # TODO(b/122242739): Reenable after fixing the flakiness? 1036 "nomac", 1037 "tflite_not_portable", 1038 ], 1039 deps = [ 1040 ":optimized_base", 1041 ":quantization_util", 1042 ":reference_base", 1043 ":test_util", 1044 "//tensorflow/lite:string", 1045 "@com_google_googletest//:gtest_main", 1046 ], 1047) 1048 1049cc_test( 1050 name = "averagepool_quantized_test", 1051 timeout = "long", 1052 srcs = [ 1053 "averagepool_quantized_test.cc", 1054 ], 1055 shard_count = 1, 1056 deps = [ 1057 ":optimized_base", 1058 ":reference_base", 1059 ":test_util", 1060 "@com_google_googletest//:gtest_main", 1061 ], 1062) 1063 1064cc_test( 1065 name = "maxpool_quantized_test", 1066 timeout = "long", 1067 srcs = [ 1068 "maxpool_quantized_test.cc", 1069 ], 1070 shard_count = 1, 1071 deps = [ 1072 ":optimized_base", 1073 ":reference_base", 1074 ":test_util", 1075 "@com_google_googletest//:gtest_main", 1076 ], 1077) 1078 1079cc_test( 1080 name = "log_quantized_test", 1081 srcs = ["log_quantized_test.cc"], 1082 linkopts = select({ 1083 "//tensorflow:windows": [], 1084 "//conditions:default": ["-lm"], 1085 }), 1086 deps = [ 1087 ":optimized_base", 1088 ":reference_base", 1089 "//tensorflow/lite:string", 1090 "@com_google_googletest//:gtest_main", 1091 ], 1092) 1093 1094cc_library( 1095 name = "cpu_check", 1096 srcs = ["optimized/cpu_check.cc"], 1097 hdrs = [ 1098 "optimized/cpu_check.h", 1099 "optimized/neon_check.h", 1100 "optimized/sse_check.h", 1101 ], 1102 compatible_with = get_compatible_with_portable(), 1103 copts = tflite_copts(), 1104 deps = select({ 1105 ":haswell": tflite_deps_intel, 1106 ":ios_x86_64": tflite_deps_intel, 1107 ":k8": tflite_deps_intel, 1108 ":x86": tflite_deps_intel, 1109 ":x86_64": tflite_deps_intel, 1110 ":darwin": tflite_deps_intel, 1111 ":darwin_x86_64": tflite_deps_intel, 1112 ":freebsd": tflite_deps_intel, 1113 ":windows": tflite_deps_intel, 1114 "//conditions:default": [], 1115 }), 1116) 1117 1118cc_test( 1119 name = "batch_to_space_nd_test", 1120 srcs = ["batch_to_space_nd_test.cc"], 1121 deps = [ 1122 ":optimized_base", 1123 "@com_google_googletest//:gtest_main", 1124 ], 1125) 1126 1127cc_test( 1128 name = "non_max_suppression_test", 1129 srcs = ["non_max_suppression_test.cc"], 1130 deps = [ 1131 ":reference_base", 1132 "//tensorflow/lite/kernels:test_util", 1133 "@com_google_googletest//:gtest_main", 1134 ], 1135) 1136 1137cc_test( 1138 name = "per_channel_dequantize_test", 1139 srcs = ["per_channel_dequantize_test.cc"], 1140 deps = [ 1141 ":reference_base", 1142 ":types", 1143 "//tensorflow/lite/kernels:test_util", 1144 "@com_google_googletest//:gtest_main", 1145 ], 1146) 1147 1148exports_files(["optimized/eigen_tensor_reduced_instantiations_oss.h"]) 1149 1150filegroup( 1151 name = "optimized_op_headers", 1152 srcs = glob([ 1153 "optimized/*.h", 1154 ]), 1155 visibility = ["//tensorflow/lite:__subpackages__"], 1156) 1157 1158filegroup( 1159 name = "reference_op_headers", 1160 srcs = glob([ 1161 "reference/*.h", 1162 ]), 1163 visibility = ["//tensorflow/lite:__subpackages__"], 1164) 1165 1166filegroup( 1167 name = "headers", 1168 srcs = glob([ 1169 "*.h", 1170 ]), 1171 visibility = ["//tensorflow/lite:__subpackages__"], 1172) 1173 1174transitive_hdrs( 1175 name = "nnapi_external_headers", 1176 visibility = ["//tensorflow/lite:__subpackages__"], 1177 deps = [ 1178 "//third_party/eigen3", 1179 "@gemmlowp", 1180 ], 1181) 1182 1183# --------------------------------------------------------- 1184# The public target "install_nnapi_extra_headers" is only 1185# used for external targets that requires exporting optmized 1186# and reference op headers. 1187 1188genrule( 1189 name = "install_nnapi_extra_headers", 1190 srcs = [ 1191 ":nnapi_external_headers", 1192 ":headers", 1193 ":optimized_op_headers", 1194 ":reference_op_headers", 1195 ], 1196 outs = ["include"], 1197 cmd = """ 1198 mkdir $@ 1199 for f in $(SRCS); do 1200 d="$${f%/*}" 1201 d="$${d#bazel-out*genfiles/}" 1202 d="$${d#*external/eigen_archive/}" 1203 1204 if [[ $${d} == *local_config_* ]]; then 1205 continue 1206 fi 1207 1208 if [[ $${d} == external* ]]; then 1209 extname="$${d#*external/}" 1210 extname="$${extname%%/*}" 1211 if [[ $${TF_SYSTEM_LIBS:-} == *$${extname}* ]]; then 1212 continue 1213 fi 1214 fi 1215 1216 mkdir -p "$@/$${d}" 1217 cp "$${f}" "$@/$${d}/" 1218 done 1219 """, 1220 tags = ["manual"], 1221 visibility = ["//visibility:private"], 1222) 1223 1224tflite_portable_test_suite_combined(combine_conditions = {"deps": ["//testing/base/public:gunit_main"]}) 1225