Skip to content

Commit 3f3140d

Browse files
ecalubaquibcopybara-github
authored andcommitted
Use pyrwap rules for LiteRT repo to fix duplicate registration errors
PiperOrigin-RevId: 758995263
1 parent 6eefc3f commit 3f3140d

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

tflite/python/BUILD

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
load("@flatbuffers//:build_defs.bzl", "flatbuffer_py_library")
22
load("@org_tensorflow//tensorflow:pytype.default.bzl", "pytype_strict_contrib_test", "pytype_strict_library")
33
load("@org_tensorflow//tensorflow:strict.default.bzl", "py_strict_binary", "py_strict_library", "py_strict_test")
4-
load("@org_tensorflow//tensorflow:tensorflow.default.bzl", "get_compatible_with_portable")
4+
load("@org_tensorflow//tensorflow:tensorflow.default.bzl", "get_compatible_with_portable", "pywrap_library")
5+
load("@org_tensorflow//tensorflow/core/platform:build_config_root.bzl", "if_pywrap")
56
load("@rules_shell//shell:sh_test.bzl", "sh_test")
67
load("//tflite:special_rules.bzl", "internal_visibility_allowlist")
78

@@ -474,7 +475,9 @@ pytype_strict_library(
474475
"@org_tensorflow//tensorflow/python/framework:tensor_shape",
475476
"@org_tensorflow//tensorflow/python/util:deprecation",
476477
"@org_tensorflow//tensorflow/python/util:tf_export",
477-
],
478+
] + if_pywrap(
479+
if_true = [":pywrap_tflite"],
480+
),
478481
)
479482

480483
py_strict_library(
@@ -515,7 +518,9 @@ pytype_strict_contrib_test(
515518
"@org_tensorflow//tensorflow/python/ops:math_ops",
516519
"@org_tensorflow//tensorflow/python/platform:client_testlib",
517520
"@org_tensorflow//third_party/py/numpy",
518-
],
521+
] + if_pywrap(
522+
if_true = [":pywrap_tflite"],
523+
),
519524
)
520525

521526
py_strict_library(
@@ -633,3 +638,21 @@ py_strict_test(
633638
"@org_tensorflow//tensorflow/python/trackable:autotrackable",
634639
],
635640
)
641+
642+
pywrap_library(
643+
name = "pywrap_tflite",
644+
common_lib_versions = {
645+
"framework": "2",
646+
},
647+
pywrap_count = 7,
648+
visibility = ["//visibility:public"],
649+
deps = [
650+
"//tflite/python/analyzer_wrapper:_pywrap_analyzer_wrapper",
651+
"//tflite/python/interpreter_wrapper:_pywrap_tensorflow_interpreter_wrapper",
652+
"//tflite/python/metrics:_pywrap_tensorflow_lite_metrics_wrapper",
653+
"//tflite/python/optimize:_pywrap_tensorflow_lite_calibration_wrapper",
654+
"//tflite/testing:_pywrap_string_util",
655+
"//tflite/tools/optimize/python:_pywrap_modify_model_interface",
656+
"//tflite/tools/optimize/sparsity:format_converter_wrapper_pybind11",
657+
],
658+
)

tflite/python/metrics/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pybind_extension(
3636
pytype_srcs = [
3737
"_pywrap_tensorflow_lite_metrics_wrapper.pyi",
3838
],
39-
visibility = ["__subpackages__"],
39+
visibility = ["//visibility:public"],
4040
deps = [
4141
":metrics_wrapper_lib",
4242
"@com_google_protobuf//:protobuf",

tflite/tools/optimize/python/BUILD

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ py_strict_library(
5454
pybind_extension(
5555
name = "_pywrap_modify_model_interface",
5656
srcs = ["modify_model_interface.cc"],
57+
# copybara:comment_begin(oss-only)
58+
common_lib_packages = [
59+
"tflite/python",
60+
],
61+
# copybara:comment_end
5762
enable_stub_generation = True,
5863
pytype_srcs = [
5964
"_pywrap_modify_model_interface.pyi",

tflite/tools/optimize/sparsity/BUILD

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
load("@org_tensorflow//tensorflow:strict.default.bzl", "py_strict_test")
22
load("@org_tensorflow//tensorflow:tensorflow.default.bzl", "pybind_extension")
3+
load("@org_tensorflow//tensorflow/core/platform:build_config_root.bzl", "if_pywrap")
34

45
package(
56
# copybara:uncomment default_applicable_licenses = ["@org_tensorflow//tensorflow:license"],
@@ -12,6 +13,11 @@ package(
1213
pybind_extension(
1314
name = "format_converter_wrapper_pybind11",
1415
srcs = ["format_converter_wrapper_pybind11.cc"],
16+
# copybara:comment_begin(oss-only)
17+
common_lib_packages = [
18+
"tflite/python",
19+
],
20+
# copybara:comment_end
1521
copts = [
1622
"-fexceptions",
1723
"-fno-strict-aliasing",
@@ -37,5 +43,7 @@ py_strict_test(
3743
"@absl_py//absl/testing:absltest",
3844
#internal proto upb dep
3945
"@org_tensorflow//third_party/py/numpy",
40-
],
46+
] + if_pywrap(
47+
if_true = ["//tflite/python:pywrap_tflite"],
48+
),
4149
)

0 commit comments

Comments
 (0)