microsoft/onnxruntime-extensions

Public

mirrored fromhttps://github.com/microsoft/onnxruntime-extensionsAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
9edf572de9b3e5eb261ca06060e6b2e4ab4012df

Branches

Tags

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

Clone

HTTPS

Download ZIP

.pipelines/ci.yml

924lines · 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-1201:
449 python.version: '3.12'
450 torch.version: 'torch torchvision torchaudio'
451 ort.version: '1.20.1'
452 py312-1192:
453 python.version: '3.12'
454 torch.version: 'torch torchvision torchaudio'
455 ort.version: '1.19.2'
456 py311-1181:
457 python.version: '3.11'
458 torch.version: 'torch torchvision torchaudio'
459 ort.version: '1.18.1'
460 py310-1171:
461 python.version: '3.10'
462 torch.version: 'torch torchvision torchaudio'
463 ort.version: '1.17.1'
464 py310-1163:
465 python.version: '3.10'
466 torch.version: 'torch torchvision torchaudio'
467 ort.version: '1.16.3'
468
469 steps:
470 - task: UsePythonVersion@0
471 inputs:
472 versionSpec: $(python.version)
473 disableDownloadFromRegistry: true
474 addToPath: true
475 architecture: 'x64'
476 displayName: Use ADO python task
477
478 - script: |
479 python -m pip install --upgrade pip
480 python -m pip install onnxruntime==$(ort.version)
481 python -m pip install -r requirements-dev.txt
482 displayName: Install requirements{-dev}.txt and cmake python modules
483
484 - script: |
485 set CMAKE_ARGS=-DOCOS_ONNXRUNTIME_VERSION=$(ort.version)
486 python -m pip install -v .
487 displayName: Build the wheel
488
489 - script: |
490 python -m pip install $(torch.version)
491 displayName: Install pytorch
492
493 - script: |
494 cd test && python -m pytest .
495 displayName: Run python test
496
497 #################
498 # Windows PyDebug
499 #################
500 - job: WinPyDbgBuild
501 pool:
502 name: 'onnxruntime-extensions-Windows-CPU'
503
504 steps:
505 - task: UsePythonVersion@0
506 inputs:
507 versionSpec: '3.12'
508 disableDownloadFromRegistry: true
509 addToPath: true
510 architecture: 'x64'
511 displayName: Use ADO python task
512
513 - script: |
514 python -m pip install --upgrade setuptools pip
515 python -m pip install "numpy < 2.0.0"
516 python -m pip install -v -e .
517 displayName: Build onnxruntime-extensions in editable mode.
518 env:
519 OCOS_NO_OPENCV: 1
520 OCOS_SCB_DEBUG: 1
521
522 - script: |
523 python -m pip install -r requirements-dev.txt
524 python -m pip install torch torchvision torchaudio
525 displayName: Install dependencies for pytest
526
527 - script: |
528 cd test
529 python -m pytest --ignore=test_cv2.py --ignore=test_tools_add_pre_post_processing_to_model.py . --verbose
530 displayName: Run python test
531
532- stage: WindowsCUDABuilds
533 dependsOn: []
534 jobs:
535 - job: WindowsCUDABoth
536 pool:
537 name: 'onnxruntime-extensions-Win2022-GPU-A10'
538 variables:
539 ORT_VERSION: '1.17.1'
540 timeoutInMinutes: 120
541 steps:
542 - template: templates/set_winenv.yml
543 parameters:
544 EnvSetupScript: 'set_env_cuda.bat'
545 DownloadCUDA: true
546
547 - script: |
548 nvidia-smi
549 nvcc --version
550 where nvcc
551 displayName: check cuda version
552
553 - task: DownloadGitHubRelease@0
554 inputs:
555 connection: 'GitHub - Release'
556 userRepository: 'microsoft/onnxruntime'
557 defaultVersionType: 'specificTag'
558 version: 'v$(ORT_VERSION)'
559 itemPattern: '*-win-x64-gpu-$(ORT_VERSION)*'
560 downloadPath: '$(Build.SourcesDirectory)'
561 displayName: Download the ONNXRuntime prebuilt package.
562
563 - task: ExtractFiles@1
564 inputs:
565 archiveFilePatterns: '**/*.zip'
566 destinationFolder: '$(Build.SourcesDirectory)'
567 cleanDestinationFolder: false
568 overwriteExistingFiles: true
569 displayName: Unpack ONNXRuntime package.
570
571 - script: |
572 set CUDA_PATH=$(Agent.TempDirectory)\v11.8
573 call .\build.bat -T cuda="%CUDA_PATH%" -DOCOS_ENABLE_CTEST=ON^
574 -DCMAKE_CUDA_FLAGS_INIT=-allow-unsupported-compiler^
575 -DOCOS_USE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=70;86^
576 -DOCOS_ONNXRUNTIME_VERSION="$(ORT_VERSION)" -DONNXRUNTIME_PKG_DIR=.\onnxruntime-win-x64-gpu-$(ORT_VERSION)
577 displayName: build the customop library with onnxruntime
578
579 - script: |
580 cd out/Windows
581 ctest -C RelWithDebInfo --output-on-failure
582 displayName: Run C++ native tests
583
584 - task: UsePythonVersion@0
585 inputs:
586 versionSpec: '3.12'
587 disableDownloadFromRegistry: true
588 addToPath: true
589 architecture: 'x64'
590 displayName: Use ADO python task
591
592 - script: |
593 set CUDA_PATH=$(Agent.TempDirectory)\v11.8
594 python -m pip install --upgrade setuptools pip
595 python -m pip install "numpy < 2.0.0" coloredlogs flatbuffers packaging protobuf sympy
596 python -m pip install onnxruntime-gpu==$(ORT_VERSION)
597 python -m pip install -v --config-settings "ortx-user-option=use-cuda,cuda_archs=70;86" .
598 displayName: Build and install onnxruntime-extensions CUDA package.
599
600 - script: |
601 python -m pip install -r requirements-dev.txt
602 python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
603 displayName: Install dependencies for Python unit tests
604
605 - script: |
606 cd test
607 python -m pytest . --verbose
608 cd cuda
609 python -m pytest . --verbose
610 displayName: Run python test for CPU and CUDA kernels
611
612- stage: LinuxCUDABuilds
613 dependsOn: []
614 jobs:
615 - job: LinuxGPU
616 pool:
617 name: 'onnxruntime-extensions-Linux-GPU-A10'
618 timeoutInMinutes: 120
619 variables:
620 ORT_VERSION: '1.17.1'
621 TORCH_VERSION: 'torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118'
622 steps:
623 - task: mspremier.PostBuildCleanup.PostBuildCleanup-task.PostBuildCleanup@3
624 displayName: 'Clean Agent Directories'
625 condition: always()
626
627 - script: |
628 nvidia-smi
629 displayName: check cuda version
630
631 - checkout: self
632 clean: true
633 submodules: none
634
635 - task: UsePythonVersion@0
636 inputs:
637 versionSpec: '3.12'
638 addToPath: true
639
640 - task: DownloadGitHubRelease@0
641 inputs:
642 connection: 'GitHub - Release'
643 userRepository: 'microsoft/onnxruntime'
644 defaultVersionType: 'specificTag'
645 version: 'v$(ORT_VERSION)'
646 itemPattern: '*-linux-x64-gpu-$(ORT_VERSION)*'
647 downloadPath: '$(Build.SourcesDirectory)'
648 displayName: Download the ONNXRuntime prebuilt package.
649
650 - task: ExtractFiles@1
651 inputs:
652 archiveFilePatterns: '**/*.tgz'
653 destinationFolder: '$(Build.SourcesDirectory)'
654 cleanDestinationFolder: false
655 overwriteExistingFiles: true
656 displayName: Unpack ONNXRuntime package.
657
658 - template: ../tools/ci_build/github/azure-pipeline/templates/get-docker-image-steps.yml
659 parameters:
660 Dockerfile: tools/ci_build/github/linux/docker/Dockerfile.ubuntu_cuda11_8_tensorrt8_6
661 Context: tools/ci_build/github/linux/docker
662 DockerBuildArgs: "--build-arg BUILD_UID=$( id -u )"
663 Repository: onnxruntime-extensionscuda11build
664 UpdateDepsTxt: false
665
666 - task: CmdLine@2
667 inputs:
668 script: |
669 docker run --gpus all --rm \
670 --volume $(Build.SourcesDirectory):/onnxruntime-extensions \
671 --volume $(Build.SourcesDirectory)/onnxruntime-linux-x64-gpu-$(ORT_VERSION):/onnxruntime \
672 -e CUDA_PATH=/usr/local/cuda-11.8 \
673 onnxruntime-extensionscuda11build \
674 /bin/bash -c "
675 set -ex; \
676 pushd /onnxruntime-extensions; \
677 sh ./build.sh -DOCOS_ENABLE_CTEST=ON -DOCOS_USE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=86 -DOCOS_ONNXRUNTIME_VERSION="$(ORT_VERSION)" -DONNXRUNTIME_PKG_DIR=/onnxruntime; \
678 popd; \
679 "
680 workingDirectory: $(Build.SourcesDirectory)
681 displayName: build the customop library with onnxruntime
682
683 - task: CmdLine@2
684 inputs:
685 script: |
686 docker run --gpus all --rm \
687 --volume $(Build.SourcesDirectory):/onnxruntime-extensions \
688 --volume $(Build.SourcesDirectory)/onnxruntime-linux-x64-gpu-$(ORT_VERSION):/onnxruntime \
689 -e CUDA_PATH=/usr/local/cuda-11.8 \
690 onnxruntime-extensionscuda11build \
691 /bin/bash -c "
692 set -ex; \
693 pushd /onnxruntime-extensions; \
694 cd out/Linux/RelWithDebInfo; \
695 ctest -C RelWithDebInfo --output-on-failure; \
696 popd; \
697 "
698 workingDirectory: $(Build.SourcesDirectory)
699 displayName: Run C++ native tests
700
701 - task: CmdLine@2
702 inputs:
703 script: |
704 docker run --gpus all --rm \
705 --volume $(Build.SourcesDirectory):/onnxruntime-extensions \
706 --volume $(Build.SourcesDirectory)/onnxruntime-linux-x64-gpu-$(ORT_VERSION):/onnxruntime \
707 -e CUDA_PATH=/usr/local/cuda-11.8 \
708 onnxruntime-extensionscuda11build \
709 /bin/bash -c "
710 set -ex; \
711 pushd /onnxruntime-extensions; \
712 python3 -m pip install --upgrade pip; \
713 python3 -m pip install --upgrade setuptools; \
714 python3 -m pip install onnxruntime-gpu==$(ORT_VERSION); \
715 python3 -m pip install -v --config-settings 'ortx-user-option=use-cuda,cuda_archs=70;86' . ; \
716 python3 -m pip install $(TORCH_VERSION) ; \
717 python3 -m pip install -r requirements-dev.txt; \
718 cd test && python -m pytest . --verbose; \
719 cd cuda && python -m pytest . --verbose; \
720 popd; \
721 "
722 workingDirectory: $(Build.SourcesDirectory)
723 displayName: Build the library and Python unit tests
724
725- stage: WebAssemblyBuilds
726 dependsOn: []
727 jobs:
728
729 #############
730 # WebAssembly
731 #############
732 - job: WebAssembly
733 pool:
734 vmImage: 'ubuntu-latest'
735
736 steps:
737 - script: |
738 cd $(Build.BinariesDirectory)
739 git clone https://github.com/emscripten-core/emsdk --depth 1 --branch 4.0.3
740 emsdk/emsdk install latest
741 emsdk/emsdk activate latest
742 displayName: Setup emscripten pipeline
743
744 - script: |
745 bash ./build.sh \
746 -DCMAKE_TOOLCHAIN_FILE=$(Build.BinariesDirectory)/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \
747 -DOCOS_ENABLE_STATIC_LIB=OFF \
748 -DOCOS_ENABLE_SPM_TOKENIZER=ON \
749 -DOCOS_BUILD_PYTHON=OFF \
750 -DOCOS_ENABLE_VISION=OFF \
751 -DOCOS_ENABLE_CTEST=OFF \
752 -DOCOS_ENABLE_C_API=ON
753 displayName: build ort-extensions as an executable
754
755 - script: |
756 bash ./build.sh \
757 -DCMAKE_TOOLCHAIN_FILE=$(Build.BinariesDirectory)/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \
758 -DOCOS_ENABLE_STATIC_LIB=ON \
759 -DOCOS_ENABLE_SPM_TOKENIZER=ON \
760 -DOCOS_BUILD_PYTHON=OFF \
761 -DOCOS_ENABLE_VISION=OFF \
762 -DOCOS_ENABLE_CTEST=OFF \
763 -DOCOS_ENABLE_C_API=ON
764 displayName: build ort-extensions as a static library
765
766- stage: AndroidBuilds
767 dependsOn: []
768 jobs:
769
770 #############
771 # Android
772 #############
773 - job: AndroidPackage_BuildOnly
774 pool:
775 vmImage: 'macOS-13'
776 timeoutInMinutes: 120
777 steps:
778 - task: UsePythonVersion@0
779 inputs:
780 versionSpec: "3.12"
781 addToPath: true
782 architecture: "x64"
783 displayName: "Use Python 3.12"
784
785 - task: JavaToolInstaller@0
786 displayName: Use jdk 17
787 inputs:
788 versionSpec: '17'
789 jdkArchitectureOption: 'x64'
790 jdkSourceOption: 'PreInstalled'
791
792 - script: brew install coreutils ninja
793 displayName: Install coreutils and ninja
794
795 - bash: |
796 set -e -x
797
798 _BUILD_CFG="x86_64 $(Build.BinariesDirectory)/android_aar" ./build.android
799
800 VERSION=$(cat ./version.txt)
801 AAR_PATH="$(Build.BinariesDirectory)/android_aar/aar_out/com/microsoft/onnxruntime/onnxruntime-extensions-android/${VERSION}/onnxruntime-extensions-android-${VERSION}.aar"
802
803 # Do not output ##vso[] commands with `set -x` or they may be parsed again and include a trailing quote.
804 set +x
805 echo "##vso[task.setvariable variable=ORT_EXTENSIONS_AAR_PATH]${AAR_PATH}"
806 displayName: Build onnxruntime-extensions AAR package
807
808 - job: AndroidCpp_BuildOnly
809 pool:
810 vmImage: 'macOS-13'
811 timeoutInMinutes: 45
812 steps:
813 - task: UsePythonVersion@0
814 inputs:
815 versionSpec: "3.12"
816 addToPath: true
817 architecture: "x64"
818 displayName: "Use Python 3.12"
819
820 - task: JavaToolInstaller@0
821 displayName: Use jdk 17
822 inputs:
823 versionSpec: '17'
824 jdkArchitectureOption: 'x64'
825 jdkSourceOption: 'PreInstalled'
826
827 - script: brew install ninja
828 displayName: Install ninja
829
830 - bash: |
831 python ./tools/build.py \
832 --config RelWithDebInfo \
833 --android \
834 --android_abi x86_64 \
835 --enable_cxx_tests \
836 --update --build --parallel
837 displayName: Build onnxruntime-extensions for Android
838
839- stage: IosBuilds
840 dependsOn: []
841 jobs:
842
843 #############
844 # iOS
845 #############
846 - job: IosPackage
847 pool:
848 vmImage: 'macOS-13'
849 timeoutInMinutes: 120
850 steps:
851 - template: templates/use-xcode-version.yml
852
853 - task: UsePythonVersion@0
854 inputs:
855 versionSpec: '3.12'
856 disableDownloadFromRegistry: true
857 addToPath: true
858 architecture: 'x64'
859 displayName: "Use Python 3.12"
860
861 - script: |
862 python -m pip install cmake
863 displayName: "Install CMake"
864
865 - template: templates/set-package-version-variable-step.yml
866 parameters:
867 PackageVersionVariableName: ORT_EXTENSIONS_POD_VERSION
868
869 - script: |
870 python ./tools/ios/build_xcframework.py \
871 --output_dir $(Build.BinariesDirectory)/xcframework_out \
872 --platform_arch iphonesimulator x86_64 \
873 --config RelWithDebInfo \
874 --ios_deployment_target 13.0 \
875 -- \
876 --enable_cxx_tests
877 displayName: "Build xcframework for iphonesimulator x86_64"
878
879 - script: |
880 python ./tools/ios/assemble_pod_package.py \
881 --staging-dir $(Build.BinariesDirectory)/pod_staging \
882 --xcframework-output-dir $(Build.BinariesDirectory)/xcframework_out \
883 --pod-version ${ORT_EXTENSIONS_POD_VERSION}
884 displayName: "Assemble pod"
885
886 # Note: In this CI, we only specify to build for iphonesimulator x86_64 arch in build_framework.py command however
887 # this test app's podfile by default is setup for all platforms, and due to that we have to explicitly exclude the
888 # macos target below when installing the pod for the test app.
889 - script: |
890 ORT_EXTENSIONS_LOCAL_POD_PATH=$(Build.BinariesDirectory)/pod_staging \
891 EXCLUDE_MACOS_TARGET=true \
892 pod install
893 displayName: "Install pods for OrtExtensionsUsage"
894 workingDirectory: $(Build.SourcesDirectory)/test/ios/OrtExtensionsUsage
895
896 - script: |
897 set -e
898
899 SIMULATOR_DEVICE_INFO=$(python ./tools/ios/get_simulator_device_info.py)
900
901 echo "Simulator device info:"
902 echo "${SIMULATOR_DEVICE_INFO}"
903
904 SIMULATOR_DEVICE_ID=$(jq --raw-output '.device_udid' <<< "${SIMULATOR_DEVICE_INFO}")
905
906 # Do not output ##vso[] commands with `set -x` or they may be parsed again and include a trailing quote.
907 set +x
908 echo "##vso[task.setvariable variable=ORT_EXTENSIONS_SIMULATOR_DEVICE_ID]${SIMULATOR_DEVICE_ID}"
909 displayName: "Get simulator device info"
910
911 - script: |
912 xcrun simctl bootstatus ${ORT_EXTENSIONS_SIMULATOR_DEVICE_ID} -b
913 displayName: "Wait for simulator device to boot"
914
915 - script: |
916 xcrun xcodebuild \
917 -sdk iphonesimulator \
918 -configuration Debug \
919 -parallel-testing-enabled NO \
920 -workspace $(Build.SourcesDirectory)/test/ios/OrtExtensionsUsage/OrtExtensionsUsage.xcworkspace \
921 -scheme OrtExtensionsUsage \
922 -destination "platform=iOS Simulator,id=${ORT_EXTENSIONS_SIMULATOR_DEVICE_ID}" \
923 test CODE_SIGNING_ALLOWED=NO
924 displayName: "Build and test OrtExtensionsUsage"
925