Skip to content

Latest commit

 

History

History
88 lines (63 loc) · 2.83 KB

developer_guide.md

File metadata and controls

88 lines (63 loc) · 2.83 KB

XLA developer guide

This guide shows you how to get started developing the XLA project.

Before you begin, complete the following prerequisites:

  1. Go to CONTRIBUTING.md and review the contribution process.
  2. If you haven't already done so, sign the Contributor License Agreement.
  3. Install or configure the following dependencies:

Then follow the steps below to get the source code, set up an environment, build the repository, and create a pull request.

Get the code

  1. Create a fork of the XLA repository.
  2. Clone your fork of the repo, replacing <USER> with your GitHub username:
    git clone https://github.com/<USER>/xla.git
  3. Change into the xla directory: cd xla
  4. Configure the remote upstream repo:
    git remote add upstream https://github.com/openxla/xla.git

Set up an environment

  1. Install Bazel.

    To build XLA, you must have Bazel installed. The recommended way to install Bazel is using Bazelisk, which automatically downloads the correct Bazel version for XLA. If Bazelisk is unavailable, you can install Bazel manually.

  2. Create and run a TensorFlow Docker container.

    To get the TensorFlow Docker image for both CPU and GPU building, run the following command:

    docker run --name xla -w /xla -it -d --rm -v $PWD:/xla tensorflow/build:latest-python3.9 bash

Build

Build for CPU:

docker exec xla ./configure.py --backend=CPU
docker exec xla bazel build --test_output=all --spawn_strategy=sandboxed //xla/...

Build for GPU:

docker exec xla ./configure.py --backend=CUDA
docker exec xla bazel build --test_output=all --spawn_strategy=sandboxed //xla/...

NB: please note that with hermetic CUDA rules, you don't have to build XLA in Docker. You can build XLA for GPU on your machine without GPUs and without NVIDIA driver installed:

./configure.py --backend=CUDA

bazel build --test_output=all --spawn_strategy=sandboxed //xla/...

Your first build will take quite a while because it has to build the entire stack, including XLA, MLIR, and StableHLO.

To learn more about building XLA, see Build from source.

Create a pull request

When you're ready to send changes for review, create a pull request.

To learn about the XLA code review philosophy, see Code reviews.