Update apache-tvm to v0.15.0 #2063
Workflow file for this run
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 workflow will install Python dependencies, run tests and lint with a single version of Python | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: Build | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
schedule: | |
- cron: "15 21 * * FRI" | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-22.04, macos-12, windows-2022] | |
python-version: ['3.8', '3.9', '3.10'] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Lint with flake8 | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install flake8 | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
# The GitHub editor is 127 chars wide | |
flake8 . --count --max-complexity=10 --max-line-length=127 --statistics | |
# PyTorch CPU for Linux has different pip syntax wrt Win and Mac. | |
- name: Install torch-2.0.0+cpu if linux | |
if: ${{ startsWith(matrix.os, 'ubuntu') }} | |
run: python -m pip install torch==2.0.0 --extra-index-url https://download.pytorch.org/whl/cpu | |
- name: Install torch-2.0.0+cpu if not linux | |
if: ${{ !startsWith(matrix.os, 'ubuntu') }} | |
run: python -m pip install torch==2.0.0 | |
- name: Install basic dependencies | |
run: | | |
python -m pip install -e .[tests] -f https://download.pytorch.org/whl/torch_stable.html | |
# Compile (but not push) documentation only for one of the runs (Linux py3.8). | |
- name: Generate Documentation | |
if: ${{ matrix.python-version == '3.8' && startsWith(matrix.os, 'ubuntu') }} | |
run: | | |
# We're mocking out the torch. So now we also need to sub this on out | |
find ../. -type f -exec sed -i 's/{torch.__version__}/1.12.0/g' {} + | |
find ../. -type f -exec sed -i 's/torch.__version__/"1.12.0"/g' {} + | |
make sphinx-site -C website/ | |
# now refresh the code | |
git checkout . && python -m pip install -e .[tests] -f https://download.pytorch.org/whl/torch_stable.html | |
- name: Run basic tests without extra | |
run: pytest | |
- name: Coverage on basic tests without extra | |
run: coverage run -a -m pytest tests/test_no_extra_install.py | |
- name: If mac, install libomp to facilitate lgbm install | |
if: ${{ startsWith(matrix.os, 'macos')}} | |
run: | | |
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/fb8323f2b170bd4ae97e1bac9bf3e2983af3fdb0/Formula/libomp.rb | |
brew unlink libomp | |
brew install ./libomp.rb | |
export CC=/usr/bin/clang | |
export CXX=/usr/bin/clang++ | |
export CPPFLAGS="$CPPFLAGS -Xpreprocessor -fopenmp" | |
export CFLAGS="$CFLAGS -I/usr/local/opt/libomp/include" | |
export CXXFLAGS="$CXXFLAGS -I/usr/local/opt/libomp/include" | |
export LDFLAGS="$LDFLAGS -Wl,-rpath,/usr/local/opt/libomp/lib -L/usr/local/opt/libomp/lib -lomp" | |
- name: Install extra dependencies | |
run: | | |
python -m pip install .[extra,onnx,sparkml] | |
python -m pip install pandas | |
- uses: actions/cache@v3 | |
# TVM takes forever, we try to cache it. | |
if: ${{ startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')}} | |
id: cache | |
env: | |
CACHE_NUMBER: 9 | |
with: | |
path: ~/work/hummingbird/tvm | |
key: ${{ matrix.os }}-${{ env.CACHE_NUMBER }}-${{ matrix.python-version }}-tvm-0.13.0 | |
# Getting TVM requires: 1) Install LLVM 2) fetching TVM from github, 3) cmake, 4) make, 5) install python dependency. | |
# 2 to 4 will be retrieved from the cache. | |
# The pipeline only works for Unix systems. For windows we will have to compile LLVM from source which is a no go. | |
- name: Install LLVM if Ubuntu | |
if: ${{ startsWith(matrix.os, 'ubuntu') }} | |
run: | | |
sudo apt install -y llvm-14 | |
sudo update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-14 10 | |
- name: Install LLVM if Mac | |
if: ${{ startsWith(matrix.os, 'macos') }} | |
run: | | |
brew install llvm@14 | |
- name: Fetch and prepare TVM for compilation if Mac or Ubuntu | |
if: ${{ steps.cache.outputs.cache-hit != 'true' && (startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')) }} | |
run: | | |
cd ~/work/hummingbird | |
git clone https://github.com/apache/tvm.git | |
cd tvm | |
git checkout tags/v0.13.0 | |
git submodule update --recursive --init | |
cmake -E make_directory build | |
- name: CMake TVM if Mac | |
if: ${{ steps.cache.outputs.cache-hit != 'true' && startsWith(matrix.os, 'macos') }} | |
working-directory: ../tvm/build | |
run: >- | |
MACOSX_DEPLOYMENT_TARGET=10.13 cmake | |
"-DUSE_RPC=ON" | |
"-DUSE_GRAPH_RUNTIME=ON" | |
"-DUSE_LLVM=$(brew --prefix llvm@14)/bin/llvm-config --link-static" | |
.. | |
- name: CMake TVM if Ubuntu | |
if: ${{ steps.cache.outputs.cache-hit != 'true' && startsWith(matrix.os, 'ubuntu') }} | |
working-directory: ../tvm/build | |
run: >- | |
cmake | |
"-DUSE_RPC=ON" | |
"-DUSE_GRAPH_RUNTIME=ON" | |
"-DUSE_LLVM=llvm-config --link-static" | |
.. | |
- name: Build TVM if Mac or Ubuntu | |
if: ${{ steps.cache.outputs.cache-hit != 'true' && (startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')) }} | |
working-directory: ../tvm/build | |
run: | | |
make -j3 | |
- name: Install python TVM if Mac or Ubuntu | |
if: ${{ startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu') }} | |
working-directory: ../tvm/python | |
run: | | |
python -m pip install -U wheel packaging | |
python setup.py bdist_wheel | |
python -m pip install dist/tvm-*.whl | |
# We don't run pytest for Linux py3.8 since we do coverage for that case. | |
- name: Test with pytest | |
if: ${{ matrix.python-version != '3.8' || startsWith(matrix.os, 'ubuntu') != true }} | |
run: pytest | |
# Run and push coverage only for Linux py3.8 | |
- name: Coverage 3.8 Linux | |
if: ${{ matrix.python-version == '3.8' && startsWith(matrix.os, 'ubuntu') }} | |
run: | | |
coverage run -a -m pytest tests | |
coverage xml | |
- name: Upload coverage to Codecov | |
if: ${{ matrix.python-version == '3.8' && startsWith(matrix.os, 'ubuntu') }} | |
uses: codecov/codecov-action@v3 | |
with: | |
file: ./coverage.xml | |
flags: unittests | |
- name: Deploy to GitHub pages 🚀 | |
if: ${{ github.ref == 'refs/heads/main' && matrix.python-version == '3.8' && startsWith(matrix.os, 'ubuntu') }} | |
uses: JamesIves/[email protected] | |
with: | |
branch: gh-pages | |
folder: website/public | |