<# .SYNOPSIS Acceptance gate for an ANSCENTER ep\ ONNX Runtime tree. Returns exit code 0 (all PASS) or 1 (any FAIL) so it can be wired into CI / a release checklist. .DESCRIPTION Run this after swapping any onnxruntime*.dll in SharedCore\ep (e.g. when unifying all EP folders onto a single ORT version). It enforces the three rules that make an ep\ tree correct for ANSCORE: CHECK 1 - API floor. Each EP folder's core onnxruntime.dll must expose an ORT C-API version >= the version ANSCORE links against (-RequiredApi, default 23 for ORT 1.23). ORT is backward compatible, so a NEWER core (1.24 => API 24) is fine; an OLDER one is not. API is derived from the file version (1. => API ). CHECK 2 - Provider/core lock. Every onnxruntime_providers_*.dll in a folder must have the EXACT same file version as that folder's onnxruntime.dll. ORT provider DLLs are version-locked to the core; a mismatch is a silent crash waiting to happen. CHECK 3 - Backend resolution. Every CUDA / cuDNN / TensorRT / OpenVINO / DirectML DLL imported by the core or its providers must exist in the ep folder, the Shared root, or System32. It also prints a UNIFICATION summary (how many distinct core versions exist across the folders) so you can see when you've reached one-version-everywhere. .PARAMETER EpRoot The ep\ folder to verify. Default: C:\Projects\SharedCore\ep (You may also pass the Shared root itself; the script appends \ep if needed.) .PARAMETER SharedRoot The Shared folder that holds the backend DLLs (nvinfer_10.dll, openvino.dll, cudart64_13.dll, DirectML.dll, ...). Default: parent of EpRoot. .PARAMETER RequiredApi Minimum acceptable ORT C-API version. Default: 23 (ANSCORE links ORT 1.23). .EXAMPLE .\verify_ep.ps1 .\verify_ep.ps1 -EpRoot C:\ProgramData\ANSCENTER\Shared\ep .\verify_ep.ps1 -RequiredApi 24 # after bumping ANSCORE's link SDK to 1.24 #> [CmdletBinding()] param( [string] $EpRoot = "C:\Projects\SharedCore\ep", [string] $SharedRoot, [int] $RequiredApi = 23 ) $ErrorActionPreference = "Stop" # --------------------------------------------------------------------------- # Helpers (kept consistent with Check-SharedCoreVersions.ps1) # --------------------------------------------------------------------------- function Coalesce($value, $fallback) { if ($value) { $value } else { $fallback } } function Get-FileVer([string]$path) { if (Test-Path -LiteralPath $path) { (Get-Item -LiteralPath $path).VersionInfo.FileVersion } else { $null } } function Find-Dumpbin { $c = Get-ChildItem ` "C:\Program Files\Microsoft Visual Studio\*\*\VC\Tools\MSVC\*\bin\Hostx64\x64\dumpbin.exe", ` "C:\Program Files (x86)\Microsoft Visual Studio\*\*\VC\Tools\MSVC\*\bin\Hostx64\x64\dumpbin.exe" ` -ErrorAction SilentlyContinue | Sort-Object FullName -Descending if ($c) { return $c[0].FullName } return $null } # Derive the ORT C-API version from a file version string. ORT 1. exposes # C-API version (1.23.* => 23, 1.24.* => 24). Returns $null if unparsable. function Get-OrtApi([string]$fileVer) { if (-not $fileVer) { return $null } $parts = $fileVer.Split('.') if ($parts.Count -lt 2) { return $null } $minor = 0 if ([int]::TryParse($parts[1], [ref]$minor)) { return $minor } return $null } # Lower-cased CUDA/TRT/OV/DML deps imported by $path (via dumpbin /DEPENDENTS). function Get-BackendDeps([string]$dumpbin, [string]$path) { if (-not $dumpbin -or -not (Test-Path -LiteralPath $path)) { return @() } $rx = '(?i)cudart|cublas|cudnn|cufft|cusparse|cusolver|nvinfer|nvonnx|nvrtc|directml|openvino' & $dumpbin /DEPENDENTS $path 2>$null | Select-String -Pattern '^\s+\S+\.dll\s*$' | ForEach-Object { $_.Line.Trim().ToLower() } | Where-Object { $_ -match $rx } | Sort-Object -Unique } # --------------------------------------------------------------------------- # Resolve paths # --------------------------------------------------------------------------- if (-not (Test-Path -LiteralPath $EpRoot)) { Write-Host "ERROR: EpRoot not found: $EpRoot" -ForegroundColor Red; exit 2 } # Allow passing the Shared root instead of the ep folder. if ((Split-Path $EpRoot -Leaf) -ine 'ep' -and (Test-Path -LiteralPath (Join-Path $EpRoot 'ep'))) { $EpRoot = Join-Path $EpRoot 'ep' } if (-not $SharedRoot) { $SharedRoot = Split-Path $EpRoot -Parent } $sys32 = Join-Path $env:WINDIR 'System32' $dumpbin = Find-Dumpbin # Providers expected per EP (DML is baked into the core; CPU has none). $epProviders = [ordered]@{ "cpu" = @() "cuda" = @("onnxruntime_providers_cuda.dll","onnxruntime_providers_tensorrt.dll") "directml" = @() "openvino" = @("onnxruntime_providers_openvino.dll") } Write-Host "" Write-Host "==================================================================" Write-Host " verify_ep - ANSCORE ONNX Runtime acceptance gate" Write-Host " ep root : $EpRoot" Write-Host " shared root : $SharedRoot" Write-Host " required API : >= $RequiredApi (ANSCORE link version)" Write-Host " dumpbin : $(Coalesce $dumpbin 'NOT FOUND - CHECK 3 will be skipped')" Write-Host "==================================================================" $overallFail = $false $coreVersions = @{} # ep -> core file version (for unification summary) foreach ($ep in $epProviders.Keys) { $epDir = Join-Path $EpRoot $ep $core = Join-Path $epDir 'onnxruntime.dll' Write-Host "" Write-Host ("-- ep\{0} ------------------------------------------------------" -f $ep) if (-not (Test-Path -LiteralPath $core)) { if (Test-Path -LiteralPath $epDir) { Write-Host " SKIP: folder present but no onnxruntime.dll" -ForegroundColor DarkYellow } else { Write-Host " SKIP: folder absent" -ForegroundColor DarkGray } continue } $coreVer = Get-FileVer $core $coreVersions[$ep] = $coreVer $epFail = $false # ----- CHECK 1: API floor ------------------------------------------------ $api = Get-OrtApi $coreVer if ($null -eq $api) { Write-Host (" CHECK 1 API : FAIL - cannot parse version '{0}'" -f $coreVer) -ForegroundColor Red $epFail = $true } elseif ($api -lt $RequiredApi) { Write-Host (" CHECK 1 API : FAIL - core {0} => API {1} < required {2}" -f $coreVer,$api,$RequiredApi) -ForegroundColor Red $epFail = $true } else { Write-Host (" CHECK 1 API : PASS - core {0} => API {1} (>= {2})" -f $coreVer,$api,$RequiredApi) -ForegroundColor Green } # ----- CHECK 2: provider/core version lock ------------------------------- $providers = Get-ChildItem -LiteralPath $epDir -Filter 'onnxruntime_providers_*.dll' -ErrorAction SilentlyContinue if (-not $providers) { Write-Host " CHECK 2 LOCK : PASS - no provider DLLs in folder (core-only EP)" -ForegroundColor Green } else { $bad = @() foreach ($p in $providers) { $pv = $p.VersionInfo.FileVersion if ($pv -ne $coreVer) { $bad += ("{0} ({1})" -f $p.Name, (Coalesce $pv 'no-version')) } } if ($bad) { Write-Host (" CHECK 2 LOCK : FAIL - version != core {0}: {1}" -f $coreVer, ($bad -join ', ')) -ForegroundColor Red $epFail = $true } else { Write-Host (" CHECK 2 LOCK : PASS - {0} provider DLL(s) all == {1}" -f $providers.Count, $coreVer) -ForegroundColor Green } } # ----- CHECK 3: backend resolution --------------------------------------- if (-not $dumpbin) { Write-Host " CHECK 3 DEPS : SKIP - dumpbin not available" -ForegroundColor DarkYellow } else { $checkFiles = @('onnxruntime.dll') + $epProviders[$ep] $deps = @() foreach ($cf in $checkFiles) { $deps += Get-BackendDeps $dumpbin (Join-Path $epDir $cf) } $deps = $deps | Sort-Object -Unique if (-not $deps) { Write-Host " CHECK 3 DEPS : PASS - no CUDA/TRT/OV/DML imports" -ForegroundColor Green } else { $missing = @() foreach ($d in $deps) { $found = (Test-Path -LiteralPath (Join-Path $epDir $d)) -or ` (Test-Path -LiteralPath (Join-Path $SharedRoot $d)) -or ` (Test-Path -LiteralPath (Join-Path $sys32 $d)) if (-not $found) { $missing += $d } } if ($missing) { Write-Host (" CHECK 3 DEPS : FAIL - missing: {0}" -f ($missing -join ', ')) -ForegroundColor Red Write-Host (" (imports: {0})" -f ($deps -join ', ')) -ForegroundColor DarkGray $epFail = $true } else { Write-Host (" CHECK 3 DEPS : PASS - all {0} backend import(s) resolved" -f $deps.Count) -ForegroundColor Green Write-Host (" {0}" -f ($deps -join ', ')) -ForegroundColor DarkGray } } } if ($epFail) { $overallFail = $true } } # --------------------------------------------------------------------------- # Unification summary # --------------------------------------------------------------------------- Write-Host "" Write-Host "-- Unification summary --------------------------------------------" $distinct = $coreVersions.Values | Where-Object { $_ } | Sort-Object -Unique if ($distinct.Count -eq 0) { Write-Host " No ORT cores found." -ForegroundColor Red $overallFail = $true } elseif ($distinct.Count -eq 1) { Write-Host (" UNIFIED: all EP folders on a single ORT version ({0})." -f $distinct[0]) -ForegroundColor Green } else { Write-Host (" {0} distinct ORT versions across folders:" -f $distinct.Count) -ForegroundColor Yellow foreach ($ep in $coreVersions.Keys) { Write-Host (" ep\{0,-9} {1}" -f $ep, $coreVersions[$ep]) } Write-Host " Safe at runtime (one EP per process) but not yet unified - see tools recommendation." -ForegroundColor Yellow } # --------------------------------------------------------------------------- # Verdict # --------------------------------------------------------------------------- Write-Host "" Write-Host "==================================================================" if ($overallFail) { Write-Host " RESULT: FAIL - one or more EP folders did not pass." -ForegroundColor Red Write-Host "==================================================================" exit 1 } else { Write-Host " RESULT: PASS - ep\ tree is correct for ANSCORE." -ForegroundColor Green Write-Host "==================================================================" exit 0 }