2020-08-05 09:57:59 +08:00
|
|
|
name: Build and Test
|
|
|
|
|
2021-10-22 12:23:21 +08:00
|
|
|
on:
|
2021-10-06 07:26:26 +08:00
|
|
|
push:
|
2021-10-22 12:23:21 +08:00
|
|
|
branches:
|
|
|
|
- main
|
2021-10-06 07:26:26 +08:00
|
|
|
pull_request:
|
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
release_id:
|
|
|
|
description: 'Release id to upload artifacts to'
|
|
|
|
default: ''
|
2020-08-05 09:57:59 +08:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
2021-07-28 07:10:10 +08:00
|
|
|
name: Build and Test (Release Asserts)
|
2020-08-08 01:32:02 +08:00
|
|
|
runs-on: ubuntu-20.04
|
2020-08-05 09:57:59 +08:00
|
|
|
steps:
|
2021-07-30 01:43:18 +08:00
|
|
|
- name: Set up Python
|
|
|
|
uses: actions/setup-python@v2
|
|
|
|
with:
|
|
|
|
python-version: 3.9
|
2021-09-28 05:07:24 +08:00
|
|
|
- name: Get torch-mlir
|
2020-08-05 09:57:59 +08:00
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
submodules: 'true'
|
2021-10-06 07:26:26 +08:00
|
|
|
- name: Install MLIR Python depends
|
2020-10-13 12:49:39 +08:00
|
|
|
run: |
|
2022-03-27 00:12:27 +08:00
|
|
|
python -m pip install -r $GITHUB_WORKSPACE/externals/llvm-project/mlir/python/requirements.txt
|
2021-10-06 07:26:26 +08:00
|
|
|
- name: Install PyTorch nightly depends
|
2021-02-22 05:36:06 +08:00
|
|
|
run: |
|
2021-08-03 01:58:02 +08:00
|
|
|
python -m pip install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
|
2021-07-28 07:10:10 +08:00
|
|
|
- name: Install Ninja
|
|
|
|
uses: llvm/actions/install-ninja@55d844821959226fab4911f96f37071c1d4c3268
|
|
|
|
- name: Get Submodule Hash
|
|
|
|
id: get-submodule-hash
|
|
|
|
run: echo "::set-output name=hash::$(md5sum $(git submodule status))"
|
2020-08-05 09:57:59 +08:00
|
|
|
shell: bash
|
2021-07-28 07:10:10 +08:00
|
|
|
- name: Ccache for C++ compilation
|
|
|
|
uses: hendrikmuhs/ccache-action@4687d037e4d7cf725512d9b819137a3af34d39b3
|
2020-08-05 09:57:59 +08:00
|
|
|
with:
|
2021-07-30 01:43:18 +08:00
|
|
|
key: ${{ runner.os }}-clangreleaseasserts-${{ steps.get-submodule-hash.outputs.hash }}
|
2021-09-28 05:07:24 +08:00
|
|
|
- name: Build and Test torch-mlir (Assert)
|
2020-08-05 09:57:59 +08:00
|
|
|
run: |
|
2021-07-28 07:10:10 +08:00
|
|
|
cd $GITHUB_WORKSPACE
|
|
|
|
mkdir build
|
|
|
|
cd build
|
2022-03-27 00:12:27 +08:00
|
|
|
cmake $GITHUB_WORKSPACE/externals/llvm-project/llvm -GNinja \
|
2021-07-28 07:10:10 +08:00
|
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
|
|
-DCMAKE_LINKER=lld \
|
|
|
|
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
|
|
|
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
|
2021-07-30 01:43:18 +08:00
|
|
|
-DPython3_EXECUTABLE=$(which python) \
|
2021-07-28 07:10:10 +08:00
|
|
|
-DLLVM_ENABLE_ASSERTIONS=ON \
|
2021-09-28 05:07:24 +08:00
|
|
|
-DLLVM_ENABLE_PROJECTS=mlir \
|
2022-02-03 07:01:38 +08:00
|
|
|
-DLLVM_EXTERNAL_PROJECTS="torch-mlir;torch-mlir-dialects" \
|
2021-09-28 05:07:24 +08:00
|
|
|
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$GITHUB_WORKSPACE" \
|
2022-02-03 07:01:38 +08:00
|
|
|
-DLLVM_EXTERNAL_TORCH_MLIR_DIALECTS_SOURCE_DIR="${GITHUB_WORKSPACE}/external/llvm-external-projects/torch-mlir-dialects" \
|
2021-09-28 05:07:24 +08:00
|
|
|
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
|
2021-09-11 02:44:38 +08:00
|
|
|
-DLLVM_TARGETS_TO_BUILD=host
|
2021-09-28 05:07:24 +08:00
|
|
|
ninja check-torch-mlir-all
|
2021-10-29 02:25:53 +08:00
|
|
|
- name: RefBackend - TorchScript end-to-end tests
|
2021-07-30 13:50:52 +08:00
|
|
|
run: |
|
|
|
|
cd $GITHUB_WORKSPACE
|
2021-09-28 05:07:24 +08:00
|
|
|
export PYTHONPATH="$GITHUB_WORKSPACE/build/tools/torch-mlir/python_packages/torch_mlir"
|
2021-09-17 06:18:17 +08:00
|
|
|
python -m e2e_testing.torchscript.main --config=refbackend -v
|
2021-10-29 02:25:53 +08:00
|
|
|
- name: TOSA backend - TorchScript end-to-end tests
|
|
|
|
run: |
|
|
|
|
cd $GITHUB_WORKSPACE
|
|
|
|
export PYTHONPATH="$GITHUB_WORKSPACE/build/tools/torch-mlir/python_packages/torch_mlir"
|
2021-10-08 10:07:03 +08:00
|
|
|
python -m e2e_testing.torchscript.main --config=tosa -v
|
2021-10-06 07:26:26 +08:00
|
|
|
|
|
|
|
# TODO: Only build packages in full Release mode.
|
|
|
|
# On the other hand, having assertions on isn't too bad of an idea at this
|
|
|
|
# early stage.
|
|
|
|
- name: Build Python wheels and smoke test.
|
|
|
|
run: |
|
|
|
|
cd $GITHUB_WORKSPACE
|
|
|
|
python -m pip install wheel
|
|
|
|
TORCH_MLIR_CMAKE_BUILD_DIR="$GITHUB_WORKSPACE/build" \
|
|
|
|
TORCH_MLIR_CMAKE_BUILD_DIR_ALREADY_BUILT=1 \
|
|
|
|
./build_tools/build_python_wheels.sh
|
2021-10-07 06:47:26 +08:00
|
|
|
|
|
|
|
# If we were given a release_id, then upload the package we just built
|
|
|
|
# to the github releases page.
|
2021-10-06 07:26:26 +08:00
|
|
|
- name: Upload Release Assets (if requested)
|
|
|
|
if: github.event.inputs.release_id != ''
|
|
|
|
id: upload-release-assets
|
|
|
|
uses: dwenegar/upload-release-assets@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.WORKFLOW_INVOCATION_TOKEN }}
|
|
|
|
with:
|
|
|
|
release_id: ${{ github.event.inputs.release_id }}
|
|
|
|
assets_path: ./wheelhouse/*.whl
|
2021-10-07 06:47:26 +08:00
|
|
|
# Publishing is necessary to make the release visible to `pip`
|
|
|
|
# on the github releases page.
|
|
|
|
- name: Publish Release (if requested)
|
|
|
|
if: github.event.inputs.release_id != ''
|
|
|
|
id: publish_release
|
|
|
|
uses: eregon/publish-release@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.WORKFLOW_INVOCATION_TOKEN }}
|
|
|
|
with:
|
|
|
|
release_id: ${{ github.event.inputs.release_id }}
|