• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Platform-specific build configurations.
2
3load("@protobuf_archive//:protobuf.bzl", "proto_gen")
4load("//tensorflow:tensorflow.bzl", "if_not_mobile")
5load("//tensorflow:tensorflow.bzl", "if_windows")
6load("//tensorflow:tensorflow.bzl", "if_not_windows")
7load("//tensorflow/core:platform/default/build_config_root.bzl", "if_static")
8load("@local_config_cuda//cuda:build_defs.bzl", "if_cuda")
9load("@local_config_rocm//rocm:build_defs.bzl", "if_rocm")
10load(
11    "//third_party/mkl:build_defs.bzl",
12    "if_mkl_ml",
13)
14
15# Appends a suffix to a list of deps.
16def tf_deps(deps, suffix):
17    tf_deps = []
18
19    # If the package name is in shorthand form (ie: does not contain a ':'),
20    # expand it to the full name.
21    for dep in deps:
22        tf_dep = dep
23
24        if not ":" in dep:
25            dep_pieces = dep.split("/")
26            tf_dep += ":" + dep_pieces[len(dep_pieces) - 1]
27
28        tf_deps += [tf_dep + suffix]
29
30    return tf_deps
31
32# Modified from @cython//:Tools/rules.bzl
33def pyx_library(
34        name,
35        deps = [],
36        py_deps = [],
37        srcs = [],
38        testonly = None,
39        **kwargs):
40    """Compiles a group of .pyx / .pxd / .py files.
41
42    First runs Cython to create .cpp files for each input .pyx or .py + .pxd
43    pair. Then builds a shared object for each, passing "deps" to each cc_binary
44    rule (includes Python headers by default). Finally, creates a py_library rule
45    with the shared objects and any pure Python "srcs", with py_deps as its
46    dependencies; the shared objects can be imported like normal Python files.
47
48    Args:
49      name: Name for the rule.
50      deps: C/C++ dependencies of the Cython (e.g. Numpy headers).
51      py_deps: Pure Python dependencies of the final library.
52      srcs: .py, .pyx, or .pxd files to either compile or pass through.
53      **kwargs: Extra keyword arguments passed to the py_library.
54    """
55
56    # First filter out files that should be run compiled vs. passed through.
57    py_srcs = []
58    pyx_srcs = []
59    pxd_srcs = []
60    for src in srcs:
61        if src.endswith(".pyx") or (src.endswith(".py") and
62                                    src[:-3] + ".pxd" in srcs):
63            pyx_srcs.append(src)
64        elif src.endswith(".py"):
65            py_srcs.append(src)
66        else:
67            pxd_srcs.append(src)
68        if src.endswith("__init__.py"):
69            pxd_srcs.append(src)
70
71    # Invoke cython to produce the shared object libraries.
72    for filename in pyx_srcs:
73        native.genrule(
74            name = filename + "_cython_translation",
75            srcs = [filename],
76            outs = [filename.split(".")[0] + ".cpp"],
77            # Optionally use PYTHON_BIN_PATH on Linux platforms so that python 3
78            # works. Windows has issues with cython_binary so skip PYTHON_BIN_PATH.
79            cmd = "PYTHONHASHSEED=0 $(location @cython//:cython_binary) --cplus $(SRCS) --output-file $(OUTS)",
80            testonly = testonly,
81            tools = ["@cython//:cython_binary"] + pxd_srcs,
82        )
83
84    shared_objects = []
85    for src in pyx_srcs:
86        stem = src.split(".")[0]
87        shared_object_name = stem + ".so"
88        native.cc_binary(
89            name = shared_object_name,
90            srcs = [stem + ".cpp"],
91            deps = deps + ["@org_tensorflow//third_party/python_runtime:headers"],
92            linkshared = 1,
93            testonly = testonly,
94        )
95        shared_objects.append(shared_object_name)
96
97    # Now create a py_library with these shared objects as data.
98    native.py_library(
99        name = name,
100        srcs = py_srcs,
101        deps = py_deps,
102        srcs_version = "PY2AND3",
103        data = shared_objects,
104        testonly = testonly,
105        **kwargs
106    )
107
108def _proto_cc_hdrs(srcs, use_grpc_plugin = False):
109    ret = [s[:-len(".proto")] + ".pb.h" for s in srcs]
110    if use_grpc_plugin:
111        ret += [s[:-len(".proto")] + ".grpc.pb.h" for s in srcs]
112    return ret
113
114def _proto_cc_srcs(srcs, use_grpc_plugin = False):
115    ret = [s[:-len(".proto")] + ".pb.cc" for s in srcs]
116    if use_grpc_plugin:
117        ret += [s[:-len(".proto")] + ".grpc.pb.cc" for s in srcs]
118    return ret
119
120def _proto_py_outs(srcs, use_grpc_plugin = False):
121    ret = [s[:-len(".proto")] + "_pb2.py" for s in srcs]
122    if use_grpc_plugin:
123        ret += [s[:-len(".proto")] + "_pb2_grpc.py" for s in srcs]
124    return ret
125
126# Re-defined protocol buffer rule to allow building "header only" protocol
127# buffers, to avoid duplicate registrations. Also allows non-iterable cc_libs
128# containing select() statements.
129def cc_proto_library(
130        name,
131        srcs = [],
132        deps = [],
133        cc_libs = [],
134        include = None,
135        protoc = "@protobuf_archive//:protoc",
136        internal_bootstrap_hack = False,
137        use_grpc_plugin = False,
138        use_grpc_namespace = False,
139        default_header = False,
140        **kargs):
141    """Bazel rule to create a C++ protobuf library from proto source files.
142
143    Args:
144      name: the name of the cc_proto_library.
145      srcs: the .proto files of the cc_proto_library.
146      deps: a list of dependency labels; must be cc_proto_library.
147      cc_libs: a list of other cc_library targets depended by the generated
148          cc_library.
149      include: a string indicating the include path of the .proto files.
150      protoc: the label of the protocol compiler to generate the sources.
151      internal_bootstrap_hack: a flag indicate the cc_proto_library is used only
152          for bootstraping. When it is set to True, no files will be generated.
153          The rule will simply be a provider for .proto files, so that other
154          cc_proto_library can depend on it.
155      use_grpc_plugin: a flag to indicate whether to call the grpc C++ plugin
156          when processing the proto files.
157      default_header: Controls the naming of generated rules. If True, the `name`
158          rule will be header-only, and an _impl rule will contain the
159          implementation. Otherwise the header-only rule (name + "_headers_only")
160          must be referred to explicitly.
161      **kargs: other keyword arguments that are passed to cc_library.
162    """
163
164    includes = []
165    if include != None:
166        includes = [include]
167
168    if internal_bootstrap_hack:
169        # For pre-checked-in generated files, we add the internal_bootstrap_hack
170        # which will skip the codegen action.
171        proto_gen(
172            name = name + "_genproto",
173            srcs = srcs,
174            includes = includes,
175            protoc = protoc,
176            visibility = ["//visibility:public"],
177            deps = [s + "_genproto" for s in deps],
178        )
179
180        # An empty cc_library to make rule dependency consistent.
181        native.cc_library(
182            name = name,
183            **kargs
184        )
185        return
186
187    grpc_cpp_plugin = None
188    plugin_options = []
189    if use_grpc_plugin:
190        grpc_cpp_plugin = "//external:grpc_cpp_plugin"
191        if use_grpc_namespace:
192            plugin_options = ["services_namespace=grpc"]
193
194    gen_srcs = _proto_cc_srcs(srcs, use_grpc_plugin)
195    gen_hdrs = _proto_cc_hdrs(srcs, use_grpc_plugin)
196    outs = gen_srcs + gen_hdrs
197
198    proto_gen(
199        name = name + "_genproto",
200        srcs = srcs,
201        outs = outs,
202        gen_cc = 1,
203        includes = includes,
204        plugin = grpc_cpp_plugin,
205        plugin_language = "grpc",
206        plugin_options = plugin_options,
207        protoc = protoc,
208        visibility = ["//visibility:public"],
209        deps = [s + "_genproto" for s in deps],
210    )
211
212    if use_grpc_plugin:
213        cc_libs += select({
214            "//tensorflow:linux_s390x": ["//external:grpc_lib_unsecure"],
215            "//conditions:default": ["//external:grpc_lib"],
216        })
217
218    if default_header:
219        header_only_name = name
220        impl_name = name + "_impl"
221    else:
222        header_only_name = name + "_headers_only"
223        impl_name = name
224
225    native.cc_library(
226        name = impl_name,
227        srcs = gen_srcs,
228        hdrs = gen_hdrs,
229        deps = cc_libs + deps,
230        includes = includes,
231        **kargs
232    )
233    native.cc_library(
234        name = header_only_name,
235        deps = ["@protobuf_archive//:protobuf_headers"] + if_static([impl_name]),
236        hdrs = gen_hdrs,
237        **kargs
238    )
239
240# Re-defined protocol buffer rule to bring in the change introduced in commit
241# https://github.com/google/protobuf/commit/294b5758c373cbab4b72f35f4cb62dc1d8332b68
242# which was not part of a stable protobuf release in 04/2018.
243# TODO(jsimsa): Remove this once the protobuf dependency version is updated
244# to include the above commit.
245def py_proto_library(
246        name,
247        srcs = [],
248        deps = [],
249        py_libs = [],
250        py_extra_srcs = [],
251        include = None,
252        default_runtime = "@protobuf_archive//:protobuf_python",
253        protoc = "@protobuf_archive//:protoc",
254        use_grpc_plugin = False,
255        **kargs):
256    """Bazel rule to create a Python protobuf library from proto source files
257
258    NOTE: the rule is only an internal workaround to generate protos. The
259    interface may change and the rule may be removed when bazel has introduced
260    the native rule.
261
262    Args:
263      name: the name of the py_proto_library.
264      srcs: the .proto files of the py_proto_library.
265      deps: a list of dependency labels; must be py_proto_library.
266      py_libs: a list of other py_library targets depended by the generated
267          py_library.
268      py_extra_srcs: extra source files that will be added to the output
269          py_library. This attribute is used for internal bootstrapping.
270      include: a string indicating the include path of the .proto files.
271      default_runtime: the implicitly default runtime which will be depended on by
272          the generated py_library target.
273      protoc: the label of the protocol compiler to generate the sources.
274      use_grpc_plugin: a flag to indicate whether to call the Python C++ plugin
275          when processing the proto files.
276      **kargs: other keyword arguments that are passed to cc_library.
277    """
278    outs = _proto_py_outs(srcs, use_grpc_plugin)
279
280    includes = []
281    if include != None:
282        includes = [include]
283
284    grpc_python_plugin = None
285    if use_grpc_plugin:
286        grpc_python_plugin = "//external:grpc_python_plugin"
287        # Note: Generated grpc code depends on Python grpc module. This dependency
288        # is not explicitly listed in py_libs. Instead, host system is assumed to
289        # have grpc installed.
290
291    proto_gen(
292        name = name + "_genproto",
293        srcs = srcs,
294        outs = outs,
295        gen_py = 1,
296        includes = includes,
297        plugin = grpc_python_plugin,
298        plugin_language = "grpc",
299        protoc = protoc,
300        visibility = ["//visibility:public"],
301        deps = [s + "_genproto" for s in deps],
302    )
303
304    if default_runtime and not default_runtime in py_libs + deps:
305        py_libs = py_libs + [default_runtime]
306
307    native.py_library(
308        name = name,
309        srcs = outs + py_extra_srcs,
310        deps = py_libs + deps,
311        imports = includes,
312        **kargs
313    )
314
315def tf_proto_library_cc(
316        name,
317        srcs = [],
318        has_services = None,
319        protodeps = [],
320        visibility = [],
321        testonly = 0,
322        cc_libs = [],
323        cc_stubby_versions = None,
324        cc_grpc_version = None,
325        j2objc_api_version = 1,
326        cc_api_version = 2,
327        js_codegen = "jspb",
328        default_header = False):
329    js_codegen = js_codegen  # unused argument
330    native.filegroup(
331        name = name + "_proto_srcs",
332        srcs = srcs + tf_deps(protodeps, "_proto_srcs"),
333        testonly = testonly,
334        visibility = visibility,
335    )
336
337    use_grpc_plugin = None
338    if cc_grpc_version:
339        use_grpc_plugin = True
340
341    cc_deps = tf_deps(protodeps, "_cc")
342    cc_name = name + "_cc"
343    if not srcs:
344        # This is a collection of sub-libraries. Build header-only and impl
345        # libraries containing all the sources.
346        proto_gen(
347            name = cc_name + "_genproto",
348            protoc = "@protobuf_archive//:protoc",
349            visibility = ["//visibility:public"],
350            deps = [s + "_genproto" for s in cc_deps],
351        )
352        native.cc_library(
353            name = cc_name,
354            deps = cc_deps + ["@protobuf_archive//:protobuf_headers"] + if_static([name + "_cc_impl"]),
355            testonly = testonly,
356            visibility = visibility,
357        )
358        native.cc_library(
359            name = cc_name + "_impl",
360            deps = [s + "_impl" for s in cc_deps] + ["@protobuf_archive//:cc_wkt_protos"],
361        )
362
363        return
364
365    cc_proto_library(
366        name = cc_name,
367        testonly = testonly,
368        srcs = srcs,
369        cc_libs = cc_libs + if_static(
370            ["@protobuf_archive//:protobuf"],
371            ["@protobuf_archive//:protobuf_headers"],
372        ),
373        copts = if_not_windows([
374            "-Wno-unknown-warning-option",
375            "-Wno-unused-but-set-variable",
376            "-Wno-sign-compare",
377        ]),
378        default_header = default_header,
379        protoc = "@protobuf_archive//:protoc",
380        use_grpc_plugin = use_grpc_plugin,
381        visibility = visibility,
382        deps = cc_deps + ["@protobuf_archive//:cc_wkt_protos"],
383    )
384
385def tf_proto_library_py(
386        name,
387        srcs = [],
388        protodeps = [],
389        deps = [],
390        visibility = [],
391        testonly = 0,
392        srcs_version = "PY2AND3",
393        use_grpc_plugin = False):
394    py_deps = tf_deps(protodeps, "_py")
395    py_name = name + "_py"
396    if not srcs:
397        # This is a collection of sub-libraries. Build header-only and impl
398        # libraries containing all the sources.
399        proto_gen(
400            name = py_name + "_genproto",
401            protoc = "@protobuf_archive//:protoc",
402            visibility = ["//visibility:public"],
403            deps = [s + "_genproto" for s in py_deps],
404        )
405        native.py_library(
406            name = py_name,
407            deps = py_deps + ["@protobuf_archive//:protobuf_python"],
408            testonly = testonly,
409            visibility = visibility,
410        )
411        return
412
413    py_proto_library(
414        name = py_name,
415        testonly = testonly,
416        srcs = srcs,
417        default_runtime = "@protobuf_archive//:protobuf_python",
418        protoc = "@protobuf_archive//:protoc",
419        srcs_version = srcs_version,
420        use_grpc_plugin = use_grpc_plugin,
421        visibility = visibility,
422        deps = deps + py_deps + ["@protobuf_archive//:protobuf_python"],
423    )
424
425def tf_jspb_proto_library(**kwargs):
426    pass
427
428def tf_nano_proto_library(**kwargs):
429    pass
430
431def tf_proto_library(
432        name,
433        srcs = [],
434        has_services = None,
435        protodeps = [],
436        visibility = [],
437        testonly = 0,
438        cc_libs = [],
439        cc_api_version = 2,
440        cc_grpc_version = None,
441        j2objc_api_version = 1,
442        js_codegen = "jspb",
443        provide_cc_alias = False,
444        default_header = False):
445    """Make a proto library, possibly depending on other proto libraries."""
446    _ignore = (js_codegen, provide_cc_alias)
447
448    tf_proto_library_cc(
449        name = name,
450        testonly = testonly,
451        srcs = srcs,
452        cc_grpc_version = cc_grpc_version,
453        cc_libs = cc_libs,
454        default_header = default_header,
455        protodeps = protodeps,
456        visibility = visibility,
457    )
458
459    tf_proto_library_py(
460        name = name,
461        testonly = testonly,
462        srcs = srcs,
463        protodeps = protodeps,
464        srcs_version = "PY2AND3",
465        use_grpc_plugin = has_services,
466        visibility = visibility,
467    )
468
469# A list of all files under platform matching the pattern in 'files'. In
470# contrast with 'tf_platform_srcs' below, which seletive collects files that
471# must be compiled in the 'default' platform, this is a list of all headers
472# mentioned in the platform/* files.
473def tf_platform_hdrs(files):
474    return native.glob(["platform/*/" + f for f in files])
475
476def tf_platform_srcs(files):
477    base_set = ["platform/default/" + f for f in files]
478    windows_set = base_set + ["platform/windows/" + f for f in files]
479    posix_set = base_set + ["platform/posix/" + f for f in files]
480
481    # Handle cases where we must also bring the posix file in. Usually, the list
482    # of files to build on windows builds is just all the stuff in the
483    # windows_set. However, in some cases the implementations in 'posix/' are
484    # just what is necessary and historically we choose to simply use the posix
485    # file instead of making a copy in 'windows'.
486    for f in files:
487        if f == "error.cc":
488            windows_set.append("platform/posix/" + f)
489
490    return select({
491        "//tensorflow:windows": native.glob(windows_set),
492        "//conditions:default": native.glob(posix_set),
493    })
494
495def tf_additional_lib_hdrs(exclude = []):
496    windows_hdrs = native.glob([
497        "platform/default/*.h",
498        "platform/windows/*.h",
499        "platform/posix/error.h",
500    ], exclude = exclude)
501    return select({
502        "//tensorflow:windows": windows_hdrs,
503        "//conditions:default": native.glob([
504            "platform/default/*.h",
505            "platform/posix/*.h",
506        ], exclude = exclude),
507    })
508
509def tf_additional_lib_srcs(exclude = []):
510    windows_srcs = native.glob([
511        "platform/default/*.cc",
512        "platform/windows/*.cc",
513        "platform/posix/error.cc",
514    ], exclude = exclude)
515    return select({
516        "//tensorflow:windows": windows_srcs,
517        "//conditions:default": native.glob([
518            "platform/default/*.cc",
519            "platform/posix/*.cc",
520        ], exclude = exclude),
521    })
522
523def tf_additional_minimal_lib_srcs():
524    return [
525        "platform/default/integral_types.h",
526        "platform/default/mutex.h",
527    ]
528
529def tf_additional_proto_hdrs():
530    return [
531        "platform/default/integral_types.h",
532        "platform/default/logging.h",
533    ] + if_windows([
534        "platform/windows/integral_types.h",
535    ])
536
537def tf_additional_proto_srcs():
538    return [
539        "platform/protobuf.cc",
540    ]
541
542def tf_additional_human_readable_json_deps():
543    return []
544
545def tf_additional_all_protos():
546    return ["//tensorflow/core:protos_all"]
547
548def tf_protos_all_impl():
549    return [
550        "//tensorflow/core:autotuning_proto_cc_impl",
551        "//tensorflow/core:conv_autotuning_proto_cc_impl",
552        "//tensorflow/core:protos_all_cc_impl",
553    ]
554
555def tf_protos_all():
556    return if_static(
557        extra_deps = tf_protos_all_impl(),
558        otherwise = ["//tensorflow/core:protos_all_cc"],
559    )
560
561def tf_profiler_all_protos():
562    return ["//tensorflow/core/profiler:protos_all"]
563
564def tf_grpc_service_all():
565    return [
566        "//tensorflow/core/profiler:profiler_analysis_proto_cc",
567        "//tensorflow/core/profiler:profiler_service_proto_cc",
568    ]
569
570def tf_protos_grappler_impl():
571    return ["//tensorflow/core/grappler/costs:op_performance_data_cc_impl"]
572
573def tf_protos_grappler():
574    return if_static(
575        extra_deps = tf_protos_grappler_impl(),
576        otherwise = ["//tensorflow/core/grappler/costs:op_performance_data_cc"],
577    )
578
579def tf_additional_cupti_wrapper_deps():
580    return [
581        "//tensorflow/core/platform/default/gpu:cupti_wrapper",
582        "@com_google_absl//absl/base",
583        "@com_google_absl//absl/strings",
584        "@com_google_absl//absl/strings:str_format",
585        "@com_google_absl//absl/container:node_hash_map",
586        "@com_google_absl//absl/container:flat_hash_map",
587    ]
588
589def tf_additional_device_tracer_srcs():
590    return ["platform/default/device_tracer.cc"]
591
592def tf_additional_device_tracer_cuda_deps():
593    return []
594
595def tf_additional_device_tracer_deps():
596    return [
597        "//tensorflow/core/profiler/lib:traceme",
598        "//tensorflow/core/profiler/internal/cpu:host_tracer",
599    ]
600
601def tf_additional_device_tracer_test_flags():
602    return []
603
604def tf_additional_libdevice_data():
605    return []
606
607def tf_additional_libdevice_deps():
608    return ["@local_config_cuda//cuda:cuda_headers"]
609
610def tf_additional_libdevice_srcs():
611    return ["platform/default/cuda_libdevice_path.cc"]
612
613def tf_additional_test_deps():
614    return []
615
616def tf_additional_test_srcs():
617    return [
618        "platform/default/test_benchmark.cc",
619    ] + select({
620        "//tensorflow:windows": [
621            "platform/windows/test.cc",
622        ],
623        "//conditions:default": [
624            "platform/posix/test.cc",
625        ],
626    })
627
628def tf_kernel_tests_linkstatic():
629    return 0
630
631def tf_additional_lib_defines():
632    """Additional defines needed to build TF libraries."""
633    return []
634
635def tf_additional_lib_deps():
636    """Additional dependencies needed to build TF libraries."""
637    return [
638        "@com_google_absl//absl/base:base",
639        "@com_google_absl//absl/container:inlined_vector",
640        "@com_google_absl//absl/types:span",
641        "@com_google_absl//absl/types:optional",
642    ] + if_static(
643        ["@nsync//:nsync_cpp"],
644        ["@nsync//:nsync_headers"],
645    )
646
647def tf_additional_core_deps():
648    return select({
649        "//tensorflow:android": [],
650        "//tensorflow:ios": [],
651        "//tensorflow:linux_s390x": [],
652        "//tensorflow:windows": [],
653        "//tensorflow:no_gcp_support": [],
654        "//conditions:default": [
655            "//tensorflow/core/platform/cloud:gcs_file_system",
656        ],
657    }) + select({
658        "//tensorflow:android": [],
659        "//tensorflow:ios": [],
660        "//tensorflow:linux_s390x": [],
661        "//tensorflow:windows": [],
662        "//tensorflow:no_hdfs_support": [],
663        "//conditions:default": [
664            "//tensorflow/core/platform/hadoop:hadoop_file_system",
665        ],
666    }) + select({
667        "//tensorflow:android": [],
668        "//tensorflow:ios": [],
669        "//tensorflow:linux_s390x": [],
670        "//tensorflow:windows": [],
671        "//tensorflow:no_aws_support": [],
672        "//conditions:default": [
673            "//tensorflow/core/platform/s3:s3_file_system",
674        ],
675    })
676
677# TODO(jart, jhseu): Delete when GCP is default on.
678def tf_additional_cloud_op_deps():
679    return select({
680        "//tensorflow:android": [],
681        "//tensorflow:ios": [],
682        "//tensorflow:linux_s390x": [],
683        "//tensorflow:windows": [],
684        "//tensorflow:api_version_2": [],
685        "//tensorflow:windows_and_api_version_2": [],
686        "//tensorflow:no_gcp_support": [],
687        "//conditions:default": [
688            "//tensorflow/contrib/cloud:bigquery_reader_ops_op_lib",
689            "//tensorflow/contrib/cloud:gcs_config_ops_op_lib",
690        ],
691    })
692
693# TODO(jhseu): Delete when GCP is default on.
694def tf_additional_cloud_kernel_deps():
695    return select({
696        "//tensorflow:android": [],
697        "//tensorflow:ios": [],
698        "//tensorflow:linux_s390x": [],
699        "//tensorflow:windows": [],
700        "//tensorflow:api_version_2": [],
701        "//tensorflow:windows_and_api_version_2": [],
702        "//tensorflow:no_gcp_support": [],
703        "//conditions:default": [
704            "//tensorflow/contrib/cloud/kernels:bigquery_reader_ops",
705            "//tensorflow/contrib/cloud/kernels:gcs_config_ops",
706        ],
707    })
708
709def tf_lib_proto_parsing_deps():
710    return [
711        ":protos_all_cc",
712        "//third_party/eigen3",
713        "//tensorflow/core/platform/default/build_config:proto_parsing",
714    ]
715
716def tf_lib_proto_compiler_deps():
717    return [
718        "@protobuf_archive//:protoc_lib",
719    ]
720
721def tf_additional_verbs_lib_defines():
722    return select({
723        "//tensorflow:with_verbs_support": ["TENSORFLOW_USE_VERBS"],
724        "//conditions:default": [],
725    })
726
727def tf_additional_mpi_lib_defines():
728    return select({
729        "//tensorflow:with_mpi_support": ["TENSORFLOW_USE_MPI"],
730        "//conditions:default": [],
731    })
732
733def tf_additional_gdr_lib_defines():
734    return select({
735        "//tensorflow:with_gdr_support": ["TENSORFLOW_USE_GDR"],
736        "//conditions:default": [],
737    })
738
739def tf_additional_numa_lib_defines():
740    return select({
741        "//tensorflow:with_numa_support": ["TENSORFLOW_USE_NUMA"],
742        "//conditions:default": [],
743    })
744
745def tf_py_clif_cc(name, visibility = None, **kwargs):
746    pass
747
748def tf_pyclif_proto_library(
749        name,
750        proto_lib,
751        proto_srcfile = "",
752        visibility = None,
753        **kwargs):
754    pass
755
756def tf_additional_binary_deps():
757    return ["@nsync//:nsync_cpp"] + if_cuda(
758        [
759            "//tensorflow/stream_executor:cuda_platform",
760        ],
761    ) + if_rocm(
762        [
763            "//tensorflow/stream_executor:rocm_platform",
764            "//tensorflow/core/platform/default/build_config:rocm",
765        ],
766    ) + [
767        # TODO(allenl): Split these out into their own shared objects (they are
768        # here because they are shared between contrib/ op shared objects and
769        # core).
770        "//tensorflow/core/kernels:lookup_util",
771        "//tensorflow/core/util/tensor_bundle",
772    ] + if_mkl_ml(
773        [
774            "//third_party/mkl:intel_binary_blob",
775        ],
776    )
777
778def tf_additional_numa_deps():
779    return select({
780        "//tensorflow:android": [],
781        "//tensorflow:ios": [],
782        "//tensorflow:windows": [],
783        "//tensorflow:macos": [],
784        "//conditions:default": [
785            "@hwloc",
786        ],
787    })
788
789def tf_additional_numa_copts():
790    return select({
791        "//tensorflow:android": [],
792        "//tensorflow:ios": [],
793        "//tensorflow:windows": [],
794        "//tensorflow:macos": [],
795        "//conditions:default": [
796            "-Ithird_party/hwloc/hwloc-master/include",
797            "-DTENSORFLOW_USE_NUMA",
798        ],
799    })
800