Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# Jupyter Notebook
.ipynb_checkpoints

# IDE
.vscode/
.idea/

# Build
/.bazelrc
/bazel-*
/artifacts
12 changes: 12 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
sh_binary(
name = "build_pip_pkg",
srcs = ["build_pip_pkg.sh"],
data = [
"LICENSE",
"MANIFEST.in",
"setup.py",
"tensorflow_addons/__init__.py",
"//tensorflow_addons/layers:layers_py",
"//tensorflow_addons/text:text_py",
],
)
30 changes: 30 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Want to contribute? Great! First, read this page (including the small print at the end).

### Before you contribute

Before we can use your code, you must sign the
[Google Individual Contributor License Agreement]
(https://cla.developers.google.com/about/google-individual)
(CLA), which you can do online. The CLA is necessary mainly because you own the
copyright to your changes, even after your contribution becomes part of our
codebase, so we need your permission to use and distribute your code. We also
need to be sure of various other things—for instance that you'll tell us if you
know that your code infringes on other people's patents. You don't have to sign
the CLA until after you've submitted your code for review and a member has
approved it, but you must do it before we can put your code into our codebase.
Before you start working on a larger contribution, you should get in touch with
us first through the issue tracker with your idea so that we can help out and
possibly guide you. Coordinating up front makes it much easier to avoid
frustration later on.

### Code reviews

All submissions, including submissions by project members, require review. We
use Github pull requests for this purpose.

### The small print

Contributions made by corporations are covered by a different agreement than
the one above, the
[Software Grant and Corporate Contributor License Agreement]
(https://cla.developers.google.com/about/google-corporate).
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ Copyright 2018 The TensorFlow Authors. All rights reserved.
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2017, The TensorFlow Authors.
Copyright 2019, The TensorFlow Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include tensorflow_addons/ *.so
28 changes: 23 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,27 @@ The tensorflow/addons repository, will contain additional functionality fitting
* The addon is useful for a large number of users (e.g., an implementation used in widely cited paper, or a utility with broad applicability)


---
# Developing

<br><br>
<div align="center">
<img src ="https://cdn.pixabay.com/photo/2017/06/16/07/26/under-construction-2408062_640.png" />
</div>
## Docker
```
docker run --rm -it -v ${PWD}:/working_dir -w /working_dir tensorflow/tensorflow:nightly-custom-op /bin/bash
```

## Packaging
```
# In docker
./configure.sh
bazel build build_pip_pkg
bazel-bin/build_pip_pkg artifacts
```

A package file artifacts/tensorflow_addons-*.whl will be generated after a build is successful.


## Testing
```
# In docker
./configure.sh
bazel test //tensorflow_addons/...
```
5 changes: 5 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
load("//tf_dependency:tf_configure.bzl", "tf_configure")

tf_configure(
name = "local_config_tf",
)
68 changes: 68 additions & 0 deletions build_pip_pkg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env bash
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
set -e
set -x

PLATFORM="$(uname -s | tr 'A-Z' 'a-z')"

PIP_FILE_PREFIX="bazel-bin/build_pip_pkg.runfiles/__main__/"

function main() {
while [[ ! -z "${1}" ]]; do
if [[ ${1} == "make" ]]; then
echo "Using Makefile to build pip package."
PIP_FILE_PREFIX=""
else
DEST=${1}
fi
shift
done

if [[ -z ${DEST} ]]; then
echo "No destination dir provided"
exit 1
fi

# Create the directory, then do dirname on a non-existent file inside it to
# give us an absolute paths with tilde characters resolved to the destination
# directory.
mkdir -p ${DEST}
DEST=$(readlink -f "${DEST}")
echo "=== destination directory: ${DEST}"

TMPDIR=$(mktemp -d -t tmp.XXXXXXXXXX)

echo $(date) : "=== Using tmpdir: ${TMPDIR}"

echo "=== Copy TensorFlow Addons files"

cp ${PIP_FILE_PREFIX}setup.py "${TMPDIR}"
cp ${PIP_FILE_PREFIX}MANIFEST.in "${TMPDIR}"
cp ${PIP_FILE_PREFIX}LICENSE "${TMPDIR}"
rsync -avm -L --exclude='*_test.py' ${PIP_FILE_PREFIX}tensorflow_addons "${TMPDIR}"

pushd ${TMPDIR}
echo $(date) : "=== Building wheel"

python setup.py bdist_wheel > /dev/null

cp dist/*.whl "${DEST}"
popd
rm -rf ${TMPDIR}
echo $(date) : "=== Output wheel file is in: ${DEST}"
}

main "$@"
35 changes: 35 additions & 0 deletions configure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
function write_to_bazelrc() {
echo "$1" >> .bazelrc
}

function write_action_env_to_bazelrc() {
write_to_bazelrc "build --action_env $1=\"$2\""
}

rm .bazelrc
if python -c "import tensorflow" &> /dev/null; then
echo 'using installed tensorflow'
else
pip install tf-nightly-2.0-preview
fi

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

write_action_env_to_bazelrc "TF_HEADER_DIR" ${TF_CFLAGS:2}
write_action_env_to_bazelrc "TF_SHARED_LIBRARY_DIR" ${TF_LFLAGS:2}
65 changes: 65 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Setup for pip package."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from setuptools import find_packages
from setuptools import setup
from setuptools.dist import Distribution

__version__ = '0.0.1'
REQUIRED_PACKAGES = [
'tf-nightly-2.0-preview',
]
project_name = 'tensorflow-addons'


class BinaryDistribution(Distribution):
"""This class is needed in order to create OS specific wheels."""

def has_ext_modules(self):
return True


setup(
name=project_name,
version=__version__,
description=('TensorFlow Addons'),
author='Google Inc.',
author_email='[email protected]',
packages=find_packages(),
install_requires=REQUIRED_PACKAGES,
include_package_data=True,
zip_safe=False,
distclass=BinaryDistribution,
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: Education',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Scientific/Engineering :: Mathematics',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Software Development :: Libraries',
],
license='Apache 2.0',
keywords='tensorflow addons machine learning',
)
Empty file added tensorflow_addons/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions tensorflow_addons/crf/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
licenses(["notice"]) # Apache 2.0

package(default_visibility = ["//visibility:public"])
4 changes: 4 additions & 0 deletions tensorflow_addons/crf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Addons - Conditional Random Fields (CRF)


## Standard API
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Github isn't making it easy to comment on empty files, so commenting here: if we don't need the python subdirs here (ie, crf/python/init.py), might be easier/clearer to remove throughout? Unless you feel it is helpful to have python/ versus cc/ for ops.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO I like the separation between python vs. cc, but am open to removing it. As far as the entirely empty dirs (like crf), the init is just there so the directory structure can be checked into git.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

Empty file.
Empty file.
23 changes: 23 additions & 0 deletions tensorflow_addons/examples/demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

# import tensorflow as tf
# import tensorflow_addons as tfa
# from tensorflow_addons.text import skip_gram_sample


# TODO: Build this out
if __name__ == "__main__":
pass
3 changes: 3 additions & 0 deletions tensorflow_addons/image/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
licenses(["notice"]) # Apache 2.0

package(default_visibility = ["//visibility:public"])
4 changes: 4 additions & 0 deletions tensorflow_addons/image/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Addons - Image


## Standard API
Empty file.
Empty file.
25 changes: 25 additions & 0 deletions tensorflow_addons/layers/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
licenses(["notice"]) # Apache 2.0

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

py_library(
name = "layers_py",
srcs = ([
"__init__.py",
"python/__init__.py",
"python/wrappers.py",
]),
srcs_version = "PY2AND3",
)

py_test(
name = "layers_wrappers_py_test",
srcs = [
"python/wrappers_test.py",
],
main = "python/wrappers_test.py",
deps = [
":layers_py",
],
srcs_version = "PY2AND3",
)
6 changes: 6 additions & 0 deletions tensorflow_addons/layers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Addons - Layers


## Standard API
In order to conform with the current API standard, all layers
must inherit from either `keras.layers.Layer` or its subclasses.
Loading