Skip to content

Commit 440bd6a

Browse files
facaiyseanpmorgan
authored andcommitted
use code_format.sh to format all files (#64)
* CLN: auto format
1 parent 1eed2e9 commit 440bd6a

Some content is hidden

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

42 files changed

+437
-413
lines changed

configure.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
# ==============================================================================
16+
# Usage: configure.sh [--quiet]
17+
#
18+
# Options:
19+
# --quiet Give less output.
20+
21+
QUIET_FLAG=""
22+
if [[ $1 == "--quiet" ]]; then
23+
QUIET_FLAG="--quiet"
24+
elif [[ ! -z "$1" ]]; then
25+
echo "Found unsupported args: $@"
26+
exit 1
27+
fi
28+
1629
function write_to_bazelrc() {
1730
echo "$1" >> .bazelrc
1831
}
@@ -22,7 +35,7 @@ function write_action_env_to_bazelrc() {
2235
}
2336

2437
[[ -f .bazelrc ]] && rm .bazelrc
25-
pip install -r requirements.txt
38+
pip install $QUIET_FLAG -r requirements.txt
2639

2740
TF_CFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))') )
2841
TF_LFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))') )

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
# ==============================================================================
15-
"""Setup for pip package"""
15+
"""Setup for pip package."""
1616
from __future__ import absolute_import
1717
from __future__ import division
1818
from __future__ import print_function
@@ -26,8 +26,9 @@
2626
version = {}
2727
base_dir = os.path.dirname(os.path.abspath(__file__))
2828
with open(os.path.join(base_dir, "tensorflow_addons", "version.py")) as fp:
29+
# yapf: disable
2930
exec(fp.read(), version)
30-
31+
# yapf: enable
3132

