Skip to content

[Task] : Use mw_main_llvm_upgrade branch. #77

[Task] : Use mw_main_llvm_upgrade branch.

[Task] : Use mw_main_llvm_upgrade branch. #77

name: Build Release and Publish windows wheels
on:
workflow_dispatch:
push:
# 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
jobs:
build_x64_msvc:
name: windows x86_64 msvc Build
runs-on: windows-2022
defaults:
run:
shell: bash
env:
CACHE_DIR: ${{ github.workspace }}\.container-cache
# Elevates permissions for `GITHUB_TOKEN`'s content scope (to allow this action to make a release)
permissions:
contents: write
# Don't run this in everyone's forks on schedule but allow to run via dispatch.
if: ${{ github.repository_owner == 'llvm' || github.event_name != 'schedule' }}
strategy:
matrix:
package: [torch-mlir]
# TODO(#10): `py_version` has no effect and wheels only get build for 3.11.
# py_version: [cp310-cp310, cp311-cp311, cp312-cp312]
py_version: [cp311-cp311]
python-version: ["3.11"]
torch-version: [stable]
steps:
- name: Checkout torch-mlir
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: mathworks/torch-mlir
ref: refs/heads/mw_main_llvm_upgrade
submodules: 'true'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Setup workspace
uses: ./.github/actions/setup-build
with:
cache-enabled: 'true'
torch-version: 'stable'
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: "Configuring MSVC"
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
- name: Install python deps (torch-${{ matrix.torch-version }})
run: |
cd $GITHUB_WORKSPACE
./build_tools/ci/install_python_deps.sh ${{ matrix.torch-version }}
- name: Put current date into a variable
run: |
echo "NOW=$(date +'%Y%m%d')" >> $GITHUB_ENV
- name: Enable cache
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: ${{ env.CACHE_DIR }}
key: build-test-cpp-asserts-windows-${{ matrix.torch-version }}-v2-${{ github.event.number || github.sha }}
restore-keys: |
build-test-cpp-asserts-windows-${{ matrix.torch-version }}-v2-
- name: ccache
uses: hendrikmuhs/ccache-action@53911442209d5c18de8a31615e0923161e435875 # v1.2.16
with:
key: ${{ github.job }}-${{ matrix.torch-version }}
save: ${{ needs.setup.outputs.write-caches == 1 }}
- name: Build torch-mlir
run: |
cd $GITHUB_WORKSPACE
cache_dir="${{ env.CACHE_DIR }}" \
./build_tools/python_deploy/build_windows_ci.sh
- name: Save cache
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
if: ${{ !cancelled() }}
with:
path: ${{ env.CACHE_DIR }}
key: build-test-cpp-asserts-windows-${{ matrix.torch-version }}-v2-${{ github.event.number || github.sha }}
- name: Build Python wheels and smoke test
run: |
tm_package_version="$(printf '${{ env.NOW }}.${{ github.run_number }}')"
echo "tm_package_version=${tm_package_version}" >> $GITHUB_ENV
printf "TORCH_MLIR_PYTHON_PACKAGE_VERSION=%s\n" ${tm_package_version} > ./torch_mlir_package_version
pip install delvewheel
TORCH_MLIR_PYTHON_PACKAGE_VERSION=${tm_package_version} TORCH_MLIR_CMAKE_BUILD_DIR="build" TORCH_MLIR_CMAKE_ALREADY_BUILT=1 python setup.py bdist_wheel
delvewheel repair --add-path ./build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir/_mlir_libs --add-dll TorchMLIRAggregateCAPI.dll --no-dll 'c10.dll;torch_python.dll;torch_cpu.dll' -v dist/torch_mlir*.whl -w dist
- name: Upload python wheels
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
if-no-files-found: error
name: snapshot-${{ matrix.package }}-${{ matrix.py_version }}-${{ env.tm_package_version }}
path: dist
- name: Release python wheels
uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1.16.0
with:
artifacts: dist/*.whl
token: "${{ secrets.GITHUB_TOKEN }}"
tag: "dev-wheels"
name: "dev-wheels"
body: "Automatic snapshot release of torch-mlir python wheels."
removeArtifacts: false
allowUpdates: true
replacesArtifacts: true
makeLatest: true