Skip to content

Commit 66f026a

Browse files
committed
2 parents 18f9fa2 + dab1812 commit 66f026a

38 files changed

+2609
-81
lines changed

CONTRIBUTING.md

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,14 @@ process can take longer than typical commit reviews so please bare with
4646
us**
4747

4848

49-
## Development Environment
50-
It is recommended that development is done in the latest
51-
`nightly-custom-op` docker image.
49+
## Development Tips
50+
Try these useful commands below:
5251

53-
```bash
54-
docker run --rm -it -v ${PWD}:/addons -w /addons tensorflow/tensorflow:nightly-custom-op /bin/bash
55-
```
56-
57-
Try these commands below:
58-
59-
* Format code automatically: `make code-format`
60-
* Run sanity check: `make sanity-check`
61-
* Run unit tests: `make unit-test`
62-
* All of the above: `make`
52+
* Format code automatically: `bash tools/run_docker.sh -c 'make code-format'`
53+
* Run sanity check: `bash tools/run_docker.sh -c 'make sanity-check'`
54+
* Run CPU unit tests: `bash tools/run_docker.sh -c 'make unit-test'`
55+
* Run GPU unit tests: `bash tools/run_docker.sh -c 'make gpu-unit-test'`
56+
* All of the above: `bash tools/run_docker.sh -c 'make'`
6357

6458
## Coding style
6559

