onnxruntime/tools/ci_build/github/azure-pipelines/templates/py-linux.yml
Yi Zhang ef281f850a
Add XNNPack build on Linux ARM64 and improve Linux CPU (#22773)
### Description
1. Add XNNPack build on Linux ARM64
2. Build only one python wheel for PR request.

[AB#49763](https://aiinfra.visualstudio.com/6a833879-cd9b-44a4-a9de-adc2d818f13c/_workitems/edit/49763)



### Motivation and Context
Why I add xnnpack build on Linux ARM64  rather than Windows ARM64.
Becuase KleidiAI  doesn't support Windows

```
IF(XNNPACK_TARGET_PROCESSOR STREQUAL "arm64" AND XNNPACK_ENABLE_ARM_I8MM AND NOT CMAKE_C_COMPILER_ID STREQUAL "MSVC")
  IF (XNNPACK_ENABLE_KLEIDIAI)
    MESSAGE(STATUS "Enabling KleidiAI for Arm64")
  ENDIF()
ELSE()
  SET(XNNPACK_ENABLE_KLEIDIAI OFF)
ENDIF()
```

---------
2024-11-09 11:26:19 +08:00

114 lines
3.5 KiB
YAML

parameters:
- name: arch
type: string
- name: machine_pool
type: string
- name: cmake_build_type
type: string
default: 'Release'
values:
- Debug
- Release
- RelWithDebInfo
- MinSizeRel
- name: device
type: string
default: 'CPU'
- name: with_cache
type: boolean
default: false
- name: extra_build_arg
type: string
default: ''
- name: ep
type: string
default: 'cpu'
- name: python_exe_path
type: string
default: ''
jobs:
- job: Linux_py_Wheels_${{ parameters.arch }}_${{parameters.ep}}
timeoutInMinutes: 240
workspace:
clean: all
pool: ${{ parameters.machine_pool }}
variables:
# The build machine pool doesn't have dotnet, so it can't run CG.
- name: skipComponentGovernanceDetection
value: true
- name: ORT_CACHE_DIR
value: $(Agent.TempDirectory)/ort_ccache
- name: TODAY
value: $[format('{0:dd}{0:MM}{0:yyyy}', pipeline.startTime)]
- name: extra_build_args
${{ if ne(parameters.extra_build_arg, '') }}:
value: '-x ${{ parameters.extra_build_arg }}'
${{ if eq(parameters.extra_build_arg, '') }}:
value: ''
- name: python_exe_path
${{ if ne(parameters.python_exe_path, '') }}:
value: '-p ${{ parameters.python_exe_path }}'
${{ if eq(parameters.python_exe_path, '') }}:
value: ''
steps:
- task: mspremier.PostBuildCleanup.PostBuildCleanup-task.PostBuildCleanup@3
displayName: 'Clean Agent Directories'
condition: always()
- checkout: self
clean: true
submodules: none
- template: set-nightly-build-option-variable-step.yml
- template: get-docker-image-steps.yml
parameters:
Dockerfile: tools/ci_build/github/linux/docker/inference/${{ parameters.arch }}/python/cpu/Dockerfile
Context: tools/ci_build/github/linux/docker/inference/${{ parameters.arch }}/python/cpu
DockerBuildArgs: "--build-arg BUILD_UID=$( id -u )"
Repository: onnxruntimecpubuildpython${{ parameters.arch }}
${{ if eq(parameters.arch, 'aarch64') }}:
UpdateDepsTxt: false
- template: linux-build-step-with-cache.yml
parameters:
WithCache: ${{parameters.with_cache}}
Today: $(TODAY)
AdditionalKey: Linux_py_Wheels_${{ parameters.arch }}
CacheDir: $(ORT_CACHE_DIR)
ChangeEveryCommit: true
BuildStep:
- task: Bash@3
displayName: 'Build Python Wheel'
inputs:
targetType: filePath
filePath: tools/ci_build/github/linux/run_python_dockerbuild.sh
arguments: -i onnxruntimecpubuildpython${{ parameters.arch }} -d "${{ parameters.device }}" -c ${{ parameters.cmake_build_type }} $(extra_build_args) $(python_exe_path)
${{ if eq(parameters.with_cache, 'true') }}:
env:
ADDITIONAL_DOCKER_PARAMETER: "--volume $(ORT_CACHE_DIR):/cache -e CCACHE_DIR=/cache -e ORT_BUILD_WITH_CACHE=1"
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: ONNXRuntime python wheel'
inputs:
PathtoPublish: '$(Build.BinariesDirectory)/dist'
ArtifactName: onnxruntime-${{ parameters.ep }}
- task: PublishPipelineArtifact@0
displayName: 'Publish Test Binaries'
inputs:
artifactName: 'drop-linux-cpu-${{ parameters.arch }}-${{ parameters.ep }}'
targetPath: '$(Build.BinariesDirectory)/${{ parameters.cmake_build_type }}'
- template: component-governance-component-detection-steps.yml
parameters :
condition : 'succeeded'