Files
tensorflow--tensorflow/tensorflow/lite/python/optimize/BUILD
T
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

110 lines
3.7 KiB
Python

load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@xla//third_party/rules_python/python:py_library.bzl", "py_library")
load("//tensorflow:tensorflow.bzl", "py_test")
load("//tensorflow:tensorflow.default.bzl", "pybind_extension")
package(
# copybara:uncomment default_applicable_licenses = ["//tensorflow:LICENSE"],
default_visibility = ["//visibility:public"],
licenses = ["notice"],
)
cc_library(
name = "calibration_wrapper_lib",
srcs = ["calibration_wrapper.cc"],
hdrs = ["calibration_wrapper.h"],
deps = [
"//tensorflow/compiler/mlir/lite:offset_buffer",
"//tensorflow/compiler/mlir/lite/schema:schema_fbs_with_mutable",
"//tensorflow/lite:framework",
"//tensorflow/lite:shared_library",
"//tensorflow/lite:string_util",
"//tensorflow/lite/core:framework",
"//tensorflow/lite/core/c:common",
"//tensorflow/lite/core/kernels:builtin_ops",
"//tensorflow/lite/python/interpreter_wrapper:numpy",
"//tensorflow/lite/python/interpreter_wrapper:python_error_reporter",
"//tensorflow/lite/python/interpreter_wrapper:python_utils",
"//tensorflow/lite/tools/optimize:quantization_wrapper_utils",
"//tensorflow/lite/tools/optimize:quantize_model",
"//tensorflow/lite/tools/optimize/calibration:calibration_reader",
"//tensorflow/lite/tools/optimize/calibration:calibrator_lib",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/types:optional",
"@xla//third_party/python_runtime:headers", # buildcleaner: keep
],
)
pybind_extension(
name = "_pywrap_tensorflow_lite_calibration_wrapper",
srcs = [
"calibration_wrapper_pybind11.cc",
],
hdrs = ["calibration_wrapper.h"],
additional_stubgen_deps = [
"//third_party/py/numpy:numpy",
],
common_lib_packages = [
"litert/python",
"tensorflow/lite/python",
],
enable_stub_generation = True,
link_in_framework = True,
pytype_srcs = [
"_pywrap_tensorflow_lite_calibration_wrapper.pyi",
],
wrap_py_init = True,
deps = [
":calibration_wrapper_lib",
"//tensorflow/lite:framework",
"//tensorflow/lite/core:framework_stable",
"//tensorflow/python/lib/core:pybind11_lib",
"@pybind11",
"@xla//third_party/python_runtime:headers",
],
)
py_library(
name = "calibrator",
srcs = [
"calibrator.py",
],
strict_deps = True,
visibility = ["//visibility:public"],
deps = [
":_pywrap_tensorflow_lite_calibration_wrapper", # buildcleaner: keep
"//tensorflow/lite/python:convert_phase",
"//tensorflow/lite/python:interpreter",
"//tensorflow/python/framework:dtypes",
"//tensorflow/python/util:lazy_loader",
"//third_party/py/numpy",
],
)
py_test(
name = "calibrator_test",
srcs = ["calibrator_test.py"],
data = [
":test_data",
"//tensorflow/lite:testdata/multi_add.bin",
],
strict_deps = True,
tags = ["no_oss"],
deps = [
":calibrator",
"@absl_py//absl/testing:parameterized",
#internal proto upb dep
"//third_party/py/numpy",
"//tensorflow:tensorflow_py_no_contrib",
"//tensorflow/lite/python:lite",
"//tensorflow/lite/python:schema_py",
"//tensorflow/lite/tools:flatbuffer_utils",
"//tensorflow/python/framework:dtypes",
"//tensorflow/python/framework:test_lib",
"//tensorflow/python/platform:client_testlib",
"//tensorflow/python/platform:resource_loader",
],
)