113 lines
3.3 KiB
Python
113 lines
3.3 KiB
Python
load("@rules_cc//cc:cc_library.bzl", "cc_library")
|
|
load("//tensorflow:tensorflow.default.bzl", "get_compatible_with_portable", "pybind_extension")
|
|
|
|
package(
|
|
# copybara:uncomment default_applicable_licenses = ["//tensorflow:LICENSE"],
|
|
default_visibility = ["//visibility:public"],
|
|
licenses = ["notice"],
|
|
)
|
|
|
|
cc_library(
|
|
name = "numpy",
|
|
srcs = ["numpy.cc"],
|
|
hdrs = ["numpy.h"],
|
|
compatible_with = get_compatible_with_portable(),
|
|
deps = [
|
|
"//tensorflow/lite:string_util",
|
|
"//tensorflow/lite/core/c:c_api_types",
|
|
"//tensorflow/lite/core/c:common",
|
|
"//third_party/py/numpy:headers",
|
|
"@xla//third_party/python_runtime:headers", # buildcleaner: keep
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "interpreter_wrapper_lib",
|
|
srcs = ["interpreter_wrapper.cc"],
|
|
hdrs = [
|
|
"interpreter_wrapper.h",
|
|
],
|
|
compatible_with = get_compatible_with_portable(),
|
|
deps = [
|
|
":numpy",
|
|
":python_error_reporter",
|
|
":python_utils",
|
|
"//tensorflow/lite:framework",
|
|
"//tensorflow/lite:shared_library",
|
|
"//tensorflow/lite:string_util",
|
|
"//tensorflow/lite:util",
|
|
"//tensorflow/lite/core:framework",
|
|
"//tensorflow/lite/core/api",
|
|
"//tensorflow/lite/core/c:common",
|
|
"//tensorflow/lite/core/kernels:builtin_ops",
|
|
"//tensorflow/lite/delegates/xnnpack:xnnpack_delegate",
|
|
"//tensorflow/lite/kernels:reference_ops",
|
|
"//tensorflow/lite/kernels/internal:compatibility",
|
|
"@com_google_absl//absl/memory",
|
|
"@com_google_absl//absl/strings",
|
|
"@com_google_absl//absl/strings:str_format",
|
|
"@xla//third_party/python_runtime:headers", # buildcleaner: keep
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "python_error_reporter",
|
|
srcs = ["python_error_reporter.cc"],
|
|
hdrs = ["python_error_reporter.h"],
|
|
compatible_with = get_compatible_with_portable(),
|
|
deps = [
|
|
"//tensorflow/lite:stateful_error_reporter",
|
|
"@xla//third_party/python_runtime:headers", # buildcleaner: keep
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "python_utils",
|
|
srcs = ["python_utils.cc"],
|
|
hdrs = ["python_utils.h"],
|
|
compatible_with = get_compatible_with_portable(),
|
|
deps = [
|
|
"@xla//third_party/python_runtime:headers", # buildcleaner: keep
|
|
],
|
|
)
|
|
|
|
config_setting(
|
|
name = "tflite_pip_with_flex",
|
|
define_values = {
|
|
"tflite_pip_with_flex": "true",
|
|
},
|
|
)
|
|
|
|
pybind_extension(
|
|
name = "_pywrap_tensorflow_interpreter_wrapper",
|
|
srcs = [
|
|
"interpreter_wrapper_pybind11.cc",
|
|
],
|
|
hdrs = ["interpreter_wrapper.h"],
|
|
additional_stubgen_deps = [
|
|
"//third_party/py/numpy:numpy",
|
|
],
|
|
common_lib_packages = [
|
|
"litert/python",
|
|
"tensorflow/lite/python",
|
|
],
|
|
compatible_with = get_compatible_with_portable(),
|
|
enable_stub_generation = True,
|
|
link_in_framework = True,
|
|
pytype_srcs = [
|
|
"_pywrap_tensorflow_interpreter_wrapper.pyi",
|
|
],
|
|
wrap_py_init = True,
|
|
deps = [
|
|
":interpreter_wrapper_lib",
|
|
"//tensorflow/lite:framework",
|
|
"//tensorflow/lite/core:framework_stable",
|
|
"//tensorflow/python/lib/core:pybind11_lib",
|
|
"@pybind11",
|
|
"@xla//third_party/python_runtime:headers",
|
|
] + select({
|
|
":tflite_pip_with_flex": ["//tensorflow/lite/delegates/flex:delegate"],
|
|
"//conditions:default": [],
|
|
}),
|
|
)
|