microsoft/onnxruntime-extensions

Public

mirrored from https://github.com/microsoft/onnxruntime-extensionsAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
snnn-patch-1

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

.pipelines/ci.yml

928lines · modecode

1# Pipeline trigger settings
2trigger:
3 branches:
4 include:
5 - main
6 - rel-*
7 paths:
8 exclude:
9 - docs/**
10 - README.md
11 - tutorials/**
12pr:
13 branches:
14 include:
15 - main
16 - rel-*
17 paths:
18 exclude:
19 - docs/**
20 - README.md
21 - tutorials/**
22
23stages:
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==1.13.1+cpu torchvision==0.14.1+cpu torchaudio==0.13.1 --index-url https://download.pytorch.org/whl/cpu'
57 ort.version: '1.15.1'
58
59 steps:
60 - task: DownloadGitHubRelease@0
61 inputs:
62 connection: 'GitHub - Release'
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: cd test && python -m pytest . --verbose
110 displayName: Run python test
111
112 ###############
113 # Linux PyDebug
114 ###############
115 - job: LinuxPyDbg
116 pool:
117 name: 'onnxruntime-extensions-Linux-CPU'
118
119 steps:
120 - task: UsePythonVersion@0
121 inputs:
122 versionSpec: '3.x'
123 disableDownloadFromRegistry: true
124 addToPath: true
125 architecture: 'x64'
126
127 - script: |
128 python -m pip install --upgrade setuptools pip
129 python -m pip install 'numpy < 2.0.0'
130 export OCOS_NO_OPENCV=1
131 export OCOS_SCB_DEBUG=1
132 CPU_NUMBER=8 python -m pip install -e .
133 displayName: Build the python library in editable mode
134
135 - script: |
136 python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
137 python -m pip install -r requirements-dev.txt
138 displayName: Install requirements-dev.txt
139
140 - script: |
141 cd test
142 python -m pytest --ignore=test_cv2.py --ignore=test_tools_add_pre_post_processing_to_model.py . --verbose
143 displayName: Run python test
144
145 #####################################
146 # Linux prevent exception propagation
147 #####################################
148 - job: Linux_Prevent_Exception_Propagation
149 pool:
150 name: 'onnxruntime-extensions-Linux-CPU'
151
152 steps:
153 # Simulate an embedded build as part of ORT with exceptions disabled by manually setting CMAKE_CXX_FLAGS and
154 # using _OCOS_PREVENT_EXCEPTION_PROPAGATION_OVERRIDE. The build should re-enable exceptions within ort-ext
155 # but prevent them from propagating. Unit tests are run to validate this.
156 - script: '
157 ./build_lib.sh --enable_cxx_tests --onnxruntime_version 1.14.0 --config RelWithDebInfo
158 --cmake_extra_defines
159 _OCOS_PREVENT_EXCEPTION_PROPAGATION_OVERRIDE=ON OCOS_ENABLE_CPP_EXCEPTIONS=OFF
160 CMAKE_CXX_FLAGS="-fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables"
161 '
162
163 displayName: Build ort-ext with exception propagation disabled
164
165 # As an extra validation check CMakeCache.txt as well
166 - script: |
167 grep "^_OCOS_PREVENT_EXCEPTION_PROPAGATION.*ON$" build/Linux/RelWithDebInfo/CMakeCache.txt
168 if [ $? -ne 0 ]; then
169 echo "Exception propogation was not enabled correctly."
170 exit 1
171 fi
172
173
174 ##############################
175 # Linux for selected_ops build
176 ##############################
177 - job: Linux_SelectedOpsBuild
178 pool:
179 name: 'onnxruntime-extensions-Linux-CPU'
180
181 steps:
182 # compiled as only one operator selected.
183 - bash: |
184 set -e -x -u
185 echo 'set (OCOS_ENABLE_BERT_TOKENIZER ON CACHE BOOL "" FORCE)' > cmake/_selectedoplist.cmake
186 ./build.sh -DOCOS_ENABLE_CPP_EXCEPTIONS=OFF -DOCOS_ENABLE_SELECTED_OPLIST=ON -DOCOS_ENABLE_CTEST=OFF
187 displayName: Build ort-extensions with only one operator was selected
188
189 ##############################
190 # Linux for pre-processing API
191 ##############################
192 - job: Linux_PPApiBuild
193 pool:
194 name: 'onnxruntime-extensions-Linux-CPU'
195
196 steps:
197 # compiled as only one operator selected.
198 - bash: |
199 set -e -x -u
200 ./build.sh -DOCOS_ENABLE_C_API=ON
201 cd out/Linux/RelWithDebInfo
202 ctest -C RelWithDebInfo --output-on-failure
203 displayName: Build ort-extensions with API enabled and run tests
204
205 - bash: |
206 set -e -x -u
207 ./build.sh -DOCOS_BUILD_PRESET=token_api_only -DOCOS_BUILD_SHARED_LIB=OFF
208 cd out/Linux/RelWithDebInfo
209 ctest -C RelWithDebInfo --output-on-failure
210 displayName: Build ort-extensions with tokenizer API only enabled and run tests
211
212
213- stage: MacOSBuilds
214 dependsOn: []
215 jobs:
216
217 ###########
218 # macOS C++
219 ###########
220 - job: MacOSX
221 pool:
222 vmImage: 'macOS-13'
223
224 strategy:
225 matrix:
226 ort-1181:
227 ort.version: '1.18.1'
228 ort.dirname: 'onnxruntime-osx-x86_64-$(ort.version)'
229 ort-1171:
230 ort.version: '1.17.1'
231 ort.dirname: 'onnxruntime-osx-x86_64-$(ort.version)'
232 ort-1163:
233 ort.version: '1.16.3'
234 ort.dirname: 'onnxruntime-osx-x86_64-$(ort.version)'
235 ort-1151:
236 ort.version: '1.15.1'
237 ort.dirname: 'onnxruntime-osx-x86_64-$(ort.version)'
238
239 steps:
240 - template: templates/use-xcode-version.yml
241
242 # needed for onnxruntime
243 - script: brew install libomp
244 displayName: 'Install omp'
245
246 - task: DownloadGitHubRelease@0
247 inputs:
248 connection: 'GitHub - Release'
249 userRepository: 'microsoft/onnxruntime'
250 defaultVersionType: 'specificTag'
251 version: 'v$(ort.version)'
252 itemPattern: '$(ort.dirname)*'
253 downloadPath: '$(Build.SourcesDirectory)'
254 displayName: Download the ONNXRuntime prebuilt package.
255
256 - task: ExtractFiles@1
257 inputs:
258 archiveFilePatterns: '**/*.tgz'
259 destinationFolder: '$(Build.SourcesDirectory)'
260 cleanDestinationFolder: false
261 overwriteExistingFiles: true
262 displayName: Unpack ONNXRuntime package.
263
264 - script: |
265 sh ./build.sh -DOCOS_ENABLE_CTEST=ON -DONNXRUNTIME_PKG_DIR=$(Build.SourcesDirectory)/$(ort.dirname)
266 displayName: build the customop library with onnxruntime
267
268 - script: |
269 cd out/Darwin/RelWithDebInfo
270 ctest -C RelWithDebInfo --output-on-failure
271 displayName: Run C++ native tests
272
273 ##############################
274 # MacOS for pre-processing API
275 ##############################
276 - job: MacOS_PPApiBuild
277 pool:
278 vmImage: 'macOS-13'
279
280 steps:
281 # compiled as only one operator selected.
282 - bash: |
283 set -e -x -u
284 ./build.sh -DOCOS_ENABLE_C_API=ON
285 cd out/Darwin/RelWithDebInfo
286 ctest -C RelWithDebInfo --output-on-failure
287 displayName: Build ort-extensions with API enabled and run tests
288
289 #############
290 # macOS Python
291 #############
292 - job: MacOSPython
293 pool:
294 vmImage: 'macOS-13'
295
296 strategy:
297 matrix:
298 py312-1192:
299 python.version: '3.12'
300 torch.version: 'torch torchvision torchaudio'
301 ort.version: '1.19.2'
302 py312-1181:
303 python.version: '3.12'
304 torch.version: 'torch torchvision torchaudio'
305 ort.version: '1.18.1'
306 py311-1171:
307 python.version: '3.11'
308 torch.version: 'torch torchvision torchaudio'
309 ort.version: '1.17.1'
310 py310-1163:
311 python.version: '3.10'
312 torch.version: 'torch torchvision torchaudio'
313 ort.version: '1.16.3'
314 py39-1151:
315 python.version: '3.9'
316 torch.version: 'torch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 --index-url https://download.pytorch.org/whl/cpu'
317 ort.version: '1.15.1'
318
319 steps:
320 - template: templates/use-xcode-version.yml
321
322 - task: UsePythonVersion@0
323 inputs:
324 versionSpec: '$(python.version)'
325 disableDownloadFromRegistry: true
326 addToPath: true
327
328 - script: |
329 python -m pip install --upgrade pip
330 python -m pip install --upgrade setuptools
331 python -m pip install --upgrade wheel
332 python -m pip install 'numpy < 2.0.0'
333 python -m pip install onnxruntime==$(ort.version)
334 displayName: Install requirements
335
336 - script: |
337 python -c "import onnxruntime;print(onnxruntime.__version__)"
338 displayName: Check installation
339
340 - script: |
341 python -m pip install -e .
342 displayName: Build and install the wheel
343
344 - script: python -m pip install -r requirements-dev.txt
345 displayName: Install requirements-dev.txt
346
347 - script: python -m pip install $(torch.version)
348 displayName: Install pytorch
349
350 - script: cd test && python -m pytest . --verbose
351 displayName: Run python test
352
353- stage: WindowsBuilds
354 dependsOn: []
355 jobs:
356
357 #########
358 # Windows C++
359 #########
360 - job: WindowsC
361 pool:
362 name: 'onnxruntime-extensions-Windows-CPU'
363
364 strategy:
365 matrix:
366 ort-1181:
367 ort.version: '1.18.1'
368 ort-1171:
369 ort.version: '1.17.1'
370 ort-1163:
371 ort.version: '1.16.3'
372 ort-1151:
373 ort.version: '1.15.1'
374
375 steps:
376 - task: DownloadGitHubRelease@0
377 inputs:
378 connection: 'GitHub - Release'
379 userRepository: 'microsoft/onnxruntime'
380 defaultVersionType: 'specificTag'
381 version: 'v$(ort.version)'
382 itemPattern: '*-win-x64-$(ort.version)*'
383 downloadPath: '$(Build.SourcesDirectory)'
384 displayName: Download the ONNXRuntime prebuilt package.
385
386 - task: ExtractFiles@1
387 inputs:
388 archiveFilePatterns: '**/*.zip'
389 destinationFolder: '$(Build.SourcesDirectory)'
390 cleanDestinationFolder: false
391 overwriteExistingFiles: true
392 displayName: Unpack ONNXRuntime package.
393
394 - script: |
395 @echo off
396 set vswherepath="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
397 for /f "usebackq delims=" %%i in (`%vswherepath% -latest -property installationPath`) do (
398 if exist "%%i\Common7\Tools\vsdevcmd.bat" (
399 set vsdevcmd="%%i\Common7\Tools\vsdevcmd.bat"
400 )
401 )
402
403 @echo %vsdevcmd% will be used as the VC compiler
404 @echo ##vso[task.setvariable variable=vsdevcmd]%vsdevcmd%
405 displayName: 'locate vsdevcmd via vswhere'
406
407 - script: |
408 call $(vsdevcmd)
409 call .\build.bat -DOCOS_ENABLE_CTEST=ON -DOCOS_ONNXRUNTIME_VERSION="$(ort.version)" -DONNXRUNTIME_PKG_DIR=.\onnxruntime-win-x64-$(ort.version)
410 displayName: build the customop library with onnxruntime
411
412 - script: |
413 cd out/Windows
414 ctest -C RelWithDebInfo --output-on-failure
415 displayName: Run C++ native tests
416
417 - job: WindowsStaticVC
418 pool:
419 name: 'onnxruntime-extensions-Windows-CPU'
420
421 steps:
422 - script: |
423 call .\build.bat -DOCOS_ENABLE_CTEST=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
424 cd out/Windows
425 ctest -C RelWithDebInfo --output-on-failure
426 displayName: build and test ort-extensions with VC static runtime.
427
428 - job: Windows_PPApiBuild
429 pool:
430 name: 'onnxruntime-extensions-Windows-CPU'
431
432 steps:
433 - script: |
434 call .\build.bat -DOCOS_ENABLE_C_API=ON
435 cd out\Windows
436 ctest -C RelWithDebInfo --output-on-failure
437 displayName: Build ort-extensions with API enabled and run tests
438
439 ################
440 # Windows Python
441 ################
442 - job: WindowsPython
443 pool:
444 name: 'onnxruntime-extensions-Windows-CPU'
445
446 strategy:
447 matrix:
448 py312-1192:
449 python.version: '3.12'
450 torch.version: 'torch torchvision torchaudio'
451 ort.version: '1.19.2'
452 py312-1181:
453 python.version: '3.12'
454 torch.version: 'torch torchvision torchaudio'
455 ort.version: '1.18.1'
456 py311-1171:
457 python.version: '3.11'
458 torch.version: 'torch torchvision torchaudio'
459 ort.version: '1.17.1'
460 py310-1163:
461 python.version: '3.10'
462 torch.version: 'torch torchvision torchaudio'
463 ort.version: '1.16.3'
464 py39-1151:
465 python.version: '3.9'
466 torch.version: 'torch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 --index-url https://download.pytorch.org/whl/cpu'
467 ort.version: '1.15.1'
468
469 steps:
470 - powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts"
471 displayName: Add conda to PATH
472
473 - script: conda create --yes --quiet --name pyenv -c conda-forge python=$(python.version) numpy
474 displayName: Create Anaconda environment
475
476 - script: |
477 call activate pyenv
478 python -m pip install --upgrade pip
479 python -m pip install onnxruntime==$(ort.version)
480 python -m pip install -r requirements-dev.txt
481 displayName: Install requirements{-dev}.txt and cmake python modules
482 condition: ne(variables['python.version'], '3.12')
483
484 - script: |
485 call activate pyenv
486 set CMAKE_ARGS=-DOCOS_ONNXRUNTIME_VERSION=$(ort.version)
487 python -m pip install .
488 displayName: Build the wheel
489
490 - script: |
491 call activate pyenv
492 python -m pip install $(torch.version)
493 displayName: Install pytorch
494 condition: ne(variables['python.version'], '3.12')
495
496 - script: |
497 call activate pyenv
498 pytest test
499 displayName: Run python test
500 condition: ne(variables['python.version'], '3.12')
501
502 #################
503 # Windows PyDebug
504 #################
505 - job: WinPyDbgBuild
506 pool:
507 name: 'onnxruntime-extensions-Windows-CPU'
508
509 steps:
510 - task: UsePythonVersion@0
511 inputs:
512 versionSpec: '3.x'
513 disableDownloadFromRegistry: true
514 addToPath: true
515 architecture: 'x64'
516 displayName: Use ADO python task
517
518 - script: |
519 python -m pip install --upgrade setuptools pip
520 python -m pip install "numpy < 2.0.0"
521 set OCOS_NO_OPENCV=1
522 set OCOS_SCB_DEBUG=1
523 python -m pip install -v -e .
524 displayName: Build onnxruntime-extensions in editable mode.
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: 'GitHub - Release'
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: 'GitHub - Release'
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 ./tools/build.py \
836 --config RelWithDebInfo \
837 --android \
838 --android_abi x86_64 \
839 --enable_cxx_tests \
840 --update --build --parallel
841 displayName: Build onnxruntime-extensions for Android
842
843- stage: IosBuilds
844 dependsOn: []
845 jobs:
846
847 #############
848 # iOS
849 #############
850 - job: IosPackage
851 pool:
852 vmImage: 'macOS-13'
853 timeoutInMinutes: 120
854 steps:
855 - template: templates/use-xcode-version.yml
856
857 - task: UsePythonVersion@0
858 inputs:
859 versionSpec: '3.12'
860 disableDownloadFromRegistry: true
861 addToPath: true
862 architecture: 'x64'
863 displayName: "Use Python 3.12"
864
865 - script: |
866 python -m pip install cmake
867 displayName: "Install CMake"
868
869 - template: templates/set-package-version-variable-step.yml
870 parameters:
871 PackageVersionVariableName: ORT_EXTENSIONS_POD_VERSION
872
873 - script: |
874 python ./tools/ios/build_xcframework.py \
875 --output_dir $(Build.BinariesDirectory)/xcframework_out \
876 --platform_arch iphonesimulator x86_64 \
877 --config RelWithDebInfo \
878 --ios_deployment_target 13.0 \
879 -- \
880 --enable_cxx_tests
881 displayName: "Build xcframework for iphonesimulator x86_64"
882
883 - script: |
884 python ./tools/ios/assemble_pod_package.py \
885 --staging-dir $(Build.BinariesDirectory)/pod_staging \
886 --xcframework-output-dir $(Build.BinariesDirectory)/xcframework_out \
887 --pod-version ${ORT_EXTENSIONS_POD_VERSION}
888 displayName: "Assemble pod"
889
890 # Note: In this CI, we only specify to build for iphonesimulator x86_64 arch in build_framework.py command however
891 # this test app's podfile by default is setup for all platforms, and due to that we have to explicitly exclude the
892 # macos target below when installing the pod for the test app.
893 - script: |
894 ORT_EXTENSIONS_LOCAL_POD_PATH=$(Build.BinariesDirectory)/pod_staging \
895 EXCLUDE_MACOS_TARGET=true \
896 pod install
897 displayName: "Install pods for OrtExtensionsUsage"
898 workingDirectory: $(Build.SourcesDirectory)/test/ios/OrtExtensionsUsage
899
900 - script: |
901 set -e
902
903 SIMULATOR_DEVICE_INFO=$(python ./tools/ios/get_simulator_device_info.py)
904
905 echo "Simulator device info:"
906 echo "${SIMULATOR_DEVICE_INFO}"
907
908 SIMULATOR_DEVICE_ID=$(jq --raw-output '.device_udid' <<< "${SIMULATOR_DEVICE_INFO}")
909
910 # Do not output ##vso[] commands with `set -x` or they may be parsed again and include a trailing quote.
911 set +x
912 echo "##vso[task.setvariable variable=ORT_EXTENSIONS_SIMULATOR_DEVICE_ID]${SIMULATOR_DEVICE_ID}"
913 displayName: "Get simulator device info"
914
915 - script: |
916 xcrun simctl bootstatus ${ORT_EXTENSIONS_SIMULATOR_DEVICE_ID} -b
917 displayName: "Wait for simulator device to boot"
918
919 - script: |
920 xcrun xcodebuild \
921 -sdk iphonesimulator \
922 -configuration Debug \
923 -parallel-testing-enabled NO \
924 -workspace $(Build.SourcesDirectory)/test/ios/OrtExtensionsUsage/OrtExtensionsUsage.xcworkspace \
925 -scheme OrtExtensionsUsage \
926 -destination "platform=iOS Simulator,id=${ORT_EXTENSIONS_SIMULATOR_DEVICE_ID}" \
927 test CODE_SIGNING_ALLOWED=NO
928 displayName: "Build and test OrtExtensionsUsage"
929