microsoft/onnxruntime-extensions

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
f6940f355009d9e29b08f3185191fa0ab9a8187f

Branches

Tags

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

Clone

HTTPS

Download ZIP

.pipelines/ci.yml

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