Skip to content

Commit 569f9c3

Browse files
committed
Update
[ghstack-poisoned]
2 parents 7a121a9 + 39b994c commit 569f9c3

File tree

1 file changed

+46
-10
lines changed

1 file changed

+46
-10
lines changed

.ci/scripts/test_model.ps1

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,39 @@ Set-PSDebug -Trace 1
99
$ErrorActionPreference = 'Stop'
1010
$PSNativeCommandUseErrorActionPreference = $true
1111

12+
function ExportModel-Portable {
13+
param (
14+
[string]$model_name,
15+
[bool]$strict
16+
)
17+
18+
$exportParams = "--model_name", "$modelName"
19+
if ($strict) {
20+
$exportParams += "--strict"
21+
}
22+
python -m examples.portable.scripts.export @exportParams
23+
if ($LASTEXITCODE -ne 0) {
24+
Write-Host "Model export failed. Exit code: $LASTEXITCODE."
25+
exit $LASTEXITCODE
26+
}
27+
28+
"$modelName.pte"
29+
}
30+
31+
function ExportModel-Xnnpack {
32+
param (
33+
[string]$model_name
34+
)
35+
36+
python -m examples.xnnpack.aot_compiler --model_name="${MODEL_NAME}" --delegate
37+
if ($LASTEXITCODE -ne 0) {
38+
Write-Host "Model export failed. Exit code: $LASTEXITCODE."
39+
exit $LASTEXITCODE
40+
}
41+
42+
"$($modelName)_xnnpack_fp32.pte"
43+
}
44+
1245
.ci/scripts/setup-windows.ps1
1346

1447
# Build the runner
@@ -27,19 +60,22 @@ $executorBinaryPath = Join-Path -Path $buildDir -ChildPath "Release\executor_run
2760
Pop-Location
2861

2962
# 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
63+
switch ($backend) {
64+
"portable" {
65+
$model_path = ExportModel-Portable -model_name $modelName -strict $strict
66+
}
67+
"xnnpack" {
68+
$model_path = ExportModel-Xnnpack -model_name $modelName
69+
}
70+
default {
71+
Write-Host "Unknown backend $backend."
72+
exit 1
73+
}
3874
}
3975

4076
# Run the runner
41-
& "$executorBinaryPath" --model_path="$modelName.pte"
77+
& "$executorBinaryPath" --model_path="$model_path"
4278
if ($LASTEXITCODE -ne 0) {
4379
Write-Host "Model execution failed. Exit code: $LASTEXITCODE."
4480
exit $LASTEXITCODE
45-
}
81+
}

0 commit comments

Comments
 (0)