• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1load("//tensorflow:tensorflow.bzl", "pybind_extension")
2load("//tensorflow:tensorflow.bzl", "pytype_strict_library")
3
4# buildifier: disable=same-origin-load
5load("//tensorflow:tensorflow.bzl", "get_compatible_with_portable", "if_portable")
6load(
7    "//tensorflow/core/platform:build_config.bzl",
8    "tf_proto_library",
9)
10
11package(
12    default_visibility = ["//visibility:public"],
13    licenses = ["notice"],
14)
15
16cc_library(
17    name = "metrics_wrapper_lib",
18    srcs = if_portable(
19        if_false = ["wrapper/metrics_wrapper_nonportable.cc"],
20        if_true = ["wrapper/metrics_wrapper_portable.cc"],
21    ),
22    hdrs = ["wrapper/metrics_wrapper.h"],
23    compatible_with = get_compatible_with_portable(),
24    visibility = ["//visibility:private"],
25    deps = [
26        "//third_party/python_runtime:headers",
27    ] + if_portable(
28        if_false = [
29            "//learning/brain/google/monitoring:metrics_exporter",
30        ],
31        if_true = [],
32    ),
33)
34
35pybind_extension(
36    name = "_pywrap_tensorflow_lite_metrics_wrapper",
37    srcs = ["wrapper/metrics_wrapper_pybind11.cc"],
38    hdrs = ["wrapper/metrics_wrapper.h"],
39    compatible_with = get_compatible_with_portable(),
40    visibility = ["//visibility:private"],
41    deps = [
42        ":metrics_wrapper_lib",
43        "//tensorflow/python:pybind11_lib",
44        "//third_party/python_runtime:headers",
45        "@com_google_protobuf//:protobuf",
46        "@pybind11",
47    ],
48)
49
50pytype_strict_library(
51    name = "metrics_wrapper",
52    srcs = ["wrapper/metrics_wrapper.py"],
53    srcs_version = "PY3",
54    deps = [
55        ":_pywrap_tensorflow_lite_metrics_wrapper",
56        ":converter_error_data_proto_py",
57        "//tensorflow/lite/python:wrap_toco",
58    ],
59)
60
61py_test(
62    name = "metrics_wrapper_test",
63    srcs = ["wrapper/metrics_wrapper_test.py"],
64    python_version = "PY3",
65    srcs_version = "PY3",
66    deps = [
67        ":metrics_wrapper",
68        "//tensorflow:tensorflow_py",
69        "//tensorflow/python:client_testlib",
70        "//tensorflow/python:framework_test_lib",
71    ],
72)
73
74pytype_strict_library(
75    name = "metrics_interface",
76    srcs = ["metrics_interface.py"],
77    compatible_with = get_compatible_with_portable(),
78    srcs_version = "PY3",
79    visibility = ["//visibility:private"],
80)
81
82genrule(
83    name = "metrics_py_gen",
84    srcs = if_portable(
85        if_false = ["metrics_nonportable.py"],
86        if_true = ["metrics_portable.py"],
87    ),
88    outs = ["metrics.py"],
89    cmd = (
90        "cat $(SRCS) > $(OUTS)"
91    ),
92    compatible_with = get_compatible_with_portable(),
93)
94
95pytype_strict_library(
96    name = "metrics",
97    srcs = ["metrics.py"],
98    compatible_with = get_compatible_with_portable(),
99    srcs_version = "PY3",
100    visibility = ["//tensorflow/lite:__subpackages__"],
101    deps = if_portable(
102        if_false = [
103            ":converter_error_data_proto_py",
104            ":metrics_wrapper",
105            "//tensorflow/python/eager:monitoring",
106        ],
107        if_true = [],
108    ) + [":metrics_interface"],
109)
110
111py_test(
112    name = "metrics_test",
113    srcs = if_portable(
114        if_false = ["metrics_nonportable_test.py"],
115        if_true = ["metrics_portable_test.py"],
116    ),
117    data = [
118        "//tensorflow/lite/python/testdata/control_flow_v1_saved_model:saved_model.pb",
119    ],
120    main = if_portable(
121        if_false = "metrics_nonportable_test.py",
122        if_true = "metrics_portable_test.py",
123    ),
124    python_version = "PY3",
125    deps = [
126        ":converter_error_data_proto_py",
127        ":metrics",
128        "//tensorflow:tensorflow_py",
129        "//tensorflow/lite/python:lite",
130        "//tensorflow/python:client_testlib",
131        "//tensorflow/python:framework_test_lib",
132    ],
133)
134
135tf_proto_library(
136    name = "converter_error_data_proto",
137    srcs = ["converter_error_data.proto"],
138    cc_api_version = 2,
139)
140
141# copybara:uncomment_begin(google-only)
142# py_proto_library(
143#     name = "converter_error_data_proto_py",
144#     api_version = 2,
145#     deps = [":converter_error_data_proto"],
146# )
147# copybara:uncomment_end
148