@@ -73,10 +67,10 @@ Please see our [Style Guide](STYLE_GUIDE.md) for more details.
7367
Nighly CI tests are ran and results can be found on the central README. To
7468
subscribe for alerts please join the [addons-testing mailing list](https://groups.google.com/a/tensorflow.org/forum/#!forum/addons-testing).
7569

76-
#### Locally Testing
70+
#### Locally Testing CPU
7771

7872
```bash
79-
docker run --rm -it -v ${PWD}:/addons -w /addons tensorflow/tensorflow:nightly-custom-op make unit-test
73+
bash tools/run_docker.sh -c 'make unit-test'
8074
```
8175

8276
or run manually:
@@ -88,7 +82,25 @@ docker run --rm -it -v ${PWD}:/addons -w /addons tensorflow/tensorflow:nightly-c
8882

8983
bazel test -c opt -k \
9084
--test_timeout 300,450,1200,3600 \
91-
--test_output=errors \
85+
--test_output=all \
86+
//tensorflow_addons/...
87+
```
88+
89+
#### Locally Testing GPU
90+
```bash
91+
bash tools/run_docker.sh -d gpu -c 'make gpu-unit-test'
92+
```
93+
94+
or run manually:
95+
96+
```bash
97+
docker run --runtime=nvidia --rm -it -v ${PWD}:/addons -w /addons tensorflow/tensorflow:custom-op-gpu /bin/bash
98+
./configure.sh # Links project with TensorFlow dependency
99+
100+
bazel test -c opt -k \
101+
--test_timeout 300,450,1200,3600 \
102+
--test_output=all \
103+
--jobs=1 \
92104
//tensorflow_addons/...
93105
```
94106

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ developments that cannot be integrated into core TensorFlow
3737
| [tfa.metrics](tensorflow_addons/metrics/README.md) | SIG-Addons | @squadrick |
3838
| [tfa.optimizers](tensorflow_addons/optimizers/README.md) | SIG-Addons | @facaiy @windqaq @squadrick |
3939
| [tfa.rnn](tensorflow_addons/rnn/README.md) | Google | @qlzh727 |
40-
| [tfa.seq2seq](tensorflow_addons/seq2seq/README.md) | Google | @qlzh727 |
40+
| [tfa.seq2seq](tensorflow_addons/seq2seq/README.md) | Google/SIG-Addons | @qlzh727 @guillaumekln |
4141
| [tfa.text](tensorflow_addons/text/README.md) | SIG-Addons | @seanpmorgan @facaiy |
4242

4343
## Installation

WORKSPACE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
12
load("//build_deps/tf_dependency:tf_configure.bzl", "tf_configure")
23
load("//build_deps/gpu:cuda_configure.bzl", "cuda_configure")
34

5+
6+
http_archive(
7+
name = "cub_archive",
8+
build_file = "//build_deps/gpu:cub.BUILD",
9+
sha256 = "6bfa06ab52a650ae7ee6963143a0bbc667d6504822cbd9670369b598f18c58c3",
10+
strip_prefix = "cub-1.8.0",
11+
urls = [
12+
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/NVlabs/cub/archive/1.8.0.zip",
13+
"https://github.com/NVlabs/cub/archive/1.8.0.zip",
14+
],
15+
)
16+
417
tf_configure(
518
name = "local_config_tf",
619
)

build_deps/gpu/cub.BUILD

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Description: CUB library which is a set of primitives for GPU programming.
2+
3+
load("@local_config_cuda//cuda:build_defs.bzl", "cuda_default_copts", "if_cuda")
4+
5+
package(
6+
default_visibility = ["//visibility:public"],
7+
)
8+
9+
licenses(["notice"]) # BSD
10+
11+
filegroup(
12+
name = "cub_header_files",
13+
srcs = glob([
14+
"cub/**",
15+
]),
16+
)
17+
18+
cc_library(
19+
name = "cub",
20+
hdrs = if_cuda([":cub_header_files"]),
21+
include_prefix = "gpu",
22+
deps = [
23+
"@local_config_cuda//cuda:cuda_headers",
24+
],
25+
)

build_deps/gpu/cuda/BUILD.tpl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load(":build_defs.bzl", "cuda_header_library")
2+
13
licenses(["restricted"]) # MPL2, portions GPL v3, LGPL v3, BSD-like
24

35
package(default_visibility = ["//visibility:public"])
@@ -37,11 +39,12 @@ config_setting(
3739
visibility = ["//visibility:public"],
3840
)
3941

40-
cc_library(
42+
cuda_header_library(
4143
name = "cuda_headers",
4244
hdrs = [
4345
%{cuda_headers}
4446
],
47+
include_prefix = "third_party/gpus",
4548
includes = [
4649
".",
4750
"cuda/include",

build_deps/gpu/cuda/build_defs.bzl.tpl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,32 @@ def if_cuda_is_configured(x):
3131
if cuda_is_configured():
3232
return x
3333
return []
34+
35+
def cuda_header_library(
36+
name,
37+
hdrs,
38+
include_prefix = None,
39+
strip_include_prefix = None,
40+
deps = [],
41+
**kwargs):
42+
"""Generates a cc_library containing both virtual and system include paths.
43+
44+
Generates both a header-only target with virtual includes plus the full
45+
target without virtual includes. This works around the fact that bazel can't
46+
mix 'includes' and 'include_prefix' in the same target."""
47+
48+
native.cc_library(
49+
name = name + "_virtual",
50+
hdrs = hdrs,
51+
include_prefix = include_prefix,
52+
strip_include_prefix = strip_include_prefix,
53+
deps = deps,
54+
visibility = ["//visibility:private"],
55+
)
56+
57+
native.cc_library(
58+
name = name,
59+
textual_hdrs = hdrs,
60+
deps = deps + [":%s_virtual" % name],
61+
**kwargs
62+
)

build_deps/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
tf-nightly-2.0-preview
1+
tf-nightly-2.0-preview==2.0.0.dev20190731

build_deps/requirements_gpu.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
tf-nightly-gpu-2.0-preview
1+
tf-nightly-gpu-2.0-preview==2.0.0.dev20190731

tensorflow_addons/custom_ops/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
| Image | Ops for image manipulation |
77
| Seq2seq | Ops for seq2seq encoder-decoder framework |
88
| Text | Ops for text processing |
9+
| Layers | Ops for model layers |
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
licenses(["notice"]) # Apache 2.0
2+
3+
package(default_visibility = ["//visibility:public"])
4+
5+
load("@local_config_tf//:build_defs.bzl", "D_GLIBCXX_USE_CXX11_ABI")
6+
load("@local_config_cuda//cuda:build_defs.bzl", "if_cuda_is_configured", "if_cuda")
7+
8+
cc_binary(
9+
name = "_correlation_cost_ops.so",
10+
srcs = [
11+
"cc/kernels/correlation_cost_op.cc",
12+
"cc/kernels/correlation_cost_op.h",
13+
"cc/kernels/correlation_cost_op_gpu.cu.cc",
14+
"cc/ops/correlation_cost_op.cc",
15+
],
16+
copts = [
17+
"-pthread",
18+
"-std=c++11",
19+
D_GLIBCXX_USE_CXX11_ABI,
20+
],
21+
linkshared = 1,
22+
deps = [
23+
"@local_config_tf//:libtensorflow_framework",
24+
"@local_config_tf//:tf_header_lib",
25+
] + if_cuda_is_configured([":correlation_cost_ops_gpu"]),
26+
)
27+
28+
cc_library(
29+
name = "correlation_cost_ops_gpu",
30+
srcs = [
31+
"cc/kernels/correlation_cost_op.h",
32+
"cc/kernels/correlation_cost_op_gpu.cu.cc",
33+
],
34+
copts = if_cuda_is_configured([
35+
"-DGOOGLE_CUDA=1",
36+
"-x cuda",
37+
"-nvcc_options=relaxed-constexpr",
38+
"-nvcc_options=ftz=true",
39+
]),
40+
deps = [
41+
"@local_config_tf//:libtensorflow_framework",
42+
"@local_config_tf//:tf_header_lib",
43+
] + if_cuda_is_configured([
44+
"@local_config_cuda//cuda:cuda_libs",
45+
"@local_config_cuda//cuda:cuda_headers",
46+
"@cub_archive//:cub",
47+
]),
48+
alwayslink = 1,
49+
)

0 commit comments

Comments
 (0)