diff --git a/.github/workflows/publish-c-apidocs.yml b/.github/workflows/publish-c-apidocs.yml index 487336428a..4e478204f1 100644 --- a/.github/workflows/publish-c-apidocs.yml +++ b/.github/workflows/publish-c-apidocs.yml @@ -1,15 +1,25 @@ name: Update C/C++ API Docs + +# Run when the C API changes or every month so that the artifact does not expire on: push: branches: - main paths: - include/onnxruntime/core/session - + schedule: + - cron: '0 0 1 * *' workflow_dispatch: +concurrency: + group: "apidocs-c" + cancel-in-progress: false + +permissions: + contents: write + jobs: - publish: + build: name: Generate C/C++ API docs runs-on: ubuntu-latest steps: @@ -21,27 +31,21 @@ jobs: sudo apt-get install libclang-cpp14 wget https://www.doxygen.nl/files/doxygen-1.9.6.linux.bin.tar.gz tar xvzf doxygen-1.9.6.linux.bin.tar.gz - - name: Set commit ID - id: vars - run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - name: Run doxygen run: | mkdir -p build/doxygen cd docs/c_cxx ../../doxygen-1.9.6/bin/doxygen - - uses: actions/checkout@v2 - with: - ref: gh-pages - clean: false - - name: Move API docs into target area + - name: Log source commit + run: git rev-parse --short HEAD > build/doxygen/html/source-version.txt + - name: Move C/C++ docs into site run: | - rm -rf docs/api/c - mv build/doxygen/html docs/api/c - - name: Create Pull Request - uses: peter-evans/create-pull-request@v3 + mkdir -p _site/docs/api + rm -rf site/docs/api/c + mv build/doxygen/html _site/docs/api/c + - name: Upload new site + uses: actions/upload-artifact@v3 with: - branch: gh-pages-pr-c-docs - base: gh-pages - title: '[Automated]: Update C/C++ API docs' - commit-message: 'Update C/C++ API docs to commit ${{ steps.vars.outputs.sha_short }}' - add-paths: docs/api/c + name: onnxruntime-c-apidocs + path: _site + retention-days: 60 diff --git a/.github/workflows/publish-csharp-apidocs.yml b/.github/workflows/publish-csharp-apidocs.yml index 095b5297c1..7d33a782fb 100644 --- a/.github/workflows/publish-csharp-apidocs.yml +++ b/.github/workflows/publish-csharp-apidocs.yml @@ -1,11 +1,28 @@ name: Update C# API Docs + +# Run when the C# API changes or every month so that the artifact does not expire on: push: branches: - main + paths: + - csharp + schedule: + - cron: '0 0 1 * *' + workflow_dispatch: + +concurrency: + group: "apidocs-csharp" + cancel-in-progress: false + +permissions: + contents: write + jobs: - publish: - runs-on: windows-latest + build: + runs-on: ubuntu-latest + env: + DOCFXVERSION: 2.62.2 steps: - uses: actions/checkout@v3 - name: Setup .NET @@ -17,39 +34,25 @@ jobs: - name: Download DocFX run: | mkdir -p build/docfx - Invoke-WebRequest -Uri "https://github.com/dotnet/docfx/releases/download/v${env:DOCFXVERSION}/docfx.zip" -OutFile "build/docfx/docfx.zip" - [System.IO.Compression.ZipFile]::ExtractToDirectory("build/docfx/docfx.zip", "build/docfx" ) - cd build/docfx - ls - env: - DOCFXVERSION: 2.59.3 + wget https://github.com/dotnet/docfx/releases/download/v${DOCFXVERSION}/docfx-linux-x64-v${DOCFXVERSION}.zip -O build/docfx/docfx.zip + unzip build/docfx/docfx.zip -d build/docfx - name: Install NuGet uses: nuget/setup-nuget@v1 - name: Build Documentation run: | - ls - build/docfx/docfx.exe metadata csharp/ApiDocs/docfx.json + build/docfx/docfx metadata csharp/ApiDocs/docfx.json dotnet build csharp/ApiDocs/ApiDocs.csproj --no-restore - build/docfx/docfx.exe build csharp/ApiDocs/docfx.json - - name: Set commit ID - id: vars - run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - - uses: actions/checkout@v2 - with: - ref: gh-pages - clean: false - - name: Move API docs into target area + build/docfx/docfx build csharp/ApiDocs/docfx.json + - name: Log source commit + run: git rev-parse --short HEAD > csharp/ApiDocs/csharp/source-version.txt + - name: Move C# docs into site run: | - if (Test-Path -Path docs/api/csharp) {rm -r -fo docs/api/csharp} - MOVE csharp/ApiDocs/csharp docs/api - rm -r -fo csharp/ApiDocs - rm -r -fo csharp/src - - name: Git Checkin - run: git add . - - name: Create Pull Request - uses: peter-evans/create-pull-request@v3 + mkdir -p _site/docs/api + rm -rf _site/docs/api/csharp + mv csharp/ApiDocs/csharp _site/docs/api/csharp + - name: Upload docs artifact + uses: actions/upload-artifact@v3 with: - branch: gh-pages-pr-csharp-docs - base: gh-pages - title: '[Automated]: Update C# API docs' - commit-message: 'Update C# API docs to commit ${{ steps.vars.outputs.sha_short }}' + name: onnxruntime-csharp-apidocs + path: _site + retention-days: 60 diff --git a/.github/workflows/publish-gh-pages.yml b/.github/workflows/publish-gh-pages.yml new file mode 100644 index 0000000000..5ddb1e3bb0 --- /dev/null +++ b/.github/workflows/publish-gh-pages.yml @@ -0,0 +1,101 @@ +# Sample workflow for building and deploying a Jekyll site to GitHub Pages +name: Publish site + +on: + # Runs on pushes targeting the branch where the website sources live + push: + branches: ["gh-pages"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Build job + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: gh-pages + + - name: Setup Pages + uses: actions/configure-pages@v3 + + - name: Build with Jekyll + uses: actions/jekyll-build-pages@v1 + with: + source: ./ + destination: ./_site + + - name: Download C apidocs artifact + uses: dawidd6/action-download-artifact@v2 + with: + name: onnxruntime-c-apidocs + workflow: publish-c-apidocs.yml + branch: main + path: apidocs + + - name: Download C# apidocs artifact + uses: dawidd6/action-download-artifact@v2 + with: + name: onnxruntime-csharp-apidocs + workflow: publish-csharp-apidocs.yml + branch: main + path: apidocs + + - name: Download Java apidocs artifact + uses: dawidd6/action-download-artifact@v2 + with: + name: onnxruntime-java-apidocs + workflow: publish-java-apidocs.yml + branch: main + path: apidocs + + - name: Download Python apidocs artifact + uses: dawidd6/action-download-artifact@v2 + with: + name: onnxruntime-python-apidocs + workflow: publish-python-apidocs.yml + branch: main + path: apidocs + + - name: Move apidocs folder into place + run: | + sudo rm -rf _site/docs/api/c + sudo mv apidocs/docs/api/c _site/docs/api + sudo rm -rf _site/docs/api/csharp + sudo mv apidocs/docs/api/csharp _site/docs/api + sudo rm -rf _site/docs/api/java + sudo mv apidocs/docs/api/java _site/docs/api + sudo rm -rf _site/docs/api/python + sudo mv apidocs/docs/api/python _site/docs/api + + - name: Upload site + uses: actions/upload-pages-artifact@v1 + with: + retention-days: 21 + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1 diff --git a/.github/workflows/publish-java-apidocs.yml b/.github/workflows/publish-java-apidocs.yml index c4d462b581..b81ea47c7f 100644 --- a/.github/workflows/publish-java-apidocs.yml +++ b/.github/workflows/publish-java-apidocs.yml @@ -1,21 +1,25 @@ name: Update Java API Docs + +# Run when the Java API changes or every month so that the artifact does not expire on: push: branches: - main paths: - java + schedule: + - cron: '0 0 1 * *' workflow_dispatch: concurrency: group: "apidocs-java" - cancel-in-progress: true + cancel-in-progress: false permissions: contents: write jobs: - publish: + build: name: Generate Java docs runs-on: ubuntu-latest steps: @@ -31,15 +35,16 @@ jobs: build-root-directory: java gradle-executable: java/gradlew arguments: javadoc - - name: Get source commit - id: vars - run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - name: Log source commit - run: echo $(git rev-parse --short HEAD) > java/build/docs/javadoc/version.txt - - name: Deploy - uses: JamesIves/github-pages-deploy-action@v4 + run: git rev-parse --short HEAD > java/build/docs/javadoc/source-version.txt + - name: Move Java docs into site + run: | + rm -rf _site/docs/api/java + mkdir -p _site/docs/api + mv java/build/docs/javadoc _site/docs/api/java + - name: Upload new site + uses: actions/upload-artifact@v3 with: - branch: gh-pages - folder: java/build/docs/javadoc - target-folder: docs/api/java - clean: true + name: onnxruntime-java-apidocs + path: _site + retention-days: 60 diff --git a/.github/workflows/publish-python-apidocs.yml b/.github/workflows/publish-python-apidocs.yml index 0ac99c0883..263dbe9229 100644 --- a/.github/workflows/publish-python-apidocs.yml +++ b/.github/workflows/publish-python-apidocs.yml @@ -1,12 +1,25 @@ name: Update Python API Docs + +# Run when the Python API changes or every month so that the artifact does not expire on: push: branches: - main + paths: + - onnxruntime/python + schedule: + - cron: '0 0 1 * *' workflow_dispatch: +concurrency: + group: "apidocs-python" + cancel-in-progress: true + +permissions: + contents: write + jobs: - publish: + build: name: Generate Python API docs runs-on: ubuntu-latest steps: @@ -27,23 +40,16 @@ jobs: run: | cd tools/doc ./builddoc.sh /usr/bin ../.. ../../build - - name: Set vars - id: vars - run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - - uses: actions/checkout@v2 - with: - ref: gh-pages - clean: false - - name: Move API docs into target area + - name: Log source commit + run: git rev-parse --short HEAD > build/docs/inference/html/source-version.txt + - name: Move Python docs into site run: | - ls docs/api - rm -rf docs/api/python - mv build/docs/inference/html docs/api/python - - name: Create Pull Request - uses: peter-evans/create-pull-request@v3 + rm -rf _site/docs/api/python + mkdir -p _site/docs/api + mv build/docs/inference/html _site/docs/api/python + - name: Upload docs artifact + uses: actions/upload-artifact@v3 with: - branch: gh-pages-pr-python-docs - base: gh-pages - title: '[Automated]: Update Python API docs' - commit-message: 'Update Python API docs to commit ${{ steps.vars.outputs.sha_short }}' - add-paths: docs/api/python + name: onnxruntime-python-apidocs + path: _site + retention-days: 60 diff --git a/docs/python/inference/examples/plot_convert_pipeline_vectorizer.py b/docs/python/inference/examples/plot_convert_pipeline_vectorizer.py deleted file mode 100644 index 3df6d6dfea..0000000000 --- a/docs/python/inference/examples/plot_convert_pipeline_vectorizer.py +++ /dev/null @@ -1,104 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -""" -Train, convert and predict with ONNX Runtime -============================================ - -This example demonstrates an end to end scenario -starting with the training of a scikit-learn pipeline -which takes as inputs not a regular vector but a -dictionary ``{ int: float }`` as its first step is a -`DictVectorizer `_. - -.. contents:: - :local: - -Train a pipeline -++++++++++++++++ - -The first step consists in retrieving the boston datset. -""" -import pandas -from sklearn.datasets import load_boston - -boston = load_boston() -X, y = boston.data, boston.target - -from sklearn.model_selection import train_test_split - -X_train, X_test, y_train, y_test = train_test_split(X, y) -X_train_dict = pandas.DataFrame(X_train[:, 1:]).T.to_dict().values() -X_test_dict = pandas.DataFrame(X_test[:, 1:]).T.to_dict().values() - -#################################### -# We create a pipeline. - -from sklearn.ensemble import GradientBoostingRegressor -from sklearn.feature_extraction import DictVectorizer -from sklearn.pipeline import make_pipeline - -pipe = make_pipeline(DictVectorizer(sparse=False), GradientBoostingRegressor()) - -pipe.fit(X_train_dict, y_train) - -#################################### -# We compute the prediction on the test set -# and we show the confusion matrix. -from sklearn.metrics import r2_score - -pred = pipe.predict(X_test_dict) -print(r2_score(y_test, pred)) - -#################################### -# Conversion to ONNX format -# +++++++++++++++++++++++++ -# -# We use module -# `sklearn-onnx `_ -# to convert the model into ONNX format. - -from skl2onnx import convert_sklearn -from skl2onnx.common.data_types import DictionaryType, FloatTensorType, Int64TensorType, SequenceType - -# initial_type = [('float_input', DictionaryType(Int64TensorType([1]), FloatTensorType([])))] -initial_type = [("float_input", DictionaryType(Int64TensorType([1]), FloatTensorType([])))] -onx = convert_sklearn(pipe, initial_types=initial_type) -with open("pipeline_vectorize.onnx", "wb") as f: - f.write(onx.SerializeToString()) - -################################## -# We load the model with ONNX Runtime and look at -# its input and output. -import onnxruntime as rt -from onnxruntime.capi.onnxruntime_pybind11_state import InvalidArgument - -sess = rt.InferenceSession("pipeline_vectorize.onnx", providers=rt.get_available_providers()) - -import numpy - -inp, out = sess.get_inputs()[0], sess.get_outputs()[0] -print("input name='{}' and shape={} and type={}".format(inp.name, inp.shape, inp.type)) -print("output name='{}' and shape={} and type={}".format(out.name, out.shape, out.type)) - -################################## -# We compute the predictions. -# We could do that in one call: - -try: - pred_onx = sess.run([out.name], {inp.name: X_test_dict})[0] -except (RuntimeError, InvalidArgument) as e: - print(e) - -############################# -# But it fails because, in case of a DictVectorizer, -# ONNX Runtime expects one observation at a time. -pred_onx = [sess.run([out.name], {inp.name: row})[0][0, 0] for row in X_test_dict] - -############################### -# We compare them to the model's ones. -print(r2_score(pred, pred_onx)) - -######################### -# Very similar. *ONNX Runtime* uses floats instead of doubles, -# that explains the small discrepencies. diff --git a/docs/python/inference/examples_md.rst b/docs/python/inference/examples_md.rst index b3426e824e..454bd423ed 100644 --- a/docs/python/inference/examples_md.rst +++ b/docs/python/inference/examples_md.rst @@ -4,21 +4,20 @@ Gallery of examples =================== - + This series of examples briefly goes into the main - feature *ONNX Runtime* implements. Each of them run in a + feature *ONNX Runtime* implements. Each of them run in a few seconds and relies on machine learned models trained with `scikit-learn `_. - + .. toctree:: :maxdepth: 1 :caption: Contents: - + auto_examples/plot_load_and_predict auto_examples/plot_common_errors auto_examples/plot_train_convert_predict auto_examples/plot_pipeline auto_examples/plot_backend - auto_examples/plot_convert_pipeline_vectorizer auto_examples/plot_metadata auto_examples/plot_profiling