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