dialects: (scf/scf_for) Factor out print and parse methods for For-like operations #14043
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
# This workflow will install MLIR, Python dependencies, run tests and lint with a single version of Python | |
name: CI - MLIR-based Testing | |
on: | |
# Trigger the workflow on push or pull request, | |
# but only for the main branch | |
push: | |
branches: | |
- main | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
python-version: ['3.10', '3.11', '3.12'] | |
env: | |
LLVM_SYMBOLIZER_PATH: /usr/lib/llvm-11/bin/llvm-symbolizer | |
MLIR-Version: d401987fe349a87c53fe25829215b080b70c0c1a | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
path: xdsl | |
fetch-depth: 2 | |
- name: Install native dependencies | |
uses: awalsh128/cache-apt-pkgs-action@latest | |
with: | |
packages: mesa-vulkan-drivers | |
version: 1.0 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
cache-dependency-glob: "xdsl/uv.lock" | |
- name: Set up Python ${{ matrix.python-version }} | |
run: | | |
# Change directory so that xdsl-opt can be found during installation. | |
cd xdsl | |
uv python install ${{ matrix.python-version }} | |
- name: Install the package locally and nbval | |
run: | | |
# Change directory so that xdsl-opt can be found during installation. | |
cd xdsl | |
VENV_EXTRAS="--all-extras" make venv | |
- name: Cache binaries | |
id: cache-binary | |
uses: actions/cache@v4 | |
with: | |
path: llvm-project/build | |
key: binaries-${{ runner.os }}-${{ env.MLIR-Version }} | |
restore-keys: binaries-${{ runner.os }}-${{ env.MLIR-Version }} | |
- name: Checkout MLIR | |
if: steps.cache-binary.outputs.cache-hit != 'true' | |
uses: actions/checkout@v4 | |
with: | |
repository: llvm/llvm-project.git | |
path: llvm-project | |
ref: ${{ env.MLIR-Version }} | |
- name: Clang Setup | |
if: steps.cache-binary.outputs.cache-hit != 'true' | |
uses: egor-tensin/setup-clang@v1 | |
- name: Ninja Setup | |
if: steps.cache-binary.outputs.cache-hit != 'true' | |
uses: lukka/get-cmake@9e431acfe656e5db66cd4930386328fce59cfaba | |
- name: MLIR Build Setup | |
if: steps.cache-binary.outputs.cache-hit != 'true' | |
run: | | |
mkdir llvm-project/build | |
cd llvm-project/build | |
cmake -G Ninja ../llvm \ | |
-DLLVM_ENABLE_PROJECTS=mlir \ | |
-DLLVM_TARGETS_TO_BUILD="X86" \ | |
-DLLVM_ENABLE_LLD=ON \ | |
-DCMAKE_C_COMPILER=clang \ | |
-DCMAKE_CXX_COMPILER=clang++ \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DLLVM_ENABLE_ASSERTIONS=ON | |
- name: MLIR Build | |
if: steps.cache-binary.outputs.cache-hit != 'true' | |
run: | | |
cd llvm-project/build | |
cmake --build . --target mlir-opt mlir-cpu-runner | |
- name: Test with pytest and generate code coverage | |
run: | | |
cd xdsl | |
uv run pytest -W error --cov --cov-config=.coveragerc . | |
- name: Execute lit tests | |
run: | | |
cd xdsl | |
# Add mlir-opt to the path | |
export PATH=$PATH:${GITHUB_WORKSPACE}/llvm-project/build/bin/ | |
uv run lit -v tests/filecheck/ -DCOVERAGE | |
uv run lit -v docs/Toy/examples/ -DCOVERAGE | |
- name: Test MLIR dependent examples/tutorials | |
run: | | |
cd xdsl | |
# Add mlir-opt to the path | |
export PATH=$PATH:${GITHUB_WORKSPACE}/llvm-project/build/bin/ | |
uv run pytest --nbval docs/mlir_interoperation.ipynb --maxfail 1 -vv | |
- name: Test ONNX-dependent marimo notebooks | |
run: | | |
cd xdsl | |
# Add mlir-opt to the path | |
export PATH=$PATH:${GITHUB_WORKSPACE}/llvm-project/build/bin/ | |
uv run make tests-marimo-onnx | |
- name: Combine coverage data | |
run: | | |
cd xdsl | |
uv run coverage combine --append | |
uv run coverage report | |
uv run coverage xml | |
- name: Upload coverage to Codecov | |
if: matrix.python-version == '3.10' | |
uses: Wandalen/wretry.action@v1 | |
with: | |
action: codecov/codecov-action@v4 | |
attempt_delay: 10000 | |
attempt_limit: 10 | |
with: | | |
fail_ci_if_error: true | |
verbose: true | |
root_dir: xdsl | |
files: coverage.xml | |
token: ${{ secrets.CODECOV_TOKEN }} |