1# Description: 2# Benchmark utility that can run on desktop and Android. 3 4package(default_visibility = ["//visibility:public"]) 5 6licenses(["notice"]) # Apache 2.0 7 8load( 9 "//tensorflow:tensorflow.bzl", 10 "tf_copts", 11 "tf_cc_test", 12 "tf_cc_binary", 13) 14 15exports_files(["LICENSE"]) 16 17cc_library( 18 name = "benchmark_model_lib", 19 testonly = 1, 20 srcs = [ 21 "benchmark_model.cc", 22 ], 23 hdrs = [ 24 "benchmark_model.h", 25 ], 26 copts = tf_copts(), 27 visibility = ["//visibility:public"], 28 deps = select({ 29 "//tensorflow:android": [ 30 "//tensorflow/core:android_tensorflow_lib", 31 "//tensorflow/core:android_tensorflow_test_lib", 32 ], 33 "//conditions:default": [ 34 "//tensorflow/core:core_cpu", 35 "//tensorflow/core:lib", 36 "//tensorflow/core:framework", 37 "//tensorflow/core:framework_internal", 38 "//tensorflow/core:framework_lite", 39 "//tensorflow/core:protos_all_cc", 40 "//tensorflow/core:tensorflow", 41 "//tensorflow/core:test", 42 ], 43 }), 44) 45 46tf_cc_test( 47 name = "benchmark_model_test", 48 size = "medium", 49 srcs = ["benchmark_model_test.cc"], 50 deps = [ 51 ":benchmark_model_lib", 52 "//tensorflow/cc:cc_ops", 53 "//tensorflow/core:core_cpu", 54 "//tensorflow/core:framework", 55 "//tensorflow/core:lib", 56 "//tensorflow/core:test", 57 "//tensorflow/core:test_main", 58 "//tensorflow/core:testlib", 59 ], 60) 61 62# This binary may be built for either desktop or Android. 63# A typical Android build command will look like the following: 64# bazel build tensorflow/core:android_tensorflow_lib \ 65# --crosstool_top=//external:android/crosstool \ 66# --cpu=armeabi-v7a \ 67# --host_crosstool_top=@bazel_tools//tools/cpp:toolchain 68# --config monolithic 69tf_cc_binary( 70 name = "benchmark_model", 71 testonly = 1, 72 srcs = ["benchmark_model_main.cc"], 73 copts = tf_copts(), 74 linkopts = select({ 75 "//tensorflow:android": [ 76 "-pie", 77 "-s", 78 "-landroid", 79 "-latomic", 80 "-ljnigraphics", 81 "-llog", 82 "-lm", 83 "-z defs", 84 "-s", 85 "-Wl,--exclude-libs,ALL", # Exclude syms in all libs from auto export 86 ], 87 "//conditions:default": [], 88 }), 89 linkstatic = 1, 90 visibility = ["//visibility:public"], 91 deps = [":benchmark_model_lib"], 92) 93