Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial API docs config using Sphinx and readthedocs. #434

Merged
merged 13 commits into from
Jan 31, 2025
Merged
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_build
17 changes: 17 additions & 0 deletions docs/.readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2

build:
os: "ubuntu-24.04"
tools:
python: "3.12"
jobs:
pre_build:
- python -m pip install .

python:
install:
- requirements: docs/requirements.txt
- requirements: pytorch-cpu-requirements.txt

sphinx:
configuration: docs/conf.py
49 changes: 49 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# API Docs

This directory uses Sphinx to build documentation that is hosted at
https://iree-turbine.readthedocs.io/.

## Building the API documentation locally

### Setup virtual environment with requirements

From this docs/ directory:

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

# Install sphinx website generator requirements and PyTorch dep.
python -m pip install -r requirements.txt
python -m pip install -r ../pytorch-cpu-requirements.txt

# Install iree-turbine itself.
# Editable so you can make local changes and preview them easily.
python -m pip install -e ..
```

### Build docs

```shell
sphinx-build -b html . _build
```

### Serve locally locally with autoreload

```shell
# Default config - only watch for changes to this folder (.rst files).
sphinx-autobuild . _build

# Advanced config - also watch for changes to the entire project (.py files).
sphinx-autobuild . _build --watch ..
```

Then open http://127.0.0.1:8000 as instructed by the logs and make changes to
the files in this directory as needed to update the documentation.

## Authoring documentation

### Useful references

* https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html
* https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html
45 changes: 45 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2025 The IREE Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import os
import sys

try:
import iree.turbine
except ImportError:
sys.path.insert(0, os.path.abspath("../"))
import iree.turbine

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "IREE Turbine"
copyright = "2025, The IREE Authors"
author = "The IREE Authors"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"myst_parser",
]

templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "*.venv", "README.md"]


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"]
39 changes: 39 additions & 0 deletions docs/core/aot.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
`iree.turbine.aot`
=====================

aot
--------------

.. automodule:: iree.turbine.aot
:imported-members:
:members:
:undoc-members:

passes
--------------

.. automodule:: iree.turbine.aot.passes
:imported-members:
:members:
:undoc-members:

support
--------------

.. automodule:: iree.turbine.aot.support.procedural
:imported-members:
:members:
:undoc-members:

.. automodule:: iree.turbine.aot.support.procedural.exported_program
:members:
:undoc-members:

build actions
--------------

.. py:module:: iree.turbine.aot.build_actions

.. autofunction:: turbine_generate
.. autoclass:: RemoteGenerator
.. autoclass:: TurbineBuilderAction
7 changes: 7 additions & 0 deletions docs/core/dynamo.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
`iree.turbine.dynamo`
=====================

.. automodule:: iree.turbine.dynamo
:imported-members:
:members:
:undoc-members:
15 changes: 15 additions & 0 deletions docs/core/runtime.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
`iree.turbine.runtime`
=====================

.. automodule:: iree.turbine.runtime
:imported-members:
:members:
:undoc-members:

op_reg
--------------

.. automodule:: iree.turbine.runtime.op_reg
:imported-members:
:members:
:undoc-members:
32 changes: 32 additions & 0 deletions docs/core/support.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
`iree.turbine.support`
=====================

.. automodule:: iree.turbine.support
:imported-members:
:members:
:undoc-members:

conversions
--------------

.. py:module:: iree.turbine.support.conversions

.. autofunction:: dtype_to_element_type
.. autofunction:: torch_dtype_to_numpy

debugging
--------------

.. py:module:: iree.turbine.support.debugging

.. autoclass:: DebugFlags
:members:
:undoc-members:

logging
--------------

.. py:module:: iree.turbine.support.logging

.. autoclass:: DefaultFormatter
.. autofunction:: get_logger
8 changes: 8 additions & 0 deletions docs/core/tools.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
`iree.turbine.tools`
=====================

.. py:module:: iree.turbine.tools

.. autoclass:: Interpreter
:members:
:undoc-members:
39 changes: 39 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
IREE Turbine documentation
==========================

Welcome to the documentation for https://github.com/iree-org/iree-turbine!

API reference material
=================

.. toctree::
:maxdepth: 1
:caption: IREE Turbine Core
:glob:

core/*

.. toctree::
:maxdepth: 1
:caption: TK and TKW
:glob:

kernel/*


Project documentation
=================

.. toctree::
:maxdepth: 1
:caption: Infrastructure
:glob:

infra/*

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
8 changes: 4 additions & 4 deletions docs/releasing.md → docs/infra/releasing.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Releasing iree-turbine
# Releasing iree-turbine packages

This project hosts the https://pypi.org/project/iree-turbine/ package, which
depends on the https://pypi.org/project/iree-base-compiler/ and
https://pypi.org/project/iree-base-runtime/ packages. Releases can either be
This project hosts the <https://pypi.org/project/iree-turbine/> package, which
depends on the <https://pypi.org/project/iree-base-compiler/> and
<https://pypi.org/project/iree-base-runtime/> packages. Releases can either be
conducted independently, or they can be coordinated across projects by
initiating a release here.

Expand Down
8 changes: 8 additions & 0 deletions docs/kernel/wave.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
TKW (`turbine.kernel.wave`)
===========================

.. py:module:: iree.turbine.kernel.wave.wave

.. autoclass:: LaunchableWave
:members:
:undoc-members:
6 changes: 6 additions & 0 deletions docs/kernel/wave_codegen.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Wave Codegen
============

.. automodule:: iree.turbine.kernel.wave.codegen
:members:
:undoc-members:
6 changes: 6 additions & 0 deletions docs/kernel/wave_ops.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Wave Ops
===================

.. automodule:: iree.turbine.kernel.ops.wave_ops
:members:
:undoc-members:
4 changes: 4 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sphinx==8.1.3
sphinx-autobuild==2024.10.3
sphinx-rtd-theme==3.0.2
myst-parser==4.0.0
Loading