• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1load("//tensorflow:tensorflow.bzl", "clean_dep")
2load("//tensorflow:tensorflow.bzl", "get_compatible_with_portable")
3load("//tensorflow/lite:build_def.bzl", "tflite_copts", "tflite_copts_warnings")
4load("//tensorflow/lite:special_rules.bzl", "tflite_portable_test_suite_combined")
5
6# copybara:uncomment_begin(google-only)
7# load("//tensorflow/lite/experimental/perfetto_profiling:build_def.bzl", "tflite_perfetto_copts")
8# copybara:uncomment_end
9
10package(
11    default_visibility = ["//visibility:public"],
12    licenses = ["notice"],
13)
14
15common_copts = tflite_copts() + tflite_copts_warnings()
16
17cc_library(
18    name = "profiler",
19    hdrs = [
20        "buffered_profiler.h",
21        "noop_profiler.h",
22        "profiler.h",
23    ],
24    copts = common_copts,
25    deps = [
26        ":profile_buffer",
27        "//tensorflow/lite/core/api",
28    ],
29)
30
31cc_test(
32    name = "profiler_test",
33    srcs = ["profiler_test.cc"],
34    deps = [
35        ":profiler",
36        "@com_google_googletest//:gtest_main",
37    ],
38)
39
40cc_library(
41    name = "atrace_profiler",
42    srcs = ["atrace_profiler.cc"],
43    hdrs = ["atrace_profiler.h"],
44    copts = common_copts,
45    visibility = ["//visibility:private"],
46    deps = [
47        "//tensorflow/lite/core/api",
48    ],
49)
50
51cc_test(
52    name = "atrace_profiler_test",
53    srcs = ["atrace_profiler_test.cc"],
54    deps = [
55        ":atrace_profiler",
56        "@com_google_googletest//:gtest_main",
57    ],
58)
59
60objc_library(
61    name = "signpost_profiler",
62    hdrs = ["signpost_profiler.h"],
63    copts = common_copts,
64    non_arc_srcs = ["signpost_profiler.mm"],
65    tags = ["apple"],
66    deps = [
67        "//tensorflow/lite/core/api",
68    ],
69)
70
71cc_library(
72    name = "platform_profiler",
73    srcs = ["platform_profiler.cc"],
74    hdrs = ["platform_profiler.h"],
75    compatible_with = get_compatible_with_portable(),
76    copts =
77        # copybara:uncomment_begin(google-only)
78        # tflite_perfetto_copts() +
79        # copybara:uncomment_end
80        common_copts,
81    deps = [
82        "//tensorflow/lite/core/api",
83    ] + select({
84        # copybara:uncomment_begin(google-only)
85        # clean_dep("//tensorflow/lite/experimental/perfetto_profiling:enable_tflite_perfetto_profiler_explicit_true"): [
86        # "//tensorflow/lite/experimental/perfetto_profiling:perfetto_profiler",
87        # ],
88        # copybara:uncomment_end
89        "//tensorflow:android": [":atrace_profiler"],
90        "//tensorflow:ios": [":signpost_profiler"],
91        "//conditions:default": [],
92    }),
93)
94
95cc_library(
96    name = "profile_buffer",
97    hdrs = ["profile_buffer.h"],
98    copts = common_copts,
99    deps = [
100        ":memory_info",
101        ":time",
102        "//tensorflow/lite/core/api",
103    ],
104)
105
106cc_test(
107    name = "profile_buffer_test",
108    srcs = ["profile_buffer_test.cc"],
109    deps = [
110        ":profile_buffer",
111        "@com_google_googletest//:gtest_main",
112    ],
113)
114
115cc_library(
116    name = "time",
117    srcs = ["time.cc"],
118    hdrs = ["time.h"],
119    copts = common_copts,
120)
121
122cc_test(
123    name = "time_test",
124    srcs = ["time_test.cc"],
125    deps = [
126        ":time",
127        "@com_google_googletest//:gtest_main",
128    ],
129)
130
131cc_library(
132    name = "memory_info",
133    srcs = ["memory_info.cc"],
134    hdrs = ["memory_info.h"],
135    copts = common_copts,
136)
137
138cc_test(
139    name = "memory_info_test",
140    srcs = ["memory_info_test.cc"],
141    tags = [
142        # Some low-level checks, like heap size check, may break in asan, msan
143        # and tsan. So, disable such tests.
144        "noasan",
145        "nomsan",
146        "notsan",
147        # TODO(b/166227284): Fix the test for Android.
148        "tflite_not_portable_android",
149    ],
150    deps = [
151        ":memory_info",
152        "@com_google_googletest//:gtest_main",
153    ],
154)
155
156cc_library(
157    name = "memory_usage_monitor",
158    srcs = ["memory_usage_monitor.cc"],
159    hdrs = ["memory_usage_monitor.h"],
160    copts = common_copts,
161    deps = [
162        ":memory_info",
163        "//tensorflow/lite:minimal_logging",
164        "@com_google_absl//absl/synchronization",
165        "@com_google_absl//absl/time",
166    ],
167)
168
169cc_test(
170    name = "memory_usage_monitor_test",
171    srcs = ["memory_usage_monitor_test.cc"],
172    tags = [
173    ],
174    deps = [
175        ":memory_info",
176        ":memory_usage_monitor",
177        "@com_google_absl//absl/time",
178        "@com_google_googletest//:gtest_main",
179    ],
180)
181
182cc_library(
183    name = "profile_summary_formatter",
184    srcs = ["profile_summary_formatter.cc"],
185    hdrs = ["profile_summary_formatter.h"],
186    copts = common_copts,
187    deps = [
188        "//tensorflow/core/util:stats_calculator_portable",
189    ],
190)
191
192cc_test(
193    name = "profile_summary_formatter_test",
194    srcs = ["profile_summary_formatter_test.cc"],
195    deps = [
196        ":profile_summary_formatter",
197        "@com_google_absl//absl/strings",
198        "@com_google_googletest//:gtest_main",
199    ],
200)
201
202cc_library(
203    name = "profile_summarizer",
204    srcs = ["profile_summarizer.cc"],
205    hdrs = ["profile_summarizer.h"],
206    copts = common_copts,
207    deps = [
208        ":memory_info",
209        ":profile_buffer",
210        ":profile_summary_formatter",
211        "//tensorflow/core/util:stats_calculator_portable",
212        "//tensorflow/lite:framework",
213        "//tensorflow/lite/schema:schema_fbs",
214    ],
215)
216
217cc_library(
218    name = "root_profiler",
219    srcs = ["root_profiler.cc"],
220    hdrs = ["root_profiler.h"],
221    compatible_with = get_compatible_with_portable(),
222    copts = common_copts,
223    deps = ["//tensorflow/lite/core/api"],
224)
225
226cc_test(
227    name = "root_profiler_test",
228    srcs = ["root_profiler_test.cc"],
229    deps = [
230        ":root_profiler",
231        "//tensorflow/lite/core/api",
232        "@com_google_googletest//:gtest_main",
233    ],
234)
235
236cc_test(
237    name = "profile_summarizer_test",
238    srcs = ["profile_summarizer_test.cc"],
239    deps = [
240        ":profile_summarizer",
241        ":profiler",
242        "//tensorflow/lite:framework",
243        "//tensorflow/lite:schema_fbs_version",
244        "//tensorflow/lite/kernels:kernel_util",
245        "//tensorflow/lite/kernels:subgraph_test_util",
246        "//tensorflow/lite/kernels:test_util",
247        "@com_google_googletest//:gtest_main",
248    ],
249)
250
251tflite_portable_test_suite_combined(combine_conditions = {"deps": ["@com_google_googletest//:gtest_main"]})
252