Python bindings

!!! info

API reference pages for IREE's runtime and compiler Python APIs are hosted on
[readthedocs](https://iree-python-api.readthedocs.io/en/latest/).

Overview

IREE offers Python bindings split into several packages, covering different components:

PIP package nameDescription
iree-compilerIREE's generic compiler tools and helpers
iree-runtimeIREE's runtime, including CPU and GPU backends
iree-tools-tfTools for importing from TensorFlow
iree-tools-tfliteTools for importing from TensorFlow Lite
iree-jaxTools for importing from JAX

Collectively, these packages allow for importing from frontends, compiling towards various targets, and executing compiled code on IREE's backends.

!!! Caution “Caution - Operating system support” Packages are currently only available on Linux and macOS. They are not available on Windows yet (see this issue).

:octicons-download-16: Prerequisites

To use IREE's Python bindings, you will first need to install Python 3 and pip, as needed.

???+ Tip “Tip - Virtual environments” We recommend using virtual environments to manage python packages, such as through venv (about, tutorial):

=== "Linux"

    ``` shell
    python -m venv .venv
    source .venv/bin/activate
    ```

=== "macOS"

    ``` shell
    python -m venv .venv
    source .venv/bin/activate
    ```

=== "Windows"

    ``` powershell
    python -m venv .venv
    .venv\Scripts\activate.bat
    ```

When done, run `deactivate`.

Installing IREE packages

:octicons-package-16: Prebuilt packages

=== “Stable releases”

Stable release packages are
[published to PyPI](https://pypi.org/user/google-iree-pypi-deploy/).

``` shell
python -m pip install \
  iree-compiler \
  iree-runtime
```

=== “:material-alert: Nightly releases”

Nightly releases are published on
[GitHub releases](https://github.com/openxla/iree/releases).

``` shell
python -m pip install \
  --find-links https://openxla.github.io/iree/pip-release-links.html \
  --upgrade \
  iree-compiler \
  iree-runtime
```

:material-hammer-wrench: Building from source

See Building Python bindings page for instructions for building from source.

Using the Python bindings

API reference pages for IREE's runtime and compiler Python APIs are hosted on readthedocs.

Check out the samples in IREE's samples/colab/ directory and the iree-samples repository for examples using the Python APIs.