microsoft/onnxruntime-extensions

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
asonawane/qwen

Branches

Tags

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

Clone

HTTPS

Download ZIP

.pipelines/ci.yml

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