torch-mlir/.github/workflows/buildAndTest.yml

144 lines
5.3 KiB
YAML
Raw Normal View History

name: Build and Test
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
inputs:
release_id:
description: 'Release id to upload artifacts to'
default: ''
python_package_version:
description: 'Version to use for creating the Python package'
default: ''
jobs:
build:
2022-04-04 23:20:56 +08:00
name: Build and Test and maybe Publish (Release Asserts)
2020-08-08 01:32:02 +08:00
runs-on: ubuntu-20.04
steps:
2021-09-28 05:07:24 +08:00
- name: Get torch-mlir
uses: actions/checkout@v2
with:
submodules: 'true'
- uses: ./.github/actions/setup-build
with:
cache-suffix: ''
2021-09-28 05:07:24 +08:00
- name: Build and Test torch-mlir (Assert)
run: |
cd $GITHUB_WORKSPACE
mkdir build
cd build
cmake $GITHUB_WORKSPACE/externals/llvm-project/llvm -GNinja \
-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++ \
-DPython3_EXECUTABLE=$(which python) \
-DLLVM_ENABLE_ASSERTIONS=ON \
2021-09-28 05:07:24 +08:00
-DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_EXTERNAL_PROJECTS="torch-mlir;torch-mlir-dialects" \
2021-09-28 05:07:24 +08:00
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$GITHUB_WORKSPACE" \
-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 \
[torch-mlir earthmoving (2/N)] Python code movement. This moves the bulk of the Python code (including the Torch interop) from `frontends/pytorch` into `torch-mlir/TorchPlugin`. This also required reconciling a bunch of other Python-related stuff, like the `torch` dialects. As I did this, it was simpler to just remove all the old numpy/basicpy stuff because we were going to delete it anyway and it was faster than debugging an intermediate state that would only last O(days) anyway. torch-mlir has two top-level python packages (built into the `python_packages` directory): - `torch_mlir_dialects`: `torch` dialect Python bindings (does not depend on PyTorch). This also involves building the aggregate CAPI for `torch-mlir`. - `torch_mlir`: bindings to the part of the code that links against PyTorch (or C++ code that transitively does). Additionally, there remain two more Python packages in npcomp (but outside `torch-mlir`): - `npcomp_torch`: Contains the e2e test framework and testing configs that plug into RefBackend and IREE. - `npcomp_core`: Contains the low-level interfaces to RefBackend and IREE that `npcomp_torch` uses, along with its own `MLIR_PYTHON_PACKAGE_PREFIX=npcomp.` aggregation of the core MLIR python bindings. (all other functionality has been stripped out) After all the basicpy/numpy deletions, the `npcomp` C++ code is now very tiny. It basically just contains RefBackend and the `TorchConversion` dialect/passes (e.g. `TorchToLinalg.cpp`). Correspondingly, there are now 4 main testing targets paralleling the Python layering (which is reflective of the deeper underlying dependency structure) - `check-torch-mlir`: checks the `torch-mlir` pure MLIR C++ code. - `check-torch-mlir-plugin`: checks the code in `TorchPlugin` (e.g. TorchScript import) - `check-frontends-pytorch`: Checks the little code we have in `frontends/pytorch` -- mainly things related to the e2e framework itself. - `check-npcomp`: Checks the pure MLIR C++ code inside npcomp. There is a target `check-npcomp-all` that runs all of them. The `torch-mlir/build_standalone.sh` script does a standalone build of `torch-mlir`. The e2e tests (`tools/torchscript_e2e_test.sh`) are working too. The update_torch_ods script now lives in `torch-mlir/build_tools/update_torch_ods.sh` and expects a standalone build. This change also required a fix upstream related to cross-shlib Python dependencies, so we also update llvm-project to 8dca953dd39c0cd8c80decbeb38753f58a4de580 to get https://reviews.llvm.org/D109776 (no other fixes were needed for the integrate, thankfully). This completes most of the large source code changes. Next will be bringing the CI/packaging/examples back to life.
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
- 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"
python -m e2e_testing.torchscript.main --config=refbackend -v
- name: TOSA backend - TorchScript end-to-end tests
run: |
cd $GITHUB_WORKSPACE
export PYTHONPATH="$GITHUB_WORKSPACE/build/tools/torch-mlir/python_packages/torch_mlir"
python -m e2e_testing.torchscript.main --config=tosa -v
# 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 \
TORCH_MLIR_PYTHON_PACKAGE_VERSION="${{ github.event.inputs.python_package_version }}" \
./build_tools/build_python_wheels.sh
2022-04-12 00:50:32 +08:00
# If we were given a release_id, then upload the package we just built
# to the github releases page.
- name: Upload Release Assets (if requested)
if: github.event.inputs.release_id != ''
2022-04-12 00:50:32 +08:00
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
# 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 != ''
2022-04-12 00:50:32 +08:00
id: publish_release
uses: eregon/publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.WORKFLOW_INVOCATION_TOKEN }}
with:
release_id: ${{ github.event.inputs.release_id }}
2022-04-04 23:20:56 +08:00
build-out-of-tree:
name: Build and Test out-of-tree (Release Asserts)
runs-on: ubuntu-20.04
steps:
- name: Get torch-mlir
uses: actions/checkout@v2
with:
submodules: 'true'
- uses: ./.github/actions/setup-build
with:
cache-suffix: '-out-of-tree'
2022-04-04 23:20:56 +08:00
- name: Build LLVM (standalone)
run: |
cd $GITHUB_WORKSPACE
cmake -Bllvm-build -GNinja \
-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++ \
-DPython3_EXECUTABLE=$(which python) \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_PROJECTS=mlir \
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
-DLLVM_TARGETS_TO_BUILD=host \
externals/llvm-project/llvm
ninja -Cllvm-build
- name: Build and test torch-mlir (out-of-tree)
run: |
cd $GITHUB_WORKSPACE
cmake -GNinja -Bbuild \
-DCMAKE_LINKER=lld \
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DMLIR_DIR="$(pwd)/llvm-build/lib/cmake/mlir/" \
-DLLVM_DIR="$(pwd)/llvm-build/lib/cmake/llvm/" \
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
-DPython3_EXECUTABLE=$(which python) \
.
ninja -Cbuild check-torch-mlir-all
- name: RefBackend - TorchScript end-to-end tests
run: |
cd $GITHUB_WORKSPACE
export PYTHONPATH="$GITHUB_WORKSPACE/build/python_packages/torch_mlir"
python -m e2e_testing.torchscript.main --config=refbackend -v
- name: TOSA backend - TorchScript end-to-end tests
run: |
cd $GITHUB_WORKSPACE
export PYTHONPATH="$GITHUB_WORKSPACE/build/python_packages/torch_mlir"
python -m e2e_testing.torchscript.main --config=tosa -v