|
1 | 1 | # -*- Python -*-
|
2 | 2 |
|
3 |
| -load("@protobuf//:protobuf.bzl", "cc_proto_library") |
4 |
| -load("@protobuf//:protobuf.bzl", "py_proto_library") |
| 3 | +load("@protobuf_archive//:protobuf.bzl", "cc_proto_library") |
| 4 | +load("@protobuf_archive//:protobuf.bzl", "py_proto_library") |
| 5 | +load("@local_config_cuda//cuda:build_defs.bzl", "if_cuda", "cuda_default_copts") |
| 6 | + |
| 7 | +# From tensorflow.bzl: |
| 8 | +def _cuda_copts(): |
| 9 | + """Gets the appropriate set of copts for (maybe) CUDA compilation. |
| 10 | +
|
| 11 | + If we're doing CUDA compilation, returns copts for our particular CUDA |
| 12 | + compiler. If we're not doing CUDA compilation, returns an empty list. |
| 13 | +
|
| 14 | + """ |
| 15 | + return cuda_default_copts() + select({ |
| 16 | + "//conditions:default": [], |
| 17 | + "@local_config_cuda//cuda:using_nvcc": ([ |
| 18 | + "-nvcc_options=relaxed-constexpr", |
| 19 | + "-nvcc_options=ftz=true", |
| 20 | + ]), |
| 21 | + "@local_config_cuda//cuda:using_clang": ([ |
| 22 | + "-fcuda-flush-denormals-to-zero", |
| 23 | + ]), |
| 24 | + }) |
| 25 | + |
5 | 26 |
|
6 | 27 | fold_cc_binary = native.cc_binary
|
7 | 28 | fold_cc_library = native.cc_library
|
8 | 29 |
|
| 30 | + |
9 | 31 | def fold_cc_test(deps=[], **kwargs):
|
10 | 32 | native.cc_test(deps=deps + ["//tensorflow_fold/util:test_main"],
|
11 | 33 | **kwargs)
|
12 | 34 |
|
13 |
| -fold_cuda_cc_binary = fold_cc_binary |
14 |
| -fold_cuda_cc_library = fold_cc_library |
15 |
| -fold_cuda_cc_test = fold_cc_test |
| 35 | + |
| 36 | +def fold_cuda_library(deps=[], cuda_deps=[], copts=[], **kwargs): |
| 37 | + native.cc_library( |
| 38 | + deps=deps + if_cuda(cuda_deps + [ |
| 39 | + "@local_config_cuda//cuda:cuda_headers", |
| 40 | + "@org_tensorflow//tensorflow/core:cuda", |
| 41 | + "@org_tensorflow//tensorflow/core:framework_lite", |
| 42 | + ]), |
| 43 | + copts=copts + _cuda_copts() + if_cuda(["-DGOOGLE_CUDA=1"]), |
| 44 | + **kwargs) |
| 45 | + |
| 46 | + |
| 47 | +def fold_cuda_cc_test(deps=[], cuda_deps=[], copts=[], **kwargs): |
| 48 | + native.cc_test( |
| 49 | + deps=deps + ["//tensorflow_fold/util:test_main"], |
| 50 | + copts=copts + if_cuda(["-DGOOGLE_CUDA=1"]), |
| 51 | + **kwargs) |
| 52 | + |
16 | 53 |
|
17 | 54 | def fold_fake_cc_binary(*args, **kwargs):
|
| 55 | + # Not currently supported in open source version. |
| 56 | + # Dummy rule that will make the BUILD file work. |
18 | 57 | pass
|
19 | 58 |
|
20 |
| -def fold_py_nocompile_test(*args, **kwargs): |
21 |
| - pass |
22 | 59 |
|
23 |
| -def if_cuda(x): |
24 |
| - return [] |
| 60 | +def fold_py_nocompile_test(name, srcs=[], **kwargs): |
| 61 | + # Not currently supported in open source version. |
| 62 | + # Dummy rule that will make the BUILD file work. |
| 63 | + native.py_test(name=name, |
| 64 | + srcs=srcs, |
| 65 | + deps=[], |
| 66 | + srcs_version="PY2AND3") |
| 67 | + |
25 | 68 |
|
26 | 69 | def fold_proto_library(cc_name, py_name, srcs, cc_deps=[], py_deps=[],
|
27 | 70 | visibility=None, testonly=0):
|
28 | 71 | cc_proto_library(name=cc_name,
|
29 | 72 | srcs=srcs,
|
30 | 73 | deps=cc_deps,
|
31 |
| - cc_libs=["@protobuf//:protobuf"], |
32 |
| - protoc="@protobuf//:protoc", |
33 |
| - default_runtime="@protobuf//:protobuf", |
| 74 | + cc_libs=["@protobuf_archive//:protobuf"], |
| 75 | + protoc="@protobuf_archive//:protoc", |
| 76 | + default_runtime="@protobuf_archive//:protobuf", |
34 | 77 | visibility=visibility,
|
35 | 78 | testonly=testonly)
|
36 | 79 | py_proto_library(name=py_name,
|
37 | 80 | srcs=srcs,
|
38 | 81 | srcs_version = "PY2AND3",
|
39 |
| - deps=["@protobuf//:protobuf_python"] + py_deps, |
40 |
| - default_runtime="@protobuf//:protobuf_python", |
41 |
| - protoc="@protobuf//:protoc", |
| 82 | + deps=["@protobuf_archive//:protobuf_python"] + py_deps, |
| 83 | + default_runtime="@protobuf_archive//:protobuf_python", |
| 84 | + protoc="@protobuf_archive//:protoc", |
42 | 85 | visibility=visibility,
|
43 | 86 | testonly=testonly)
|
44 | 87 |
|
|
0 commit comments