Skip to content

Commit 1705ceb

Browse files
committed
[Windows] Add model run CI
ghstack-source-id: 26c8f36 ghstack-comment-id: 3239691798 Pull-Request: #13836
1 parent d1d460f commit 1705ceb

File tree

4 files changed

+86
-21
lines changed

4 files changed

+86
-21
lines changed

.ci/scripts/setup-windows.ps1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
param (
2+
[string]$editable = $false
3+
)
4+
5+
conda create --yes --quiet -n et python=3.12
6+
conda activate et
7+
8+
# Activate the VS environment - this is required for Dynamo to work, as it uses MSVC.
9+
# There are a bunch of environment variables that it requires.
10+
# See https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line.
11+
& "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64
12+
13+
# Install test dependencies
14+
pip install -r .ci/docker/requirements-ci.txt
15+
16+
if ($editable -eq 'true') {
17+
install_executorch.bat --editable
18+
} else {
19+
install_executorch.bat
20+
}
21+
if ($LASTEXITCODE -ne 0) {
22+
Write-Host "Installation was unsuccessful. Exit code: $LASTEXITCODE."
23+
exit $LASTEXITCODE
24+
}

.ci/scripts/test_model.ps1

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
param (
2+
[string]$modelName,
3+
[string]$backend,
4+
[string]$buildDir = "cmake-out"
5+
[bool]$strict = $false
6+
)
7+
8+
Set-PSDebug -Trace 1
9+
$ErrorActionPreference = 'Stop'
10+
$PSNativeCommandUseErrorActionPreference = $true
11+
12+
.ci/scripts/setup-windows.ps1
13+
14+
# Build the runner
15+
if (Test-Path -Path $buildDir) {
16+
Remove-Item -Path $buildDir -Recurse -Force
17+
}
18+
New-Item -Path $buildDir -ItemType Directory
19+
Push-Directory $buildDir
20+
cmake .. --preset windows
21+
cmake --build . -t executor_runner -j16 --config Release
22+
if ($LASTEXITCODE -ne 0) {
23+
Write-Host "Runner build failed. Exit code: $LASTEXITCODE."
24+
exit $LASTEXITCODE
25+
}
26+
$executorBinaryPath = Join-Path -Path $buildDir -ChildPath "Release\executor_runner.exe"
27+
Pop-Location
28+
29+
# Export the model
30+
$exportParams = "--model_name", "$modelName"
31+
if ($strict) {
32+
$exportParams += "--strict"
33+
}
34+
python -m examples.portable.scripts.export @exportParams
35+
if ($LASTEXITCODE -ne 0) {
36+
Write-Host "Model export failed. Exit code: $LASTEXITCODE."
37+
exit $LASTEXITCODE
38+
}
39+
40+
# Run the runner
41+
& "$executorBinaryPath" --model_path="$(modelName).pte"
42+
if ($LASTEXITCODE -ne 0) {
43+
Write-Host "Model execution failed. Exit code: $LASTEXITCODE."
44+
exit $LASTEXITCODE
45+
}

.ci/scripts/unittest-windows.ps1

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,12 @@
11
param (
2-
[string]$editable
2+
[string]$editable = $false
33
)
44

55
Set-PSDebug -Trace 1
66
$ErrorActionPreference = 'Stop'
77
$PSNativeCommandUseErrorActionPreference = $true
88

9-
conda create --yes --quiet -n et python=3.12
10-
conda activate et
11-
12-
# Activate the VS environment - this is required for Dynamo to work, as it uses MSVC.
13-
# There are a bunch of environment variables that it requires.
14-
# See https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line.
15-
& "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64
16-
17-
# Install test dependencies
18-
pip install -r .ci/docker/requirements-ci.txt
19-
20-
if ($editable -eq 'true') {
21-
install_executorch.bat --editable
22-
} else {
23-
install_executorch.bat
24-
}
25-
if ($LASTEXITCODE -ne 0) {
26-
Write-Host "Installation was unsuccessful. Exit code: $LASTEXITCODE."
27-
exit $LASTEXITCODE
28-
}
9+
.ci/scripts/setup-windows.ps1 -editable $editable
2910

3011
# Run pytest with coverage
3112
# pytest -n auto --cov=./ --cov-report=xml

.github/workflows/trunk.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,3 +979,18 @@ jobs:
979979
# Run MCU models
980980
chmod +x examples/arm/run_mcu_models_fvp.sh
981981
examples/arm/run_mcu_models_fvp.sh --target=cortex-m55
982+
983+
test-models-windows:
984+
if: ${{ inputs.build-tool == 'cmake' }}
985+
uses: pytorch/test-infra/.github/workflows/windows_job.yml@main
986+
strategy:
987+
matrix:
988+
model: [linear, add, add_mul, ic3, ic4, mv2, mv3, resnet18, resnet50, vit, w2l, mobilebert, emformer_join, emformer_transcribe]
989+
backend: [portable, xnnpack]
990+
with:
991+
submodules: 'recursive'
992+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
993+
timeout: 60
994+
script: |
995+
conda init powershell
996+
powershell .ci/scripts/test_model.ps1 -modelName $model -backend $backend

0 commit comments

Comments
 (0)