microsoft/onnxruntime-extensions

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.11.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

.pipelines/ci.yml

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