Skip to content

Commit 0c2e513

Browse files
authored
ENH: Restructure custom ops (#49)
* ENH: Restructure custom ops
1 parent 1d6b245 commit 0c2e513

31 files changed

+100
-40
lines changed

BUILD

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ sh_binary(
66
"MANIFEST.in",
77
"setup.py",
88
"tensorflow_addons/__init__.py",
9-
"//tensorflow_addons/image:images_ops_py",
9+
"//tensorflow_addons/custom_ops:custom_ops_py",
1010
"//tensorflow_addons/layers:layers_py",
1111
"//tensorflow_addons/losses:losses_py",
1212
"//tensorflow_addons/optimizers:optimizers_py",
13-
"//tensorflow_addons/text:text_py",
1413
],
1514
)

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fitting the following criteria:
4040
* [Layers](tensorflow_addons/layers/README.md) |
4141
[Optimizers](tensorflow_addons/optimizers/README.md) |
4242
[Losses](tensorflow_addons/losses/README.md) |
43-
Custom Ops
43+
[Custom Ops](tensorflow_addons/custom_ops/README.md)
4444

4545
**Note: New contributions often require team-members to read a research
4646
paper and understand how it fits into the TensorFlow community. This

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ the list we adhere to:
3232
1) [Layers](tensorflow_addons/layers/README.md)
3333
1) [Optimizers](tensorflow_addons/optimizers/README.md)
3434
1) [Losses](tensorflow_addons/losses/README.md)
35-
1) Custom Ops
35+
1) [Custom Ops](tensorflow_addons/custom_ops/README.md)
3636

3737
#### Periodic Evaluation
3838
Based on the nature of this repository, there will be contributions that
@@ -58,11 +58,11 @@ https://bazel.build/) build system.
5858
git clone https://github.com/tensorflow/addons.git
5959
cd addons
6060
61-
# This script tells bazel where the tensorflow dependency can be found
62-
./configure.sh # Links project with TensorFlow dependency
61+
# This script links project with TensorFlow dependency
62+
./configure.sh
6363
6464
bazel build build_pip_pkg
65-
bazel-bin/build_pip_pkg artifact
65+
bazel-bin/build_pip_pkg artifacts
6666
6767
pip install artifacts/tensorflow_addons-*.whl
6868
```

tensorflow_addons/custom_ops/BUILD

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
licenses(["notice"]) # Apache 2.0
2+
3+
package(default_visibility = ["//visibility:public"])
4+
5+
py_library(
6+
name = "custom_ops_py",
7+
srcs = ["__init__.py"],
8+
srcs_version = "PY2AND3",
9+
deps = [
10+
"//tensorflow_addons/custom_ops/image:images_ops_py",
11+
"//tensorflow_addons/custom_ops/text:text_py",
12+
]
13+
)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Addons - Custom Ops
2+
3+
## Contents
4+
| Layer | Description |
5+
|:----------------------- |:-----------------------------|
6+
| Image | Ops for image manipulation |
7+
| Text | Ops for text processing |
8+
9+
10+
11+
## Contribution Guidelines
12+
#### Standard API
13+
In order to conform with the current API standard, all custom ops
14+
must:
15+
* Must be impossible to implement in one of the other API
16+
standards (Layers, Losses, etc.)
17+
18+
#### Testing Requirements
19+
* Simple unittests that demonstrate the custom op is behaving as
20+
expected.
21+
* When applicable, run all unittests with TensorFlow's
22+
`@run_all_in_graph_and_eager_modes` decorator.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Custom Op - Image

tensorflow_addons/text/__init__.py renamed to tensorflow_addons/custom_ops/image/__init__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
# ==============================================================================
15-
"""
16-
Text-processing ops.
17-
"""
15+
"""Image manipulation ops"""
1816
from __future__ import absolute_import
1917
from __future__ import division
2018
from __future__ import print_function
2119

22-
# Skip Gram Sample
23-
from tensorflow_addons.text.python.skip_gram_ops import skip_gram_sample
24-
from tensorflow_addons.text.python.skip_gram_ops import skip_gram_sample_with_text_vocab
20+
# Transforms
21+
from tensorflow_addons.custom_ops.image.python.transform import transform

tensorflow_addons/image/cc/kernels/image_projective_transform_op.cc renamed to tensorflow_addons/custom_ops/image/cc/kernels/image_projective_transform_op.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
1+
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
22
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
@@ -19,11 +19,11 @@ limitations under the License.
1919
#define EIGEN_USE_GPU
2020
#endif // GOOGLE_CUDA
2121

22-
#include "tensorflow_addons/image/cc/kernels/image_projective_transform_op.h"
2322
#include "tensorflow/core/framework/op_kernel.h"
2423
#include "tensorflow/core/framework/register_types.h"
2524
#include "tensorflow/core/framework/types.h"
2625
#include "tensorflow/core/platform/types.h"
26+
#include "tensorflow_addons/custom_ops/image/cc/kernels/image_projective_transform_op.h"
2727

2828
namespace tensorflow {
2929

0 commit comments

Comments
 (0)