Skip to content

Commit 92e44f0

Browse files
authored
Merge branch 'master' into doctest
2 parents f08aba5 + 9d9d484 commit 92e44f0

File tree

86 files changed

+2201
-1297
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2201
-1297
lines changed

.flake8

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,5 @@ per-file-ignores =
2727
tensorflow_addons/image/tests/utils_test.py:N802
2828
tensorflow_addons/image/tests/color_ops_test.py:N802
2929
tensorflow_addons/optimizers/tests/conditional_gradient_test.py:N802
30-
tensorflow_addons/optimizers/tests/lazy_adam_test.py:N802
31-
tensorflow_addons/seq2seq/tests/attention_wrapper_test.py:N802
32-
tensorflow_addons/seq2seq/tests/basic_decoder_test.py:N802
33-
tensorflow_addons/seq2seq/tests/decoder_test.py:N802
34-
tensorflow_addons/seq2seq/tests/beam_search_decoder_test.py:N802
35-
tensorflow_addons/seq2seq/tests/beam_search_ops_test.py:N802
36-
tensorflow_addons/optimizers/tests/cyclical_learning_rate_test.py:N802
3730
# variable ... in function should be lowercase
3831
tensorflow_addons/callbacks/tests/time_stopping_test.py:N806

.github/CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
/tensorflow_addons/image/tests/distance_transform_test.py @mels630
5959
/tensorflow_addons/image/distort_image_ops.py @windqaq
6060
/tensorflow_addons/image/tests/distort_image_ops_test.py @windqaq
61-
/tensorflow_addons/image/filters.py @mainak431
62-
/tensorflow_addons/image/tests/filters_test.py @mainak431
61+
/tensorflow_addons/image/filters.py @mainak431 @ghosalsattam
62+
/tensorflow_addons/image/tests/filters_test.py @mainak431 @ghosalsattam
6363
/tensorflow_addons/image/interpolate_spline.py
6464
/tensorflow_addons/image/tests/interpolate_spline_test.py
6565
/tensorflow_addons/image/resampler_ops.py @autoih

.github/workflows/backport.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
steps:
1313
- name: Backport Bot
1414
if: github.event.pull_request.merged && ( ( github.event.action == 'closed' && contains( join( github.event.pull_request.labels.*.name ), 'backport') ) || contains( github.event.label.name, 'backport' ) )
15-
uses: Gaurav0/backport@v1.0.24
15+
uses: Gaurav0/backport@d69fd1d # Version 1.0.24
1616
with:
1717
bot_username: bot-of-gabrieldemarmiesse
1818
bot_token: 1353d990cdb8b8ceb1b73d301dce83cc0da3db29

.github/workflows/ci_test.yml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,6 @@ jobs:
7070
- uses: actions/checkout@v2
7171
- name: Building the docs
7272
run: bash tools/run_build.sh docs_tests
73-
test_editable_mode:
74-
name: Check that we can fully work in editable mode
75-
runs-on: ubuntu-latest
76-
steps:
77-
- uses: actions/checkout@v2
78-
- run: bash tools/run_build.sh test_editable_mode
7973
test_python_code_only:
8074
name: Fast build to run python-only tests
8175
runs-on: ubuntu-latest
@@ -93,19 +87,6 @@ jobs:
9387
steps:
9488
- uses: actions/checkout@v2
9589
- run: bash tools/run_cpu_tests.sh
96-
test_tf220rc3_cpu_in_small_docker_image:
97-
name: Run the tf 2.2.0rc3 cpu tests in a small python docker image
98-
runs-on: ubuntu-latest
99-
steps:
100-
- uses: actions/checkout@v2
101-
- env:
102-
DOCKER_BUILDKIT: 1
103-
run: |
104-
docker build \
105-
--build-arg TF_VERSION=2.2.0rc3 \
106-
-f tools/docker/cpu_tests.Dockerfile \
107-
--target=build_wheel \
108-
./
10990
valid-codeowners:
11091
name: Check that the CODEOWNERS is valid
11192
runs-on: ubuntu-latest

.github/workflows/make_wheel_Windows.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ export TF_NEED_CUDA=0
44
export BAZEL_VC="C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/"
55

66
python -m pip install wheel setuptools tensorflow==$TF_VERSION
7-
curl -sSOL https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-windows-x86_64.exe
8-
export BAZEL_PATH=/d/a/addons/addons/bazel-${BAZEL_VERSION}-windows-x86_64.exe
97
bash ./tools/testing/build_and_run_tests.sh
108

