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:
|
2020-08-05 09:57:59 +08:00
|
|
|
|
|
|
|
jobs:
|
2022-07-30 01:52:46 +08:00
|
|
|
build-validate:
|
|
|
|
strategy:
|
|
|
|
fail-fast: true
|
|
|
|
matrix:
|
2022-08-04 03:50:54 +08:00
|
|
|
os: [macos-12, ubuntu-22.04]
|
2022-07-30 01:52:46 +08:00
|
|
|
targetarch: [x86_64, AArch64]
|
|
|
|
python-version: ["3.10"]
|
|
|
|
torch-binary: [ON, OFF]
|
|
|
|
llvmtype: [source, binary]
|
|
|
|
llvmbuildtype: [in-tree, out-of-tree]
|
|
|
|
exclude:
|
|
|
|
# No need for "out-of-tree LLVM and PyTorch source"
|
|
|
|
- llvmtype: source
|
|
|
|
llvmbuildtype: in-tree
|
|
|
|
- llvmtype: binary
|
|
|
|
llvmbuildtype: out-of-tree
|
|
|
|
# Disable M1 builds until https://github.com/llvm/torch-mlir/issues/1094 is fixed
|
|
|
|
- targetarch: AArch64
|
|
|
|
# macOS we only do source builds to reduce options
|
|
|
|
- os: macos-12
|
|
|
|
torch-binary: OFF
|
|
|
|
- os: macos-12
|
|
|
|
llvmtype: source
|
|
|
|
- os: macos-12
|
|
|
|
llvmtype: out-of-tree
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
|
2020-08-05 09:57:59 +08:00
|
|
|
steps:
|
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'
|
2022-04-04 18:13:29 +08:00
|
|
|
- uses: ./.github/actions/setup-build
|
2022-04-13 21:26:38 +08:00
|
|
|
with:
|
2022-08-03 22:53:01 +08:00
|
|
|
cache-suffix: ${{ matrix.os }}-${{ matrix.targetarch }}-${{ matrix.llvmtype }}-${{ matrix.llvmbuildtype }}
|
2022-07-30 01:52:46 +08:00
|
|
|
|
|
|
|
- name: llvm-binary-torch-src-or-binary
|
|
|
|
# Should be the fastest builds for CI and fails fast
|
|
|
|
# OSX CMake flags are ignore on Linux
|
|
|
|
if: matrix.llvmtype == 'binary'
|
2020-08-05 09:57:59 +08:00
|
|
|
run: |
|
2021-07-28 07:10:10 +08:00
|
|
|
cd $GITHUB_WORKSPACE
|
2022-07-30 01:52:46 +08:00
|
|
|
cmake $GITHUB_WORKSPACE/externals/llvm-project/llvm -B build -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 \
|
2022-07-21 07:18:16 +08:00
|
|
|
-DTORCH_MLIR_ENABLE_MHLO=ON \
|
2022-07-30 01:52:46 +08:00
|
|
|
-DTORCH_MLIR_USE_INSTALLED_PYTORCH=${{ matrix.torch-binary }} \
|
|
|
|
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.taregetarch }} \
|
|
|
|
-DMACOSX_DEPLOYMENT_TARGET=10.15 \
|
2021-09-11 02:44:38 +08:00
|
|
|
-DLLVM_TARGETS_TO_BUILD=host
|
2022-06-10 03:56:01 +08:00
|
|
|
|
2022-07-30 01:52:46 +08:00
|
|
|
- name: llvm-source-out-of-tree-torch-src-or-binary
|
2022-04-19 22:07:25 +08:00
|
|
|
# This build takes a while but is expected to almost always be cached.
|
|
|
|
# A cache invalidation occurs when the committed LLVM version is changed.
|
2022-07-30 01:52:46 +08:00
|
|
|
if: matrix.llvmtype == 'source'
|
2022-04-04 23:20:56 +08:00
|
|
|
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
|
2022-07-30 01:52:46 +08:00
|
|
|
cmake --build llvm-build
|
2022-04-04 23:20:56 +08:00
|
|
|
|
|
|
|
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/" \
|
2022-07-30 01:52:46 +08:00
|
|
|
-DMLIR_ENABLE_BINDINGS_PYTHON=OFF \
|
2022-07-21 07:18:16 +08:00
|
|
|
-DTORCH_MLIR_ENABLE_MHLO=ON \
|
2022-07-30 01:52:46 +08:00
|
|
|
-DTORCH_MLIR_USE_INSTALLED_PYTORCH=${{ matrix.torch-binary }} \
|
2022-04-04 23:20:56 +08:00
|
|
|
-DPython3_EXECUTABLE=$(which python) \
|
|
|
|
.
|
2022-07-22 05:16:03 +08:00
|
|
|
|
2022-07-30 01:52:46 +08:00
|
|
|
- name: Build and run check-torch-mlir-all
|
|
|
|
if: matrix.llvmtype == 'binary'
|
2022-07-22 05:16:03 +08:00
|
|
|
run: |
|
|
|
|
cd $GITHUB_WORKSPACE
|
|
|
|
export PYTHONPATH="$GITHUB_WORKSPACE/build/tools/torch-mlir/python_packages/torch_mlir"
|
2022-07-30 01:52:46 +08:00
|
|
|
cmake --build build --target check-torch-mlir-all
|
2022-07-22 05:16:03 +08:00
|
|
|
|
|
|
|
- name: RefBackend - TorchScript end-to-end tests
|
2022-07-30 01:52:46 +08:00
|
|
|
if: matrix.llvmtype == 'binary'
|
2022-07-22 05:16:03 +08:00
|
|
|
run: |
|
|
|
|
cd $GITHUB_WORKSPACE
|
|
|
|
export PYTHONPATH="$GITHUB_WORKSPACE/build/tools/torch-mlir/python_packages/torch_mlir"
|
|
|
|
python -m e2e_testing.torchscript.main --config=refbackend -v
|
2022-06-10 03:56:01 +08:00
|
|
|
|
2022-07-22 05:16:03 +08:00
|
|
|
- name: EagerMode - TorchScript end-to-end tests
|
2022-07-30 01:52:46 +08:00
|
|
|
if: matrix.llvmtype == 'binary'
|
2022-07-22 05:16:03 +08:00
|
|
|
run: |
|
|
|
|
cd $GITHUB_WORKSPACE
|
|
|
|
export PYTHONPATH="$GITHUB_WORKSPACE/build/tools/torch-mlir/python_packages/torch_mlir"
|
|
|
|
python -m e2e_testing.torchscript.main --config=eager_mode -v
|
2022-06-10 03:56:01 +08:00
|
|
|
|
2022-07-22 05:16:03 +08:00
|
|
|
- name: TOSA backend - TorchScript end-to-end tests
|
2022-07-30 01:52:46 +08:00
|
|
|
if: matrix.llvmtype == 'binary'
|
2022-07-22 05:16:03 +08:00
|
|
|
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
|
2022-06-10 03:56:01 +08:00
|
|
|
|
|
|
|
- name: Lazy Tensor Core - TorchScript end-to-end tests
|
|
|
|
if: matrix.llvmtype == 'binary'
|
|
|
|
run: |
|
|
|
|
cd $GITHUB_WORKSPACE
|
|
|
|
export PYTHONPATH="$GITHUB_WORKSPACE/build/tools/torch-mlir/python_packages/torch_mlir"
|
|
|
|
python -m e2e_testing.torchscript.main --config=lazy_tensor_core -v
|