Skip to content

[LLVM] Bump to ca84e9e82 (#178) #141

[LLVM] Bump to ca84e9e82 (#178)

[LLVM] Bump to ca84e9e82 (#178) #141

# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Copyright (c) 2024.
name: "Build, test, release mlir-python-bindings"
on:
workflow_dispatch:
inputs:
force_debug_with_tmate:
type: boolean
description: 'Run the build with tmate session'
required: false
default: false
debug_with_tmate:
type: boolean
description: 'Run the build with a tmate session ONLY in case of failure'
required: false
default: false
pull_request:
paths:
- ".github/workflows/build_mlir_python_bindings_wheel.yml"
- "projects/mlir-python-bindings/**"
- "third_party/llvm-project"
push:
branches:
- main
paths:
- ".github/workflows/build_mlir_python_bindings_wheel.yml"
- "projects/mlir-python-bindings/**"
- "third_party/llvm-project"
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true
jobs:
build-mlir-python-bindings:
strategy:
fail-fast: false
matrix:
include:
- name: "ubuntu_x86_64"
runs-on: "ubuntu-22.04"
os: "ubuntu"
arch: "x86_64"
- name: "ubuntu_aarch64"
runs-on: "ubuntu-22.04-arm"
os: "ubuntu"
arch: "aarch64"
- name: "windows_x86_64"
runs-on: "windows-2022"
os: "windows"
- name: "macos_arm64"
runs-on: "macos-14"
os: "macos"
arch: "aarch64"
- name: "macos_x86_64"
runs-on: "macos-13"
os: "macos"
arch: "x86_64"
runs-on: ${{ matrix.runs-on }}
name: "Build mlir-python-bindings ${{ matrix.name }}"
defaults:
run:
shell: bash
permissions:
id-token: write
contents: write
env:
# either the PR number or `branch-N` where N always increments
cache-key: mlir_python_bindings_${{ matrix.name }}_clang_${{ format('{0}-{1}', github.ref_name, github.run_number) }}
steps:
- name: "Check out repository"
uses: actions/[email protected]
- name: "Setup base"
uses: ./.github/actions/setup_base
id: setup_base
with:
cache-key: ${{ env.cache-key }}
restore-key: "mlir_python_bindings_${{ matrix.name }}_clang"
os: ${{ matrix.os }}
arch: ${{ matrix.arch }}
- name: "Download MLIR and configure build"
env:
GH_TOKEN: ${{ github.token }}
run: |
if [[ "${{ matrix.os }}" == "almalinux" ]] || [[ "${{ matrix.os }}" == "ubuntu" ]]; then
export RELEASE_PREFIX="mlir_manylinux_${{ matrix.arch }}"
else
export RELEASE_PREFIX="mlir_${{ matrix.name }}"
fi
RELEASE_URL=$(gh release view llvm --json assets -q '.assets |= sort_by(.createdAt) | .assets | map(select(.name | contains(env.RELEASE_PREFIX))) | .[-1] | .url')
curl -sLO $RELEASE_URL
RELEASE_NAME="$RELEASE_PREFIX*.tar.gz"
tar xf $RELEASE_NAME
echo WHEEL_VERSION="$(echo $RELEASE_NAME | sed "s/${RELEASE_PREFIX}_//g" | sed "s/.tar.gz//g" | sed "s/_/+/g")" >> $GITHUB_ENV
if [[ "${{ matrix.os }}" == "ubuntu" ]]; then
echo "LLVM_DIR=/host/$PWD/llvm-install/lib/cmake/llvm" >> $GITHUB_ENV
echo "MLIR_DIR=/host/$PWD/llvm-install/lib/cmake/mlir" >> $GITHUB_ENV
echo "Clang_DIR=/host/$PWD/llvm-install/lib/cmake/clang" >> $GITHUB_ENV
echo "PIP_FIND_LINKS=/host/$PWD/wheelhouse" >> $GITHUB_ENV
echo "CMAKE_PREFIX_PATH=/host/$PWD/llvm-install" >> $GITHUB_ENV
else
echo "LLVM_DIR=$PWD/llvm-install/lib/cmake/llvm" >> $GITHUB_ENV
echo "MLIR_DIR=$PWD/llvm-install/lib/cmake/mlir" >> $GITHUB_ENV
echo "Clang_DIR=$PWD/llvm-install/lib/cmake/clang" >> $GITHUB_ENV
echo "PIP_FIND_LINKS=$PWD/wheelhouse" >> $GITHUB_ENV
echo "CMAKE_PREFIX_PATH=$PWD/llvm-install" >> $GITHUB_ENV
fi
$python3_command -m pip install cibuildwheel
if [[ "${{ matrix.os }}" == "ubuntu" ]] && [[ "${{ matrix.arch }}" == "aarch64" ]]; then
sudo apt-get install libarchive-dev antlr libxml2-dev libxslt-dev libcurl4-openssl-dev
fi
if [[ "${{ matrix.os }}" == "macos" ]]; then
brew install antlr boost libarchive
fi
if [[ "${{ matrix.runs-on }}" == "macos-13" ]]; then
sudo xcode-select -s /Library/Developer/CommandLineTools
echo "SDKROOT=$(xcrun --show-sdk-path)" >> $GITHUB_ENV
fi
- name: "Build mlir-python-bindings"
run: |
$python3_command -m cibuildwheel "$PWD/projects/mlir-python-bindings" --output-dir wheelhouse
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: mlir_python_bindings_${{ matrix.name }}_artifact
path: wheelhouse/*.whl
if-no-files-found: warn
- name: "Setup tmate session"
if: (failure() && inputs.debug_with_tmate) || inputs.force_debug_with_tmate
uses: mxschmitt/[email protected]
with:
limit-access-to-actor: true
install-dependencies: ${{ startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'windows') || startsWith(matrix.os, 'ubuntu') }}
test-mlir-python-bindings:
needs: [build-mlir-python-bindings]
strategy:
fail-fast: false
matrix:
runs-on: [
"ubuntu-22.04",
"ubuntu-22.04-arm",
"macos-13",
"macos-14",
"windows-2022"
]
python-version: [
# "3.10", "3.11", "3.12",
"3.13", "3.14", "3.14t"
]
include: [
{runs-on: "ubuntu-22.04", name: "ubuntu_x86_64", os: "ubuntu"},
{runs-on: "ubuntu-22.04-arm", name: "ubuntu_aarch64", os: "ubuntu"},
{runs-on: "windows-2022", name: "windows_x86_64", os: "windows"},
{runs-on: "macos-14", name: "macos_arm64", os: "macos"},
{runs-on: "macos-13", name: "macos_x86_64", os: "macos"}
]
exclude:
# <frozen importlib._bootstrap>:491: Warning: Numpy built with MINGW-W64 on Windows 64 bits is experimental, and only available for testing. You are advised not to use it for production.
- runs-on: windows-2022
python-version: "3.14"
- runs-on: windows-2022
python-version: "3.14t"
runs-on: ${{ matrix.runs-on }}
name: "Test mlir-python-bindings ${{ matrix.name }} ${{ matrix.python-version }}"
defaults:
run:
shell: bash
steps:
- name: "Check out repository"
uses: actions/[email protected]
with:
submodules: false
- name: "Get submodules"
run: git submodule update --init --depth=1
- name: "Install Python"
uses: actions/[email protected]
with:
python-version: "${{ matrix.python-version }}"
- uses: actions/download-artifact@v4
with:
name: mlir_python_bindings_${{ matrix.name }}_artifact
path: wheelhouse
- name: "Install mlir-python-bindings"
run: python -m pip install mlir-python-bindings -f wheelhouse
- name: "Test mlir-python-bindings"
run: |
pip install mlir-python-bindings numpy -v -f wheelhouse
cd third_party/llvm-project/mlir/test/python/dialects
for f in *.py; do
if [[ "$f" == "python_test.py" ]]; then
continue
fi
python $f
done
release-mlir-python-bindings:
if: (github.event_name == 'push' && github.ref_name == 'main') || github.event_name == 'workflow_dispatch'
needs: [test-mlir-python-bindings]
runs-on: "ubuntu-22.04"
permissions:
id-token: write
contents: write
strategy:
fail-fast: false
matrix:
name: [
"ubuntu_x86_64",
"ubuntu_aarch64",
"macos_arm64",
"macos_x86_64",
"windows_x86_64"
]
name: "Release mlir-python-bindings ${{ matrix.name }}"
steps:
- uses: actions/download-artifact@v4
with:
name: mlir_python_bindings_${{ matrix.name }}_artifact
path: wheelhouse
- name: Release current commit
uses: ncipollo/[email protected]
with:
artifacts: "wheelhouse/mlir_python_bindings*.whl"
token: "${{ secrets.GITHUB_TOKEN }}"
tag: mlir-python-bindings
name: mlir-python-bindings
removeArtifacts: false
allowUpdates: true
replacesArtifacts: true
makeLatest: true
omitBody: true
build-mlir-python-bindings-wasm:
runs-on: ubuntu-22.04
name: "Build mlir-python-bindings wasm"
defaults:
run:
shell: bash
permissions:
id-token: write
contents: write
env:
cache-key: mlir_python_bindings_wasm_clang_${{ format('{0}-{1}', github.ref_name, github.run_number) }}
steps:
- name: "Check out repository"
uses: actions/[email protected]
with:
submodules: true
- name: "Setup base"
uses: ./.github/actions/setup_base
id: setup_base
with:
cache-key: ${{ env.cache-key }}
restore-key: "mlir_python_bindings_wasm_clang"
os: "ubuntu"
arch: "x86_64"
- name: Install pyodide
run: |
pip install pyodide-build>=0.28.0
echo EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version) >> $GITHUB_ENV
- name: Wheel version
run: |
pushd third_party/llvm-project
LLVM_PROJECT_COMMIT=$(git rev-parse --short HEAD)
popd
DATETIME=$(date +"%Y%m%d%H")
echo WHEEL_VERSION="${DATETIME}+${LLVM_PROJECT_COMMIT}" >> $GITHUB_ENV
- name: Setup Emscripten
uses: mymindstorm/setup-emsdk@v14
with:
version: ${{ env.EMSCRIPTEN_VERSION }}
- name: build wasm python wheel
env:
GH_TOKEN: ${{ github.token }}
run: |
RELEASE_URL=$(gh release view llvm --json assets -q '.assets |= sort_by(.createdAt) | .assets | map(select(.name | contains("mlir_manylinux_x86_64"))) | .[-1] | .url')
curl -sLO $RELEASE_URL
RELEASE_NAME="$RELEASE_PREFIX*.tar.gz"
tar xf $RELEASE_NAME
export LLVM_NATIVE_TOOL_DIR="$PWD/llvm-install/bin"
export LLVM_TABLEGEN="$LLVM_NATIVE_TOOL_DIR/llvm-tblgen"
export MLIR_TABLEGEN="$LLVM_NATIVE_TOOL_DIR/mlir-tblgen"
export MLIR_LINALG_ODS_YAML_GEN="$LLVM_NATIVE_TOOL_DIR/mlir-linalg-ods-yaml-gen"
pyodide build projects/mlir-python-bindings-wasm -o wheelhouse --compression-level 10
- name: Install pyodide and test
shell: bash
run: |
pyodide venv venv
. venv/bin/activate
pip install mlir-python-bindings -f wheelhouse
pushd third_party/llvm-project/mlir/test/python/dialects
for f in *.py; do
if [[ "$f" == "python_test.py" ]]; then
continue
fi
python $f
done
popd
- name: Upload wasm32 wheels
uses: actions/upload-artifact@v4
with:
path: wheelhouse/*.whl
name: build_artifact_python_bindings-ubuntu-wasm
- name: Release current commit
if: (github.event_name == 'push' && github.ref_name == 'main') || github.event_name == 'workflow_dispatch'
uses: ncipollo/[email protected]
with:
artifacts: "wheelhouse/mlir_python_bindings*.whl"
token: "${{ secrets.GITHUB_TOKEN }}"
tag: mlir-python-bindings
name: mlir-python-bindings
removeArtifacts: false
allowUpdates: true
replacesArtifacts: true
makeLatest: true
omitBody: true