Skip to content

Latest commit

 

History

History
116 lines (77 loc) · 3.37 KB

CONTRIBUTING.md

File metadata and controls

116 lines (77 loc) · 3.37 KB

Contribute To PyTorch/XLA

We appreciate all contributions. If you are planning to contribute a bug fix for an open issue, please comment on the thread and we're happy to provide any guidance. You are very welcome to pick issues from good first issue and help wanted labels.

If you plan to contribute new features, utility functions or extensions to the core, please first open an issue and discuss the feature with us. Sending a PR without discussion might end up resulting in a rejected PR, because we might be taking the core in a different direction than you might be aware of.

Building Manually

To build from source:

  • Clone the PyTorch repo as per instructions.

    git clone --recursive https://github.com/pytorch/pytorch
    cd pytorch/
  • Clone the PyTorch/XLA repo:

    git clone --recursive https://github.com/pytorch/xla.git

Building Docker Image

  • We provide a Dockerfile in docker/ that you can use to build images as the following:

    docker build -t torch-xla -f docker/Dockerfile .

Building With Script

  • To build and install torch and torch_xla:

    xla/scripts/build_torch_wheels.sh

Build From Source

  • Apply PyTorch patches:

    xla/scripts/apply_patches.sh
  • Install the Lark parser used for automatic code generation:

    pip install lark-parser
  • Currently PyTorch does not build with GCC 6.x, 7.x, and 8.x (various kind of ICEs). CLANG 7.x is known to be working, so install that in your VM:

    sudo apt-get install clang-7 clang++-7
    export CC=clang-7 CXX=clang++-7

    You may need to add the following line to your /etc/apt/sources.list file:

    deb http://deb.debian.org/debian/ testing main

    And run the following command before trying again to install CLANG:

    sudo apt-get update
  • Build PyTorch from source following the regular instructions.

    python setup.py install
  • Install Bazel following the instructions. You should only install version 0.24.1, as no older nor newer releases will be able to build the required dependencies.

  • Build the PyTorch/XLA source:

    cd xla/
    python setup.py install

Before Submiting A Pull Request:

In pytorch/xla repo we enforce coding style for both C++ and Python files. Please try to format your code before submitting a pull request.

C++ Style Guide

pytorch/xla uses clang-format-7 with a customized style config. If your PR touches the C++ source files, please run the following command before submmiting a PR.

# If your PR only changes foo.cpp, run the following in xla/ folder
clang-format-7 -i -style=file /PATH/TO/foo.cpp
# To format all cpp files, run the follwoing in xla/ folder
find -name '*.cpp' -o -name '*.h' | xargs clang-format-7 -i -style=file

Python Style Guide

pytorch/xla uses yapf with a customized style config. If your PR touches the Python source files, please run the following command before submmiting a PR.

#TODO: