microsoft/onnxruntime-extensions

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
edgchen1/fix_ci

Branches

Tags

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

Clone

HTTPS

Download ZIP

.pipelines/ci.yml

469lines · modecode

1# IMPORTANT: READ ME BEFORE MAKING ANY CHANGES
2#
3# Supported matrix should follow these conventions strictly and
4# for any exceptions to the rules, please document them in comments.
5#
6# * When adding new configurations to the matrix, update all platforms simultaneously.
7# * Onnxruntime version should be one release ahead of torch, torchvision, and torchaudio.
8#
9# The rationale is that the onnxruntime release process would have verified the
10# last available version of its dependencies (including the three listed above)
11# and so it's likely to be _better_ supported relative to any older versions.
12
13stages:
14
15#######
16# Linux
17#######
18- stage: Linux
19 dependsOn: []
20 jobs:
21 - job: Linux
22 pool:
23 vmImage: 'ubuntu-latest'
24
25 strategy:
26 matrix:
27 py310-1131:
28 python.version: '3.10'
29 torch.version: 'torch torchvision torchaudio'
30 ort.version: '1.13.1'
31 py39-1121:
32 python.version: '3.9'
33 torch.version: 'torch==1.12.1+cpu torchvision==0.13.1+cpu torchaudio==0.12.1+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html'
34 ort.version: '1.12.1'
35 py38-1110:
36 python.version: '3.8'
37 torch.version: 'torch==1.11.0+cpu torchvision==0.12.0+cpu torchaudio==0.11.0+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html'
38 ort.version: '1.11.0'
39 py37-1100:
40 python.version: '3.7'
41 torch.version: 'torch==1.10.0+cpu torchvision==0.11.1+cpu torchaudio==0.10.0+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html'
42 ort.version: '1.10.0'
43
44 steps:
45 - task: DownloadGitHubRelease@0
46 inputs:
47 connection: 'microsoft'
48 userRepository: 'microsoft/onnxruntime'
49 defaultVersionType: 'specificTag'
50 version: 'v$(ort.version)'
51 itemPattern: '*-linux-x64-$(ort.version)*'
52 downloadPath: '$(Build.SourcesDirectory)'
53 displayName: Download the ONNXRuntime prebuilt package.
54
55 - task: ExtractFiles@1
56 inputs:
57 archiveFilePatterns: '**/*.tgz'
58 destinationFolder: '$(Build.SourcesDirectory)'
59 cleanDestinationFolder: false
60 overwriteExistingFiles: true
61 displayName: Unpack ONNXRuntime package.
62
63 - script: |
64 CPU_NUMBER=2 sh ./build.sh -DOCOS_ENABLE_CTEST=ON -DONNXRUNTIME_PKG_DIR=$(Build.SourcesDirectory)/onnxruntime-linux-x64-$(ort.version)
65 displayName: build the customop library with onnxruntime
66
67 - script: |
68 cd out/Linux/RelWithDebInfo
69 ctest -C RelWithDebInfo --output-on-failure
70 displayName: Run C++ native tests
71
72 - task: UsePythonVersion@0
73 inputs:
74 versionSpec: '$(python.version)'
75 addToPath: true
76
77 - script: |
78 set -e -x
79 python -m pip install --upgrade pip setuptools
80 python -m pip install onnxruntime==$(ort.version) $(torch.version) -r requirements-dev.txt
81 displayName: Install Python dependencies
82
83 - script: |
84 CPU_NUMBER=2 python -m pip install -e .
85 displayName: Build the library and tests
86
87 - script: python -m pytest test --verbose
88 displayName: Run python test
89
90###########
91# macOS C++
92###########
93- stage: MacOSX
94 dependsOn: []
95 jobs:
96 - job: MacOSX
97 pool:
98 vmImage: 'macOS-12'
99
100 strategy:
101 matrix:
102 ort-1131:
103 ort.version: '1.13.1'
104 ort.dirname: 'onnxruntime-osx-x86_64-$(ort.version)'
105 ort-1121:
106 ort.version: '1.12.1'
107 ort.dirname: 'onnxruntime-osx-x86_64-$(ort.version)'
108 ort-1110:
109 ort.version: '1.11.0'
110 ort.dirname: 'onnxruntime-osx-x86_64-$(ort.version)'
111 ort-1100:
112 ort.version: '1.10.0'
113 ort.dirname: 'onnxruntime-osx-x86_64-$(ort.version)'
114
115 steps:
116 # needed for onnxruntime
117 - script: brew install libomp
118 displayName: 'Install omp'
119
120 - task: DownloadGitHubRelease@0
121 inputs:
122 connection: 'microsoft'
123 userRepository: 'microsoft/onnxruntime'
124 defaultVersionType: 'specificTag'
125 version: 'v$(ort.version)'
126 itemPattern: '$(ort.dirname)*'
127 downloadPath: '$(Build.SourcesDirectory)'
128 displayName: Download the ONNXRuntime prebuilt package.
129
130 - task: ExtractFiles@1
131 inputs:
132 archiveFilePatterns: '**/*.tgz'
133 destinationFolder: '$(Build.SourcesDirectory)'
134 cleanDestinationFolder: false
135 overwriteExistingFiles: true
136 displayName: Unpack ONNXRuntime package.
137
138 - script: |
139 sh ./build.sh -DOCOS_ENABLE_CTEST=ON -DONNXRUNTIME_PKG_DIR=$(Build.SourcesDirectory)/$(ort.dirname)
140 displayName: build the customop library with onnxruntime
141
142 - script: |
143 cd out/Darwin/RelWithDebInfo
144 ctest -C RelWithDebInfo --output-on-failure
145 displayName: Run C++ native tests
146
147#############
148# macOS Python
149#############
150- stage: MacOSPython
151 dependsOn: []
152 jobs:
153 - job: MacOSPython
154 pool:
155 vmImage: 'macOS-12'
156
157 strategy:
158 matrix:
159 py310-1131:
160 python.version: '3.10'
161 torch.version: 'torch torchvision torchaudio'
162 ort.version: '1.13.1'
163 py310-1121:
164 python.version: '3.10'
165 torch.version: 'torch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 -f https://download.pytorch.org/whl/torch_stable.html'
166 ort.version: '1.12.1'
167 py39-1110:
168 python.version: '3.9'
169 torch.version: 'torch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 -f https://download.pytorch.org/whl/torch_stable.html'
170 ort.version: '1.11.0'
171 py38-1100:
172 python.version: '3.8'
173 torch.version: 'torch==1.10.0 torchvision==0.11.1 torchaudio==0.10.0 -f https://download.pytorch.org/whl/torch_stable.html'
174 ort.version: '1.10.0'
175
176 steps:
177 # needed for onnxruntime
178 - script: brew install libomp
179 displayName: 'Install omp'
180
181 - task: UsePythonVersion@0
182 inputs:
183 versionSpec: '$(python.version)'
184 addToPath: true
185
186 - script: |
187 set -e -x
188 python -m pip install --upgrade pip setuptools wheel
189 python -m pip install onnxruntime==$(ort.version) $(torch.version) -r requirements-dev.txt
190 displayName: Install Python dependencies
191
192 - script: |
193 python -c "import onnxruntime;print(onnxruntime.__version__)"
194 displayName: Check installation
195
196 - script: |
197 python -m pip install -e .
198 displayName: Build and install the wheel
199
200 - script: cd test && python -m pytest . --verbose
201 displayName: Run python test
202
203#########
204# Windows C++
205#########
206- stage: WindowsC
207 dependsOn: []
208 jobs:
209 - job: WindowsC
210 pool:
211 vmImage: 'windows-2019'
212
213 strategy:
214 matrix:
215 ort-1131:
216 ort.version: '1.13.1'
217 ort-1121:
218 ort.version: '1.12.1'
219 ort-1110:
220 ort.version: '1.11.0'
221 ort-1100:
222 ort.version: '1.10.0'
223
224 steps:
225 - task: DownloadGitHubRelease@0
226 inputs:
227 connection: 'microsoft'
228 userRepository: 'microsoft/onnxruntime'
229 defaultVersionType: 'specificTag'
230 version: 'v$(ort.version)'
231 itemPattern: '*-win-x64-$(ort.version)*'
232 downloadPath: '$(Build.SourcesDirectory)'
233 displayName: Download the ONNXRuntime prebuilt package.
234
235 - task: ExtractFiles@1
236 inputs:
237 archiveFilePatterns: '**/*.zip'
238 destinationFolder: '$(Build.SourcesDirectory)'
239 cleanDestinationFolder: false
240 overwriteExistingFiles: true
241 displayName: Unpack ONNXRuntime package.
242
243 - script: |
244 @echo off
245 set vswherepath="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
246 for /f "usebackq delims=" %%i in (`%vswherepath% -latest -property installationPath`) do (
247 if exist "%%i\Common7\Tools\vsdevcmd.bat" (
248 set vsdevcmd="%%i\Common7\Tools\vsdevcmd.bat"
249 )
250 )
251
252 @echo %vsdevcmd% will be used as the VC compiler
253 @echo ##vso[task.setvariable variable=vsdevcmd]%vsdevcmd%
254 displayName: 'locate vsdevcmd via vswhere'
255
256 - script: |
257 call $(vsdevcmd)
258 call .\build.bat -DOCOS_ENABLE_CTEST=ON -DONNXRUNTIME_PKG_DIR=.\onnxruntime-win-x64-$(ort.version)
259 displayName: build the customop library with onnxruntime
260
261 - script: |
262 cd out/Windows
263 ctest -C RelWithDebInfo --output-on-failure
264 displayName: Run C++ native tests
265
266################
267# Windows Python
268################
269- stage: WindowsPython
270 dependsOn: []
271 jobs:
272 - job: WindowsPython
273 pool:
274 vmImage: 'windows-latest'
275
276 strategy:
277 matrix:
278 py310-1131:
279 python.version: '3.10'
280 torch.version: 'torch torchvision torchaudio'
281 ort.version: '1.13.1'
282 py39-1121:
283 python.version: '3.9'
284 torch.version: 'torch==1.12.1+cpu torchvision==0.13.1+cpu torchaudio==0.12.1+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html'
285 ort.version: '1.12.1'
286 py38-1110:
287 python.version: '3.8'
288 torch.version: 'torch==1.11.0+cpu torchvision==0.12.0+cpu torchaudio==0.11.0+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html'
289 ort.version: '1.11.0'
290 py37-1100:
291 python.version: '3.7'
292 torch.version: 'torch==1.10.0+cpu torchvision==0.11.1+cpu torchaudio==0.10.0+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html'
293 ort.version: '1.10.0'
294
295 steps:
296 - powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts"
297 displayName: Add conda to PATH
298
299 - script: conda create --yes --quiet --name pyenv -c conda-forge python=$(python.version) numpy
300 displayName: Create Anaconda environment
301
302 - script: |
303 call activate pyenv
304 python -m pip install --upgrade pip
305 python -m pip install onnxruntime==$(ort.version) -r requirements-dev.txt
306 displayName: Install Python dependencies
307
308 - script: |
309 call activate pyenv
310 python -m pip install .
311 displayName: Build the wheel
312
313 - script: |
314 call activate pyenv
315 python -m pip install $(torch.version)
316 displayName: Install pytorch
317
318 - script: |
319 call activate pyenv
320 pytest test
321 displayName: Run python test
322
323#############
324# WebAssembly
325#############
326- stage: WebAssembly
327 dependsOn: []
328 jobs:
329 - job: WebAssembly
330 pool:
331 vmImage: 'ubuntu-latest'
332
333 steps:
334 - script: |
335 cd $(Build.BinariesDirectory)
336 git clone https://github.com/emscripten-core/emsdk
337 emsdk/emsdk install latest
338 emsdk/emsdk activate latest
339 displayName: Setup emscripten pipeline
340
341 - script: |
342 bash ./build.sh \
343 -DCMAKE_TOOLCHAIN_FILE=$(Build.BinariesDirectory)/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \
344 -DOCOS_ENABLE_SPM_TOKENIZER=ON \
345 -DOCOS_BUILD_PYTHON=OFF \
346 -DOCOS_ENABLE_CV2=OFF \
347 -DOCOS_ENABLE_VISION=OFF
348 displayName: build the customop library with onnxruntime
349 # TODO add unittest for webassembly
350
351#############
352# Android
353#############
354- stage: AndroidPackage
355 dependsOn: []
356 jobs:
357 - job: AndroidPackage
358 pool:
359 vmImage: 'macOS-12'
360 timeoutInMinutes: 120
361 steps:
362 - task: UsePythonVersion@0
363 inputs:
364 versionSpec: "3.9"
365 addToPath: true
366 architecture: "x64"
367 displayName: "Use Python 3.9"
368
369 - task: JavaToolInstaller@0
370 displayName: Use jdk 11
371 inputs:
372 versionSpec: '11'
373 jdkArchitectureOption: 'x64'
374 jdkSourceOption: 'PreInstalled'
375
376 - script: brew install coreutils ninja
377 displayName: Install coreutils and ninja
378
379 - template: templates/run-with-android-emulator-steps.yml
380 parameters:
381 steps:
382
383 - bash: |
384 set -e -x
385
386 _BUILD_CFG="x86_64 $(Build.BinariesDirectory)/android_aar" ./build.android
387
388 VERSION=$(cat ./version.txt)
389 AAR_PATH="$(Build.BinariesDirectory)/android_aar/aar_out/com/microsoft/onnxruntime/onnxruntime-extensions-android/${VERSION}/onnxruntime-extensions-android-${VERSION}.aar"
390
391 echo "##vso[task.setvariable variable=ORT_EXTENSIONS_AAR_PATH]${AAR_PATH}"
392 displayName: Build onnxruntime-extensions AAR package
393
394 - bash: |
395 set -e -x
396
397 cp -r $(Build.SourcesDirectory)/java/src/test/android $(Build.BinariesDirectory)/android_test
398
399 cd $(Build.BinariesDirectory)/android_test
400
401 ./gradlew connectedDebugAndroidTest --no-daemon -DortExtensionsAarLocalPath="${ORT_EXTENSIONS_AAR_PATH}"
402 displayName: Build and run onnxruntime-extensions Android test with Android Emulator
403
404#############
405# iOS
406#############
407- stage: IosPackage
408 dependsOn: []
409 jobs:
410 - job: IosPackage
411 pool:
412 vmImage: 'macOS-12'
413 timeoutInMinutes: 120
414 steps:
415 - task: UsePythonVersion@0
416 inputs:
417 versionSpec: '3.9'
418 addToPath: true
419 architecture: 'x64'
420 displayName: "Use Python 3.9"
421
422 # iOS xcframework build doesn't work with CMake 3.25.1, pin to 3.25.0
423 - script: |
424 python -m pip install cmake==3.25.0
425 displayName: "Install CMake 3.25.0"
426
427 - template: templates/set-package-version-variable-step.yml
428 parameters:
429 PackageVersionVariableName: ORT_EXTENSIONS_POD_VERSION
430
431 - script: |
432 python ./tools/ios/build_xcframework.py \
433 --output-dir $(Build.BinariesDirectory)/xcframework_out \
434 --platform-arch iphonesimulator x86_64 \
435 --config Release
436 displayName: Build xcframework for iphonesimulator x86_64
437
438 - script: |
439 python ./tools/ios/assemble_pod_package.py \
440 --staging-dir $(Build.BinariesDirectory)/pod_staging \
441 --xcframework-output-dir $(Build.BinariesDirectory)/xcframework_out \
442 --pod-version ${ORT_EXTENSIONS_POD_VERSION}
443 displayName: Assemble pod
444
445 - script: |
446 ORT_EXTENSIONS_LOCAL_POD_PATH=$(Build.BinariesDirectory)/pod_staging \
447 pod install
448 displayName: Install pods for OrtExtensionsUsage
449 workingDirectory: $(Build.SourcesDirectory)/test/ios/OrtExtensionsUsage
450
451 - template: templates/run-with-ios-simulator-steps.yml
452 parameters:
453 steps:
454 - template: templates/xcode-build-and-test-step.yml
455 parameters:
456 xcWorkspacePath: '$(Build.SourcesDirectory)/test/ios/OrtExtensionsUsage/OrtExtensionsUsage.xcworkspace'
457 scheme: 'OrtExtensionsUsage'
458 args: '-verbose'
459
460 - script: |
461 find ~/Library/Developer/Xcode/DerivedData -name "Test-OrtExtensionsUsage-*.xcresult" -exec cp -r {} $(Build.ArtifactStagingDirectory) \;
462 displayName: Copy xcresult files
463 condition: succeededOrFailed()
464
465 - task: PublishBuildArtifacts@1
466 inputs:
467 PathtoPublish: '$(Build.ArtifactStagingDirectory)'
468 ArtifactName: 'xcresult'
469 condition: succeededOrFailed()
470