Skip to content

Latest commit

 

History

History
186 lines (131 loc) · 8.84 KB

CONTRIBUTING.md

File metadata and controls

186 lines (131 loc) · 8.84 KB

Contributing guidelines

Pull Request Checklist

Before sending your pull requests, make sure you followed this list.

How to become a contributor and submit your own code

Contributor License Agreements

We'd love to accept your patches! Before we can take them, we have to jump a couple of legal hurdles.

Please fill out either the individual or corporate Contributor License Agreement (CLA).

  • If you are an individual writing original source code and you're sure you own the intellectual property, then you'll need to sign an individual CLA.
  • If you work for a company that wants to allow you to contribute your work, then you'll need to sign a corporate CLA.

Follow either of the two links above to access the appropriate CLA and instructions for how to sign and return it. Once we receive it, we'll be able to accept your pull requests.

NOTE: Only original source code from you and other people that have signed the CLA can be accepted into the main repository.

Contributing code

If you have improvements to TensorFlow, send us your pull requests! For those just getting started, Github has a howto.

TensorFlow team members will be assigned to review your pull requests. Once the pull requests are approved and pass continuous integration checks, we will merge the pull requests. For some pull requests, we will apply the patch for each pull request to our internal version control system first, and export the change out as a new commit later, at which point the original pull request will be closed. The commits in the pull request will be squashed into a single commit with the pull request creator as the author. These pull requests will be labeled as pending merge internally.

If you want to contribute but you're not sure where to start, take a look at the issues with the "contributions welcome" label. These are issues that we believe are particularly well suited for outside contributions, often because we probably won't get to them right now. If you decide to start on an issue, leave a comment so that other people know that you're working on it. If you want to help out, but not alone, use the issue comment thread to coordinate.

Contribution guidelines and standards

Before sending your pull request for review, make sure your changes are consistent with the guidelines and follow the TensorFlow coding style.

General guidelines and philosophy for contribution

  • Include unit tests when you contribute new features, as they help to a) prove that your code works correctly, and b) guard against future breaking changes to lower the maintenance cost.
  • Bug fixes also generally require unit tests, because the presence of bugs usually indicates insufficient test coverage.
  • Keep API compatibility in mind when you change code in core TensorFlow, e.g., code in tensorflow/core and tensorflow/python. TensorFlow has reached version 1 and hence cannot make non-backward-compatible API changes without a major release. Reviewers of your pull request will comment on any API compatibility issues.
  • When you contribute a new feature to TensorFlow, the maintenance burden is (by default) transferred to the TensorFlow team. This means that benefit of the contribution must be compared against the cost of maintaining the feature.
  • Full new features (e.g., a new op implementing a cutting-edge algorithm) typically will live in tensorflow/contrib to get some airtime before decision is made regarding whether they are to be migrated to the core.

License

Include a license at the top of new files.

Bazel BUILD files also need to include a license section, e.g., BUILD example.

C++ coding style

Changes to TensorFlow C++ code should conform to Google C++ Style Guide.

Use clang-tidy to check your C/C++ changes. To install clang-tidy on ubuntu:16.04, do:

apt-get install -y clang-tidy

You can check a C/C++ file by doing:

clang-format <my_cc_file> --style=google > /tmp/my_cc_file.cc
diff <my_cc_file> /tmp/my_cc_file.cc

Python coding style

Changes to TensorFlow Python code should conform to Google Python Style Guide

Use pylint to check your Python changes. To install pylint and retrieve TensorFlow's custom style definition:

pip install pylint
wget -O /tmp/pylintrc https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/tools/ci_build/pylintrc

To check a file with pylint:

pylint --rcfile=/tmp/pylintrc myfile.py

Coding style for other languages

Running sanity check

If you have Docker installed on your system, you can perform a sanity check on your changes by running the command:

tensorflow/tools/ci_build/ci_build.sh CPU tensorflow/tools/ci_build/ci_sanity.sh

This will catch most license, Python coding style and BUILD file issues that may exist in your changes.

Running unit tests

There are two ways to run TensorFlow unit tests.

  1. Using tools and libraries installed directly on your system.

    Refer to the CPU-only developer Dockerfile and GPU developer Dockerfile for the required packages. Alternatively, use the said Docker images, e.g., tensorflow/tensorflow:nightly-devel and tensorflow/tensorflow:nightly-devel-gpu for development to avoid installing the packages directly on your system.

    Once you have the packages installed, you can run a specific unit test in bazel by doing as follows:

    If the tests are to be run on GPU, add CUDA paths to LD_LIBRARY_PATH and add the cuda option flag

    export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH"
    
    export flags="--config=opt --config=cuda -k"

    For example, to run all tests under tensorflow/python, do:

    bazel test ${flags} //tensorflow/python/...
  2. Using Docker and TensorFlow's CI scripts.

    # Install Docker first, then this will build and run cpu tests
    tensorflow/tools/ci_build/ci_build.sh CPU bazel test //tensorflow/...

    See TensorFlow Builds for details.