Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows CI and Release Builder #1521

Merged
merged 1 commit into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/setup-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ runs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: '3.10'

- name: Install MLIR Python depends
run: |
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/buildAndTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
strategy:
fail-fast: true
matrix:
os-arch: [ubuntu-x86_64, macos-arm64]
os-arch: [ubuntu-x86_64, macos-arm64, windows-x86_64]
llvm-build: [in-tree, out-of-tree]
torch-binary: [ON, OFF]
exclude:
Expand All @@ -38,12 +38,16 @@ jobs:
# Exclude macos-arm64 and llvm out-of-tree altogether
- os-arch: macos-arm64
llvm-build: out-of-tree
- os-arch: windows-x86_64
llvm-build: out-of-tree
include:
# Specify OS versions
- os-arch: ubuntu-x86_64
os: ubuntu-22.04
- os-arch: macos-arm64
os: macos-12
- os-arch: windows-x86_64
os: windows-latest
runs-on: ${{ matrix.os }}

steps:
Expand All @@ -53,6 +57,7 @@ jobs:
submodules: 'true'

- name: Fetch PyTorch commit hash
if: ${{ matrix.os-arch != 'windows-x86_64' }}
run: |
PT_HASH="$(cat ${GITHUB_WORKSPACE}/pytorch-version.txt)"
echo "PT_HASH=${PT_HASH}" >> ${GITHUB_ENV}
Expand All @@ -62,7 +67,14 @@ jobs:
with:
cache-suffix: ${{ matrix.os-arch }}-${{ matrix.llvm-build }}-${{ matrix.torch-binary }}

- name: Set up Visual Studio shell
if: ${{ matrix.os-arch == 'windows-x86_64' }}
uses: egor-tensin/vs-shell@v2
with:
arch: x64

- name: Cache PyTorch Build
if: ${{ matrix.os-arch != 'windows-x86_64' }}
id: cache-pytorch
uses: actions/cache@v3
with:
Expand Down Expand Up @@ -110,3 +122,8 @@ jobs:
if: ${{ matrix.os-arch == 'macos-arm64' }}
run: |
cmake --build build_arm64
- name: Build torch-mlir (Windows)
if: ${{ matrix.os-arch == 'windows-x86_64' }}
shell: pwsh
run: |
./build_tools/python_deploy/build_windows_ci.ps1
44 changes: 44 additions & 0 deletions .github/workflows/buildRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,56 @@ jobs:
GITHUB_TOKEN: ${{ secrets.WORKFLOW_INVOCATION_TOKEN }}
with:
release_id: ${{ github.event.inputs.release_id }}


build_windows:
name: Windows Build
runs-on: windows-latest
steps:
- name: Get torch-mlir
uses: actions/checkout@v2
with:
submodules: 'true'
- uses: ./.github/actions/setup-build
with:
cache-suffix: ''
powderluv marked this conversation as resolved.
Show resolved Hide resolved
- name: Set up Visual Studio shell
uses: egor-tensin/vs-shell@v2
with:
arch: x64
- name: Build Python wheels and smoke test.
shell: pwsh
run: |
./build_tools/python_deploy/build_windows.ps1

# If we were given a release_id, then upload the package we just built
# to the github releases page.
- name: Upload Release Assets (if requested)
if: github.event.inputs.release_id != ''
id: upload-release-assets
uses: dwenegar/upload-release-assets@v1
env:
GITHUB_TOKEN: ${{ secrets.WORKFLOW_INVOCATION_TOKEN }}
with:
release_id: ${{ github.event.inputs.release_id }}
assets_path: ./wheelhouse/torch*.whl
# Publishing is necessary to make the release visible to `pip`
# on the github releases page.
- name: Publish Release (if requested)
if: github.event.inputs.release_id != ''
id: publish_release
uses: eregon/publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.WORKFLOW_INVOCATION_TOKEN }}
with:
release_id: ${{ github.event.inputs.release_id }}

publish_releases:
runs-on: ubuntu-latest
needs:
- build_linux
- build_macos
- build_windows

# Publish even if one of the builds failed
if: ${{ always() }}
Expand Down
24 changes: 24 additions & 0 deletions build_tools/python_deploy/build_windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Uncomment if you want to install Python. GHA provides this

#Write-Host "Installing python"

#Start-Process choco 'install python --version=3.10.8' -wait -NoNewWindow

#Write-Host "python installation completed successfully"

#Write-Host "Reload environment variables"
#$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
#Write-Host "Reloaded environment variables"

Write-Host "Installing Build Dependencies"
python -m venv .\mlir_venv\
.\mlir_venv\Scripts\activate
pip install -r .\requirements.txt
Write-Host "Build Deps installation completed successfully"

Write-Host "Building torch-mlir"
$env:CMAKE_GENERATOR='Ninja'
$env:TORCH_MLIR_ENABLE_LTC='0'
python -m pip wheel -v -w wheelhouse ./ -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html -r whl-requirements.txt

Write-Host "Build completed successfully"
42 changes: 42 additions & 0 deletions build_tools/python_deploy/build_windows_ci.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#Uncomment if you want to test locally. GHA provides Python
#Write-Host "Installing python"

#Start-Process choco 'install python --version=3.10.8' -wait -NoNewWindow

#Write-Host "python installation completed successfully"

#Write-Host "Reload environment variables"
#$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
#Write-Host "Reloaded environment variables"

Write-Host "Installing Build Dependencies"
python -m venv .\mlir_venv\
.\mlir_venv\Scripts\activate
pip install -r .\requirements.txt
Write-Host "Build Deps installation completed successfully"

Write-Host "Building torch-mlir"

#Start-Process cmake '-GNinja -Bbuild \
# -DCMAKE_BUILD_TYPE=Release \
# -DPython3_FIND_VIRTUALENV=ONLY \
# -DLLVM_ENABLE_PROJECTS=mlir \
# -DLLVM_EXTERNAL_PROJECTS="torch-mlir;torch-mlir-dialects" \
# -DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$PWD" \
# -DLLVM_EXTERNAL_TORCH_MLIR_DIALECTS_SOURCE_DIR="$PWD"/externals/llvm-external-projects/torch-mlir-dialects \
# -DMLIR_ENABLE_BINDINGS_PYTHON=ON \
# -DLLVM_TARGETS_TO_BUILD=host \
# /externals/llvm-project/llvm'
#Write-Host "Build completed successfully"

Write-Host "Building torch-mlir"
$env:CMAKE_GENERATOR='Ninja'
$env:TORCH_MLIR_ENABLE_LTC='0'
python -m pip wheel -v -w wheelhouse ./ -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html -r whl-requirements.txt
Write-Host "Build completed successfully"

Write-Host "Testing torch-mlir"
$env:PYTHONPATH = "$PWD/build/cmake_build/tools/torch-mlir/python_packages/torch_mlir;$PWD/examples"
# Uncomment here to enable tests. TODO: Fix paths
#cmake --build cmake_build/build --target check-torch-mlir-all
Write-Host "Testing completed successfully"