• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Description:
2# TensorFlow is a computational framework, primarily for use in machine
3# learning applications.
4#
5# Public targets:
6#
7# ":protos_all" - exports all core TensorFlow protos
8#     ":protos_all_py" - py_proto_library version (Google-internal)
9# ":lib" - exports the public non-test headers for:
10#     //third_party/tensorflow/core/platform:: Platform-specific code and external dependencies
11#     lib/: Low-level libraries that are not TensorFlow-specific
12# ":test" - test equivalent of ":lib".
13#     This is currently public, but may be made internal in the
14#     future.  Try to avoid depending on it.
15# ":framework" - exports the public non-test headers for:
16#     util/: General low-level TensorFlow-specific libraries
17#     framework/: Support for adding new ops & kernels
18#     example/: Wrappers to simplify access to Example proto
19#     //third_party/tensorflow/lite/kernels/shim: Template for writing ops supporting TF & TF Lite.
20# ":ops" - defines TensorFlow ops, but no implementations / kernels
21#     ops/: Standard ops
22#     user_ops/: User-supplied ops
23#     This aggregates a number of smaller op libraries (":*_op_lib")
24# ":core_cpu" - exports the public non-test headers for:
25#     graph/: Support for graphs made up of ops
26#     common_runtime/: Common code for execution of graphs
27#     public/: Public APIs for running graphs
28# ":core" - The code for ":core_cpu" plus a GPU runtime
29# ":all_kernels" - The cpu-specific kernels, plus gpu kernels if
30#     built with Cuda
31# ":tensorflow_opensource" - The complete open-source package, including
32#      ":all_kernels", ":core", and a Session implementation.
33# ":tensorflow" - "tensorflow_opensource" plus some Google-internal libraries.
34# ":testlib" - TensorFlow-specific test support, e.g. utilities for testing
35#      kernels.
36# ":direct_session" - An implementation of the Session interface that
37#      directly runs Graphs via the internal TensorFlow executor.
38#  "framework_lite" - Intended to be used by operator implementations
39#      (kernels) that can also be run outside the tensorflow runtime. This
40#      contains a small set of headers and utilities that can be used for core
41#      kernels, without bringing in libraries that can bloat code size (e.g.,
42#      logging is not included because using it will bring in a large amount of
43#      ostream code).
44#
45# ":example_parser_configuration" -- A library for extracting the
46#      tensorflow.Example proto configuration from a Graph.
47#
48# Public mobile targets, e.g. for Android:
49#
50# cc_library ":portable_tensorflow_lib" - Native library
51# cc_library ":portable_tensorflow_lib_lite" - Native library, without ops,
52#   supporting SELECTIVE_REGISTRATION feature.
53#
54# Note that :framework and :lib have incomplete transitive dependencies (they
55# declare but do not define some symbols) if framework_shared_object=True
56# (meaning there is an explicit framework shared object). Missing symbols are
57# included in //tensorflow:libtensorflow_framework.so. This split supports
58# custom op registration; see comments on
59# //tensorflow:libtensorflow_framework.so. It does mean that TensorFlow cc_test
60# and cc_binary rules will not build. Using tf_cc_test and tf_cc_binary (from
61# //tensorflow/tensorflow.bzl) will include the necessary symbols in binary
62# build targets.
63
64load(
65    "//tensorflow:tensorflow.bzl",
66    "if_android",
67    "if_cuda_or_rocm",
68    "if_google",
69    "if_ios",
70    "if_libtpu",
71    "if_mobile",
72    "tf_cc_test",
73    "tf_cc_test_mkl",
74    "tf_cc_tests",
75    "tf_copts",
76    "tf_cuda_library",
77    "tf_defines_nortti_if_lite_protos",
78    "tf_features_nomodules_if_mobile",
79    "tf_opts_nortti_if_lite_protos",
80    "transitive_hdrs",
81)
82
83# buildifier: disable=same-origin-load
84load("//tensorflow:tensorflow.bzl", "cc_header_only_library")
85
86# buildifier: disable=same-origin-load
87load("//tensorflow:tensorflow.bzl", "if_nccl")
88
89# buildifier: disable=same-origin-load
90load("//tensorflow:tensorflow.bzl", "tensorflow_opensource_extra_deps")
91
92# buildifier: disable=same-origin-load
93load("//tensorflow:tensorflow.bzl", "tf_monitoring_framework_deps")
94
95# buildifier: disable=same-origin-load
96load("//tensorflow:tensorflow.bzl", "filegroup")
97
98# buildifier: disable=same-origin-load
99load("//tensorflow:tensorflow.bzl", "get_compatible_with_portable")
100
101# buildifier: disable=same-origin-load
102load("//tensorflow:tensorflow.bzl", "tf_selective_registration_deps")
103
104# For platform specific build config
105load(
106    "//tensorflow/core/platform:build_config.bzl",
107    "tf_additional_lib_deps",
108    "tf_additional_test_deps",
109    "tf_dtensor_tpu_dependencies",
110    "tf_jspb_proto_library",
111    "tf_kernel_tests_linkstatic",
112    "tf_lib_proto_parsing_deps",
113    "tf_portable_deps_no_runtime",
114    "tf_portable_proto_lib",
115    "tf_proto_library",
116    "tf_protos_all_impl",
117    "tf_protos_grappler_impl",
118    "tf_protos_profiler_impl",
119    "tf_tpu_dependencies",
120)
121load(
122    "//tensorflow/core/platform:rules_cc.bzl",
123    "cc_library",
124)
125load(
126    "//tensorflow/core/platform:build_config_root.bzl",
127    "if_dynamic_kernels",
128    "if_static",
129)
130load("@local_config_cuda//cuda:build_defs.bzl", "if_cuda")
131load("@local_config_tensorrt//:build_defs.bzl", "if_tensorrt")
132load(
133    "//third_party/mkl:build_defs.bzl",
134    "if_mkl",
135)
136
137package(
138    default_visibility = [
139        ":dependency_whitelist",
140        "//tensorflow:internal",
141        "//tensorflow_models:__subpackages__",
142    ],
143    features = if_google(["-parse_headers"]),
144    licenses = ["notice"],
145)
146
147package_group(
148    name = "dependency_whitelist",
149    packages = [
150        "//learning/freud/topic_models/tensorflow/...",
151        "//learning/infra/mira/...",
152        "//perftools/accelerators/xprof/api/...",
153        "//quality/webanswers/brain/tokenization/custom_tf_ops/kernels/...",
154        "//smartass/brain/server/...",
155    ],
156)
157
158# Export the BUILD file so automated tooling can check licenses
159exports_files([
160    "BUILD",
161])
162
163# Authorized users go here.
164package_group(
165    name = "friends",
166    packages = if_google([
167        "//learning/brain/...",
168        "//tensorflow/...",
169        "@tf_runtime//...",
170        "//third_party/tf_runtime_google/...",
171    ]),
172)
173
174# -----------------------------------------------------------------------------
175# Public targets
176
177# Protos which are needed for core tensorflow, including on mobile builds.
178#
179# Note that some protos are in neither additional_core_proto_srcs nor this
180# filegroup; e.g.  ones with individual proto_library targets.
181COMMON_PROTO_SRCS = [
182    "//tensorflow/core/protobuf:bfc_memory_map.proto",
183    "//tensorflow/core/protobuf:config.proto",
184    "//tensorflow/core/protobuf:cluster.proto",
185    "//tensorflow/core/protobuf:debug.proto",
186    "//tensorflow/core/protobuf:device_filters.proto",
187    "//tensorflow/core/protobuf:device_properties.proto",
188    "//tensorflow/core/protobuf:graph_debug_info.proto",
189    "//tensorflow/core/protobuf:queue_runner.proto",
190    "//tensorflow/core/protobuf:rewriter_config.proto",
191    "//tensorflow/core/protobuf:tensor_bundle.proto",
192    "//tensorflow/core/protobuf:saver.proto",
193    "//tensorflow/core/protobuf:status.proto",
194    "//tensorflow/core/protobuf:verifier_config.proto",
195]
196
197EXAMPLE_PROTO_SRCS = [
198    "//tensorflow/core/example:example.proto",
199    "//tensorflow/core/example:feature.proto",
200]
201
202UTIL_PROTO_SRCS = [
203    "//tensorflow/core/util:event.proto",
204    "//tensorflow/core/util:memmapped_file_system.proto",
205    "//tensorflow/core/util:saved_tensor_slice.proto",
206]
207
208FRAMEWORK_PROTO_SRCS = [
209    "//tensorflow/core/framework:allocation_description.proto",
210    "//tensorflow/core/framework:api_def.proto",
211    "//tensorflow/core/framework:attr_value.proto",
212    "//tensorflow/core/framework:cost_graph.proto",
213    "//tensorflow/core/framework:device_attributes.proto",
214    "//tensorflow/core/framework:function.proto",
215    "//tensorflow/core/framework:graph.proto",
216    "//tensorflow/core/framework:graph_transfer_info.proto",
217    "//tensorflow/core/framework:kernel_def.proto",
218    "//tensorflow/core/framework:log_memory.proto",
219    "//tensorflow/core/framework:model.proto",
220    "//tensorflow/core/framework:node_def.proto",
221    "//tensorflow/core/framework:op_def.proto",
222    "//tensorflow/core/framework:dataset_metadata.proto",
223    "//tensorflow/core/framework:dataset_options.proto",
224    "//tensorflow/core/framework:reader_base.proto",
225    "//tensorflow/core/framework:resource_handle.proto",
226    "//tensorflow/core/framework:step_stats.proto",
227    "//tensorflow/core/framework:summary.proto",
228    "//tensorflow/core/framework:tensor.proto",
229    "//tensorflow/core/framework:tensor_description.proto",
230    "//tensorflow/core/framework:tensor_shape.proto",
231    "//tensorflow/core/framework:tensor_slice.proto",
232    "//tensorflow/core/framework:types.proto",
233    "//tensorflow/core/framework:variable.proto",
234    "//tensorflow/core/framework:versions.proto",
235]
236
237PROFILER_PROTO_SRCS = [
238    "//tensorflow/core/profiler/protobuf:xplane.proto",
239    "//tensorflow/core/profiler:profiler_options.proto",
240]
241
242ERROR_CODES_PROTO_SRCS = [
243    "//tensorflow/core/protobuf:error_codes.proto",
244    "//tensorflow/core/lib/core:error_codes.proto",
245]
246
247CORE_PROTO_SRCS = COMMON_PROTO_SRCS + EXAMPLE_PROTO_SRCS + FRAMEWORK_PROTO_SRCS + UTIL_PROTO_SRCS + PROFILER_PROTO_SRCS + ERROR_CODES_PROTO_SRCS
248
249tf_proto_library(
250    name = "protos_all",
251    srcs = [],
252    cc_api_version = 2,
253    create_go_proto = False,
254    make_default_target_header_only = True,
255    protodeps = [
256        "//tensorflow/core/example:protos_all",
257        "//tensorflow/core/framework:protos_all",
258        "//tensorflow/core/lib/core:error_codes_proto",
259        "//tensorflow/core/profiler/protobuf:xplane_proto",
260        "//tensorflow/core/profiler:profiler_options_proto",
261        "//tensorflow/core/protobuf:error_codes_proto_impl",
262        "//tensorflow/core/protobuf:for_core_protos",
263        "//tensorflow/core/util:protos_all",
264        "//tensorflow/core/util:test_log_proto_impl",
265        "//tensorflow/core/grappler/costs:op_performance_data",
266    ],
267    visibility = ["//visibility:public"],
268)
269
270tf_jspb_proto_library(
271    name = "protos_all_jspb_proto",
272    visibility = ["//visibility:public"],
273    deps = [":protos_all"],
274)
275
276alias(
277    name = "example_protos",
278    actual = "//tensorflow/core/example:example_protos",
279    visibility = ["//visibility:public"],
280)
281
282java_proto_library(
283    name = "example_java_proto",
284    visibility = ["//visibility:public"],
285    deps = [":example_protos"],
286)
287
288cc_library(
289    name = "platform_base",
290    hdrs = ["//tensorflow/core/platform:base_hdrs"],
291    compatible_with = get_compatible_with_portable(),
292    copts = tf_copts(),
293    tags = ["avoid_dep"],
294    deps = [
295        "//tensorflow/core/platform",
296        "//tensorflow/core/platform:byte_order",
297        "//tensorflow/core/platform:cord",
298        "//tensorflow/core/platform:env_time",
299        "//tensorflow/core/platform:logging",
300        "//tensorflow/core/platform:macros",
301        "//tensorflow/core/platform:stack_frame",
302        "//tensorflow/core/platform:threadpool_interface",
303        "//tensorflow/core/platform:threadpool_options",
304        "//tensorflow/core/platform:types",
305        "@com_google_absl//absl/base",
306        "@com_google_absl//absl/strings",
307    ],
308)
309
310# Minimal lib so that tools used for mobile compilation
311# don't have to depend on lib/platformlib.
312cc_library(
313    name = "lib_proto_parsing",
314    hdrs = [
315        "//tensorflow/core/lib/core:legacy_lib_proto_parsing_headers",
316        "//tensorflow/core/lib/strings:legacy_lib_proto_parsing_headers",
317        "//tensorflow/core/platform:lib_proto_parsing_hdrs",
318    ],
319    copts = tf_copts(),
320    deps = tf_lib_proto_parsing_deps() + [
321        ":platform_base",
322        "@com_google_absl//absl/strings",
323        "@double_conversion//:double-conversion",
324        "//tensorflow/core/lib/core:errors",
325        "//tensorflow/core/lib/core:stringpiece",
326        "//tensorflow/core/lib/core:status",
327        "//tensorflow/core/lib/strings:numbers",
328        "//tensorflow/core/lib/strings:strcat",
329        "//tensorflow/core/platform:platform_port",
330        "//tensorflow/core/platform:logging",
331        "//tensorflow/core/platform:macros",
332        "//tensorflow/core/platform:protobuf",
333        "//tensorflow/core/platform",
334        "//tensorflow/core/platform:status",
335        "//tensorflow/core/platform:stringpiece",
336        "//tensorflow/core/platform:tstring",
337        "//tensorflow/core/platform:types",
338    ],
339)
340
341# This build rule (along with :lib_internal, :framework, and
342# :framework_internal) purposefully omits the definitions of many declared
343# symbols, which are included in //tensorflow:libtensorflow_framework.so. Using
344# tf_cc_test and tf_cc_binary will include the necessary symbols.
345cc_library(
346    name = "lib",
347    hdrs = [
348        # TODO(rmlarsen): Remove bfloat16.h once dependency in third_party/swift is updated.
349        "//tensorflow/core/lib/bfloat16:bfloat16.h",
350        "//tensorflow/core/lib/core:legacy_lib_core_headers",
351        "//tensorflow/core/lib/gtl:legacy_lib_gtl_headers",
352        "//tensorflow/core/lib/hash:legacy_lib_hash_all_headers",
353        "//tensorflow/core/lib/histogram:legacy_lib_histogram_all_headers",
354        "//tensorflow/core/lib/io:legacy_lib_io_headers",
355        "//tensorflow/core/lib/math:math_util.h",
356        "//tensorflow/core/lib/monitoring:legacy_lib_monitoring_lib_headers",
357        "//tensorflow/core/lib/random:legacy_lib_random_headers",
358        "//tensorflow/core/lib/strings:legacy_lib_string_headers",
359        "//tensorflow/core/platform:lib_hdrs",
360        "//tensorflow/core/util:lib_hdrs",
361        "//tensorflow/tsl/platform:lib_hdrs",
362    ],
363    visibility = ["//visibility:public"],
364    deps = [
365        ":lib_internal",
366        "@com_google_absl//absl/container:inlined_vector",
367        "@com_google_absl//absl/strings",
368        "@com_google_absl//absl/strings:cord",
369        "@com_google_absl//absl/types:optional",
370    ],
371)
372
373alias(
374    name = "feature_util",
375    actual = "//tensorflow/core/example:feature_util",
376    visibility = ["//visibility:public"],
377)
378
379# DEPRECATED: use platform:stringpiece instead.
380cc_library(
381    name = "core_stringpiece",
382    hdrs = ["//tensorflow/core/lib/core:legacy_lib_core_stringpiece_header"],
383    copts = tf_copts(),
384    deps = [
385        "//tensorflow/core/platform:stringpiece",
386    ],
387)
388
389# Test support library needed for all tests
390# This is currently public, but may be made internal in the
391# future.  Try to avoid depending on it.
392
393cc_library(
394    name = "test",
395    testonly = 1,
396    srcs = [
397        "//tensorflow/core/platform:legacy_test_srcs",
398    ],
399    hdrs = [
400        "//tensorflow/core/lib/core:legacy_lib_core_status_test_util_header",
401        "//tensorflow/core/platform:test_hdrs",
402        "//tensorflow/core/util:test_hdrs",
403    ],
404    copts = tf_copts(),
405    linkopts = select({
406        "//tensorflow:windows": [],
407        "//conditions:default": ["-lm"],
408    }),
409    visibility = ["//visibility:public"],
410    deps = [
411        ":function_ops_op_lib",
412        ":functional_ops_op_lib",
413        ":lib",
414        ":lib_internal",
415        ":protos_all_cc",
416        "//tensorflow/tsl/platform/default/build_config:gtest",
417        "//tensorflow/core/kernels:required",
418        "@com_google_benchmark//:benchmark",
419        "@com_google_googletest//:gtest",
420    ] + tf_additional_test_deps(),
421)
422
423# This build rule (along with :framework_internal, :lib, and :lib_internal)
424# purposefully omits the definitions of many declared symbols, which are
425# included in //tensorflow:libtensorflow_framework.so. Using tf_cc_test and tf_cc_binary
426# will include the necessary symbols.
427tf_cuda_library(
428    name = "framework",
429    hdrs = [
430        "//tensorflow/core/example:feature_util.h",
431        "//tensorflow/core/framework:allocator.h",
432        "//tensorflow/core/framework:allocator_registry.h",
433        "//tensorflow/core/framework:attr_value_util.h",
434        "//tensorflow/core/framework:bfloat16.h",
435        "//tensorflow/core/framework:bounds_check.h",
436        "//tensorflow/core/framework:cancellation.h",
437        "//tensorflow/core/framework:collective.h",
438        "//tensorflow/core/framework:common_shape_fns.h",
439        "//tensorflow/core/framework:control_flow.h",  # TODO(josh11b): Make internal?
440        "//tensorflow/core/framework:dataset.h",
441        "//tensorflow/core/framework:dataset_stateful_op_allowlist.h",
442        "//tensorflow/core/framework:device.h",
443        "//tensorflow/core/framework:device_base.h",
444        "//tensorflow/core/framework:device_factory.h",
445        "//tensorflow/core/framework:function.h",
446        "//tensorflow/core/framework:function_handle_cache.h",
447        "//tensorflow/core/framework:graph_def_util.h",
448        "//tensorflow/core/framework:graph_to_functiondef.h",
449        "//tensorflow/core/framework:kernel_def_builder.h",
450        "//tensorflow/core/framework:kernel_def_util.h",
451        "//tensorflow/core/framework:kernel_shape_util.h",
452        "//tensorflow/core/framework:log_memory.h",
453        "//tensorflow/core/framework:logging.h",
454        "//tensorflow/core/framework:lookup_interface.h",
455        "//tensorflow/core/framework:memory_types.h",
456        "//tensorflow/core/framework:metrics.h",
457        "//tensorflow/core/framework:node_def_builder.h",
458        "//tensorflow/core/framework:node_def_util.h",
459        "//tensorflow/core/framework:node_properties.h",
460        "//tensorflow/core/framework:numeric_op.h",
461        "//tensorflow/core/framework:numeric_types.h",
462        "//tensorflow/core/framework:op.h",
463        "//tensorflow/core/framework:op_def_builder.h",
464        "//tensorflow/core/framework:op_def_util.h",
465        "//tensorflow/core/framework:op_kernel.h",
466        "//tensorflow/core/framework:op_requires.h",
467        "//tensorflow/core/framework:ops_util.h",
468        "//tensorflow/core/framework:partial_tensor_shape.h",
469        "//tensorflow/core/framework:queue_interface.h",
470        "//tensorflow/core/framework:reader_interface.h",
471        "//tensorflow/core/framework:reader_op_kernel.h",
472        "//tensorflow/core/framework:register_types.h",
473        "//tensorflow/core/framework:register_types_traits.h",
474        "//tensorflow/core/framework/registration:options.h",
475        "//tensorflow/core/framework:resource_mgr.h",
476        "//tensorflow/core/framework:resource_handle.h",
477        "//tensorflow/core/framework:resource_op_kernel.h",
478        "//tensorflow/core/framework:rng_alg.h",
479        "//tensorflow/core/framework/registration:registration.h",
480        "//tensorflow/core/framework:session_state.h",
481        "//tensorflow/core/framework:shape_inference.h",
482        "//tensorflow/core/framework:shared_ptr_variant.h",
483        "//tensorflow/core/framework:stats_aggregator.h",
484        "//tensorflow/core/framework:tensor.h",
485        "//tensorflow/core/framework:tensor_shape.h",
486        "//tensorflow/core/framework:tensor_slice.h",
487        "//tensorflow/core/framework:tensor_types.h",
488        "//tensorflow/core/framework:tensor_util.h",
489        "//tensorflow/core/framework:thread_factory.h",
490        "//tensorflow/core/framework:tracking_allocator.h",
491        "//tensorflow/core/framework:type_index.h",
492        "//tensorflow/core/framework:type_traits.h",
493        "//tensorflow/core/framework:typed_allocator.h",
494        "//tensorflow/core/framework:types.h",
495        "//tensorflow/core/framework:variant.h",
496        "//tensorflow/core/framework:variant_encode_decode.h",
497        "//tensorflow/core/framework:variant_op_registry.h",
498        "//tensorflow/core/framework:variant_tensor_data.h",
499        "//tensorflow/core/util/sparse:framework_group",
500        "//tensorflow/core/util:framework_srcs",
501        "//tensorflow/core/util:memmapped_file_system_hdrs",
502        "//tensorflow/core/util:determinism_hdr",
503        "//tensorflow/core/public:version.h",
504        "//tensorflow/lite/kernels/shim:tf_headers",
505    ] + if_mkl([
506        "//tensorflow/core/util:mkl_util_hdrs",
507    ]),
508    visibility = ["//visibility:public"],
509    deps = [
510        ":framework_internal",
511        "@com_google_absl//absl/base",
512    ],
513)
514
515alias(
516    name = "ptr_util",
517    actual = "//tensorflow/core/util:ptr_util",
518)
519
520# TODO(gonnet): Remove this alias once all users have been moved to the actual target.
521alias(
522    name = "reader_base",
523    actual = "//tensorflow/core/framework:reader_base",
524    visibility = ["//visibility:public"],
525)
526
527# TODO(gonnet): Remove this alias once all users have been moved to the actual target.
528alias(
529    name = "op_gen_lib",
530    actual = "//tensorflow/core/framework:op_gen_lib",
531    visibility = ["//visibility:public"],
532)
533
534cc_library(
535    name = "session_options",
536    hdrs = ["//tensorflow/core/public:session_options.h"],
537    visibility = ["//visibility:public"],
538    deps = [
539        ":lib",
540        ":protos_all_cc",
541    ],
542)
543
544cc_library(
545    name = "framework_types_hdr",
546    hdrs = ["//tensorflow/core/framework:types.h"],
547    linkstatic = 1,
548    visibility = ["//visibility:public"],
549)
550
551cc_library(
552    name = "framework_lite",
553    hdrs = [
554        "//tensorflow/core/framework:numeric_types.h",
555        "//tensorflow/core/framework:tensor_types.h",
556        "//tensorflow/core/framework:type_traits.h",
557        "//tensorflow/core/platform:framework_lite_hdrs",
558        "//tensorflow/tsl/platform/default:integral_types.h",
559        "//tensorflow/tsl/platform/default:logging.h",
560    ],
561    visibility = ["//visibility:public"],
562    deps =
563        # copybara:uncomment_begin
564        # if_mobile(["@nsync//:nsync_cpp"]) +
565        # copybara:uncomment_end_uncomment_begin
566        # ["@nsync//:nsync_cpp"] +
567        # copybara:comment_end
568        [
569            "//third_party/eigen3",
570            "//tensorflow/core/platform:dynamic_annotations",
571            "//tensorflow/core/platform:platform_port",
572            "//tensorflow/core/platform:thread_annotations",
573            "//tensorflow/core/platform:mutex",
574            "//tensorflow/tsl/platform/default/build_config:minimal",
575            "//tensorflow/core/platform:types",
576        ],
577)
578
579# One target for all user ops.
580alias(
581    name = "user_ops_op_lib",
582    actual = "//tensorflow/core/user_ops:user_ops_op_lib",
583    visibility = ["//visibility:public"],
584)
585
586cc_library(
587    name = "ops",
588    visibility = ["//visibility:public"],
589    deps = [
590        ":user_ops_op_lib",
591        "//tensorflow/c/kernels:bitcast_op_lib",
592        "//tensorflow/c/kernels:histogram_summary_op_lib",
593        "//tensorflow/c/kernels:merge_summary_op_lib",
594        "//tensorflow/c/kernels:summary_op_lib",
595        "//tensorflow/core/ops:ops",
596        "//tensorflow/dtensor/cc:dtensor_ops",
597    ] + select({
598        # Non-tpu platforms don't need tpu dependency.
599        "//tensorflow:chromiumos": [],
600        "//tensorflow:fuchsia": [],
601        "//conditions:default": [
602            "//tensorflow/core/tpu/ops",
603            "//tensorflow/dtensor/cc:dtensor_tpu_ops",
604        ],
605    }) + if_tensorrt([
606        "//tensorflow/compiler/tf2tensorrt:trt_engine_resource_ops_op_lib",
607        "//tensorflow/compiler/tf2tensorrt:trt_op_libs",
608    ]) + if_libtpu(
609        if_false = ["//tensorflow/compiler/mlir/tensorflow:mlir_passthrough_op"],
610        if_true = [],
611    ),
612)
613
614alias(
615    name = "core_cpu",
616    actual = "//tensorflow/core/common_runtime:core_cpu",
617    visibility = ["//visibility:public"],
618)
619
620alias(
621    name = "core",
622    actual =
623        "//tensorflow/core/common_runtime:core",
624    visibility = ["//visibility:public"],
625)
626
627# This includes implementations of all kernels built into TensorFlow.
628cc_library(
629    name = "all_kernels_impl",
630    visibility = [":__subpackages__"],
631    deps = [
632        "//tensorflow/c/kernels:bitcast_op",
633        "//tensorflow/c/kernels:histogram_summary_op",
634        "//tensorflow/c/kernels:merge_summary_op",
635        "//tensorflow/c/kernels:summary_op",
636        "//tensorflow/core/kernels:array",
637        "//tensorflow/core/kernels:audio",
638        "//tensorflow/core/kernels:batch_kernels",
639        "//tensorflow/core/kernels:bincount_op",
640        "//tensorflow/core/kernels:boosted_trees_ops",
641        "//tensorflow/core/kernels:candidate_sampler_ops",
642        "//tensorflow/core/kernels:checkpoint_ops",
643        "//tensorflow/core/kernels:clustering_ops",
644        "//tensorflow/core/kernels:collective_ops",
645        "//tensorflow/core/kernels:constant_op",
646        "//tensorflow/core/kernels:control_flow_ops",
647        "//tensorflow/core/kernels:count_ops",
648        "//tensorflow/core/kernels:ctc_ops",
649        "//tensorflow/core/kernels:data_flow",
650        "//tensorflow/core/kernels:decode_proto_op",
651        "//tensorflow/core/kernels:encode_proto_op",
652        "//tensorflow/core/kernels:composite_tensor_ops",
653        "//tensorflow/core/kernels:fact_op",
654        "//tensorflow/core/kernels:fake_quant_ops",
655        "//tensorflow/core/kernels:filesystem_ops",
656        "//tensorflow/core/kernels:function_ops",
657        "//tensorflow/core/kernels:functional_ops",
658        "//tensorflow/core/kernels:grappler",
659        "//tensorflow/core/kernels:histogram_op",
660        "//tensorflow/core/kernels:io",
661        "//tensorflow/core/kernels:isotonic_regression_op",
662        "//tensorflow/core/kernels:lookup",
663        "//tensorflow/core/kernels:logging",
664        "//tensorflow/core/kernels:manip",
665        "//tensorflow/core/kernels:math",
666        "//tensorflow/core/kernels:multinomial_op",
667        "//tensorflow/core/kernels:mutex_ops",
668        "//tensorflow/core/kernels:nn",
669        "//tensorflow/core/kernels:parameterized_truncated_normal_op",
670        "//tensorflow/core/kernels:parsing",
671        "//tensorflow/core/kernels:partitioned_function_ops",
672        "//tensorflow/core/kernels:pooling_ops",
673        "//tensorflow/core/kernels:quantized_ops",
674        "//tensorflow/core/kernels:ragged_ops",
675        "//tensorflow/core/kernels:random_index_shuffle_ops",
676        "//tensorflow/core/kernels:random_ops",
677        "//tensorflow/core/kernels:stateful_random_ops",
678        "//tensorflow/core/kernels:random_binomial_op",
679        "//tensorflow/core/kernels:random_poisson_op",
680        "//tensorflow/core/kernels:required",
681        "//tensorflow/core/kernels:resource_variable_ops",
682        "//tensorflow/core/kernels:rnn_ops",
683        "//tensorflow/core/kernels:scoped_allocator_ops",
684        "//tensorflow/core/kernels:sdca_ops",
685        "//tensorflow/core/kernels:searchsorted_op",
686        "//tensorflow/core/kernels:set_kernels",
687        "//tensorflow/core/kernels:sparse",
688        "//tensorflow/core/kernels:state",
689        "//tensorflow/core/kernels:stateless_random_ops",
690        "//tensorflow/core/kernels:stateless_random_gamma_op",
691        "//tensorflow/core/kernels:stateless_shuffle",
692        "//tensorflow/core/kernels:string",
693        "//tensorflow/core/kernels:summary_kernels",
694        "//tensorflow/core/kernels:training_ops",
695        "//tensorflow/core/kernels/uniform_quant_ops:kernels",
696        "//tensorflow/core/kernels:word2vec_kernels",
697        "//tensorflow/core/kernels/linalg:linalg",
698        "//tensorflow/core/kernels/image:image",
699        "//tensorflow/core/kernels/sparse:kernels",
700        "//tensorflow/dtensor/cc:dtensor_kernels",
701    ] + if_mkl([
702        "//tensorflow/core/kernels/mkl:mkl_aggregate_ops",
703        "//tensorflow/core/kernels/mkl:mkl_concat_op",
704        "//tensorflow/core/kernels/mkl:mkl_dequantize_op",
705        "//tensorflow/core/kernels/mkl:mkl_conv_op",
706        "//tensorflow/core/kernels/mkl:mkl_cwise_ops_common",
707        "//tensorflow/core/kernels/mkl:mkl_fused_batch_norm_op",
708        "//tensorflow/core/kernels/mkl:mkl_identity_op",
709        "//tensorflow/core/kernels/mkl:mkl_input_conversion_op",
710        "//tensorflow/core/kernels/mkl:mkl_layer_norm_op",
711        "//tensorflow/core/kernels/mkl:mkl_lrn_op",
712        "//tensorflow/core/kernels/mkl:mkl_pooling_ops",
713        "//tensorflow/core/kernels/mkl:mkl_qmatmul_op",
714        "//tensorflow/core/kernels/mkl:mkl_requantize_ops",
715        "//tensorflow/core/kernels/mkl:mkl_quantize_op",
716        "//tensorflow/core/kernels/mkl:mkl_relu_op",
717        "//tensorflow/core/kernels/mkl:mkl_reshape_op",
718        "//tensorflow/core/kernels/mkl:mkl_slice_op",
719        "//tensorflow/core/kernels/mkl:mkl_softmax_op",
720        "//tensorflow/core/kernels/mkl:mkl_swish_op",
721        "//tensorflow/core/kernels/mkl:mkl_fused_mish_op",
722        "//tensorflow/core/kernels/mkl:mkl_transpose_op",
723        "//tensorflow/core/kernels/mkl:mkl_batch_matmul_op",
724        "//tensorflow/core/kernels/mkl:mkl_einsum_op",
725        "//tensorflow/core/kernels/mkl:mkl_matmul_op",
726        "//tensorflow/core/kernels/mkl:mkl_tfconv_op",
727        "//tensorflow/core/kernels/mkl:mkl_tmp_bf16_ops",
728    ]) + if_cuda_or_rocm([
729        "//tensorflow/core/kernels:cudnn_rnn_kernels",
730    ]) + if_cuda([
731        "//tensorflow/core/grappler/optimizers:gpu_swapping_kernels",
732        "//tensorflow/core/grappler/optimizers:gpu_swapping_ops",
733    ]) + if_nccl([
734        "//tensorflow/core/kernels:nccl_kernels",
735    ]) + if_tensorrt([
736        "//tensorflow/compiler/tf2tensorrt:trt_engine_resource_op_kernels",
737        "//tensorflow/compiler/tf2tensorrt:trt_op_kernels",
738    ]) + tf_tpu_dependencies() + tf_dtensor_tpu_dependencies(),
739)
740
741cc_library(
742    name = "dynamic_kernels_impl",
743    visibility = [":__subpackages__"],
744    deps = [
745        "//tensorflow/core/kernels:sobol_op",
746    ],
747)
748
749cc_library(
750    name = "all_kernels",
751    visibility = ["//visibility:public"],
752    deps = if_dynamic_kernels(
753        [],
754        otherwise = [":dynamic_kernels_impl"],
755    ) + [
756        # TODO(gunan): Split this up and load the resulting kernels dynamically once
757        # the dependency issues are resolved.
758        ":all_kernels_impl",
759        # TODO(gunan): Work on the API between these and rest of TF and make
760        # these also dynamically loading.
761        "//tensorflow/core/kernels:dataset_ops",  # Depends on grappler
762        "//tensorflow/core/kernels:list_kernels",  # Depends on variant_op_registry.h
763        "//tensorflow/core/kernels:map_kernels",
764        "//tensorflow/core/kernels:tensor_map",
765    ],
766)
767
768tf_cuda_library(
769    name = "tensorflow_opensource",
770    copts = tf_copts(),
771    visibility = ["//visibility:public"],
772    deps = [
773        ":all_kernels",
774        ":core",
775        ":direct_session",
776        ":example_parser_configuration",
777        ":gpu_runtime",
778        ":lib",
779        ":ops",
780    ] + tensorflow_opensource_extra_deps(),
781)
782
783cc_library(
784    name = "tensorflow",
785    visibility = ["//visibility:public"],
786    deps = [
787        ":tensorflow_opensource",
788        "//tensorflow/tsl/platform/default/build_config:tensorflow_platform_specific",
789    ],
790)
791
792cc_library(
793    name = "distributed_tensorflow_dependencies",
794    visibility = ["//visibility:public"],
795    deps = [
796        "//tensorflow/core/distributed_runtime/rpc:grpc_session",
797        "//tensorflow/core/kernels:data_service_ops",
798        "//tensorflow/distribute/experimental/rpc/kernels:rpc_ops",
799    ],
800)
801
802cc_library(
803    name = "testlib_kernels_impl",
804    deps = [
805        "//tensorflow/core/kernels:aggregate_ops",
806        "//tensorflow/core/kernels:bcast_ops",
807        "//tensorflow/core/kernels:cast_op",
808        "//tensorflow/core/kernels:constant_op",
809        "//tensorflow/core/kernels:host_constant_op",
810        "//tensorflow/core/kernels:identity_op",
811        "//tensorflow/core/kernels:random_ops",
812        "//tensorflow/core/kernels:reduction_ops",
813        "//tensorflow/core/kernels:reshape_op",
814    ],
815)
816
817# Test support library needed for higher-level (TensorFlow-specific) tests
818tf_cuda_library(
819    name = "testlib",
820    testonly = 1,
821    srcs = [
822        "//tensorflow/core/common_runtime:testlib_srcs",
823        "//tensorflow/core/graph:testlib_srcs",
824    ],
825    hdrs = [
826        "//tensorflow/core/common_runtime:testlib_headers",
827        "//tensorflow/core/graph:testlib_headers",
828        # TODO(josh11b): Drop this once users are depending on
829        # kernels:ops_testutil instead.
830        "//tensorflow/core/kernels:ops_testutil.h",
831        # TODO(gonnet): Stop exporting these headers once users depend on
832        # the tensorflow/core/framework:* targets directly.
833        "//tensorflow/core/framework:shape_inference_testutil.h",
834        "//tensorflow/core/framework:tensor_testutil.h",
835        "//tensorflow/core/framework:fake_input.h",
836        "//tensorflow/core/framework:function_testlib.h",
837    ],
838    copts = tf_copts(),
839    visibility = ["//visibility:public"],
840    deps = [
841        ":core_cpu",
842        ":core_cpu_internal",
843        ":core_cpu_lib",
844        ":framework",
845        ":framework_internal",
846        ":lib",
847        ":lib_internal",
848        ":ops",
849        ":protos_all_cc",
850        ":test",
851        # TODO(gunan): resolve dependency issues and load these kernels dynamically.
852        ":testlib_kernels_impl",
853        "//tensorflow/cc:scope",
854        "//tensorflow/core/common_runtime:testlib_ops",
855        "//tensorflow/core/framework:fake_input",
856        "//tensorflow/core/framework:function_testlib",
857        "//tensorflow/core/framework:shape_inference_testutil",
858        "//tensorflow/core/framework:tensor_testutil",
859        "//tensorflow/core/kernels:ops_testutil",
860        "//tensorflow/core/kernels:ops_util",
861    ] + if_mkl(["//tensorflow/core/graph:mkl_graph_util"]),
862)
863
864# This is a link-only library to provide a DirectSession
865# implementation of the Session interface.
866tf_cuda_library(
867    name = "direct_session",
868    copts = tf_copts(),
869    linkstatic = 1,
870    visibility = ["//visibility:public"],
871    deps = [
872        "//tensorflow/core/common_runtime:direct_session_internal",
873    ],
874    alwayslink = 1,
875)
876
877# -----------------------------------------------------------------------------
878# Public Android targets
879
880# Sources required to build the TensorFlow framework without the runtime on
881# mobile platforms. This is essentially the sources required to build
882# tensorflow/core/framework:tensor without using granular targets.
883filegroup(
884    name = "mobile_srcs_no_runtime",
885    srcs = [
886        "//tensorflow/compiler/jit:mobile_srcs_no_runtime",
887        "//tensorflow/core/activity_watcher:activity_watcher_headers",
888        "//tensorflow/core/example:mobile_srcs_no_runtime",
889        "//tensorflow/core/framework:attr_value_proto_text_srcs",
890        "//tensorflow/core/framework:mobile_srcs_no_runtime",
891        "//tensorflow/core/lib/core:mobile_srcs_no_runtime",
892        "//tensorflow/core/lib/gtl:mobile_srcs_no_runtime",
893        "//tensorflow/core/lib/hash:mobile_srcs_no_runtime",
894        "//tensorflow/core/lib/strings:mobile_srcs_no_runtime",
895        "//tensorflow/core/platform:mobile_srcs_no_runtime",
896        "//tensorflow/core/public:mobile_srcs_no_runtime",
897        "//tensorflow/core/util:mobile_srcs_no_runtime",
898        "//tensorflow/core/util/ctc:mobile_srcs",
899        "//tensorflow/core/profiler:mobile_srcs_no_runtime",
900    ] + glob(
901        [
902            "client/**/*.cc",
903        ],
904        exclude = [
905            "**/*test.*",
906            "**/*testutil*",
907            "**/*testlib*",
908            "**/*main.cc",
909        ],
910    ),
911    visibility = ["//visibility:public"],
912)
913
914# Sources required to build the TensorFlow framework with runtime on
915# mobile platforms without granular targets. It is assumed that the source
916# files in tensorflow/core:mobile_srcs_no_runtime have been compiled
917# separately and are linked in as a dependency.
918filegroup(
919    name = "mobile_srcs_only_runtime",
920    srcs = [
921        # Sources for which we do not yet have granular targets.
922        "//tensorflow/c/eager:srcs",
923        # StreamExecutor C API is currently not supported for mobile.
924        # Including just the header for SP_Stream reference in kernels C API.
925        "//tensorflow/c/experimental/stream_executor:headers",
926        "//tensorflow/c:srcs",
927        "//tensorflow/core/common_runtime:mobile_srcs_only_runtime",
928        "//tensorflow/core/common_runtime/eager:srcs",
929        "//tensorflow/core/framework:mobile_srcs_only_runtime",
930        "//tensorflow/core/graph:mobile_srcs_only_runtime",
931        "//tensorflow/core/kernels:mobile_srcs",
932        "//tensorflow/core/lib/io:mobile_srcs_only_runtime",
933        "//tensorflow/core/nccl:mobile_srcs",
934        "//tensorflow/core/profiler:mobile_srcs_only_runtime",
935        "//tensorflow/core/public:mobile_srcs_only_runtime",
936        "//tensorflow/core/util/sparse:mobile_srcs_only_runtime",
937        "//tensorflow/core/util/tensor_bundle:mobile_srcs",
938        "//tensorflow/core/util:mobile_srcs_only_runtime",
939
940        # Sources for which we already have granular targets.
941        "//tensorflow/core/lib/core:mobile_srcs_only_runtime",
942        "//tensorflow/core/lib/gtl:mobile_srcs_only_runtime",
943        "//tensorflow/core/lib/hash:mobile_srcs_only_runtime",
944        "//tensorflow/core/lib/histogram:mobile_srcs_only_runtime",
945        "//tensorflow/core/lib/math:mobile_srcs_only_runtime",
946        "//tensorflow/core/lib/monitoring:mobile_srcs_only_runtime",
947        "//tensorflow/core/lib/random:mobile_srcs_only_runtime",
948        "//tensorflow/core/lib/strings:mobile_srcs_only_runtime",
949        "//tensorflow/core/platform:mobile_srcs_only_runtime",
950
951        # Wav io files
952        "//tensorflow/core/lib/wav:wav_io.h",
953        "//tensorflow/core/lib/wav:wav_io.cc",
954    ],
955    visibility = ["//visibility:public"],
956)
957
958filegroup(
959    name = "mobile_srcs",
960    srcs = [
961        ":mobile_srcs_no_runtime",
962        ":mobile_srcs_only_runtime",
963    ],
964    visibility = ["//visibility:public"],
965)
966
967# All the aliases for stuff under ops/
968# Once the dependencies move to the real targets, remove the aliases here!
969
970[
971    alias(
972        name = "%s" % (name,),
973        actual = "//tensorflow/core/ops:%s" % (name,),
974        visibility = ["//visibility:public"],
975    )
976    for name in [
977        "array_grad",
978        "array_ops_op_lib",
979        "audio_ops_op_lib",
980        "batch_ops_op_lib",
981        "bitwise_ops_op_lib",
982        "boosted_trees_ops_op_lib",
983        "candidate_sampling_ops_op_lib",
984        "checkpoint_ops_op_lib",
985        "clustering_ops_op_lib",
986        "collective_ops_op_lib",
987        "control_flow_ops_op_lib",
988        "count_ops_op_lib",
989        "ctc_ops_op_lib",
990        "cudnn_rnn_ops_op_lib",
991        "data_flow_ops_op_lib",
992        "dataset_ops_op_lib",
993        "debug_ops_op_lib",
994        "decode_proto_ops_op_lib",
995        "encode_proto_ops_op_lib",
996        "experimental_dataset_ops_op_lib",
997        "filesystem_ops_op_lib",
998        "function_ops_op_lib",
999        "functional_grad",
1000        "functional_ops_op_lib",
1001        "image_ops_op_lib",
1002        "io_ops_op_lib",
1003        "linalg_ops_op_lib",
1004        "list_ops_op_lib",
1005        "logging_ops_op_lib",
1006        "lookup_ops_op_lib",
1007        "manip_ops_op_lib",
1008        "map_ops_op_lib",
1009        "math_grad",
1010        "math_ops_op_lib",
1011        "mkl_array_ops_op_lib",
1012        "mkl_nn_ops_op_lib",
1013        "nccl_ops_op_lib",
1014        "nn_grad",
1015        "nn_ops_op_lib",
1016        "no_op_op_lib",
1017        "parsing_ops_op_lib",
1018        "portable_op_registrations_and_gradients",
1019        "ragged_array_ops_op_lib",
1020        "ragged_conversion_ops_op_lib",
1021        "ragged_math_ops_op_lib",
1022        "ragged_ops",
1023        "composite_tensor_ops_op_lib",
1024        "random_grad_op_lib",
1025        "random_index_shuffle_ops_op_lib",
1026        "random_ops_op_lib",
1027        "resource_variable_ops_op_lib",
1028        "risc_ops_op_lib",
1029        "rnn_ops_op_lib",
1030        "scoped_allocator_ops_op_lib",
1031        "script_ops_op_lib",
1032        "sdca_ops_op_lib",
1033        "sendrecv_ops_op_lib",
1034        "set_ops_op_lib",
1035        "sparse_csr_matrix_ops_op_lib",
1036        "sparse_ops_op_lib",
1037        "special_math_ops_op_lib",
1038        "spectral_ops_op_lib",
1039        "state_ops_op_lib",
1040        "stateful_random_ops_op_lib",
1041        "stateless_random_ops_op_lib",
1042        "stateless_random_ops_v2_op_lib",
1043        "string_ops_op_lib",
1044        "summary_ops_op_lib",
1045        "tpu_configuration_ops_op_lib",
1046        "tpu_cross_replica_ops_op_lib",
1047        "tpu_embedding_ops_op_lib",
1048        "tpu_embedding_load_retrieve_ops_op_lib",
1049        "tpu_functional_ops_op_lib",
1050        "tpu_heartbeat_ops_op_lib",
1051        "tpu_host_compute_ops_op_lib",
1052        "tpu_infeed_ops_op_lib",
1053        "tpu_outfeed_ops_op_lib",
1054        "tpu_ordinal_selector_ops_op_lib",
1055        "tpu_replication_ops_op_lib",
1056        "tpu_sharding_util_ops_op_lib",
1057        "training_ops_op_lib",
1058        "uniform_quant_ops_op_lib",
1059        "word2vec_ops",
1060    ]
1061]
1062
1063# Native library support for mobile applications.  Does not contain
1064# operators, use :portable_tensorflow_lib if you want full operator
1065# support.
1066#
1067# If you just need TensorFlow types, e.g. Tensors, use
1068# :portable_tensorflow_lib_lite_no_runtime.
1069#
1070# These targets link against either full or lite protos depending
1071# on the bazel define TENSORFLOW_PROTOS=full/lite respectively.
1072#
1073# Compiles to a trivial library on non-mobile to prevent irrelevant
1074# build errors. If not building this e.g. as part of an android_binary,
1075# a command such as the following must be used:
1076# bazel build -c opt tensorflow/core:portable_tensorflow_lib \
1077# --define=TENSORFLOW_PROTOS=lite \
1078# --crosstool_top=//external:android/crosstool \
1079# --cpu=armeabi-v7a \
1080# --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
1081cc_library(
1082    name = "portable_tensorflow_lib_lite",
1083    srcs = if_mobile([":mobile_srcs"]),
1084    copts = tf_copts(android_optimization_level_override = None) + tf_opts_nortti_if_lite_protos() + if_ios(["-Os"]),
1085    defines = ["SUPPORT_SELECTIVE_REGISTRATION"] +
1086              select({
1087                  "//tensorflow:chromiumos": ["IS_MOBILE_PLATFORM"],
1088                  "//tensorflow:fuchsia": ["IS_MOBILE_PLATFORM"],
1089                  "//conditions:default": [],
1090              }) +
1091              tf_defines_nortti_if_lite_protos(),
1092    # Using private headers from other libraries violates layering check.
1093    features = ["-layering_check"],
1094    linkopts = if_android(["-lz"]) + if_ios(["-lz"]),
1095    tags = [
1096        "manual",
1097        "notap",
1098    ],
1099    visibility = ["//visibility:public"],
1100    deps = [
1101        "//tensorflow/core/util:stats_calculator_portable",
1102        "//tensorflow/core:mobile_additional_lib_deps",
1103    ] + tf_portable_proto_lib() + tf_portable_deps_no_runtime(),
1104    alwayslink = 1,
1105)
1106
1107# copybara:uncomment_begin(google-only)
1108# cc_library(
1109#     name = "portable_tensorflow_lib_lite_no_runtime",
1110#     srcs = if_mobile([":mobile_srcs_no_runtime"]),
1111#     copts = tf_copts(android_optimization_level_override = None) + tf_opts_nortti_if_lite_protos() + if_ios(["-Os"]),
1112#     defines = ["SUPPORT_SELECTIVE_REGISTRATION"] + select({
1113#         "//tensorflow:chromiumos": ["IS_MOBILE_PLATFORM"],
1114#         "//tensorflow:fuchsia": ["IS_MOBILE_PLATFORM"],
1115#         "//conditions:default": [],
1116#     }) + tf_defines_nortti_if_lite_protos() + select({
1117#         "//tensorflow:android": ["TF_USE_SNAPPY"],
1118#         "//conditions:default": [],
1119#     }),
1120#     features = ["-layering_check"],
1121#     tags = [
1122#         "manual",
1123#         "notap",
1124#     ],
1125#     visibility = ["//visibility:public"],
1126#     deps = [
1127#         "@com_google_absl//absl/algorithm:container",
1128#         "@com_google_absl//absl/base",
1129#         "@com_google_absl//absl/meta:type_traits",
1130#         "@com_google_absl//absl/strings",
1131#         "@com_google_absl//absl/types:optional",
1132#         "//tensorflow/core/util:managed_stack_trace",
1133#         "//tensorflow/core/util:stats_calculator_portable",
1134#         "//tensorflow/core:mobile_additional_lib_deps",
1135#     ] + tf_portable_proto_lib() + tf_portable_deps_no_runtime(),
1136#     alwayslink = 1,
1137# )
1138# copybara:uncomment_end
1139
1140cc_library(
1141    name = "mobile_additional_lib_deps",
1142    deps = tf_additional_lib_deps() + [
1143        ":platform_base",
1144        "@com_google_absl//absl/container:btree",
1145        "@com_google_absl//absl/status",
1146        "@com_google_absl//absl/container:flat_hash_map",
1147        "@com_google_absl//absl/container:flat_hash_set",
1148        "@com_google_absl//absl/strings",
1149    ],
1150)
1151
1152cc_library(
1153    name = "portable_tensorflow_lib",
1154    srcs = if_mobile([":portable_op_registrations_and_gradients"]),
1155    copts = tf_copts() + tf_opts_nortti_if_lite_protos() + if_ios(["-Os"]),
1156    # Using private headers from other libraries violates layering check.
1157    features = tf_features_nomodules_if_mobile() + ["-layering_check"],
1158    tags = [
1159        "manual",
1160        "notap",
1161    ],
1162    visibility = ["//visibility:public"],
1163    deps = [
1164        ":portable_tensorflow_lib_lite",
1165        ":protos_all_cc_impl",
1166        "//tensorflow/core/kernels:portable_tensorflow_kernels",
1167        "//third_party/eigen3",
1168        "@com_google_protobuf//:protobuf",
1169    ],
1170    alwayslink = 1,
1171)
1172
1173# This is like android_test_srcs, minus the things that are already in mobile_srcs.
1174filegroup(
1175    name = "android_test_srcs_no_core",
1176    testonly = 1,
1177    srcs = [
1178        "//tensorflow/core/framework:android_test_hdrs",
1179        "//tensorflow/core/framework:android_test_srcs_no_core",
1180        "//tensorflow/core/platform:android_test_srcs",
1181        "//tensorflow/core/util:android_test_srcs",
1182    ],
1183    visibility = ["//visibility:public"],
1184)
1185
1186# Portable library providing testing functionality for TensorFlow.
1187cc_library(
1188    name = "portable_tensorflow_test_lib",
1189    testonly = 1,
1190    srcs = if_mobile([
1191        ":android_test_srcs_no_core",
1192    ]),
1193    hdrs = [
1194        "//tensorflow/core/framework:android_test_hdrs",
1195        "//tensorflow/core/util:android_test_hdrs",
1196    ],
1197    copts = tf_copts(android_optimization_level_override = None) + if_ios(["-Os"]),
1198    features = tf_features_nomodules_if_mobile() + tf_opts_nortti_if_lite_protos(),
1199    tags = [
1200        "manual",
1201        "notap",
1202    ],
1203    visibility = ["//visibility:public"],
1204    deps = [
1205        ":portable_tensorflow_lib",
1206        "//tensorflow/core/kernels:portable_tensorflow_kernels",
1207        "//tensorflow/tsl/platform/default/build_config:gtest",
1208        "//third_party/eigen3",
1209    ],
1210)
1211
1212# -----------------------------------------------------------------------------
1213# Libraries with GPU facilities that are useful for writing kernels.
1214alias(
1215    name = "gpu_lib",
1216    actual =
1217        "//tensorflow/core/common_runtime/gpu:gpu_lib",
1218    visibility = ["//visibility:public"],
1219)
1220
1221alias(
1222    name = "gpu_headers_lib",
1223    actual =
1224        "//tensorflow/core/common_runtime/gpu:gpu_headers_lib",
1225    visibility = ["//visibility:public"],
1226)
1227
1228alias(
1229    name = "cuda",
1230    actual = "//tensorflow/core/common_runtime/gpu:cuda",
1231    visibility = ["//visibility:public"],
1232)
1233
1234# -----------------------------------------------------------------------------
1235# Clif-related proto libraries.
1236
1237# The following targets will be moved to core/example. The aliases are only temporary
1238# since moving existing users will require several CLs over several projects.
1239[
1240    [
1241        alias(
1242            name = "example_%s_pyclif%s" % (proto_name, target_suffix),
1243            actual = "//tensorflow/core/example:%s_pyclif%s" % (proto_name, target_suffix),
1244            visibility = ["//visibility:public"],
1245        )
1246        for target_suffix in [
1247            "",
1248            "_pb2",
1249        ]
1250    ]
1251    for proto_name in [
1252        "example",
1253        "feature",
1254    ]
1255]
1256
1257# -----------------------------------------------------------------------------
1258# Internal targets
1259filegroup(
1260    name = "lib_internal_private_headers",
1261    srcs = [
1262        "//tensorflow/core/platform:legacy_lib_internal_headers",
1263        "//tensorflow/core/platform:lib_internal_private_hdrs",
1264        "//tensorflow/core/lib/core:legacy_lib_core_all_headers",
1265        "//tensorflow/core/lib/gtl:legacy_lib_gtl_all_headers",
1266        "//tensorflow/core/lib/histogram:legacy_lib_histogram_all_headers",
1267        "//tensorflow/core/lib/hash:legacy_lib_hash_all_headers",
1268        "//tensorflow/core/lib/monitoring:legacy_lib_monitoring_all_headers",
1269        "//tensorflow/core/lib/io:legacy_lib_io_all_headers",
1270        "//tensorflow/core/lib/random:legacy_lib_random_all_headers",
1271        "//tensorflow/core/lib/strings:legacy_lib_strings_all_headers",
1272        "//tensorflow/core/lib/math:math_util.h",
1273    ] + glob(
1274        [
1275            "lib/**/*.h",
1276        ],
1277        exclude = [
1278            "**/*test*",
1279            "lib/gif/**/*",
1280            "lib/jpeg/**/*",
1281            "lib/png/**/*",
1282        ],
1283    ),
1284    visibility = ["//visibility:private"],
1285)
1286
1287filegroup(
1288    name = "lib_internal_public_headers",
1289    srcs = [
1290        "//tensorflow/core/lib/core:legacy_lib_internal_core_headers",
1291        "//tensorflow/core/lib/gtl:legacy_lib_internal_public_gtl_headers",
1292        "//tensorflow/core/lib/hash:legacy_lib_internal_public_headers",
1293        "//tensorflow/core/lib/io:legacy_lib_internal_public_headers",
1294        "//tensorflow/core/lib/llvm_rtti:legacy_lib_core_all_headers",
1295        "//tensorflow/core/lib/random:legacy_lib_internal_public_random_headers",
1296        "//tensorflow/core/lib/strings:legacy_lib_internal_public_string_headers",
1297        "//tensorflow/core/lib/wav:wav_io.h",
1298        "//tensorflow/core/platform:legacy_platform_lib_hdrs",
1299        "//tensorflow/core/platform:lib_internal_public_hdrs",
1300        "//tensorflow/core/util:lib_internal_public_hdrs",
1301    ],
1302    visibility = ["//visibility:private"],
1303)
1304
1305cc_library(
1306    name = "lib_internal",
1307    srcs = [":lib_internal_private_headers"],
1308    hdrs = [":lib_internal_public_headers"],
1309    copts = tf_copts(),
1310    linkopts = select({
1311        "//tensorflow:freebsd": [],
1312        "//tensorflow:windows": [],
1313        "//tensorflow:android": [],
1314        "//conditions:default": [
1315            "-ldl",
1316            "-lpthread",
1317        ],
1318    }),
1319    deps = tf_additional_lib_deps() + [
1320        "@com_google_absl//absl/meta:type_traits",
1321        "@com_google_absl//absl/strings",
1322        "@com_google_absl//absl/status",
1323        "//third_party/eigen3",
1324        "@com_google_absl//absl/base:core_headers",
1325        "//tensorflow/tsl/platform/default/build_config:platformlib",
1326    ] + if_static([":lib_internal_impl"]),
1327)
1328
1329# Until we can ditch config=monolithic on windows, we have to provide an always
1330# headers only library for pybind rules to depend on.
1331cc_library(
1332    name = "lib_headers_for_pybind",
1333    srcs = [":lib_internal_private_headers"],
1334    hdrs = [":lib_internal_public_headers"],
1335    copts = tf_copts(),
1336    linkopts = select({
1337        "//tensorflow:freebsd": [],
1338        "//tensorflow:windows": [],
1339        "//tensorflow:android": [],
1340        "//conditions:default": [
1341            "-ldl",
1342            "-lpthread",
1343        ],
1344    }),
1345    visibility = ["//tensorflow:internal"],
1346    deps = tf_additional_lib_deps() + [
1347        "@com_google_absl//absl/meta:type_traits",
1348        "@com_google_absl//absl/strings",
1349        "//third_party/eigen3",
1350        "@com_google_absl//absl/base:core_headers",
1351        "//tensorflow/tsl/platform/default/build_config:platformlib",
1352    ],
1353)
1354
1355cc_library(
1356    name = "lib_internal_impl",
1357    srcs = [
1358        ":lib_internal_private_headers",
1359        "//tensorflow/core/platform:legacy_lib_internal_srcs",
1360    ] + glob(
1361        [
1362            "lib/**/*.cc",
1363        ],
1364        exclude = [
1365            "**/*test*",
1366            "framework/variant.cc",
1367            "lib/gif/**/*",
1368            "lib/jpeg/**/*",
1369            "lib/png/**/*",
1370        ],
1371    ),
1372    hdrs = [":lib_internal_public_headers"],
1373    copts = tf_copts(),
1374    deps = tf_additional_lib_deps() + [
1375        ":core_stringpiece",
1376        ":lib_proto_parsing",
1377        "@com_google_absl//absl/memory",
1378        "@com_google_absl//absl/strings",
1379        "//third_party/eigen3",
1380        "//tensorflow/core/lib/core:arena",
1381        "//tensorflow/core/lib/core:bitmap",
1382        "//tensorflow/core/lib/core:blocking_counter",
1383        "//tensorflow/core/lib/core:bits",
1384        "//tensorflow/core/lib/core:coding",
1385        "//tensorflow/core/lib/core:errors",
1386        "//tensorflow/core/lib/core:notification",
1387        "//tensorflow/core/lib/core:raw_coding",
1388        "//tensorflow/core/lib/core:refcount",
1389        "//tensorflow/core/lib/core:status",
1390        "//tensorflow/core/lib/core:stringpiece",
1391        "//tensorflow/core/lib/core:threadpool",
1392        "//tensorflow/core/lib/core:threadpool_interface",
1393        "//tensorflow/core/lib/core:threadpool_options",
1394        "//tensorflow/core/lib/gtl:array_slice",
1395        "//tensorflow/core/lib/gtl:cleanup",
1396        "//tensorflow/core/lib/gtl:compactptrset",
1397        "//tensorflow/core/lib/gtl:edit_distance",
1398        "//tensorflow/core/lib/gtl:flatmap",
1399        "//tensorflow/core/lib/gtl:flatrep",
1400        "//tensorflow/core/lib/gtl:flatset",
1401        "//tensorflow/core/lib/gtl:inlined_vector",
1402        "//tensorflow/core/lib/gtl:int_type",
1403        "//tensorflow/core/lib/gtl:iterator_range",
1404        "//tensorflow/core/lib/gtl:manual_constructor",
1405        "//tensorflow/core/lib/gtl:map_util",
1406        "//tensorflow/core/lib/gtl:optional",
1407        "//tensorflow/core/lib/gtl:priority_queue_util",
1408        "//tensorflow/core/lib/gtl:top_n",
1409        "//tensorflow/core/lib/hash:crc32c",
1410        "//tensorflow/core/lib/hash",
1411        "//tensorflow/core/lib/histogram",
1412        "//tensorflow/core/lib/io:block",
1413        "//tensorflow/core/lib/io:buffered_inputstream",
1414        "//tensorflow/core/lib/io:compression",
1415        "//tensorflow/core/lib/io:inputbuffer",
1416        "//tensorflow/core/lib/io:inputstream_interface",
1417        "//tensorflow/core/lib/io:iterator",
1418        "//tensorflow/core/lib/io:path",
1419        "//tensorflow/core/lib/io:proto_encode_helper",
1420        "//tensorflow/core/lib/io:random_inputstream",
1421        "//tensorflow/core/lib/io:record_reader",
1422        "//tensorflow/core/lib/io:record_writer",
1423        "//tensorflow/core/lib/io:snappy_compression_options",
1424        "//tensorflow/core/lib/io:snappy_inputbuffer",
1425        "//tensorflow/core/lib/io:snappy_inputstream",
1426        "//tensorflow/core/lib/io:snappy_outputbuffer",
1427        "//tensorflow/core/lib/io:table",
1428        "//tensorflow/core/lib/io:table_options",
1429        "//tensorflow/core/lib/io:zlib_compression_options",
1430        "//tensorflow/core/lib/io:zlib_inputstream",
1431        "//tensorflow/core/lib/io:zlib_outputbuffer",
1432        "//tensorflow/core/lib/math:math_util",
1433        "//tensorflow/core/lib/wav:wav_io",
1434        "//tensorflow/core/lib/monitoring:collected_metrics",
1435        "//tensorflow/core/lib/monitoring:collection_registry",
1436        "//tensorflow/core/lib/monitoring:counter",
1437        "//tensorflow/core/lib/monitoring:gauge",
1438        "//tensorflow/core/lib/monitoring:metric_def",
1439        "//tensorflow/core/lib/monitoring:percentile_sampler",
1440        "//tensorflow/core/lib/monitoring:sampler",
1441        "//tensorflow/core/lib/monitoring:timed",
1442        "//tensorflow/core/lib/random:exact_uniform_int",
1443        "//tensorflow/core/lib/random:philox",
1444        "//tensorflow/core/lib/random:philox_random",
1445        "//tensorflow/core/lib/random",
1446        "//tensorflow/core/lib/random:weighted_picker",
1447        "//tensorflow/core/lib/strings:base64",
1448        "//tensorflow/core/lib/strings:numbers",
1449        "//tensorflow/core/lib/strings:ordered_code",
1450        "//tensorflow/core/lib/strings:proto_serialization",
1451        "//tensorflow/core/lib/strings:proto_text_util",
1452        "//tensorflow/core/lib/strings:scanner",
1453        "//tensorflow/core/lib/strings:str_util",
1454        "//tensorflow/core/lib/strings:strcat",
1455        "//tensorflow/core/lib/strings:stringprintf",
1456        "//tensorflow/core/platform:abi",
1457        "//tensorflow/core/platform:bfloat16",
1458        "//tensorflow/core/platform:base64",
1459        "//tensorflow/core/platform:blocking_counter",
1460        "//tensorflow/core/platform:casts",
1461        "//tensorflow/core/platform:coding",
1462        "//tensorflow/core/platform:context",
1463        "//tensorflow/core/platform:cord",
1464        "//tensorflow/core/platform:cpu_feature_guard",
1465        "//tensorflow/core/platform:denormal",
1466        "//tensorflow/core/platform:dynamic_annotations",
1467        "//tensorflow/core/platform:env",
1468        "//tensorflow/core/platform:env_impl",
1469        "//tensorflow/core/platform:errors",
1470        "//tensorflow/core/platform:file_statistics",
1471        "//tensorflow/core/platform:fingerprint",
1472        "//tensorflow/core/platform:hash",
1473        "//tensorflow/core/platform:load_library",
1474        "//tensorflow/core/platform:logger",
1475        "//tensorflow/core/platform:mutex",
1476        "//tensorflow/core/platform:notification",
1477        "//tensorflow/core/platform:net",
1478        "//tensorflow/core/platform:null_file_system",
1479        "//tensorflow/core/platform:numbers",
1480        "//tensorflow/core/platform:path",
1481        "//tensorflow/core/platform:platform_port",
1482        "//tensorflow/core/platform:platform_strings",
1483        "//tensorflow/core/platform:prefetch",
1484        "//tensorflow/core/platform:profile_utils_cpu_utils",
1485        "//tensorflow/core/platform:protobuf_internal",
1486        "//tensorflow/core/platform:regexp",
1487        "//tensorflow/core/platform:resource",
1488        "//tensorflow/core/platform:scanner",
1489        "//tensorflow/core/platform:setround",
1490        "//tensorflow/core/platform:stacktrace",
1491        "//tensorflow/core/platform:stacktrace_handler",
1492        "//tensorflow/core/platform:status",
1493        "//tensorflow/core/platform:statusor",
1494        "//tensorflow/core/platform:strcat",
1495        "//tensorflow/core/platform:stringpiece",
1496        "//tensorflow/core/platform:stringprintf",
1497        "//tensorflow/core/platform:strong_hash",
1498        "//tensorflow/core/platform:str_util",
1499        "//tensorflow/core/platform:tensor_coding",
1500        "//tensorflow/core/platform:thread_annotations",
1501        "//tensorflow/core/platform:threadpool_interface",
1502        "//tensorflow/core/platform:threadpool_options",
1503        "//tensorflow/core/platform:tracing",
1504        "//tensorflow/core/platform:tstring",
1505        "//tensorflow/core/platform:unbounded_work_queue",
1506        "//tensorflow/tsl/platform/default/build_config:platformlib",
1507        "//tensorflow/core/util:env_var",
1508        "//tensorflow/core/util:reporter",  # TODO(gunan): REMOVE as soon as cc_shared_library is supported.
1509        "@snappy",
1510        "@zlib",
1511        "@double_conversion//:double-conversion",
1512        "@com_google_protobuf//:protobuf",
1513    ] + select({
1514        "//tensorflow:fuchsia": [],
1515        "//conditions:default": ["//tensorflow/core/platform:subprocess"],
1516    }) + tf_protos_all_impl() + tf_protos_grappler_impl() + tf_protos_profiler_impl() + tf_monitoring_framework_deps(),
1517    # Alwayslink causes a cc_binary to "always link" in the
1518    # srcs for a given cc_library, even if they are unreferenced, see:
1519    # https://docs.bazel.build/versions/master/be/c-cpp.html#cc_library.alwayslink
1520    # tensorflow/core:lib_internal_impl has alwayslink set so that libtensorflow_framework.so
1521    # contains all of the srcs within lib_internal_impl.
1522    # NOTE(bmzhao): As we refactor tensorflow's BUILD files to more granular targets,
1523    # we've removed srcs from core:lib_internal_impl, and have added deps on these
1524    # granular targets instead. Since alwayslink doesn't apply to these deps,
1525    # we will sometimes need to add alwayslink to the granular libraries instead.
1526    # Ideally, this will be resolved once bazel has full cc_shared_library support.
1527    alwayslink = 1,
1528)
1529
1530alias(
1531    name = "gif_internal",
1532    actual = "//tensorflow/core/lib/gif:gif_internal",
1533)
1534
1535alias(
1536    name = "jpeg_internal",
1537    actual = "//tensorflow/core/lib/jpeg:jpeg_internal",
1538)
1539
1540cc_library(
1541    name = "tflite_portable_logging",
1542    hdrs = [
1543        "//tensorflow/core/platform:tflite_portable_logging_hdrs",
1544        "//tensorflow/tsl/platform/default:integral_types.h",
1545        "//tensorflow/tsl/platform/default:logging.h",
1546    ],
1547    compatible_with = get_compatible_with_portable(),
1548    copts = tf_copts(),
1549    linkopts = select({
1550        "//tensorflow:freebsd": [],
1551        "//tensorflow:windows": [],
1552        "//conditions:default": [
1553            "-ldl",
1554        ],
1555    }),
1556    visibility = ["//visibility:public"],
1557    deps = [
1558        ":platform_base",
1559        "//tensorflow/core/platform:logging",
1560    ],
1561)
1562
1563alias(
1564    name = "portable_jpeg_internal",
1565    actual = "//tensorflow/core/lib/jpeg:portable_jpeg_internal",
1566)
1567
1568alias(
1569    name = "portable_gif_internal",
1570    actual = "//tensorflow/core/lib/gif:portable_gif_internal",
1571)
1572
1573alias(
1574    name = "error_codes_proto_impl",
1575    actual = "//tensorflow/core/protobuf:error_codes_proto_impl",
1576)
1577
1578alias(
1579    name = "error_codes_proto_impl_cc",
1580    actual = "//tensorflow/core/protobuf:error_codes_proto_impl_cc",
1581)
1582
1583# copybara:uncomment_begin(google-only)
1584# alias(
1585#     name = "error_codes_proto",
1586#     actual = "//tensorflow/core/lib/core:error_codes_proto",
1587# )
1588# copybara:uncomment_end
1589
1590alias(
1591    name = "version_lib",
1592    actual = "//tensorflow/core/util:version_info",
1593)
1594
1595filegroup(
1596    name = "framework_internal_private_headers",
1597    srcs = [
1598        "//tensorflow/core/example:feature_util.h",
1599        "//tensorflow/core/framework:framework_internal_private_hdrs",
1600        "//tensorflow/core/graph:framework_internal_private_headers",
1601        "//tensorflow/core/public:session_options.h",
1602        "//tensorflow/core/public:version.h",
1603        "//tensorflow/core/util:framework_internal_private_hdrs",
1604        "//tensorflow/core/util:memmapped_file_system_hdrs",
1605        "//tensorflow/core/util/sparse:framework_internal_private_headers_group",
1606    ],
1607    visibility = ["//visibility:private"],
1608)
1609
1610filegroup(
1611    name = "framework_internal_public_headers",
1612    srcs = [
1613        "//tensorflow/core/framework:model.h",
1614        "//tensorflow/core/framework:op_segment.h",
1615        "//tensorflow/core/framework:ref_var.h",
1616        "//tensorflow/core/framework:rendezvous.h",  # only needed for tests
1617        "//tensorflow/core/framework:resource_var.h",
1618        "//tensorflow/core/framework:run_handler.h",
1619        "//tensorflow/core/framework:run_handler_util.h",
1620        "//tensorflow/core/framework:shared_ptr_variant.h",
1621        "//tensorflow/core/framework:tensor_reference.h",
1622        "//tensorflow/core/framework:tracking_allocator.h",  # only needed for tests
1623        "//tensorflow/core/framework:variant.h",
1624        "//tensorflow/core/util:framework_internal_public_hdrs",
1625    ],
1626    visibility = ["//visibility:private"],
1627)
1628
1629tf_cuda_library(
1630    name = "framework_internal",
1631    srcs = [":framework_internal_private_headers"],
1632    hdrs = [":framework_internal_public_headers"],
1633    deps = [
1634        ":framework_internal_headers_lib",
1635        "//third_party/eigen3",
1636        ":lib",
1637    ] + if_static(
1638        extra_deps = [
1639            ":framework_internal_impl",
1640            "@com_google_protobuf//:protobuf",
1641        ],
1642        otherwise = [
1643            "//tensorflow/core/util:managed_stack_trace",
1644            "@com_google_protobuf//:protobuf_headers",
1645        ],
1646    ),
1647    alwayslink = 1,
1648)
1649
1650cc_header_only_library(
1651    name = "framework_internal_headers_lib",
1652    # Fully depend on external repositories, because identifying the headers
1653    # is fragile.
1654    extra_deps = [
1655        "@com_google_absl//absl/strings",
1656        "@com_google_absl//absl/types:span",
1657    ],
1658    deps = [
1659        ":lib",
1660        ":lib_internal",
1661        "//tensorflow/core/framework:bounds_check",
1662        "//tensorflow/tsl/platform/default/build_config:platformlib",
1663    ],
1664)
1665
1666tf_cuda_library(
1667    name = "framework_internal_impl",
1668    srcs = [
1669        ":framework_internal_private_headers",
1670        "//tensorflow/core/framework:framework_internal_impl_srcs",
1671        "//tensorflow/core/graph:framework_internal_impl_srcs",
1672        "//tensorflow/core/util:framework_internal_impl_srcs",
1673        "//tensorflow/core/util:memmapped_file_system_srcs",
1674        "//tensorflow/core/util/sparse:framework_internal_impl_group",
1675    ] + glob(
1676        [
1677        ],
1678        exclude = [
1679            "**/*test*",
1680            "**/*main.cc",
1681        ],
1682    ),
1683    hdrs = [":framework_internal_public_headers"],
1684    copts = tf_copts(),
1685    linkopts = select({
1686        "//tensorflow:freebsd": ["-lm"],
1687        "//tensorflow:windows": [],
1688        "//conditions:default": [
1689            "-ldl",
1690            "-lm",
1691        ],
1692    }),
1693    deps = [
1694        ":feature_util",
1695        ":lib",
1696        ":lib_internal",
1697        ":protos_all_cc",
1698        "@com_google_absl//absl/base",
1699        "@com_google_absl//absl/container:flat_hash_map",
1700        "@com_google_absl//absl/container:flat_hash_set",
1701        "@com_google_absl//absl/memory",
1702        "@com_google_absl//absl/strings",
1703        "@com_google_absl//absl/synchronization",
1704        "@com_google_absl//absl/time",
1705        "//third_party/eigen3",
1706        "//tensorflow/core/example:feature_util",
1707        "//tensorflow/core/framework:allocator",
1708        "//tensorflow/core/framework:allocator_registry_impl",
1709        "//tensorflow/core/framework:attr_value_proto_text",
1710        "//tensorflow/core/framework:attr_value_util",
1711        "//tensorflow/core/framework:bfloat16",
1712        "//tensorflow/core/framework:bounds_check",
1713        "//tensorflow/core/framework:common_shape_fns",
1714        "//tensorflow/core/framework:kernel_shape_util",
1715        "//tensorflow/core/framework:node_def_util",
1716        "//tensorflow/core/framework:node_properties",
1717        "//tensorflow/core/framework:numeric_types",
1718        "//tensorflow/core/framework:op",
1719        "//tensorflow/core/framework:op_def_builder",
1720        "//tensorflow/core/framework:op_def_util",
1721        "//tensorflow/core/framework:resource_handle",
1722        "//tensorflow/core/framework/registration",
1723        "//tensorflow/core/framework:shape_inference",
1724        "//tensorflow/core/framework:tensor",
1725        "//tensorflow/core/framework:tensor_shape",
1726        "//tensorflow/core/platform:env_impl",
1727        "//tensorflow/core/platform:fingerprint",
1728        "//tensorflow/tsl/platform/default/build_config:platformlib",
1729        "//tensorflow/core/profiler/lib:annotated_traceme",
1730        "//tensorflow/core/profiler/lib:scoped_memory_debug_annotation",
1731        "//tensorflow/core/profiler/lib:traceme",
1732        "//tensorflow/core/util:determinism",
1733        "//tensorflow/core/util:managed_stack_trace",
1734        "//tensorflow/core/util:einsum_op_util",
1735        "//tensorflow/core/util:padding",
1736        "//tensorflow/core/util:port",
1737        "//tensorflow/core/util:stats_calculator_portable",
1738        "//tensorflow/core/util:tensor_format",
1739        "//tensorflow/compiler/jit:common",
1740        "@com_google_absl//absl/container:btree",
1741    ] + if_cuda([
1742        "@local_config_cuda//cuda:cudnn_header",
1743    ]) + if_static(
1744        extra_deps = ["@com_google_protobuf//:protobuf"],
1745        otherwise = ["@com_google_protobuf//:protobuf_headers"],
1746    ),
1747    alwayslink = 1,
1748)
1749
1750cc_header_only_library(
1751    name = "framework_headers_lib",
1752    # Fully depend on external repositories, because identifying the headers
1753    # is fragile.
1754    extra_deps = [
1755        "@com_google_absl//absl/strings",
1756        "@com_google_absl//absl/types:span",
1757    ],
1758    visibility = ["//visibility:public"],
1759    deps = [
1760        ":framework",
1761        "//tensorflow/core/framework:reader_base",
1762    ],
1763)
1764
1765cc_header_only_library(
1766    name = "stream_executor_headers_lib",
1767    # Fully depend on external repositories, because identifying the headers
1768    # is fragile.
1769    extra_deps = [
1770        "@com_google_absl//absl/strings",
1771        "@com_google_absl//absl/types:span",
1772    ],
1773    visibility = ["//visibility:public"],
1774    deps = [
1775        "//tensorflow/core/platform:stream_executor",
1776    ],
1777)
1778
1779# Like stream_executor library, but compiles without --config=cuda
1780# and does not include any cuda dependencies.
1781alias(
1782    name = "stream_executor_no_cuda",
1783    actual = "//tensorflow/core/platform:stream_executor_no_cuda",
1784    visibility = ["//visibility:public"],
1785)
1786
1787alias(
1788    name = "cuda_device_functions",
1789    actual = "//tensorflow/core/util:gpu_device_functions",
1790    visibility = ["//visibility:public"],
1791)
1792
1793# Library containing all of the graph construction code that is
1794# independent of the runtime.
1795tf_cuda_library(
1796    name = "graph",
1797    srcs = ["//tensorflow/core/graph:graph_srcs"],
1798    hdrs = ["//tensorflow/core/graph:graph_headers"],
1799    deps = [
1800        ":framework",
1801        ":framework_internal",
1802        ":lib",
1803        ":lib_internal",
1804        ":protos_all_cc",
1805        "//third_party/eigen3",
1806        "@com_google_absl//absl/container:flat_hash_map",
1807        "@com_google_absl//absl/container:flat_hash_set",
1808        "@com_google_absl//absl/strings",
1809    ],
1810)
1811
1812filegroup(
1813    name = "core_cpu_base_headers",
1814    srcs = [
1815        "//tensorflow/core/common_runtime:core_cpu_base_headers",
1816    ],
1817)
1818
1819tf_cuda_library(
1820    name = "core_cpu_base",
1821    hdrs = [
1822        ":core_cpu_base_headers",
1823        "//tensorflow/core/public:session.h",
1824    ],
1825    copts = tf_copts(),
1826    deps = ["//tensorflow/core/common_runtime:core_cpu_base_no_ops"] + if_static([
1827        ":function_ops_op_lib",
1828        ":functional_grad",
1829        ":functional_ops_op_lib",
1830        "//tensorflow/core/framework:bounds_check",
1831        "//tensorflow/core/kernels:required",
1832    ]),
1833    alwayslink = 1,
1834)
1835
1836alias(
1837    name = "core_cpu_lib",
1838    actual =
1839        "//tensorflow/core/common_runtime:core_cpu_lib",
1840)
1841
1842alias(
1843    name = "core_cpu_internal",
1844    actual =
1845        "//tensorflow/core/common_runtime:core_cpu_internal",
1846)
1847
1848alias(
1849    name = "direct_session_internal",
1850    actual =
1851        "//tensorflow/core/common_runtime:direct_session_internal",
1852)
1853
1854alias(
1855    name = "example_parser_configuration",
1856    actual = "//tensorflow/core/example:example_parser_configuration",
1857    visibility = ["//visibility:public"],
1858)
1859
1860alias(
1861    name = "gpu_runtime",
1862    actual =
1863        "//tensorflow/core/common_runtime/gpu:gpu_runtime",
1864)
1865
1866# -----------------------------------------------------------------------------
1867# Tests
1868
1869cc_library(
1870    name = "lib_test_internal",
1871    testonly = 1,
1872    hdrs = [
1873        "//tensorflow/core/lib/gtl:legacy_lib_test_internal_headers",
1874        "//tensorflow/core/lib/io:legacy_lib_test_internal_headers",
1875        "//tensorflow/core/lib/random:legacy_lib_test_internal_headers",
1876    ],
1877    deps = [
1878        ":lib",
1879        ":lib_internal",
1880    ],
1881)
1882
1883# Main program for tests
1884alias(
1885    name = "test_main",
1886    actual = "//tensorflow/core/platform:test_main",
1887    visibility = ["//tensorflow:internal"],
1888)
1889
1890tf_cc_tests(
1891    name = "low_level_library_tests",
1892    size = "small",
1893    srcs = [
1894        "//tensorflow/core/lib/core:legacy_lib_core_all_tests",
1895        "//tensorflow/core/lib/gtl:legacy_lib_gtl_tests",
1896        "//tensorflow/core/lib/hash:legacy_lib_hash_all_tests",
1897        "//tensorflow/core/lib/histogram:legacy_lib_histogram_all_tests",
1898        "//tensorflow/core/lib/io:legacy_lib_io_all_tests",
1899        "//tensorflow/core/lib/math:math_util_test.cc",
1900        "//tensorflow/core/lib/monitoring:collection_registry_test.cc",
1901        "//tensorflow/core/lib/monitoring:counter_test.cc",
1902        "//tensorflow/core/lib/monitoring:gauge_test.cc",
1903        "//tensorflow/core/lib/monitoring:metric_def_test.cc",
1904        "//tensorflow/core/lib/monitoring:percentile_sampler_test.cc",
1905        "//tensorflow/core/lib/monitoring:sampler_test.cc",
1906        "//tensorflow/core/lib/random:legacy_lib_random_tests",
1907        "//tensorflow/core/lib/strings:legacy_low_level_library_tests",
1908        "//tensorflow/core/lib/wav:wav_io_test.cc",
1909    ],
1910    deps = [
1911        ":lib",
1912        ":lib_internal",
1913        ":lib_test_internal",
1914        ":protos_all_cc",
1915        ":test",
1916        ":test_main",
1917        "//tensorflow/core/platform:scanner",
1918        "//tensorflow/core/platform:str_util",
1919        "//tensorflow/core/platform:strcat",
1920        "//tensorflow/core/platform:stringpiece",
1921        "//tensorflow/core/platform:stringprintf",
1922        "//third_party/eigen3",
1923        "@com_google_absl//absl/strings",
1924        "@com_google_absl//absl/synchronization",
1925        "@com_google_absl//absl/types:optional",
1926        "@zlib",
1927    ],
1928)
1929
1930tf_cc_tests(
1931    name = "cell_reader_test",
1932    size = "small",
1933    srcs = [
1934        "//tensorflow/core/lib/monitoring:cell_reader_test.cc",
1935        "//tensorflow/core/lib/monitoring:test_utils_test.cc",
1936    ],
1937    deps = [
1938        ":test",
1939        ":test_main",
1940        "//tensorflow/core:protos_all_cc",
1941        "//tensorflow/core/lib/monitoring:cell_reader",
1942        "//tensorflow/core/lib/monitoring:counter",
1943        "//tensorflow/core/lib/monitoring:gauge",
1944        "//tensorflow/core/lib/monitoring:percentile_sampler",
1945        "//tensorflow/core/lib/monitoring:sampler",
1946        "//tensorflow/core/lib/monitoring:test_utils",
1947        "//tensorflow/core/lib/monitoring:types",
1948        "//tensorflow/core/platform:errors",
1949        "//tensorflow/core/platform:protobuf",
1950        "//tensorflow/core/platform:status",
1951        "//tensorflow/core/platform:status_matchers",
1952    ],
1953)
1954
1955tf_cc_test(
1956    name = "lib_random_random_distributions_test",
1957    srcs = ["//tensorflow/core/lib/random:legacy_lib_random_random_distributions_test"],
1958    tags = ["optonly"],
1959    deps = [
1960        ":lib",
1961        ":lib_internal",
1962        ":lib_test_internal",
1963        ":protos_all_cc",
1964        ":test",
1965        ":test_main",
1966        "//third_party/eigen3",
1967    ],
1968)
1969
1970tf_cc_test(
1971    name = "lib_strings_ordered_code_test",
1972    srcs = ["//tensorflow/core/lib/strings:legacy_strings_ordered_code_test"],
1973    extra_copts = ["$(STACK_FRAME_UNLIMITED)"],  # Tests initialize large vectors
1974    deps = [
1975        ":lib",
1976        ":lib_internal",
1977        ":test",
1978        ":test_main",
1979    ],
1980)
1981
1982tf_cc_test(
1983    name = "lib_strings_proto_serialization_test",
1984    srcs = ["//tensorflow/core/lib/strings:legacy_strings_proto_serialization_test"],
1985    deps = [
1986        ":lib",
1987        ":lib_internal",
1988        ":lib_test_internal",
1989        ":protos_all_cc",
1990        ":test",
1991        ":test_main",
1992        "@com_google_absl//absl/memory",
1993    ],
1994)
1995
1996tf_cc_test(
1997    name = "lib_random_weighted_picker_test",
1998    size = "medium",
1999    srcs = ["//tensorflow/core/lib/random:legacy_lib_random_random_weighted_picker_test"],
2000    deps = [
2001        ":lib",
2002        ":lib_internal",
2003        ":test",
2004        ":test_main",
2005    ],
2006)
2007
2008tf_cc_tests(
2009    name = "core_higher_level_tests",
2010    size = "small",
2011    srcs = [
2012        "//tensorflow/core/example:feature_util_test.cc",
2013        "//tensorflow/core/graph:algorithm_test.cc",
2014        "//tensorflow/core/graph:control_flow_test.cc",
2015        "//tensorflow/core/graph:costmodel_test.cc",
2016        "//tensorflow/core/graph:edgeset_test.cc",
2017        "//tensorflow/core/graph:graph_def_builder_test.cc",
2018        "//tensorflow/core/graph:graph_partition_test.cc",
2019        "//tensorflow/core/graph:graph_test.cc",
2020        "//tensorflow/core/graph:node_builder_test.cc",
2021        "//tensorflow/core/graph:optimizer_cse_test.cc",
2022        "//tensorflow/core/graph:subgraph_test.cc",
2023        "//tensorflow/core/graph:tensor_id_test.cc",
2024        "//tensorflow/core/graph:validate_test.cc",
2025        "//tensorflow/core/util/sparse:higher_level_tests_group",
2026    ],
2027    linkopts = select({
2028        "//tensorflow:macos": ["-headerpad_max_install_names"],
2029        "//conditions:default": [],
2030    }),
2031    linkstatic = tf_kernel_tests_linkstatic(),
2032    deps = [
2033        ":core",
2034        ":core_cpu",
2035        ":core_cpu_internal",
2036        ":direct_session_internal",
2037        ":framework",
2038        ":framework_internal",
2039        ":lib",
2040        ":lib_internal",
2041        ":ops",
2042        ":protos_all_cc",
2043        ":test",
2044        ":test_main",
2045        ":testlib",
2046        "//tensorflow/cc:cc_ops",
2047        "//tensorflow/cc:cc_ops_internal",
2048        "//tensorflow/cc:function_ops",
2049        "//tensorflow/cc:ops",
2050        "//tensorflow/cc:scope",
2051        "//tensorflow/cc:sendrecv_ops",
2052        "//tensorflow/cc:while_loop",
2053        "//tensorflow/core/kernels:ops_util",
2054        "//tensorflow/core/platform:regexp",
2055        "//tensorflow/core/util:protos_test_cc",
2056        "//third_party/eigen3",
2057        "@com_google_absl//absl/base",
2058        "@com_google_absl//absl/memory",
2059        "@com_google_absl//absl/strings",
2060    ],
2061)
2062
2063tf_cc_test_mkl(
2064    name = "mkl_related_tests",
2065    size = "small",
2066    srcs = [
2067        "//tensorflow/core/util:mkl_util_test_srcs",
2068    ],
2069    linkstatic = 1,
2070    deps = [
2071        ":core",
2072        ":core_cpu",
2073        ":core_cpu_internal",
2074        ":direct_session_internal",
2075        ":framework",
2076        ":framework_internal",
2077        ":lib",
2078        ":lib_internal",
2079        ":ops",
2080        ":protos_all_cc",
2081        ":test",
2082        ":test_main",
2083        ":testlib",
2084        "//tensorflow/cc:cc_ops",
2085        "//tensorflow/cc:scope",
2086        "//tensorflow/cc:sendrecv_ops",
2087        "//tensorflow/core/kernels:ops_util",
2088        "//third_party/eigen3",
2089    ] + if_mkl([
2090        "//tensorflow/core/kernels/mkl:mkl_aggregate_ops",
2091        "//tensorflow/core/kernels/mkl:mkl_batch_matmul_op",
2092        "//tensorflow/core/kernels/mkl:mkl_einsum_op",
2093        "//tensorflow/core/kernels/mkl:mkl_concat_op",
2094        "//tensorflow/core/kernels/mkl:mkl_conv_op",
2095        "//tensorflow/core/kernels/mkl:mkl_cwise_ops_common",
2096        "//tensorflow/core/kernels/mkl:mkl_dequantize_op",
2097        "//tensorflow/core/kernels/mkl:mkl_fused_batch_norm_op",
2098        "//tensorflow/core/kernels/mkl:mkl_identity_op",
2099        "//tensorflow/core/kernels/mkl:mkl_input_conversion_op",
2100        "//tensorflow/core/kernels/mkl:mkl_lrn_op",
2101        "//tensorflow/core/kernels/mkl:mkl_matmul_op",
2102        "//tensorflow/core/kernels/mkl:mkl_pooling_ops",
2103        "//tensorflow/core/kernels/mkl:mkl_qmatmul_op",
2104        "//tensorflow/core/kernels/mkl:mkl_quantize_op",
2105        "//tensorflow/core/kernels/mkl:mkl_relu_op",
2106        "//tensorflow/core/kernels/mkl:mkl_reshape_op",
2107        "//tensorflow/core/kernels/mkl:mkl_slice_op",
2108        "//tensorflow/core/kernels/mkl:mkl_softmax_op",
2109        "//tensorflow/core/kernels/mkl:mkl_tfconv_op",
2110        "//tensorflow/core/kernels/mkl:mkl_transpose_op",
2111        "//tensorflow/core/kernels/mkl:mkl_tmp_bf16_ops",
2112    ]),
2113)
2114
2115# Test data
2116filegroup(
2117    name = "image_testdata",
2118    srcs = [
2119        # PNG data
2120        "//tensorflow/core/lib/png:testdata",
2121        "//tensorflow/core/lib/ssim:testdata",
2122        "//tensorflow/core/lib/psnr:testdata",
2123        # JPEG data
2124        "//tensorflow/core/lib/jpeg/testdata",
2125        # GIF data
2126        "//tensorflow/core/lib/gif/testdata:gif_testdata",
2127        # BMP data
2128        "//tensorflow/core/lib/bmp:bmp_testdata",
2129    ],
2130    visibility = ["//visibility:public"],
2131)
2132
2133transitive_hdrs(
2134    name = "headers",
2135    visibility = ["//tensorflow:__subpackages__"],
2136    deps = [
2137        ":core",
2138        ":framework",
2139        ":lib",
2140        ":protos_all_cc",
2141        "//tensorflow/core/platform:platform_strings",
2142        "//tensorflow/core/platform:stream_executor",
2143    ],
2144)
2145
2146# copybara:uncomment_begin(google-only)
2147# py_proto_library(
2148#     name = "protos_all_py_pb2",
2149#     has_services = 0,
2150#     api_version = 2,
2151#     visibility = ["//visibility:public"],
2152#     deps = [":protos_all"],
2153# )
2154#
2155# alias(
2156#     name = "worker_service_cc_grpc_proto",
2157#     actual = "//tensorflow/core/protobuf:worker_service_cc_grpc_proto",
2158#     visibility = ["//tensorflow:internal"],
2159# )
2160#
2161# alias(
2162#     name = "master_service_cc_grpc_proto",
2163#     actual = "//tensorflow/core/protobuf:master_service_cc_grpc_proto",
2164#     visibility = ["//tensorflow:internal"],
2165# )
2166#
2167# go_library(
2168#     name = "protos_all_go_proto",
2169#     srcs = ["protos_all_go_proto.go"],
2170#     visibility = ["//visibility:public"],
2171#     deps = [
2172#         "//tensorflow/core/example:example_parser_configuration_go_proto",
2173#         "//tensorflow/core/example:example_protos_go_proto",
2174#         "//tensorflow/core/protobuf:for_core_protos_go_proto",
2175#         "//tensorflow/core/util:event_go_proto",
2176#         "//tensorflow/core/util:memmapped_file_system_go_proto",
2177#         "//tensorflow/core/util:saved_tensor_slice_go_proto",
2178#     ],
2179# )
2180# copybara:uncomment_end
2181