-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add auto doc gen for ORTModule API during CI build (#7046)
In addition to ORTModule auto documentation during packaging, this PR also update golden numbers to fix CI
- Loading branch information
Thiago Crepaldi
authored
Mar 22, 2021
1 parent
3b58fc7
commit 867804b
Showing
30 changed files
with
210 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
# -*- coding: utf-8 -*- | ||
# | ||
# Configuration file for the Sphinx documentation builder. | ||
|
||
# -- Project information ----------------------------------------------------- | ||
|
||
project = 'ORTModule' | ||
copyright = '2018-2021, Microsoft' | ||
author = 'Microsoft' | ||
version = '0.1' # TODO: Should use `onnxruntime.__version__` instead? | ||
release = version | ||
|
||
# -- General configuration --------------------------------------------------- | ||
|
||
extensions = ['sphinx.ext.autodoc', | ||
'sphinx.ext.intersphinx' | ||
] | ||
templates_path = ['_templates'] | ||
exclude_patterns = [] | ||
|
||
# -- Options for HTML output ------------------------------------------------- | ||
|
||
html_theme = 'sphinx_rtd_theme' | ||
html_static_path = ['_static'] | ||
|
||
# -- Options for intersphinx extension --------------------------------------- | ||
|
||
intersphinx_mapping = {'https://docs.python.org/': None} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
This document describes ORTModule PyTorch frontend API for the ONNX Runtime (aka ORT) training acelerator. | ||
|
||
What is new | ||
=========== | ||
|
||
Version 0.1 | ||
----------- | ||
|
||
#. Initial version | ||
|
||
Overview | ||
======== | ||
The aim of ORTModule is to provide a drop-in replacement for one or more torch.nn.Module objects in a user’s PyTorch program, | ||
and execute the forward and backward passes of those modules using ORT. | ||
|
||
As a result, the user will be able to accelerate their training script gradually using ORT, | ||
without having to modify their training loop. | ||
|
||
Users will be able to use standard PyTorch debugging techniques for convergence issues, | ||
e.g. by probing the computed gradients on the model’s parameters. | ||
|
||
The following code example illustrates how ORTModule would be used in a user’s training script, | ||
in the simple case where the entire model can be offloaded to ONNX Runtime: | ||
|
||
.. code-block:: python | ||
# Original PyTorch model | ||
class NeuralNet(torch.nn.Module): | ||
def __init__(self, input_size, hidden_size, num_classes): | ||
... | ||
def forward(self, x): | ||
... | ||
model = NeuralNet(input_size=784, hidden_size=500, num_classes=10) | ||
model = ORTModule(model) # Only change to original PyTorch script | ||
criterion = torch.nn.CrossEntropyLoss() | ||
optimizer = torch.optim.SGD(model.parameters(), lr=1e-4) | ||
# Training Loop is unchanged | ||
for data, target in data_loader: | ||
optimizer.zero_grad() | ||
output = model(data) | ||
loss = criterion(output, target) | ||
loss.backward() | ||
optimizer.step() | ||
API | ||
=== | ||
|
||
.. automodule:: onnxruntime.training.ortmodule | ||
:members: | ||
:show-inheritance: | ||
:member-order: bysource | ||
.. :inherited-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.. ORTModule documentation master file, created by | ||
sphinx-quickstart on Thu Mar 11 10:21:00 2021. | ||
You can adapt this file completely to your liking, but it should at least | ||
contain the root `toctree` directive. | ||
ORTModule documentation | ||
======================= | ||
|
||
ORTModule is a PyTorch frontend API for `ONNX Runtime <https://www.onnxruntime.ai/docs/>`_, | ||
a cross-platform inferencing and training accelerator. | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: Contents: | ||
|
||
content | ||
|
||
|
||
Indices and tables | ||
================== | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
sphinx | ||
sphinx_gallery | ||
|
||
sphinx_rtd_theme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,4 +112,3 @@ make install | |
|
||
cd / | ||
rm -rf /tmp/src | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,25 @@ | ||
# This script must be executed from this folder. | ||
|
||
# $1 python path | ||
# $2 source folder | ||
# $3 build folder | ||
echo "----" | ||
echo $1 | ||
echo $2 | ||
echo $3 | ||
echo "----" | ||
ls $3/Release | ||
echo "----" | ||
# $4 build config | ||
|
||
# Install doc generation tools | ||
$1/python -m pip install -r $2/docs/python/requirements.txt | ||
export PYTHONPATH=$3/Release:$PYTHONPATH | ||
$1/python -m sphinx -j1 -v -T -b html -d $3/docs/_doctrees/html $2/docs/python $3/docs/html | ||
$1/python -u $2/tools/doc/rename_folders.py $3/docs/html | ||
# zip -r $3/python_doc.zip $3/docs/html | ||
|
||
# Fake onnxruntime installation | ||
export PYTHONPATH=$3/$4:$PYTHONPATH | ||
|
||
# Remove old docs | ||
rm -rf $3/docs/ | ||
|
||
# Inference doc | ||
$1/python -m sphinx -j1 -v -T -b html -d $3/docs/inference/_doctrees/html $2/docs/python/inference $3/docs/inference/html | ||
$1/python -u $2/tools/doc/rename_folders.py $3/docs/inference/html | ||
# (cd $3/docs/inference/html && zip -r $3/docs/python_inference_doc.zip .) | ||
|
||
# Training doc | ||
$1/python -m sphinx -j1 -v -T -b html -d $3/docs/training/_doctrees/html $2/docs/python/training $3/docs/training/html | ||
$1/python -u $2/tools/doc/rename_folders.py $3/docs/training/html | ||
# (cd $3/docs/training/html && zip -r $3/docs/python_training_doc.zip .) |