mirror of https://github.com/llvm/torch-mlir
187 lines
7.7 KiB
YAML
187 lines
7.7 KiB
YAML
name: Build and Test
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [ main ]
|
|
push:
|
|
branches: [ main ]
|
|
workflow_dispatch:
|
|
|
|
# Ensure that only a single job or workflow using the same
|
|
# concurrency group will run at a time. This would cancel
|
|
# any in-progress jobs in the same github workflow and github
|
|
# ref (e.g. refs/heads/main or refs/pull/<pr_number>/merge).
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
|
|
# Provisioned Jobs:
|
|
# ubuntu - x86_64 - llvm in-tree - pytorch binary - build+test # most used dev flow and fastest signal
|
|
# ubuntu - x86_64 - llvm out-of-tree - pytorch source - build+test # most elaborate build
|
|
# macos - arm64 - llvm in-tree - pytorch binary - build only # cross compile, can't test arm64
|
|
jobs:
|
|
build-test:
|
|
strategy:
|
|
fail-fast: true
|
|
matrix:
|
|
os-arch: [ubuntu-x86_64, macos-arm64]
|
|
llvm-build: [in-tree, out-of-tree]
|
|
torch-binary: [ON, OFF]
|
|
exclude:
|
|
# Exclude llvm in-tree and pytorch source
|
|
- llvm-build: in-tree
|
|
torch-binary: OFF
|
|
# Exclude llvm out-of-tree and pytorch binary
|
|
- llvm-build: out-of-tree
|
|
torch-binary: ON
|
|
# Exclude macos-arm64 and llvm out-of-tree altogether
|
|
- os-arch: macos-arm64
|
|
llvm-build: out-of-tree
|
|
include:
|
|
# Specify OS versions
|
|
- os-arch: ubuntu-x86_64
|
|
os: ubuntu-22.04
|
|
- os-arch: macos-arm64
|
|
os: macos-12
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
|
- name: Checkout torch-mlir
|
|
uses: actions/checkout@v2
|
|
with:
|
|
submodules: 'true'
|
|
|
|
- name: Setup ccache
|
|
uses: ./.github/actions/setup-build
|
|
with:
|
|
cache-suffix: ${{ matrix.os-arch }}-${{ matrix.llvm-build }}-${{ matrix.torch-binary }}
|
|
|
|
- name: Configure os-arch='ubuntu-x86_64' llvm-build='in-tree' torch-binary='${{ matrix.torch-binary }}'
|
|
# Fastest build, most used dev flow
|
|
if: ${{ matrix.os-arch == 'ubuntu-x86_64' && matrix.llvm-build == 'in-tree' }}
|
|
run: |
|
|
cmake -GNinja -Bbuild \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DCMAKE_C_COMPILER=clang \
|
|
-DCMAKE_CXX_COMPILER=clang++ \
|
|
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
|
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
|
-DCMAKE_LINKER=lld \
|
|
-DLLVM_ENABLE_ASSERTIONS=ON \
|
|
-DLLVM_ENABLE_PROJECTS=mlir \
|
|
-DLLVM_EXTERNAL_PROJECTS="torch-mlir;torch-mlir-dialects" \
|
|
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$GITHUB_WORKSPACE" \
|
|
-DLLVM_EXTERNAL_TORCH_MLIR_DIALECTS_SOURCE_DIR="${GITHUB_WORKSPACE}/externals/llvm-external-projects/torch-mlir-dialects" \
|
|
-DLLVM_TARGETS_TO_BUILD=host \
|
|
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
|
|
-DTORCH_MLIR_USE_INSTALLED_PYTORCH="${{ matrix.torch-binary }}" \
|
|
-DPython3_EXECUTABLE="$(which python)" \
|
|
$GITHUB_WORKSPACE/externals/llvm-project/llvm
|
|
|
|
- name: Configure os-arch='ubuntu-x86_64' llvm-build='out-of-tree' torch-binary='${{ matrix.torch-binary }}'
|
|
# Most elaborate build, but cached
|
|
if: ${{ matrix.os-arch == 'ubuntu-x86_64' && matrix.llvm-build == 'out-of-tree' }}
|
|
run: |
|
|
cmake -GNinja -Bllvm-build \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DCMAKE_C_COMPILER=clang \
|
|
-DCMAKE_CXX_COMPILER=clang++ \
|
|
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
|
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
|
-DCMAKE_LINKER=lld \
|
|
-DLLVM_ENABLE_ASSERTIONS=ON \
|
|
-DLLVM_ENABLE_PROJECTS=mlir \
|
|
-DLLVM_TARGETS_TO_BUILD=host \
|
|
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
|
|
-DPython3_EXECUTABLE="$(which python)" \
|
|
$GITHUB_WORKSPACE/externals/llvm-project/llvm
|
|
cmake --build llvm-build
|
|
|
|
cmake -GNinja -Bbuild \
|
|
-DCMAKE_C_COMPILER=clang \
|
|
-DCMAKE_CXX_COMPILER=clang++ \
|
|
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
|
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
|
-DCMAKE_LINKER=lld \
|
|
-DLLVM_DIR="$GITHUB_WORKSPACE/llvm-build/lib/cmake/llvm/" \
|
|
-DMLIR_DIR="$GITHUB_WORKSPACE/llvm-build/lib/cmake/mlir/" \
|
|
-DMLIR_ENABLE_BINDINGS_PYTHON=OFF \
|
|
-DTORCH_MLIR_USE_INSTALLED_PYTORCH="${{ matrix.torch-binary }}" \
|
|
-DPython3_EXECUTABLE="$(which python)" \
|
|
$GITHUB_WORKSPACE
|
|
|
|
- name: Configure os-arch='macos-arm64' llvm-build='in-tree' torch-binary='${{ matrix.torch-binary }}'
|
|
# cross compile, can't test arm64
|
|
if: ${{ matrix.os-arch == 'macos-arm64' && matrix.llvm-build == 'in-tree' }}
|
|
run: |
|
|
# TODO: Reenable LTC after build on macOS-arm64 is fixed (https://github.com/llvm/torch-mlir/issues/1253)
|
|
cmake -GNinja -Bbuild_arm64 \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DCMAKE_C_COMPILER=clang \
|
|
-DCMAKE_CXX_COMPILER=clang++ \
|
|
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
|
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
|
-DCMAKE_LINKER=lld \
|
|
-DCMAKE_OSX_ARCHITECTURES=arm64 \
|
|
-DLLVM_ENABLE_ASSERTIONS=ON \
|
|
-DLLVM_ENABLE_PROJECTS=mlir \
|
|
-DLLVM_EXTERNAL_PROJECTS="torch-mlir;torch-mlir-dialects" \
|
|
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$GITHUB_WORKSPACE" \
|
|
-DLLVM_EXTERNAL_TORCH_MLIR_DIALECTS_SOURCE_DIR="${GITHUB_WORKSPACE}/externals/llvm-external-projects/torch-mlir-dialects" \
|
|
-DLLVM_TARGETS_TO_BUILD=AArch64 \
|
|
-DLLVM_USE_HOST_TOOLS=ON \
|
|
-DLLVM_ENABLE_ZSTD=OFF \
|
|
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
|
|
-DTORCH_MLIR_ENABLE_MHLO=OFF \
|
|
-DTORCH_MLIR_ENABLE_LTC=OFF \
|
|
-DTORCH_MLIR_USE_INSTALLED_PYTORCH="${{ matrix.torch-binary }}" \
|
|
-DMACOSX_DEPLOYMENT_TARGET=12.0 \
|
|
-DPython3_EXECUTABLE="$(which python)" \
|
|
$GITHUB_WORKSPACE/externals/llvm-project/llvm
|
|
|
|
- name: Build torch-mlir
|
|
if: ${{ matrix.os-arch == 'ubuntu-x86_64' }}
|
|
run: |
|
|
cmake --build build
|
|
|
|
- name: Build torch-mlir (cross-compile)
|
|
if: ${{ matrix.os-arch == 'macos-arm64' }}
|
|
run: |
|
|
cmake --build build_arm64
|
|
|
|
- name: Run torch-mlir unit tests
|
|
if: ${{ matrix.os-arch == 'ubuntu-x86_64' }}
|
|
run: |
|
|
cmake --build build --target check-torch-mlir-all
|
|
|
|
- name: Run refbackend e2e integration tests
|
|
if: ${{ matrix.os-arch == 'ubuntu-x86_64' && matrix.llvm-build == 'in-tree' }}
|
|
run: |
|
|
export PYTHONPATH="$GITHUB_WORKSPACE/build/tools/torch-mlir/python_packages/torch_mlir"
|
|
python -m e2e_testing.torchscript.main --config=refbackend -v
|
|
|
|
- name: Run eager_mode e2e integration tests
|
|
if: ${{ matrix.os-arch == 'ubuntu-x86_64' && matrix.llvm-build == 'in-tree' }}
|
|
run: |
|
|
export PYTHONPATH="$GITHUB_WORKSPACE/build/tools/torch-mlir/python_packages/torch_mlir"
|
|
python -m e2e_testing.torchscript.main --config=eager_mode -v
|
|
|
|
- name: Run mhlo e2e integration tests
|
|
if: ${{ matrix.os-arch == 'ubuntu-x86_64' && matrix.llvm-build == 'in-tree' }}
|
|
run: |
|
|
export PYTHONPATH="$GITHUB_WORKSPACE/build/tools/torch-mlir/python_packages/torch_mlir"
|
|
python -m e2e_testing.torchscript.main --config=mhlo -v
|
|
|
|
- name: Run tosa e2e integration tests
|
|
if: ${{ matrix.os-arch == 'ubuntu-x86_64' && matrix.llvm-build == 'in-tree' }}
|
|
run: |
|
|
export PYTHONPATH="$GITHUB_WORKSPACE/build/tools/torch-mlir/python_packages/torch_mlir"
|
|
python -m e2e_testing.torchscript.main --config=tosa -v
|
|
|
|
- name: Run lazy_tensor_core e2e integration tests
|
|
if: ${{ matrix.os-arch == 'ubuntu-x86_64' && matrix.llvm-build == 'in-tree' }}
|
|
run: |
|
|
export PYTHONPATH="$GITHUB_WORKSPACE/build/tools/torch-mlir/python_packages/torch_mlir"
|
|
python -m e2e_testing.torchscript.main --config=lazy_tensor_core -v
|