microsoft/onnxruntime-extensions

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
debug_i

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