11-
./bazel-${BAZEL_VERSION}-windows-x86_64.exe build \
9+
bazel.exe build \
1210
-c opt \
1311
--enable_runfiles \
1412
--noshow_progress \

.github/workflows/make_wheel_macOS.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export TF_NEED_CUDA=0
55
python --version
66
python -m pip install delocate wheel setuptools tensorflow==$TF_VERSION
77

8-
bash tools/install_deps/bazel_macos.sh $BAZEL_VERSION
98
bash tools/testing/build_and_run_tests.sh
109

1110
bazel build \

.github/workflows/release-drafter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
update_release_draft:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: release-drafter/release-drafter@v5
13+
- uses: release-drafter/release-drafter@74e7c42 # Version 5.7.0
1414
with:
1515
config-name: release-template.yml
1616
env:

.github/workflows/release.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
- r*
1616

1717
env:
18-
BAZEL_VERSION: 1.1.0
18+
BAZEL_VERSION: '1.1.0'
1919
MIN_PY_VERSION: '3.5'
2020
MAX_PY_VERSION: '3.8'
2121

@@ -41,7 +41,7 @@ jobs:
4141
matrix:
4242
os: ['macos-latest', 'windows-latest', 'ubuntu-18.04']
4343
py-version: ['3.5', '3.6', '3.7', '3.8']
44-
tf-version: ['2.1.0', '2.2.0rc3']
44+
tf-version: ['2.2.0rc4']
4545
fail-fast: false
4646
steps:
4747
- uses: actions/[email protected]
@@ -57,10 +57,15 @@ jobs:
5757
- uses: actions/setup-python@v1
5858
with:
5959
python-version: ${{ matrix.py-version }}
60+
- name: Setup Bazel
61+
# Ubuntu bazel is run inside of the docker image
62+
if: matrix.os != 'ubuntu-18.04'
63+
# MacOS VMs share IP addr on GH actions. This bazel installation authenticates token to prevent api rate limiting.
64+
uses: jwlawson/actions-setup-bazel@784af34 # Version 1.1
65+
with:
66+
bazel-version: ${{ env.BAZEL_VERSION}}
67+
github-api-token: ${{ secrets.GITHUB_TOKEN }}
6068
- name: Build wheels
61-
if: |
62-
(matrix.py-version != '3.8' || matrix.tf-version != '2.1.0')
63-
&& (github.event_name != 'pull_request' || matrix.py-version == env.MIN_PY_VERSION || matrix.py-version == env.MAX_PY_VERSION)
6469
env:
6570
OS: ${{ runner.os }}
6671
PY_VERSION: ${{ matrix.py-version }}
@@ -69,9 +74,6 @@ jobs:
6974
shell: bash
7075
run: bash .github/workflows/make_wheel_${OS}.sh
7176
- uses: actions/upload-artifact@v1
72-
if: |
73-
(matrix.py-version != '3.8' || matrix.tf-version != '2.1.0')
74-
&& (github.event_name != 'pull_request' || matrix.py-version == env.MIN_PY_VERSION || matrix.py-version == env.MAX_PY_VERSION)
7577
with:
7678
name: ${{ runner.os }}-${{ matrix.py-version }}-tf${{ matrix.tf-version }}-wheel
7779
path: wheelhouse
@@ -82,16 +84,15 @@ jobs:
8284
strategy:
8385
matrix:
8486
os: ['macOS', 'Windows', 'Linux']
85-
py-version: ['3.5', '3.6', '3.7']
87+
py-version: ['3.5', '3.6', '3.7', '3.8']
88+
tf-version: ['2.2.0rc4']
8689
fail-fast: false
8790
steps:
8891
- uses: actions/download-artifact@v1
89-
if: github.event_name != 'pull_request' || matrix.py-version == env.MIN_PY_VERSION || matrix.py-version == env.MAX_PY_VERSION
9092
with:
91-
name: ${{ matrix.os }}-${{ matrix.py-version }}-tf2.1.0-wheel
93+
name: ${{ matrix.os }}-${{ matrix.py-version }}-tf${{ matrix.tf-version }}-wheel
9294
path: ./dist
93-
- if: github.event_name != 'pull_request' || matrix.py-version == env.MIN_PY_VERSION || matrix.py-version == env.MAX_PY_VERSION
94-
run: |
95+
- run: |
9596
set -e -x
9697
ls -la dist/
9798
sha256sum dist/*.whl

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ wheels/
2323
*.egg-info/
2424
.installed.cfg
2525
*.egg
26+
pip-wheel-metadata
2627

2728
# Jupyter Notebook
2829
.ipynb_checkpoints

CONTRIBUTING.md

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ conda activate my_dev_environement
160160
Just run from the root:
161161

162162
```
163+
pip install tensorflow==2.2.0rc4
164+
# you can use "pip install tensorflow-cpu==2.2.0rc4" too if you're not testing on gpu.
163165
pip install -e ./
164166
```
165167

@@ -247,7 +249,7 @@ If you need a custom C++/Cuda op for your test, compile your ops with
247249

248250
```bash
249251
python configure.py
250-
pip install tensorflow==2.1.0 -e ./ -r tools/install_deps/pytest.txt
252+
pip install tensorflow==2.2.0rc4 -e ./ -r tools/install_deps/pytest.txt
251253
bash tools/install_so_files.sh # Linux/macos/WSL2
252254
sh tools/install_so_files.sh # PowerShell
253255
```
@@ -275,14 +277,14 @@ docker run --runtime=nvidia --rm -it -v ${PWD}:/addons -w /addons tensorflow/ten
275277

276278
Configure:
277279
```
278-
python3 -m pip install tensorflow==2.1.0
280+
python3 -m pip install tensorflow==2.2.0rc4
279281
python3 ./configure.py # Links project with TensorFlow dependency
280282
```
281283

282284
Install in editable mode
283285
```
284286
python3 -m pip install -e .
285-
python3 -m pip install pytest pytest-xdist
287+
python3 -m pip install -r tools/install_deps/pytest.txt
286288
```
287289

288290
Compile the custom ops
@@ -295,6 +297,10 @@ Run selected tests:
295297
python3 -m pytest path/to/file/or/directory/to/test
296298
```
297299

300+
Run the gpu only tests with `pytest -m needs_gpu ./tensorflow_addons`.
301+
Run the cpu only tests with `pytest -m 'not needs_gpu' ./tensorflow_addons`.
302+
303+
298304
#### Testing with Bazel
299305

300306
Testing with Bazel is still supported but not recommended unless you have prior experience
@@ -309,9 +315,9 @@ quickly, as Bazel has great support for caching and distributed testing.
309315
To test with Bazel:
310316

311317
```
312-
python3 -m pip install tensorflow==2.1.0
318+
python3 -m pip install tensorflow==2.2.0rc4
313319
python3 configure.py
314-
python3 -m pip install pytest
320+
python3 -m pip install -r tools/install_deps/pytest.txt
315321
bazel test -c opt -k \
316322
--test_timeout 300,450,1200,3600 \
317323
--test_output=all \
@@ -409,22 +415,46 @@ on Tensors, `if` or `for` for example. Or with `TensorArray`. In short, when the
409415
conversion to graph is not trivial. No need to use it on all
410416
your tests. Having fast tests is important.
411417

412-
#### cpu_and_gpu
418+
#### Selecting the devices to run the test
419+
420+
By default, each test is wrapped behind the scenes with a
421+
```python
422+
with tf.device("CPU:0"):
423+
...
424+
```
413425

414-
Will run your test function twice, once with `with tf.device("/device:CPU:0")` and
415-
once with `with tf.device("/device:GPU:0")`. If a GPU is not present on the system,
416-
the second test is skipped. To use it:
426+
This is automatic. But it's also possible to ask the test runner to run
427+
the test twice, on CPU and on GPU, or only on GPU. Here is how to do it.
417428

418429
```python
419-
@pytest.mark.usefixtures("cpu_and_gpu")
430+
import pytest
431+
432+
@pytest.mark.with_device(["cpu", "gpu"])
420433
def test_something():
421-
assert ...== ...
434+
# the code here will run twice, once on gpu, once on cpu.
435+
...
436+
437+
@pytest.mark.with_device(["gpu"])
438+
def test_something_else():
439+
# This test will be only run on gpu.
440+
# The test runner will call with tf.device("GPU:0") behind the scenes.
441+
...
442+
443+
@pytest.mark.with_device(["cpu"])
444+
def test_something_more():
445+
# Don't do that, this is the default behavior.
446+
...
422447
```
423448

449+
Note that if a gpu is not detected on the system, the test will be
450+
skipped and not marked as failed. Only the first gpu of the system is used,
451+
even when running pytest in multiprocessing mode. (`-n` argument).
452+
Beware of the out of cuda memory errors if the number of pytest workers is too high.
453+
424454
##### When to use it?
425455

426-
When you test custom CUDA code. We can expect existing TensorFlow ops to behave the same
427-
on CPU and GPU.
456+
When you test custom CUDA code or float16 ops.
457+
We can expect other existing TensorFlow ops to behave the same on CPU and GPU.
428458

429459
#### data_format
430460

0 commit comments

Comments
 (0)