|
| 1 | +# Copyright (C) 2025, Advanced Micro Devices, Inc. |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | + |
| 4 | +name: Build mlir-air Wheels |
| 5 | + |
| 6 | +on: |
| 7 | + pull_request: |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + AIR_COMMIT: |
| 11 | + description: 'AIR commit to build' |
| 12 | + type: string |
| 13 | + required: false |
| 14 | + default: '' |
| 15 | + push: |
| 16 | + tags: |
| 17 | + - 'v*.*.*' |
| 18 | + schedule: |
| 19 | + - cron: '0 4 * * *' # Daily at 4 AM |
| 20 | + |
| 21 | +defaults: |
| 22 | + run: |
| 23 | + shell: bash |
| 24 | + |
| 25 | +concurrency: |
| 26 | + group: ci-build-air-wheels-${{ github.event.number || github.sha }} |
| 27 | + cancel-in-progress: true |
| 28 | + |
| 29 | +jobs: |
| 30 | + build-repo: |
| 31 | + name: Build and upload mlir_air wheels |
| 32 | + |
| 33 | + runs-on: ubuntu-latest |
| 34 | + |
| 35 | + permissions: |
| 36 | + id-token: write |
| 37 | + contents: write |
| 38 | + packages: read |
| 39 | + |
| 40 | + strategy: |
| 41 | + fail-fast: false |
| 42 | + matrix: |
| 43 | + include: |
| 44 | + - python_version: "3.10" |
| 45 | + ENABLE_RTTI: ON |
| 46 | + |
| 47 | + - python_version: "3.10" |
| 48 | + ENABLE_RTTI: OFF |
| 49 | + |
| 50 | + - python_version: "3.11" |
| 51 | + ENABLE_RTTI: ON |
| 52 | + |
| 53 | + - python_version: "3.11" |
| 54 | + ENABLE_RTTI: OFF |
| 55 | + |
| 56 | + - python_version: "3.12" |
| 57 | + ENABLE_RTTI: ON |
| 58 | + |
| 59 | + - python_version: "3.12" |
| 60 | + ENABLE_RTTI: OFF |
| 61 | + |
| 62 | + - python_version: "3.13" |
| 63 | + ENABLE_RTTI: ON |
| 64 | + |
| 65 | + - python_version: "3.13" |
| 66 | + ENABLE_RTTI: OFF |
| 67 | + |
| 68 | + - python_version: "3.14" |
| 69 | + ENABLE_RTTI: ON |
| 70 | + |
| 71 | + - python_version: "3.14" |
| 72 | + ENABLE_RTTI: OFF |
| 73 | + |
| 74 | + steps: |
| 75 | + - name: Free disk space |
| 76 | + uses: descriptinc/free-disk-space@main |
| 77 | + with: |
| 78 | + tool-cache: true |
| 79 | + android: true |
| 80 | + dotnet: true |
| 81 | + haskell: true |
| 82 | + large-packages: true |
| 83 | + swap-storage: false |
| 84 | + |
| 85 | + - uses: actions/checkout@v4 |
| 86 | + with: |
| 87 | + submodules: "true" |
| 88 | + |
| 89 | + |
| 90 | + name: Build mlir-air |
| 91 | + id: runcmd |
| 92 | + with: |
| 93 | + distro: none |
| 94 | + arch: none |
| 95 | + base_image: quay.io/pypa/manylinux_2_34_x86_64:latest |
| 96 | + githubToken: ${{ github.token }} |
| 97 | + env: | |
| 98 | + AIR_WHEEL_VERSION: ${{ (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')) && github.ref_name || '""' }} |
| 99 | + run: | |
| 100 | + git config --global --add safe.directory $PWD |
| 101 | + AIR_VERSION=$(git rev-parse --short HEAD) |
| 102 | + echo "Building mlir-air version $AIR_VERSION" |
| 103 | +
|
| 104 | + if ! command -v python${{ matrix.python_version }} &> /dev/null; then |
| 105 | + echo "Python ${{ matrix.python_version }} not found, installing..." |
| 106 | + yum update -y |
| 107 | + yum install -y yum-utils |
| 108 | + yum install -y python${{ matrix.python_version }} python${{ matrix.python_version }}-devel |
| 109 | + fi |
| 110 | +
|
| 111 | + yum install -y ninja-build clang lld zip unzip binutils |
| 112 | +
|
| 113 | + python${{ matrix.python_version }} -m venv ${{ github.workspace }}/air-venv |
| 114 | + source ${{ github.workspace }}/air-venv/bin/activate |
| 115 | +
|
| 116 | + pip install -r utils/requirements.txt |
| 117 | + EUDSL_PYTHON_EXTRAS_HOST_PACKAGE_PREFIX=aie pip install -r utils/requirements_extras.txt |
| 118 | +
|
| 119 | + export ENABLE_RTTI=${{ matrix.ENABLE_RTTI }} |
| 120 | +
|
| 121 | + NO_RTTI="" |
| 122 | + NO_RTTI_UNDERSCORE="" |
| 123 | + NO_RTTI_DOT="" |
| 124 | + if [ x"$ENABLE_RTTI" == x"OFF" ]; then |
| 125 | + NO_RTTI="-no-rtti" |
| 126 | + NO_RTTI_UNDERSCORE="_no_rtti" |
| 127 | + NO_RTTI_DOT=".no.rtti" |
| 128 | + MLIR_AIE_WHEELS_URL="https://github.com/Xilinx/mlir-aie/releases/expanded_assets/latest-wheels-no-rtti" |
| 129 | + else |
| 130 | + MLIR_AIE_WHEELS_URL="https://github.com/Xilinx/mlir-aie/releases/expanded_assets/latest-wheels-2/" |
| 131 | + fi |
| 132 | + |
| 133 | + VERSION=$(utils/clone-llvm.sh --get-wheel-version) |
| 134 | + pip -q download --no-deps "mlir$NO_RTTI==$VERSION" \ |
| 135 | + -f https://github.com/Xilinx/mlir-aie/releases/expanded_assets/mlir-distro |
| 136 | + unzip -q mlir*.whl |
| 137 | + find mlir$NO_RTTI_UNDERSCORE -exec touch -a -m -t 201108231405.14 {} \; |
| 138 | + export MLIR_INSTALL_ABS_PATH=$PWD/mlir$NO_RTTI_UNDERSCORE |
| 139 | +
|
| 140 | + MLIR_AIE_VERSION=$(utils/clone-mlir-aie.sh --get-wheel-version) |
| 141 | + pip -q download --no-deps --platform manylinux_2_35_x86_64 "mlir_aie==${MLIR_AIE_VERSION}${NO_RTTI_DOT}" \ |
| 142 | + -f "$MLIR_AIE_WHEELS_URL" |
| 143 | + unzip -q mlir_aie*.whl |
| 144 | + export MLIR_AIE_INSTALL_PATH=$PWD/mlir_aie |
| 145 | +
|
| 146 | + export MLIR_AIR_SOURCE_DIR=$PWD |
| 147 | + export WHEELHOUSE_DIR=$PWD/wheelhouse |
| 148 | + if [ x"${{ inputs.AIR_COMMIT }}" == x"" ]; then |
| 149 | + export AIR_PROJECT_COMMIT=$AIR_VERSION |
| 150 | + else |
| 151 | + AIR_VERSION="${{ inputs.AIR_COMMIT }}" |
| 152 | + export AIR_PROJECT_COMMIT=${AIR_VERSION:0:7} |
| 153 | + fi |
| 154 | + export DATETIME=$(date +"%Y%m%d%H") |
| 155 | + |
| 156 | + rm -rf $WHEELHOUSE_DIR/mlir_air*.whl |
| 157 | + rm -rf $WHEELHOUSE_DIR/repaired_wheel/* |
| 158 | +
|
| 159 | + pushd utils/mlir_air_wheels |
| 160 | +
|
| 161 | + pip install setuptools wheel auditwheel patchelf importlib_metadata |
| 162 | + CIBW_ARCHS=x86_64 pip wheel . -v -w $WHEELHOUSE_DIR --no-build-isolation |
| 163 | +
|
| 164 | + popd |
| 165 | +
|
| 166 | + auditwheel repair -w $WHEELHOUSE_DIR/repaired_wheel $WHEELHOUSE_DIR/mlir_air*.whl --plat manylinux_2_35_x86_64 --exclude libmlir_async_runtime.so --exclude libmlir_c_runner_utils.so --exclude libmlir_float16_utils.so --exclude libmlir_runner_utils.so --exclude libmlir_apfloat_wrappers.so |
| 167 | +
|
| 168 | + - name: Upload mlir_air |
| 169 | + uses: actions/upload-artifact@v4 |
| 170 | + with: |
| 171 | + path: wheelhouse/mlir_air*whl |
| 172 | + name: mlir_air_rtti_${{ matrix.ENABLE_RTTI }}-${{ matrix.python_version }} |
| 173 | + |
| 174 | + - name: Release |
| 175 | + if: | |
| 176 | + github.event_name == 'workflow_dispatch' || |
| 177 | + github.event_name == 'schedule' || |
| 178 | + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) |
| 179 | + |
| 180 | + with: |
| 181 | + artifacts: wheelhouse/mlir_air*whl |
| 182 | + token: "${{ secrets.GITHUB_TOKEN }}" |
| 183 | + tag: ${{ github.event_name == 'push' && github.ref_name || (matrix.ENABLE_RTTI == 'ON' && 'latest-air-wheels' || 'latest-air-wheels-no-rtti') }} |
| 184 | + name: ${{ github.event_name == 'push' && github.ref_name || (matrix.ENABLE_RTTI == 'ON' && 'latest-air-wheels' || 'latest-air-wheels-no-rtti') }} |
| 185 | + allowUpdates: true |
| 186 | + replacesArtifacts: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} |
| 187 | + makeLatest: ${{ github.event_name == 'push' }} |
0 commit comments