Files
wehub-resource-sync 8a852e4b4e
cffconvert / validate (push) Has been skipped
License Check / license-check (push) Failing after 2s
chore: import upstream snapshot with attribution
2026-07-13 12:14:16 +08:00

101 lines
2.9 KiB
Python

# Description:
# TensorFlow Lite Example Label Image.
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")
load("//tensorflow/lite:build_def.bzl", "tflite_linkopts")
package(
# copybara:uncomment default_applicable_licenses = ["//tensorflow:LICENSE"],
default_visibility = ["//visibility:public"],
licenses = ["notice"],
)
exports_files(glob([
"testdata/*.bmp",
]))
cc_binary(
name = "label_image",
srcs = [
"get_top_n.h",
"get_top_n_impl.h",
"label_image.cc",
],
linkopts = tflite_linkopts() + select({
"//tensorflow:android": [
"-pie", # Android 5.0 and later supports only PIE
"-lm", # some builtin ops, e.g., tanh, need -lm
"-Wl,-rpath=/data/local/tmp", # for hexagon delegate
],
"//conditions:default": [],
}),
deps = [
":bitmap_helpers",
"//tensorflow/lite:framework",
"//tensorflow/lite:string",
"//tensorflow/lite/c:c_api_types",
"//tensorflow/lite/c:common",
"//tensorflow/lite/core:cc_api_stable",
"//tensorflow/lite/kernels:builtin_ops",
"//tensorflow/lite/profiling:profile_buffer",
"//tensorflow/lite/profiling:profiler",
"//tensorflow/lite/schema:schema_fbs",
"//tensorflow/lite/tools:command_line_flags",
"//tensorflow/lite/tools:tool_params",
"//tensorflow/lite/tools/delegates:delegate_provider_hdr",
"//tensorflow/lite/tools/delegates:tflite_execution_providers",
],
)
cc_library(
name = "bitmap_helpers",
srcs = ["bitmap_helpers.cc"],
hdrs = [
"bitmap_helpers.h",
"bitmap_helpers_impl.h",
"label_image.h",
"log.h",
],
deps = [
"//tensorflow/core/platform:tstring",
"//tensorflow/lite:builtin_op_data",
"//tensorflow/lite:framework",
"//tensorflow/lite:string",
"//tensorflow/lite:string_util",
"//tensorflow/lite/c:c_api_types",
"//tensorflow/lite/kernels:builtin_ops",
"//tensorflow/lite/schema:schema_fbs",
"@tsl//tsl/platform:tstring",
] + select({
"//tensorflow:android": [
"//tensorflow/lite/delegates/gpu:delegate",
"//tensorflow/lite/delegates/hexagon:hexagon_delegate",
],
"//tensorflow:android_arm64": [
"//tensorflow/lite/delegates/gpu:delegate",
"//tensorflow/lite/delegates/hexagon:hexagon_delegate",
],
"//conditions:default": [],
}),
)
cc_test(
name = "label_image_test",
srcs = [
"get_top_n.h",
"get_top_n_impl.h",
"label_image_test.cc",
],
data = [
"testdata/grace_hopper.bmp",
],
deps = [
":bitmap_helpers",
"//tensorflow/lite/c:c_api_types",
"//tensorflow/lite/c:common",
"@com_google_googletest//:gtest_main",
],
)