microsoft/onnxruntime-extensions
Publicmirrored fromhttps://github.com/microsoft/onnxruntime-extensionsAvailable
.pipelines/ci.yml
817lines · modecode
| 1 | # Pipeline trigger settings |
| 2 | trigger: |
| 3 | branches: |
| 4 | include: |
| 5 | - main |
| 6 | - rel-* |
| 7 | paths: |
| 8 | exclude: |
| 9 | - docs/** |
| 10 | - README.md |
| 11 | - tutorials/** |
| 12 | pr: |
| 13 | branches: |
| 14 | include: |
| 15 | - main |
| 16 | - rel-* |
| 17 | paths: |
| 18 | exclude: |
| 19 | - docs/** |
| 20 | - README.md |
| 21 | - tutorials/** |
| 22 | |
| 23 | stages: |
| 24 | |
| 25 | - stage: LinuxBuilds |
| 26 | dependsOn: [] |
| 27 | jobs: |
| 28 | |
| 29 | ####### |
| 30 | # Linux |
| 31 | ####### |
| 32 | - job: Linux |
| 33 | pool: |
| 34 | name: 'onnxruntime-extensions-Linux-CPU' |
| 35 | |
| 36 | strategy: |
| 37 | matrix: |
| 38 | py311-1150: |
| 39 | python.version: '3.11' |
| 40 | torch.version: 'torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu' |
| 41 | ort.version: '1.15.0' |
| 42 | py310-1141: |
| 43 | python.version: '3.10' |
| 44 | torch.version: 'torch==1.13.1+cpu torchvision==0.14.1+cpu torchaudio==0.13.1 --index-url https://download.pytorch.org/whl/cpu' |
| 45 | ort.version: '1.14.1' |
| 46 | py39-1131: |
| 47 | python.version: '3.9' |
| 48 | torch.version: 'torch==1.12.1+cpu torchvision==0.13.1+cpu torchaudio==0.12.1+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html' |
| 49 | ort.version: '1.13.1' |
| 50 | py38-1121: |
| 51 | python.version: '3.8' |
| 52 | torch.version: 'torch==1.11.0+cpu torchvision==0.12.0+cpu torchaudio==0.11.0+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html' |
| 53 | ort.version: '1.12.1' |
| 54 | |
| 55 | steps: |
| 56 | - task: DownloadGitHubRelease@0 |
| 57 | inputs: |
| 58 | connection: 'GitHub - Release' |
| 59 | userRepository: 'microsoft/onnxruntime' |
| 60 | defaultVersionType: 'specificTag' |
| 61 | version: 'v$(ort.version)' |
| 62 | itemPattern: '*-linux-x64-$(ort.version)*' |
| 63 | downloadPath: '$(Build.SourcesDirectory)' |
| 64 | displayName: Download the ONNXRuntime prebuilt package. |
| 65 | |
| 66 | - task: ExtractFiles@1 |
| 67 | inputs: |
| 68 | archiveFilePatterns: '**/*.tgz' |
| 69 | destinationFolder: '$(Build.SourcesDirectory)' |
| 70 | cleanDestinationFolder: false |
| 71 | overwriteExistingFiles: true |
| 72 | displayName: Unpack ONNXRuntime package. |
| 73 | |
| 74 | - script: | |
| 75 | CPU_NUMBER=8 sh ./build.sh -DOCOS_ENABLE_CTEST=ON -DOCOS_ONNXRUNTIME_VERSION="$(ort.version)" -DONNXRUNTIME_PKG_DIR=$(Build.SourcesDirectory)/onnxruntime-linux-x64-$(ort.version) |
| 76 | displayName: build the customop library with onnxruntime |
| 77 | |
| 78 | - script: | |
| 79 | cd out/Linux/RelWithDebInfo |
| 80 | ctest -C RelWithDebInfo --output-on-failure |
| 81 | displayName: Run C++ native tests |
| 82 | |
| 83 | - task: UsePythonVersion@0 |
| 84 | inputs: |
| 85 | versionSpec: '$(python.version)' |
| 86 | addToPath: true |
| 87 | |
| 88 | - script: | |
| 89 | python -m pip install --upgrade pip |
| 90 | python -m pip install --upgrade setuptools |
| 91 | python -m pip install onnxruntime==$(ort.version) |
| 92 | python -m pip install -r requirements.txt |
| 93 | displayName: Install requirements.txt |
| 94 | |
| 95 | - script: | |
| 96 | CPU_NUMBER=8 python -m pip install . |
| 97 | displayName: Build the library and tests |
| 98 | |
| 99 | - script: python -m pip install $(torch.version) |
| 100 | displayName: Install pytorch |
| 101 | |
| 102 | - script: | |
| 103 | python -m pip install -r requirements-dev.txt |
| 104 | displayName: Install requirements-dev.txt |
| 105 | |
| 106 | - script: cd test && python -m pytest . --verbose |
| 107 | displayName: Run python test |
| 108 | |
| 109 | ############### |
| 110 | # Linux PyDebug |
| 111 | ############### |
| 112 | - job: LinuxPyDbg |
| 113 | pool: |
| 114 | name: 'onnxruntime-extensions-Linux-CPU' |
| 115 | |
| 116 | steps: |
| 117 | - task: UsePythonVersion@0 |
| 118 | inputs: |
| 119 | versionSpec: '3.x' |
| 120 | disableDownloadFromRegistry: true |
| 121 | addToPath: false |
| 122 | architecture: 'x64' |
| 123 | |
| 124 | - script: | |
| 125 | python -m pip install --upgrade setuptools pip |
| 126 | python -m pip install numpy |
| 127 | export OCOS_NO_OPENCV=1 |
| 128 | export OCOS_SCB_DEBUG=1 |
| 129 | CPU_NUMBER=8 python -m pip install -e . |
| 130 | displayName: Build the python library in editable mode |
| 131 | |
| 132 | - script: | |
| 133 | python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu |
| 134 | python -m pip install -r requirements-dev.txt |
| 135 | displayName: Install requirements-dev.txt |
| 136 | |
| 137 | - script: | |
| 138 | cd test |
| 139 | python -m pytest --ignore=test_cv2.py --ignore=test_tools_add_pre_post_processing_to_model.py . --verbose |
| 140 | displayName: Run python test |
| 141 | |
| 142 | ##################################### |
| 143 | # Linux prevent exception propagation |
| 144 | ##################################### |
| 145 | - job: Linux_Prevent_Exception_Propagation |
| 146 | pool: |
| 147 | name: 'onnxruntime-extensions-Linux-CPU' |
| 148 | |
| 149 | steps: |
| 150 | # Simulate an embedded build as part of ORT with exceptions disabled by manually setting CMAKE_CXX_FLAGS and |
| 151 | # using _OCOS_PREVENT_EXCEPTION_PROPAGATION_OVERRIDE. The build should re-enable exceptions within ort-ext |
| 152 | # but prevent them from propagating. Unit tests are run to validate this. |
| 153 | - script: ' |
| 154 | ./build_lib.sh --enable_cxx_tests --onnxruntime_version 1.14.0 --config RelWithDebInfo |
| 155 | --cmake_extra_defines |
| 156 | _OCOS_PREVENT_EXCEPTION_PROPAGATION_OVERRIDE=ON OCOS_ENABLE_CPP_EXCEPTIONS=OFF |
| 157 | CMAKE_CXX_FLAGS="-fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables" |
| 158 | ' |
| 159 | |
| 160 | displayName: Build ort-ext with exception propagation disabled |
| 161 | |
| 162 | # As an extra validation check CMakeCache.txt as well |
| 163 | - script: | |
| 164 | grep "^_OCOS_PREVENT_EXCEPTION_PROPAGATION.*ON$" build/Linux/RelWithDebInfo/CMakeCache.txt |
| 165 | if [ $? -ne 0 ]; then |
| 166 | echo "Exception propogation was not enabled correctly." |
| 167 | exit 1 |
| 168 | fi |
| 169 | |
| 170 | |
| 171 | ############################## |
| 172 | # Linux for selected_ops build |
| 173 | ############################## |
| 174 | - job: Linux_SelectedOpsBuild |
| 175 | pool: |
| 176 | name: 'onnxruntime-extensions-Linux-CPU' |
| 177 | |
| 178 | steps: |
| 179 | # compiled as only one operator selected. |
| 180 | - bash: | |
| 181 | set -e -x -u |
| 182 | echo 'set (OCOS_ENABLE_BERT_TOKENIZER ON CACHE BOOL "" FORCE)' > cmake/_selectedoplist.cmake |
| 183 | ./build.sh -DOCOS_ENABLE_CPP_EXCEPTIONS=OFF -DOCOS_ENABLE_SELECTED_OPLIST=ON |
| 184 | displayName: Build ort-extensions with only one operator was selected |
| 185 | |
| 186 | - stage: MacOSBuilds |
| 187 | dependsOn: [] |
| 188 | jobs: |
| 189 | |
| 190 | ########### |
| 191 | # macOS C++ |
| 192 | ########### |
| 193 | - job: MacOSX |
| 194 | pool: |
| 195 | vmImage: 'macOS-13' |
| 196 | |
| 197 | strategy: |
| 198 | matrix: |
| 199 | ort-1150: |
| 200 | ort.version: '1.15.0' |
| 201 | ort.dirname: 'onnxruntime-osx-x86_64-$(ort.version)' |
| 202 | ort-1141: |
| 203 | ort.version: '1.14.1' |
| 204 | ort.dirname: 'onnxruntime-osx-x86_64-$(ort.version)' |
| 205 | ort-1131: |
| 206 | ort.version: '1.13.1' |
| 207 | ort.dirname: 'onnxruntime-osx-x86_64-$(ort.version)' |
| 208 | ort-1121: |
| 209 | ort.version: '1.12.1' |
| 210 | ort.dirname: 'onnxruntime-osx-x86_64-$(ort.version)' |
| 211 | |
| 212 | steps: |
| 213 | - template: templates/use-xcode-version.yml |
| 214 | |
| 215 | # needed for onnxruntime |
| 216 | - script: brew install libomp |
| 217 | displayName: 'Install omp' |
| 218 | |
| 219 | - task: DownloadGitHubRelease@0 |
| 220 | inputs: |
| 221 | connection: 'GitHub - Release' |
| 222 | userRepository: 'microsoft/onnxruntime' |
| 223 | defaultVersionType: 'specificTag' |
| 224 | version: 'v$(ort.version)' |
| 225 | itemPattern: '$(ort.dirname)*' |
| 226 | downloadPath: '$(Build.SourcesDirectory)' |
| 227 | displayName: Download the ONNXRuntime prebuilt package. |
| 228 | |
| 229 | - task: ExtractFiles@1 |
| 230 | inputs: |
| 231 | archiveFilePatterns: '**/*.tgz' |
| 232 | destinationFolder: '$(Build.SourcesDirectory)' |
| 233 | cleanDestinationFolder: false |
| 234 | overwriteExistingFiles: true |
| 235 | displayName: Unpack ONNXRuntime package. |
| 236 | |
| 237 | - script: | |
| 238 | sh ./build.sh -DOCOS_ENABLE_CTEST=ON -DONNXRUNTIME_PKG_DIR=$(Build.SourcesDirectory)/$(ort.dirname) |
| 239 | displayName: build the customop library with onnxruntime |
| 240 | |
| 241 | - script: | |
| 242 | cd out/Darwin/RelWithDebInfo |
| 243 | ctest -C RelWithDebInfo --output-on-failure |
| 244 | displayName: Run C++ native tests |
| 245 | |
| 246 | ############# |
| 247 | # macOS Python |
| 248 | ############# |
| 249 | - job: MacOSPython |
| 250 | pool: |
| 251 | vmImage: 'macOS-13' |
| 252 | |
| 253 | strategy: |
| 254 | matrix: |
| 255 | py311-1150: |
| 256 | python.version: '3.11' |
| 257 | torch.version: 'torch torchvision torchaudio' |
| 258 | ort.version: '1.15.0' |
| 259 | py310-1141: |
| 260 | python.version: '3.10' |
| 261 | torch.version: 'torch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 --index-url https://download.pytorch.org/whl/cpu' |
| 262 | ort.version: '1.14.1' |
| 263 | py39-1131: |
| 264 | python.version: '3.9' |
| 265 | torch.version: 'torch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 -f https://download.pytorch.org/whl/torch_stable.html' |
| 266 | ort.version: '1.13.1' |
| 267 | py38-1120: |
| 268 | python.version: '3.8' |
| 269 | torch.version: 'torch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 -f https://download.pytorch.org/whl/torch_stable.html' |
| 270 | ort.version: '1.12.0' |
| 271 | |
| 272 | steps: |
| 273 | - template: templates/use-xcode-version.yml |
| 274 | |
| 275 | - task: UsePythonVersion@0 |
| 276 | inputs: |
| 277 | versionSpec: '$(python.version)' |
| 278 | disableDownloadFromRegistry: true |
| 279 | addToPath: true |
| 280 | |
| 281 | - script: | |
| 282 | python -m pip install --upgrade pip |
| 283 | python -m pip install --upgrade setuptools |
| 284 | python -m pip install --upgrade wheel |
| 285 | python -m pip install onnxruntime==$(ort.version) |
| 286 | python -m pip install -r requirements.txt |
| 287 | displayName: Install requirements.txt |
| 288 | |
| 289 | - script: | |
| 290 | python -c "import onnxruntime;print(onnxruntime.__version__)" |
| 291 | displayName: Check installation |
| 292 | |
| 293 | - script: | |
| 294 | python -m pip install -e . |
| 295 | displayName: Build and install the wheel |
| 296 | |
| 297 | - script: python -m pip install -r requirements-dev.txt |
| 298 | displayName: Install requirements-dev.txt |
| 299 | |
| 300 | - script: python -m pip install $(torch.version) |
| 301 | displayName: Install pytorch |
| 302 | |
| 303 | - script: cd test && python -m pytest . --verbose |
| 304 | displayName: Run python test |
| 305 | |
| 306 | - stage: WindowsBuilds |
| 307 | dependsOn: [] |
| 308 | jobs: |
| 309 | |
| 310 | ######### |
| 311 | # Windows C++ |
| 312 | ######### |
| 313 | - job: WindowsC |
| 314 | pool: |
| 315 | name: 'onnxruntime-extensions-Windows-CPU' |
| 316 | |
| 317 | strategy: |
| 318 | matrix: |
| 319 | ort-1150: |
| 320 | ort.version: '1.15.0' |
| 321 | ort-1141: |
| 322 | ort.version: '1.14.1' |
| 323 | ort-1131: |
| 324 | ort.version: '1.13.1' |
| 325 | ort-1121: |
| 326 | ort.version: '1.12.1' |
| 327 | |
| 328 | steps: |
| 329 | - task: DownloadGitHubRelease@0 |
| 330 | inputs: |
| 331 | connection: 'GitHub - Release' |
| 332 | userRepository: 'microsoft/onnxruntime' |
| 333 | defaultVersionType: 'specificTag' |
| 334 | version: 'v$(ort.version)' |
| 335 | itemPattern: '*-win-x64-$(ort.version)*' |
| 336 | downloadPath: '$(Build.SourcesDirectory)' |
| 337 | displayName: Download the ONNXRuntime prebuilt package. |
| 338 | |
| 339 | - task: ExtractFiles@1 |
| 340 | inputs: |
| 341 | archiveFilePatterns: '**/*.zip' |
| 342 | destinationFolder: '$(Build.SourcesDirectory)' |
| 343 | cleanDestinationFolder: false |
| 344 | overwriteExistingFiles: true |
| 345 | displayName: Unpack ONNXRuntime package. |
| 346 | |
| 347 | - script: | |
| 348 | @echo off |
| 349 | set vswherepath="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" |
| 350 | for /f "usebackq delims=" %%i in (`%vswherepath% -latest -property installationPath`) do ( |
| 351 | if exist "%%i\Common7\Tools\vsdevcmd.bat" ( |
| 352 | set vsdevcmd="%%i\Common7\Tools\vsdevcmd.bat" |
| 353 | ) |
| 354 | ) |
| 355 | |
| 356 | @echo %vsdevcmd% will be used as the VC compiler |
| 357 | @echo ##vso[task.setvariable variable=vsdevcmd]%vsdevcmd% |
| 358 | displayName: 'locate vsdevcmd via vswhere' |
| 359 | |
| 360 | - script: | |
| 361 | call $(vsdevcmd) |
| 362 | call .\build.bat -DOCOS_ENABLE_CTEST=ON -DOCOS_ONNXRUNTIME_VERSION="$(ort.version)" -DONNXRUNTIME_PKG_DIR=.\onnxruntime-win-x64-$(ort.version) |
| 363 | displayName: build the customop library with onnxruntime |
| 364 | |
| 365 | - script: | |
| 366 | cd out/Windows |
| 367 | ctest -C RelWithDebInfo --output-on-failure |
| 368 | displayName: Run C++ native tests |
| 369 | |
| 370 | - job: WindowsStaticVC |
| 371 | pool: |
| 372 | name: 'onnxruntime-extensions-Windows-CPU' |
| 373 | |
| 374 | steps: |
| 375 | # the vcpkg build requires a cmake python module |
| 376 | - script: python -m pip install cmake |
| 377 | displayName: Install cmake python module |
| 378 | |
| 379 | - script: | |
| 380 | call .\build.bat -DOCOS_ENABLE_CTEST=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded |
| 381 | cd out/Windows |
| 382 | ctest -C RelWithDebInfo --output-on-failure |
| 383 | displayName: build and test ort-extensions with VC static runtime. |
| 384 | |
| 385 | ################ |
| 386 | # Windows Python |
| 387 | ################ |
| 388 | - job: WindowsPython |
| 389 | pool: |
| 390 | name: 'onnxruntime-extensions-Windows-CPU' |
| 391 | |
| 392 | strategy: |
| 393 | matrix: |
| 394 | py311-1150: |
| 395 | python.version: '3.11' |
| 396 | torch.version: 'torch torchvision torchaudio' |
| 397 | ort.version: '1.15.0' |
| 398 | py310-1141: |
| 399 | python.version: '3.10' |
| 400 | torch.version: 'torch torchvision torchaudio' |
| 401 | ort.version: '1.14.1' |
| 402 | py39-1131: |
| 403 | python.version: '3.9' |
| 404 | torch.version: 'torch==1.12.1+cpu torchvision==0.13.1+cpu torchaudio==0.12.1+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html' |
| 405 | ort.version: '1.13.1' |
| 406 | py38-1121: |
| 407 | python.version: '3.8' |
| 408 | torch.version: 'torch==1.11.0+cpu torchvision==0.12.0+cpu torchaudio==0.11.0+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html' |
| 409 | ort.version: '1.12.1' |
| 410 | |
| 411 | steps: |
| 412 | - powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" |
| 413 | displayName: Add conda to PATH |
| 414 | |
| 415 | - script: conda create --yes --quiet --name pyenv -c conda-forge python=$(python.version) numpy |
| 416 | displayName: Create Anaconda environment |
| 417 | |
| 418 | - script: | |
| 419 | call activate pyenv |
| 420 | python -m pip install --upgrade pip |
| 421 | python -m pip install onnxruntime==$(ort.version) |
| 422 | python -m pip install -r requirements.txt |
| 423 | python -m pip install -r requirements-dev.txt |
| 424 | displayName: Install requirements{-dev}.txt and cmake python modules |
| 425 | |
| 426 | - script: | |
| 427 | call activate pyenv |
| 428 | set CMAKE_ARGS=-DOCOS_ONNXRUNTIME_VERSION=$(ort.version) |
| 429 | python -m pip install . |
| 430 | displayName: Build the wheel |
| 431 | |
| 432 | - script: | |
| 433 | call activate pyenv |
| 434 | python -m pip install $(torch.version) |
| 435 | displayName: Install pytorch |
| 436 | |
| 437 | - script: | |
| 438 | call activate pyenv |
| 439 | pytest test |
| 440 | displayName: Run python test |
| 441 | |
| 442 | ################# |
| 443 | # Windows PyDebug |
| 444 | ################# |
| 445 | - job: WinPyDbgBuild |
| 446 | pool: |
| 447 | name: 'onnxruntime-extensions-Windows-CPU' |
| 448 | |
| 449 | steps: |
| 450 | - task: UsePythonVersion@0 |
| 451 | inputs: |
| 452 | versionSpec: '3.x' |
| 453 | disableDownloadFromRegistry: true |
| 454 | addToPath: false |
| 455 | architecture: 'x64' |
| 456 | displayName: Use ADO python task |
| 457 | |
| 458 | - script: | |
| 459 | python -m pip install --upgrade setuptools pip |
| 460 | python -m pip install numpy |
| 461 | set OCOS_NO_OPENCV=1 |
| 462 | set OCOS_SCB_DEBUG=1 |
| 463 | python -m pip install -v -e . |
| 464 | displayName: Build onnxruntime-extensions in editable mode. |
| 465 | |
| 466 | - script: | |
| 467 | python -m pip install -r requirements-dev.txt |
| 468 | python -m pip install torch torchvision torchaudio |
| 469 | displayName: Install dependencies for pytest |
| 470 | |
| 471 | - script: | |
| 472 | cd test |
| 473 | python -m pytest --ignore=test_cv2.py --ignore=test_tools_add_pre_post_processing_to_model.py . --verbose |
| 474 | displayName: Run python test |
| 475 | |
| 476 | - stage: WindowsCUDABuilds |
| 477 | dependsOn: [] |
| 478 | jobs: |
| 479 | - job: WindowsC |
| 480 | pool: |
| 481 | name: 'onnxruntime-extensions-Win2022-GPU-A10' |
| 482 | variables: |
| 483 | ORT_VERSION: '1.16.2' |
| 484 | steps: |
| 485 | - template: templates/set_winenv.yml |
| 486 | parameters: |
| 487 | EnvSetupScript: 'set_env_cuda.bat' |
| 488 | DownloadCUDA: true |
| 489 | |
| 490 | - script: | |
| 491 | nvidia-smi |
| 492 | nvcc --version |
| 493 | where nvcc |
| 494 | displayName: check cuda version |
| 495 | |
| 496 | - task: DownloadGitHubRelease@0 |
| 497 | inputs: |
| 498 | connection: 'GitHub - Release' |
| 499 | userRepository: 'microsoft/onnxruntime' |
| 500 | defaultVersionType: 'specificTag' |
| 501 | version: 'v$(ORT_VERSION)' |
| 502 | itemPattern: '*-win-x64-gpu-$(ORT_VERSION)*' |
| 503 | downloadPath: '$(Build.SourcesDirectory)' |
| 504 | displayName: Download the ONNXRuntime prebuilt package. |
| 505 | |
| 506 | - task: ExtractFiles@1 |
| 507 | inputs: |
| 508 | archiveFilePatterns: '**/*.zip' |
| 509 | destinationFolder: '$(Build.SourcesDirectory)' |
| 510 | cleanDestinationFolder: false |
| 511 | overwriteExistingFiles: true |
| 512 | displayName: Unpack ONNXRuntime package. |
| 513 | |
| 514 | - script: | |
| 515 | set CUDA_PATH=$(Agent.TempDirectory)\v11.8 |
| 516 | call .\build.bat -T cuda="%CUDA_PATH%" -DOCOS_ENABLE_CTEST=ON -DOCOS_USE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=86 -DOCOS_ONNXRUNTIME_VERSION="$(ORT_VERSION)" -DONNXRUNTIME_PKG_DIR=.\onnxruntime-win-x64-gpu-$(ORT_VERSION) |
| 517 | displayName: build the customop library with onnxruntime |
| 518 | |
| 519 | - script: | |
| 520 | cd out/Windows |
| 521 | ctest -C RelWithDebInfo --output-on-failure |
| 522 | displayName: Run C++ native tests |
| 523 | |
| 524 | - stage: LinuxCUDABuilds |
| 525 | dependsOn: [] |
| 526 | jobs: |
| 527 | - job: LinuxGPU |
| 528 | pool: |
| 529 | name: 'onnxruntime-extensions-Linux-GPU-A10' |
| 530 | variables: |
| 531 | ORT_VERSION: '1.16.2' |
| 532 | TORCH_VERSION: 'torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118' |
| 533 | steps: |
| 534 | - task: mspremier.PostBuildCleanup.PostBuildCleanup-task.PostBuildCleanup@3 |
| 535 | displayName: 'Clean Agent Directories' |
| 536 | condition: always() |
| 537 | |
| 538 | - script: | |
| 539 | nvidia-smi |
| 540 | displayName: check cuda version |
| 541 | |
| 542 | - checkout: self |
| 543 | clean: true |
| 544 | submodules: none |
| 545 | |
| 546 | - task: UsePythonVersion@0 |
| 547 | inputs: |
| 548 | versionSpec: '3.8' |
| 549 | addToPath: true |
| 550 | |
| 551 | - task: DownloadGitHubRelease@0 |
| 552 | inputs: |
| 553 | connection: 'GitHub - Release' |
| 554 | userRepository: 'microsoft/onnxruntime' |
| 555 | defaultVersionType: 'specificTag' |
| 556 | version: 'v$(ORT_VERSION)' |
| 557 | itemPattern: '*-linux-x64-$(ORT_VERSION)*' |
| 558 | downloadPath: '$(Build.SourcesDirectory)' |
| 559 | displayName: Download the ONNXRuntime prebuilt package. |
| 560 | |
| 561 | - task: ExtractFiles@1 |
| 562 | inputs: |
| 563 | archiveFilePatterns: '**/*.tgz' |
| 564 | destinationFolder: '$(Build.SourcesDirectory)' |
| 565 | cleanDestinationFolder: false |
| 566 | overwriteExistingFiles: true |
| 567 | displayName: Unpack ONNXRuntime package. |
| 568 | |
| 569 | - template: ../tools/ci_build/github/azure-pipeline/templates/get-docker-image-steps.yml |
| 570 | parameters: |
| 571 | Dockerfile: tools/ci_build/github/linux/docker/Dockerfile.ubuntu_cuda11_8_tensorrt8_6 |
| 572 | Context: tools/ci_build/github/linux/docker |
| 573 | DockerBuildArgs: "--build-arg BUILD_UID=$( id -u )" |
| 574 | Repository: onnxruntime-extensionscuda11build |
| 575 | UpdateDepsTxt: false |
| 576 | |
| 577 | - task: CmdLine@2 |
| 578 | inputs: |
| 579 | script: | |
| 580 | docker run --gpus all --rm \ |
| 581 | --volume $(Build.SourcesDirectory):/onnxruntime-extensions \ |
| 582 | --volume $(Build.SourcesDirectory)/onnxruntime-linux-x64-$(ORT_VERSION):/onnxruntime \ |
| 583 | -e CUDA_PATH=/usr/local/cuda-11.8 \ |
| 584 | onnxruntime-extensionscuda11build \ |
| 585 | /bin/bash -c " |
| 586 | set -ex; \ |
| 587 | pushd /onnxruntime-extensions; \ |
| 588 | sh ./build.sh -DOCOS_ENABLE_CTEST=ON -DOCOS_USE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=86 -DOCOS_ONNXRUNTIME_VERSION="$(ORT_VERSION)" -DONNXRUNTIME_PKG_DIR=/onnxruntime; \ |
| 589 | popd; \ |
| 590 | " |
| 591 | workingDirectory: $(Build.SourcesDirectory) |
| 592 | displayName: build the customop library with onnxruntime |
| 593 | |
| 594 | - task: CmdLine@2 |
| 595 | inputs: |
| 596 | script: | |
| 597 | docker run --gpus all --rm \ |
| 598 | --volume $(Build.SourcesDirectory):/onnxruntime-extensions \ |
| 599 | --volume $(Build.SourcesDirectory)/onnxruntime-linux-x64-$(ORT_VERSION):/onnxruntime \ |
| 600 | -e CUDA_PATH=/usr/local/cuda-11.8 \ |
| 601 | onnxruntime-extensionscuda11build \ |
| 602 | /bin/bash -c " |
| 603 | set -ex; \ |
| 604 | pushd /onnxruntime-extensions; \ |
| 605 | cd out/Linux/RelWithDebInfo; \ |
| 606 | ctest -C RelWithDebInfo --output-on-failure; \ |
| 607 | popd; \ |
| 608 | " |
| 609 | workingDirectory: $(Build.SourcesDirectory) |
| 610 | displayName: Run C++ native tests |
| 611 | |
| 612 | - script: | |
| 613 | python -m pip install --upgrade pip |
| 614 | python -m pip install --upgrade setuptools |
| 615 | python -m pip install onnxruntime-gpu==$(ORT_VERSION) |
| 616 | python -m pip install -r requirements.txt |
| 617 | displayName: Install requirements.txt |
| 618 | |
| 619 | - script: | |
| 620 | python -m pip install . |
| 621 | displayName: Build the library and tests |
| 622 | |
| 623 | - script: python -m pip install $(TORCH_VERSION) |
| 624 | displayName: Install pytorch |
| 625 | |
| 626 | - script: | |
| 627 | python -m pip install -r requirements-dev.txt |
| 628 | displayName: Install requirements-dev.txt |
| 629 | |
| 630 | - script: cd test && python -m pytest . --verbose |
| 631 | displayName: Run python test |
| 632 | |
| 633 | - stage: WebAssemblyBuilds |
| 634 | dependsOn: [] |
| 635 | jobs: |
| 636 | |
| 637 | ############# |
| 638 | # WebAssembly |
| 639 | ############# |
| 640 | - job: WebAssembly |
| 641 | pool: |
| 642 | vmImage: 'ubuntu-latest' |
| 643 | |
| 644 | steps: |
| 645 | - script: | |
| 646 | cd $(Build.BinariesDirectory) |
| 647 | git clone https://github.com/emscripten-core/emsdk |
| 648 | emsdk/emsdk install latest |
| 649 | emsdk/emsdk activate latest |
| 650 | displayName: Setup emscripten pipeline |
| 651 | |
| 652 | - script: | |
| 653 | bash ./build.sh \ |
| 654 | -DCMAKE_TOOLCHAIN_FILE=$(Build.BinariesDirectory)/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \ |
| 655 | -DOCOS_ENABLE_SPM_TOKENIZER=ON \ |
| 656 | -DOCOS_BUILD_PYTHON=OFF \ |
| 657 | -DOCOS_ENABLE_CV2=OFF \ |
| 658 | -DOCOS_ENABLE_VISION=OFF |
| 659 | displayName: build the customop library with onnxruntime |
| 660 | # TODO add unittest for webassembly |
| 661 | |
| 662 | - stage: AndroidBuilds |
| 663 | dependsOn: [] |
| 664 | jobs: |
| 665 | |
| 666 | ############# |
| 667 | # Android |
| 668 | ############# |
| 669 | - job: AndroidPackage_BuildOnly |
| 670 | pool: |
| 671 | vmImage: 'macOS-13' |
| 672 | timeoutInMinutes: 120 |
| 673 | steps: |
| 674 | - task: UsePythonVersion@0 |
| 675 | inputs: |
| 676 | versionSpec: "3.9" |
| 677 | addToPath: true |
| 678 | architecture: "x64" |
| 679 | displayName: "Use Python 3.9" |
| 680 | |
| 681 | - task: JavaToolInstaller@0 |
| 682 | displayName: Use jdk 17 |
| 683 | inputs: |
| 684 | versionSpec: '17' |
| 685 | jdkArchitectureOption: 'x64' |
| 686 | jdkSourceOption: 'PreInstalled' |
| 687 | |
| 688 | - script: brew install coreutils ninja |
| 689 | displayName: Install coreutils and ninja |
| 690 | |
| 691 | - bash: | |
| 692 | set -e -x |
| 693 | |
| 694 | _BUILD_CFG="x86_64 $(Build.BinariesDirectory)/android_aar" ./build.android |
| 695 | |
| 696 | VERSION=$(cat ./version.txt) |
| 697 | AAR_PATH="$(Build.BinariesDirectory)/android_aar/aar_out/com/microsoft/onnxruntime/onnxruntime-extensions-android/${VERSION}/onnxruntime-extensions-android-${VERSION}.aar" |
| 698 | |
| 699 | # Do not output ##vso[] commands with `set -x` or they may be parsed again and include a trailing quote. |
| 700 | set +x |
| 701 | echo "##vso[task.setvariable variable=ORT_EXTENSIONS_AAR_PATH]${AAR_PATH}" |
| 702 | displayName: Build onnxruntime-extensions AAR package |
| 703 | |
| 704 | - job: AndroidCpp_BuildOnly |
| 705 | pool: |
| 706 | vmImage: 'macOS-13' |
| 707 | timeoutInMinutes: 30 |
| 708 | steps: |
| 709 | - task: UsePythonVersion@0 |
| 710 | inputs: |
| 711 | versionSpec: "3.9" |
| 712 | addToPath: true |
| 713 | architecture: "x64" |
| 714 | displayName: "Use Python 3.9" |
| 715 | |
| 716 | - task: JavaToolInstaller@0 |
| 717 | displayName: Use jdk 17 |
| 718 | inputs: |
| 719 | versionSpec: '17' |
| 720 | jdkArchitectureOption: 'x64' |
| 721 | jdkSourceOption: 'PreInstalled' |
| 722 | |
| 723 | - script: brew install ninja |
| 724 | displayName: Install ninja |
| 725 | |
| 726 | - bash: | |
| 727 | python ./tools/build.py \ |
| 728 | --config RelWithDebInfo \ |
| 729 | --android \ |
| 730 | --android_abi x86_64 \ |
| 731 | --enable_cxx_tests \ |
| 732 | --update --build --parallel |
| 733 | displayName: Build onnxruntime-extensions for Android |
| 734 | |
| 735 | - stage: IosBuilds |
| 736 | dependsOn: [] |
| 737 | jobs: |
| 738 | |
| 739 | ############# |
| 740 | # iOS |
| 741 | ############# |
| 742 | - job: IosPackage |
| 743 | pool: |
| 744 | vmImage: 'macOS-13' |
| 745 | timeoutInMinutes: 120 |
| 746 | steps: |
| 747 | - template: templates/use-xcode-version.yml |
| 748 | |
| 749 | - task: UsePythonVersion@0 |
| 750 | inputs: |
| 751 | versionSpec: '3.9' |
| 752 | disableDownloadFromRegistry: true |
| 753 | addToPath: true |
| 754 | architecture: 'x64' |
| 755 | displayName: "Use Python 3.9" |
| 756 | |
| 757 | # iOS xcframework build doesn't work with CMake 3.25.1, pin to 3.25.0 |
| 758 | - script: | |
| 759 | python -m pip install cmake==3.25.0 |
| 760 | displayName: "Install CMake 3.25.0" |
| 761 | |
| 762 | - template: templates/set-package-version-variable-step.yml |
| 763 | parameters: |
| 764 | PackageVersionVariableName: ORT_EXTENSIONS_POD_VERSION |
| 765 | |
| 766 | - script: | |
| 767 | python ./tools/ios/build_xcframework.py \ |
| 768 | --output_dir $(Build.BinariesDirectory)/xcframework_out \ |
| 769 | --platform_arch iphonesimulator x86_64 \ |
| 770 | --config RelWithDebInfo \ |
| 771 | --ios_deployment_target 13.0 \ |
| 772 | -- \ |
| 773 | --enable_cxx_tests |
| 774 | displayName: "Build xcframework for iphonesimulator x86_64" |
| 775 | |
| 776 | - script: | |
| 777 | python ./tools/ios/assemble_pod_package.py \ |
| 778 | --staging-dir $(Build.BinariesDirectory)/pod_staging \ |
| 779 | --xcframework-output-dir $(Build.BinariesDirectory)/xcframework_out \ |
| 780 | --pod-version ${ORT_EXTENSIONS_POD_VERSION} |
| 781 | displayName: "Assemble pod" |
| 782 | |
| 783 | - script: | |
| 784 | ORT_EXTENSIONS_LOCAL_POD_PATH=$(Build.BinariesDirectory)/pod_staging \ |
| 785 | pod install |
| 786 | displayName: "Install pods for OrtExtensionsUsage" |
| 787 | workingDirectory: $(Build.SourcesDirectory)/test/ios/OrtExtensionsUsage |
| 788 | |
| 789 | - script: | |
| 790 | set -e |
| 791 | |
| 792 | SIMULATOR_DEVICE_INFO=$(python ./tools/ios/get_simulator_device_info.py) |
| 793 | |
| 794 | echo "Simulator device info:" |
| 795 | echo "${SIMULATOR_DEVICE_INFO}" |
| 796 | |
| 797 | SIMULATOR_DEVICE_ID=$(jq --raw-output '.device_udid' <<< "${SIMULATOR_DEVICE_INFO}") |
| 798 | |
| 799 | # Do not output ##vso[] commands with `set -x` or they may be parsed again and include a trailing quote. |
| 800 | set +x |
| 801 | echo "##vso[task.setvariable variable=ORT_EXTENSIONS_SIMULATOR_DEVICE_ID]${SIMULATOR_DEVICE_ID}" |
| 802 | displayName: "Get simulator device info" |
| 803 | |
| 804 | - script: | |
| 805 | xcrun simctl bootstatus ${ORT_EXTENSIONS_SIMULATOR_DEVICE_ID} -b |
| 806 | displayName: "Wait for simulator device to boot" |
| 807 | |
| 808 | - script: | |
| 809 | xcrun xcodebuild \ |
| 810 | -sdk iphonesimulator \ |
| 811 | -configuration Debug \ |
| 812 | -parallel-testing-enabled NO \ |
| 813 | -workspace $(Build.SourcesDirectory)/test/ios/OrtExtensionsUsage/OrtExtensionsUsage.xcworkspace \ |
| 814 | -scheme OrtExtensionsUsage \ |
| 815 | -destination "platform=iOS Simulator,id=${ORT_EXTENSIONS_SIMULATOR_DEVICE_ID}" \ |
| 816 | test CODE_SIGNING_ALLOWED=NO |
| 817 | displayName: "Build and test OrtExtensionsUsage" |
| 818 | |