Bump actions/download-artifact from 3 to 4.1.7 in /.github/workflows #153
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
name: Build torch-mlir | |
on: | |
workflow_dispatch: | |
push: | |
paths: | |
- externals/** | |
- .github/workflows/build_torch_mlir.yml | |
# uncomment these when iterating on this file | |
# pull_request: | |
# paths: | |
# - externals/** | |
# - .github/workflows/build_torch_mlir.yml | |
jobs: | |
get_torch_mlir_commit: | |
name: Get latest torch-mlir commit | |
runs-on: ubuntu-20.04 | |
outputs: | |
TORCH_MLIR_COMMIT: ${{ steps.get_torch_mlir_commit.outputs.TORCH_MLIR_COMMIT }} | |
steps: | |
- name: Get torch-mlir commit | |
id: get_torch_mlir_commit | |
run: | | |
sudo apt install jq | |
TORCH_MLIR_COMMIT=$(curl -s https://api.github.com/repos/llvm/torch-mlir/commits/main | jq -r '.sha[:8]') | |
echo "TORCH_MLIR_COMMIT=${TORCH_MLIR_COMMIT}" | tee -a $GITHUB_OUTPUT | |
build: | |
name: Build distro of TorchMLIR | |
needs: get_torch_mlir_commit | |
runs-on: ${{ matrix.os }} | |
continue-on-error: true | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ ubuntu-20.04, macos-latest ] | |
arch: [ AArch64, X86 ] | |
py_version: [ "3.11" ] | |
exclude: | |
- os: macos-latest | |
arch: X86 | |
outputs: | |
TORCH_MLIR_COMMIT: ${{ needs.get_torch_mlir_commit.outputs.TORCH_MLIR_COMMIT }} | |
steps: | |
- name: Compute torch-mlir base path and output commit | |
run: | | |
echo "TORCH_MLIR_MAIN_SRC_DIR=${GITHUB_WORKSPACE}/sandbox" | tee -a $GITHUB_ENV | |
echo "TORCH_MLIR_MAIN_BINARY_DIR=${GITHUB_WORKSPACE}/sandbox/build" | tee -a $GITHUB_ENV | |
echo "TORCH_MLIR_INSTALL_DIR=${GITHUB_WORKSPACE}/torch_mlir_install" | tee -a $GITHUB_ENV | |
echo "TORCH_MLIR_HOST_MAIN_BUILD_DIR=${GITHUB_WORKSPACE}/sandbox/build_host" | tee -a $GITHUB_ENV | |
echo "TORCH_MLIR_COMMIT=${{ needs.get_torch_mlir_commit.outputs.TORCH_MLIR_COMMIT }}" | tee -a $GITHUB_ENV | |
- name: Set up Python | |
uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 # v4.3.0 | |
with: | |
python-version: ${{ matrix.py_version }} | |
- name: Checkout torch-mlir | |
uses: actions/checkout@v3 | |
with: | |
repository: llvm/torch-mlir | |
path: sandbox | |
submodules: recursive | |
- name: Install Python depends | |
run: | | |
python -m pip install -r ${TORCH_MLIR_MAIN_SRC_DIR}/build-requirements.txt | |
- name: Install Ninja | |
uses: llvm/actions/install-ninja@6a57890d0e3f9f35dfc72e7e48bc5e1e527cdd6c # Jan 17 | |
- name: Ccache for C++ compilation | |
uses: hendrikmuhs/ccache-action@621a41397ed83711c72862638d9ff6e63fca3041 # v1.2.3 | |
with: | |
key: ${{ matrix.os }}-${{ matrix.arch }}-torch-mlir | |
# LLVM needs serious cache size | |
max-size: 6G | |
- name: Install cross-compilation toolchain | |
if: contains(matrix.os, 'ubuntu') && contains(matrix.arch, 'AArch64') | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y binutils-aarch64-linux-gnu \ | |
g++-aarch64-linux-gnu gcc-aarch64-linux-gnu | |
- name: Build host llvmtblgen/mlirtblgen | |
if: contains(matrix.os, 'ubuntu') && contains(matrix.arch, 'AArch64') | |
run: | | |
cmake \ | |
-DBUILD_SHARED_LIBS=OFF \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_CXX_COMPILER=g++ \ | |
-DCMAKE_CXX_FLAGS="-O2 -static-libgcc -static-libstdc++" \ | |
-DCMAKE_C_COMPILER=gcc \ | |
-DLLVM_ENABLE_PROJECTS=mlir \ | |
-DLLVM_ENABLE_TERMINFO=OFF \ | |
-DLLVM_ENABLE_ZLIB=OFF \ | |
-DLLVM_ENABLE_ZSTD=OFF \ | |
-DLLVM_TARGETS_TO_BUILD=X86 \ | |
-S${TORCH_MLIR_MAIN_SRC_DIR}/externals/llvm-project/llvm \ | |
-B${TORCH_MLIR_HOST_MAIN_BUILD_DIR} | |
cmake --build ${TORCH_MLIR_HOST_MAIN_BUILD_DIR} \ | |
--target llvm-tblgen mlir-tblgen mlir-linalg-ods-yaml-gen mlir-pdll | |
- name: Choose compiler and set env vars | |
run: | | |
if [ x"${{ matrix.os }}" == x"macos-latest" ]; then | |
echo "CXX_COMPILER=clang++" | tee -a $GITHUB_ENV | |
echo "C_COMPILER=clang" | tee -a $GITHUB_ENV | |
echo "LLVM_DEFAULT_TARGET_TRIPLE=arm64-apple-darwin21.6.0" | tee -a $GITHUB_ENV | |
echo "LLVM_HOST_TRIPLE=arm64-apple-darwin21.6.0" | tee -a $GITHUB_ENV | |
echo "ARCH=AArch64" | tee -a $GITHUB_ENV | |
elif [ x"${{ matrix.os }}" == x"ubuntu-20.04" ] && [ x"${{ matrix.arch }}" == x"AArch64" ]; then | |
echo "CXX_COMPILER=aarch64-linux-gnu-g++" | tee -a $GITHUB_ENV | |
echo "C_COMPILER=aarch64-linux-gnu-gcc" | tee -a $GITHUB_ENV | |
echo "LLVM_DEFAULT_TARGET_TRIPLE=aarch64-linux-gnu" | tee -a $GITHUB_ENV | |
echo "LLVM_HOST_TRIPLE=aarch64-linux-gnu" | tee -a $GITHUB_ENV | |
echo "ARCH=AArch64" | tee -a $GITHUB_ENV | |
else | |
echo "CXX_COMPILER=g++" | tee -a $GITHUB_ENV | |
echo "C_COMPILER=gcc" | tee -a $GITHUB_ENV | |
echo "LLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-linux-gnu" | tee -a $GITHUB_ENV | |
echo "LLVM_HOST_TRIPLE=x86_64-unknown-linux-gnu" | tee -a $GITHUB_ENV | |
echo "ARCH=X86" | tee -a $GITHUB_ENV | |
fi | |
- name: Patch/disable tests | |
shell: bash | |
run: | | |
sed -i.bak 's/check-torch-mlir-capi/#check-torch-mlir-capi/g' ${TORCH_MLIR_MAIN_SRC_DIR}/CMakeLists.txt | |
sed -i.bak 's/add_subdirectory(CAPI)/#add_subdirectory(CAPI)/g' ${TORCH_MLIR_MAIN_SRC_DIR}/test/CMakeLists.txt | |
- name: Configure CMake | |
run: | | |
CMAKE_CONFIGS="\ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_CXX_COMPILER=$CXX_COMPILER \ | |
-DCMAKE_C_COMPILER=$C_COMPILER \ | |
-DCMAKE_INSTALL_PREFIX=$TORCH_MLIR_INSTALL_DIR \ | |
-DLLVM_CCACHE_BUILD=ON \ | |
-DLLVM_DEFAULT_TARGET_TRIPLE=$LLVM_DEFAULT_TARGET_TRIPLE \ | |
-DLLVM_ENABLE_ASSERTIONS=ON \ | |
-DLLVM_ENABLE_PROJECTS=mlir \ | |
-DLLVM_ENABLE_TERMINFO=OFF \ | |
-DLLVM_ENABLE_ZLIB=OFF \ | |
-DLLVM_ENABLE_ZSTD=OFF \ | |
-DLLVM_EXTERNAL_PROJECTS=torch-mlir;torch-mlir-dialects \ | |
-DLLVM_EXTERNAL_TORCH_MLIR_DIALECTS_SOURCE_DIR=${TORCH_MLIR_MAIN_SRC_DIR}/externals/llvm-external-projects/torch-mlir-dialects \ | |
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR=$TORCH_MLIR_MAIN_SRC_DIR \ | |
-DLLVM_HOST_TRIPLE=$LLVM_HOST_TRIPLE \ | |
-DLLVM_INCLUDE_UTILS=ON \ | |
-DLLVM_INSTALL_UTILS=ON \ | |
-DLLVM_TARGETS_TO_BUILD=$ARCH \ | |
-DLLVM_TARGET_ARCH=$ARCH \ | |
-DLLVM_USE_HOST_TOOLS=ON \ | |
-DMLIR_BUILD_MLIR_C_DYLIB=1 \ | |
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \ | |
-DMLIR_ENABLE_EXECUTION_ENGINE=ON \ | |
-DPython3_EXECUTABLE=$(which python) \ | |
-DTORCH_MLIR_ENABLE_LTC=OFF \ | |
-DTORCH_MLIR_ENABLE_ONLY_MLIR_PYTHON_BINDINGS=ON \ | |
-DTORCH_MLIR_ENABLE_STABLEHLO=OFF \ | |
-DTORCH_MLIR_USE_INSTALLED_PYTORCH=ON" | |
if [ x"${{ matrix.os }}" == x"macos-latest" ]; then | |
CMAKE_CONFIGS="${CMAKE_CONFIGS} \ | |
-DCMAKE_OSX_ARCHITECTURES=arm64 \ | |
-DMACOSX_DEPLOYMENT_TARGET=12.0" | |
elif [ x"${{ matrix.os }}" == x"ubuntu-20.04" ] && [ x"${{ matrix.arch }}" == x"AArch64" ]; then | |
CMAKE_CONFIGS="${CMAKE_CONFIGS} \ | |
-DLLVM_TABLEGEN=$TORCH_MLIR_HOST_MAIN_BUILD_DIR/bin/llvm-tblgen \ | |
-DMLIR_LINALG_ODS_YAML_GEN=$TORCH_MLIR_HOST_MAIN_BUILD_DIR/bin/mlir-linalg-ods-yaml-gen \ | |
-DMLIR_LINALG_ODS_YAML_GEN_EXE=$TORCH_MLIR_HOST_MAIN_BUILD_DIR/bin/mlir-linalg-ods-yaml-gen \ | |
-DMLIR_PDLL_TABLEGEN=$TORCH_MLIR_HOST_MAIN_BUILD_DIR/bin/mlir-pdll \ | |
-DMLIR_TABLEGEN=$TORCH_MLIR_HOST_MAIN_BUILD_DIR/bin/mlir-tblgen" | |
fi | |
echo $CMAKE_CONFIGS | |
if [ x"${{ matrix.os }}" == x"ubuntu-20.04" ] && [ x"${{ matrix.arch }}" == x"AArch64" ]; then | |
cmake -G Ninja \ | |
$CMAKE_CONFIGS \ | |
-DCMAKE_CXX_FLAGS="-O2 -static-libgcc -static-libstdc++" \ | |
-S${TORCH_MLIR_MAIN_SRC_DIR}/externals/llvm-project/llvm \ | |
-B${TORCH_MLIR_MAIN_BINARY_DIR} | |
else | |
cmake -G Ninja \ | |
$CMAKE_CONFIGS \ | |
-S${TORCH_MLIR_MAIN_SRC_DIR}/externals/llvm-project/llvm \ | |
-B${TORCH_MLIR_MAIN_BINARY_DIR} | |
fi | |
- name: Build distro | |
run: | | |
cmake --build ${TORCH_MLIR_MAIN_BINARY_DIR} --target install | |
ccache -s | |
- name: Make tarballs | |
run: | | |
OUTPUT="torch-mlir-${TORCH_MLIR_COMMIT}-${{ matrix.os }}-${{ matrix.arch }}" | |
cd "$TORCH_MLIR_INSTALL_DIR"/.. | |
XZ_OPT='-T0 -9' tar -cJf "${OUTPUT}.tar.xz" torch_mlir_install | |
mkdir -p ${{ github.sha }}/ | |
mv *.tar.xz ${{ github.sha }}/ | |
- name: Upload an artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
if-no-files-found: error | |
name: build_artifact | |
path: ${{ github.sha }} | |
upload-tarballs: | |
runs-on: ubuntu-20.04 | |
needs: build | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Download artifacts | |
uses: actions/[email protected] | |
with: | |
name: build_artifact | |
path: ${{ github.sha }} | |
- name: Set up a release page | |
id: setup_release | |
run: | | |
TORCH_MLIR_COMMIT="${{ needs.build.outputs.TORCH_MLIR_COMMIT }}" | |
echo "Created at $(date) build of [https://github.com/llvm/torch-mlir/commit/${TORCH_MLIR_COMMIT}](https://github.com/llvm/torch-mlir/commit/${TORCH_MLIR_COMMIT})" > body.md | |
echo "tag_name=torch-mlir-${TORCH_MLIR_COMMIT}" | tee -a $GITHUB_OUTPUT | |
echo "release_title=torch-mlir-${TORCH_MLIR_COMMIT}" | tee -a $GITHUB_OUTPUT | |
- name: Release current commit | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "${{ github.sha }}/*.tar.xz,${{ github.sha }}/*.whl,${{ github.sha }}/*.exe" | |
bodyFile: body.md | |
token: "${{ secrets.PI_CI }}" | |
tag: "${{ steps.setup_release.outputs.tag_name }}" | |
name: "${{ steps.setup_release.outputs.release_title }}" | |
removeArtifacts: false | |
allowUpdates: true | |
prerelease: true | |
replacesArtifacts: true | |
- name: Update latest release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "${{ github.sha }}/*.tar.xz,${{ github.sha }}/*.whl,${{ github.sha }}/*.exe" | |
bodyFile: body.md | |
token: "${{ secrets.PI_CI }}" | |
tag: "torch-mlir-latest" | |
name: "torch-mlir-latest" | |
removeArtifacts: true | |
allowUpdates: true | |
prerelease: true | |
replacesArtifacts: true |