3233
REQUIRED_PACKAGES = [
3334
'six >= 1.10.0',

tensorflow_addons/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package(default_visibility = ["//visibility:public"])
55
py_library(
66
name = "tensorflow_addons",
77
data = [
8-
"__init__.py",
9-
"version.py",
8+
"__init__.py",
9+
"version.py",
1010
],
1111
)

tensorflow_addons/__init__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
# ==============================================================================
15-
"""Useful extra functionality for TensorFlow maintained by SIG-addons"""
15+
"""Useful extra functionality for TensorFlow maintained by SIG-addons."""
1616
from __future__ import absolute_import
1717
from __future__ import division
1818
from __future__ import print_function
@@ -22,13 +22,12 @@
2222
# tensorflow_probability namespace. Hence, we disable this lint check throughout
2323
# the file.
2424
#
25-
# pylint: disable=g-import-not-at-top
2625

2726

2827
# Ensure TensorFlow is importable and its version is sufficiently recent. This
2928
# needs to happen before anything else, since the imports below will try to
3029
# import tensorflow, too.
31-
def _ensure_tf_install(): # pylint: disable=g-statement-before-imports
30+
def _ensure_tf_install():
3231
"""Attempt to import tensorflow, and ensure its version is sufficient.
3332
3433
Raises:
@@ -60,8 +59,7 @@ def _ensure_tf_install(): # pylint: disable=g-statement-before-imports
6059
"This version of TensorFlow Addons requires TensorFlow "
6160
"version >= {required}; Detected an installation of version "
6261
"{present}. Please upgrade TensorFlow to proceed.".format(
63-
required=required_tensorflow_version,
64-
present=tf.__version__))
62+
required=required_tensorflow_version, present=tf.__version__))
6563

6664

6765
_ensure_tf_install()
@@ -80,4 +78,3 @@ def _ensure_tf_install(): # pylint: disable=g-statement-before-imports
8078
from tensorflow_addons.custom_ops import text
8179

8280
from tensorflow_addons.version import __version__
83-
# pylint: enable=g-import-not-at-top

tensorflow_addons/custom_ops/BUILD

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ py_library(
77
srcs = ["__init__.py"],
88
srcs_version = "PY2AND3",
99
deps = [
10-
"//tensorflow_addons/custom_ops/image:images_ops_py",
11-
"//tensorflow_addons/custom_ops/text:text_py",
12-
]
10+
"//tensorflow_addons/custom_ops/image:images_ops_py",
11+
"//tensorflow_addons/custom_ops/text:text_py",
12+
],
1313
)

tensorflow_addons/custom_ops/image/BUILD

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,25 @@ licenses(["notice"]) # Apache 2.0
22

33
package(default_visibility = ["//visibility:public"])
44

5-
65
cc_binary(
76
name = "python/_image_ops.so",
87
srcs = [
98
"cc/kernels/image_projective_transform_op.cc",
109
"cc/kernels/image_projective_transform_op.h",
1110
"cc/ops/image_ops.cc",
1211
],
12+
copts = [
13+
"-pthread",
14+
"-std=c++11",
15+
"-D_GLIBCXX_USE_CXX11_ABI=0",
16+
],
1317
linkshared = 1,
1418
deps = [
1519
"@local_config_tf//:libtensorflow_framework",
1620
"@local_config_tf//:tf_header_lib",
1721
],
18-
copts = ["-pthread", "-std=c++11", "-D_GLIBCXX_USE_CXX11_ABI=0"]
1922
)
2023

21-
2224
py_library(
2325
name = "images_ops_py",
2426
srcs = ([
@@ -27,23 +29,21 @@ py_library(
2729
"python/transform.py",
2830
]),
2931
data = [
30-
":python/_image_ops.so"
32+
":python/_image_ops.so",
3133
],
3234
srcs_version = "PY2AND3",
3335
)
3436

35-
3637
# TODO: use cuda_py_test later.
3738
py_test(
3839
name = "transform_ops_test",
3940
size = "small",
4041
srcs = [
41-
"python/transform_test.py"
42+
"python/transform_test.py",
4243
],
4344
main = "python/transform_test.py",
45+
srcs_version = "PY2AND3",
4446
deps = [
4547
":images_ops_py",
4648
],
47-
srcs_version = "PY2AND3",
4849
)
49-

tensorflow_addons/custom_ops/image/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
# ==============================================================================
15-
"""Image manipulation ops"""
15+
"""Image manipulation ops."""
1616
from __future__ import absolute_import
1717
from __future__ import division
1818
from __future__ import print_function

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ limitations under the License.
1919
#define EIGEN_USE_GPU
2020
#endif // GOOGLE_CUDA
2121

22+
#include "tensorflow_addons/custom_ops/image/cc/kernels/image_projective_transform_op.h"
2223
#include "tensorflow/core/framework/op_kernel.h"
2324
#include "tensorflow/core/framework/register_types.h"
2425
#include "tensorflow/core/framework/types.h"
2526
#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

@@ -73,12 +73,11 @@ class ImageProjectiveTransform : public OpKernel {
7373
const Tensor& transform_t = ctx->input(1);
7474
OP_REQUIRES(ctx, images_t.shape().dims() == 4,
7575
errors::InvalidArgument("Input images must have rank 4"));
76-
OP_REQUIRES(ctx,
77-
(TensorShapeUtils::IsMatrix(transform_t.shape()) &&
78-
(transform_t.dim_size(0) == images_t.dim_size(0) ||
79-
transform_t.dim_size(0) == 1) &&
80-
transform_t.dim_size(1) ==
81-
ProjectiveGenerator<Device, T>::kNumParameters),
76+
OP_REQUIRES(ctx, (TensorShapeUtils::IsMatrix(transform_t.shape()) &&
77+
(transform_t.dim_size(0) == images_t.dim_size(0) ||
78+
transform_t.dim_size(0) == 1) &&
79+
transform_t.dim_size(1) ==
80+
ProjectiveGenerator<Device, T>::kNumParameters),
8281
errors::InvalidArgument(
8382
"Input transform should be num_images x 8 or 1 x 8"));
8483

@@ -106,9 +105,8 @@ class ImageProjectiveTransform : public OpKernel {
106105

107106
Tensor* output_t;
108107
OP_REQUIRES_OK(ctx, ctx->allocate_output(
109-
0,
110-
TensorShape({images_t.dim_size(0), out_height,
111-
out_width, images_t.dim_size(3)}),
108+
0, TensorShape({images_t.dim_size(0), out_height,
109+
out_width, images_t.dim_size(3)}),
112110
&output_t));
113111
auto output = output_t->tensor<T, 4>();
114112
auto images = images_t.tensor<T, 4>();

tensorflow_addons/custom_ops/image/cc/kernels/image_projective_transform_op.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ class ProjectiveGenerator {
4545
static const int kNumParameters = 8;
4646

4747
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
48-
ProjectiveGenerator(typename TTypes<T, 4>::ConstTensor input,
49-
typename TTypes<float>::ConstMatrix transforms,
50-
const Interpolation interpolation)
48+
ProjectiveGenerator(typename TTypes<T, 4>::ConstTensor input,
49+
typename TTypes<float>::ConstMatrix transforms,
50+
const Interpolation interpolation)
5151
: input_(input), transforms_(transforms), interpolation_(interpolation) {}
5252

5353
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T

tensorflow_addons/custom_ops/image/cc/kernels/image_projective_transform_op_gpu.cu.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ limitations under the License.
1717

1818
#define EIGEN_USE_GPU
1919

20+
#include "tensorflow_addons/custom_ops/image/cc/kernels/image_projective_transform_op.h"
2021
#include "tensorflow/core/framework/register_types.h"
2122
#include "tensorflow/core/framework/types.h"
2223
#include "tensorflow/core/platform/types.h"
23-
#include "tensorflow_addons/custom_ops/image/cc/kernels/image_projective_transform_op.h"
2424

2525
namespace tensorflow {
2626

0 commit comments

Comments
 (0)