mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-02 03:55:34 +00:00
Move binary size check to separate pipeline (#10254)
Move binary size check(s) to a separate pipeline. In the future, other binary size-related builds can go here. Add publishing of build artifacts for easier analysis. Add optional build with debug info.
This commit is contained in:
parent
3d9d8e20cc
commit
d43ef67d2b
3 changed files with 153 additions and 67 deletions
|
|
@ -0,0 +1,117 @@
|
|||
# steps in this build:
|
||||
# 1a. Android minimal baseline build (arm64-v8a, including no kernels, with exceptions disabled)
|
||||
# 1b. Android minimal baseline build with debug info
|
||||
|
||||
parameters:
|
||||
- name: DoBuildWithDebugInfo
|
||||
displayName: Create additional build with debug information?
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
jobs:
|
||||
- job: BinarySizeChecks
|
||||
timeoutInMinutes: 30
|
||||
workspace:
|
||||
clean: all
|
||||
pool: Linux-CPU-2019
|
||||
|
||||
steps:
|
||||
- checkout: self
|
||||
clean: true
|
||||
submodules: recursive
|
||||
|
||||
- template: templates/get-docker-image-steps.yml
|
||||
parameters:
|
||||
Dockerfile: tools/ci_build/github/linux/docker/Dockerfile.manylinux2014_cpu
|
||||
Context: tools/ci_build/github/linux/docker
|
||||
DockerBuildArgs: "--build-arg BUILD_UID=$( id -u )"
|
||||
Repository: onnxruntimecpubuild
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: 1a. Build onnxruntime minimal baseline for Android arm64-v8a
|
||||
inputs:
|
||||
script: |
|
||||
NDK_HOME=$(realpath $ANDROID_NDK_HOME)
|
||||
BINARY_SIZE_THRESHOLD_IN_BYTES=1306224
|
||||
docker run --rm \
|
||||
--volume $(Build.SourcesDirectory):/onnxruntime_src \
|
||||
--volume $(Build.BinariesDirectory):/build \
|
||||
--volume $ANDROID_HOME:/android_home \
|
||||
--volume $NDK_HOME:/ndk_home \
|
||||
-e ALLOW_RELEASED_ONNX_OPSET_ONLY=1 \
|
||||
-e NIGHTLY_BUILD \
|
||||
-e BUILD_BUILDNUMBER \
|
||||
-e BUILD_SOURCEVERSION=$(Build.SourceVersion) \
|
||||
-e BUILD_ID=$(Build.BuildId) \
|
||||
-e BUILD_REASON=$(Build.Reason) \
|
||||
-e BUILD_BRANCH=$(Build.SourceBranch) \
|
||||
onnxruntimecpubuild \
|
||||
/bin/bash /onnxruntime_src/tools/ci_build/github/linux/ort_minimal/build_minimal_ort_android_baseline_and_report_bin_size.sh \
|
||||
-b /build/1a \
|
||||
-t ${BINARY_SIZE_THRESHOLD_IN_BYTES}
|
||||
workingDirectory: $(Build.SourcesDirectory)
|
||||
|
||||
- task: AzureCLI@2
|
||||
displayName: 1a. Publish binary size data
|
||||
# only publish size data for CI builds on master
|
||||
condition: and(succeededOrFailed(), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI'), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
|
||||
inputs:
|
||||
azureSubscription: AIInfraBuild
|
||||
scriptLocation: inlineScript
|
||||
scriptType: bash
|
||||
inlineScript: |
|
||||
BINARY_SIZE_DATA_FILE="$(Build.BinariesDirectory)/1a/MinSizeRel/binary_size_data.txt"
|
||||
if [[ ! -f "${BINARY_SIZE_DATA_FILE}" ]]; then
|
||||
echo "File not found: ${BINARY_SIZE_DATA_FILE}"
|
||||
exit 1
|
||||
fi
|
||||
/usr/bin/python3 $(Build.SourcesDirectory)/tools/ci_build/github/windows/post_binary_sizes_to_dashboard.py \
|
||||
--commit_hash=$(Build.SourceVersion) \
|
||||
--size_data_file="${BINARY_SIZE_DATA_FILE}" \
|
||||
--build_project=onnxruntime \
|
||||
--build_id=$(Build.BuildId)
|
||||
workingDirectory: '$(Build.BinariesDirectory)'
|
||||
|
||||
- task: PublishPipelineArtifact@1
|
||||
displayName: 1a. Publish binary artifact
|
||||
inputs:
|
||||
targetPath: $(Build.BinariesDirectory)/1a/MinSizeRel/libonnxruntime.so
|
||||
artifactName: AndroidMinimalBaselineBinary
|
||||
|
||||
- ${{ if parameters.DoBuildWithDebugInfo }}:
|
||||
- task: CmdLine@2
|
||||
displayName: 1b. Build onnxruntime minimal baseline for Android arm64-v8a with debug info
|
||||
inputs:
|
||||
script: |
|
||||
NDK_HOME=$(realpath $ANDROID_NDK_HOME)
|
||||
docker run --rm \
|
||||
--volume $(Build.SourcesDirectory):/onnxruntime_src \
|
||||
--volume $(Build.BinariesDirectory):/build \
|
||||
--volume $ANDROID_HOME:/android_home \
|
||||
--volume $NDK_HOME:/ndk_home \
|
||||
-e ALLOW_RELEASED_ONNX_OPSET_ONLY=1 \
|
||||
-e NIGHTLY_BUILD \
|
||||
-e BUILD_BUILDNUMBER \
|
||||
-e BUILD_SOURCEVERSION=$(Build.SourceVersion) \
|
||||
-e BUILD_ID=$(Build.BuildId) \
|
||||
-e BUILD_REASON=$(Build.Reason) \
|
||||
-e BUILD_BRANCH=$(Build.SourceBranch) \
|
||||
onnxruntimecpubuild \
|
||||
/bin/bash /onnxruntime_src/tools/ci_build/github/linux/ort_minimal/build_minimal_ort_android_baseline_and_report_bin_size.sh \
|
||||
-b /build/1b \
|
||||
-d
|
||||
workingDirectory: $(Build.SourcesDirectory)
|
||||
|
||||
- task: PublishPipelineArtifact@1
|
||||
displayName: 1b. Publish binary artifact
|
||||
inputs:
|
||||
targetPath: $(Build.BinariesDirectory)/1b/MinSizeRel/libonnxruntime.so
|
||||
artifactName: AndroidMinimalBaselineDebugBinary
|
||||
|
||||
- template: templates/component-governance-component-detection-steps.yml
|
||||
parameters:
|
||||
condition: succeeded()
|
||||
|
||||
- task: mspremier.PostBuildCleanup.PostBuildCleanup-task.PostBuildCleanup@3
|
||||
displayName: 'Clean Agent Directories'
|
||||
condition: always()
|
||||
|
|
@ -11,14 +11,12 @@
|
|||
# 4. Build minimal ORT with type reduction from a globally allowed types list.
|
||||
# This step uses a hard-coded list of types which may not include the types needed by the models
|
||||
# in <repo root>/onnxruntime/test/testdata/, so the tests for those models are skipped.
|
||||
# 5. Build baseline minimal ORT for Android arm64-v8a including no kernels and disable exceptions.
|
||||
# This step is to report the baseline binary size for Android.
|
||||
# 6. Build extended minimal ORT with runtime optimization replay enabled.
|
||||
# 7. Build with all optional features disabled and no kernels.
|
||||
# 7a: regular build with python enabled checks that the exclusions don't break code paths in a full build.
|
||||
# 7b: minimal build with exceptions and python disabled checks that the exclusions don't break code paths in a
|
||||
# 5. Build extended minimal ORT with runtime optimization replay enabled.
|
||||
# 6. Build with all optional features disabled and no kernels.
|
||||
# 6a: regular build with python enabled checks that the exclusions don't break code paths in a full build.
|
||||
# 6b: minimal build with exceptions and python disabled checks that the exclusions don't break code paths in a
|
||||
# minimal build.
|
||||
# 7c: extended minimal build with exceptions and python disabled checks that the exclusions don't break code paths
|
||||
# 6c: extended minimal build with exceptions and python disabled checks that the exclusions don't break code paths
|
||||
# in an extended minimal build.
|
||||
|
||||
jobs:
|
||||
|
|
@ -154,51 +152,7 @@ jobs:
|
|||
workingDirectory: $(Build.SourcesDirectory)
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: 5. Build onnxruntime minimal baseline for Android arm64-v8a and report binary size
|
||||
inputs:
|
||||
script: |
|
||||
NDK_HOME=$(realpath $ANDROID_NDK_HOME)
|
||||
docker run --rm \
|
||||
--volume $(Build.SourcesDirectory):/onnxruntime_src \
|
||||
--volume $(Build.BinariesDirectory):/build \
|
||||
--volume $ANDROID_HOME:/android_home \
|
||||
--volume $NDK_HOME:/ndk_home \
|
||||
--volume $(test_data_directory):/home/onnxruntimedev/.test_data \
|
||||
-e ALLOW_RELEASED_ONNX_OPSET_ONLY=1 \
|
||||
-e NIGHTLY_BUILD \
|
||||
-e BUILD_BUILDNUMBER \
|
||||
-e BUILD_SOURCEVERSION=$(Build.SourceVersion) \
|
||||
-e BUILD_ID=$(Build.BuildId) \
|
||||
-e BUILD_REASON=$(Build.Reason) \
|
||||
-e BUILD_BRANCH=$(Build.SourceBranch) \
|
||||
onnxruntimecpubuild \
|
||||
/bin/bash /onnxruntime_src/tools/ci_build/github/linux/ort_minimal/build_minimal_ort_android_baseline_and_report_bin_size.sh \
|
||||
/build/5
|
||||
workingDirectory: $(Build.SourcesDirectory)
|
||||
|
||||
|
||||
- task: AzureCLI@2
|
||||
displayName: 'Publish binary size data'
|
||||
condition: and(succeededOrFailed(), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI'), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
|
||||
inputs:
|
||||
azureSubscription: AIInfraBuild
|
||||
scriptLocation: inlineScript
|
||||
scriptType: bash
|
||||
inlineScript: |
|
||||
BINARY_SIZE_DATA_FILE="$(Build.BinariesDirectory)/5/MinSizeRel/binary_size_data.txt"
|
||||
if [[ ! -f "${BINARY_SIZE_DATA_FILE}" ]]; then
|
||||
echo "File not found: ${BINARY_SIZE_DATA_FILE}"
|
||||
exit 1
|
||||
fi
|
||||
/usr/bin/python3 $(Build.SourcesDirectory)/tools/ci_build/github/windows/post_binary_sizes_to_dashboard.py \
|
||||
--commit_hash=$(Build.SourceVersion) \
|
||||
--size_data_file="${BINARY_SIZE_DATA_FILE}" \
|
||||
--build_project=onnxruntime \
|
||||
--build_id=$(Build.BuildId)
|
||||
workingDirectory: '$(Build.BinariesDirectory)'
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: 6. Build extended minimal onnxruntime with runtime optimization replay enabled
|
||||
displayName: 5. Build extended minimal onnxruntime with runtime optimization replay enabled
|
||||
inputs:
|
||||
script: |
|
||||
docker run --rm \
|
||||
|
|
@ -209,7 +163,7 @@ jobs:
|
|||
-e BUILD_BUILDNUMBER \
|
||||
onnxruntimecpubuild \
|
||||
/opt/python/cp37-cp37m/bin/python3 /onnxruntime_src/tools/ci_build/build.py \
|
||||
--build_dir /build/6 --cmake_generator Ninja \
|
||||
--build_dir /build/5 --cmake_generator Ninja \
|
||||
--config Debug \
|
||||
--skip_submodule_sync \
|
||||
--build_shared_lib \
|
||||
|
|
@ -219,7 +173,7 @@ jobs:
|
|||
workingDirectory: $(Build.SourcesDirectory)
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: 7a. Regular build with python and all optional features disabled.
|
||||
displayName: 6a. Regular build with python and all optional features disabled.
|
||||
inputs:
|
||||
script: |
|
||||
docker run --rm \
|
||||
|
|
@ -231,7 +185,7 @@ jobs:
|
|||
-e BUILD_BUILDNUMBER \
|
||||
onnxruntimecpubuild \
|
||||
/opt/python/cp37-cp37m/bin/python3 /onnxruntime_src/tools/ci_build/build.py \
|
||||
--build_dir /build/7a \
|
||||
--build_dir /build/6a \
|
||||
--cmake_generator Ninja \
|
||||
--config MinSizeRel \
|
||||
--skip_submodule_sync \
|
||||
|
|
@ -247,7 +201,7 @@ jobs:
|
|||
workingDirectory: $(Build.SourcesDirectory)
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: 7b. Minimal build with all optional features disabled.
|
||||
displayName: 6b. Minimal build with all optional features disabled.
|
||||
inputs:
|
||||
script: |
|
||||
docker run --rm \
|
||||
|
|
@ -259,7 +213,7 @@ jobs:
|
|||
-e BUILD_BUILDNUMBER \
|
||||
onnxruntimecpubuild \
|
||||
/opt/python/cp37-cp37m/bin/python3 /onnxruntime_src/tools/ci_build/build.py \
|
||||
--build_dir /build/7b \
|
||||
--build_dir /build/6b \
|
||||
--cmake_generator Ninja \
|
||||
--config MinSizeRel \
|
||||
--skip_submodule_sync \
|
||||
|
|
@ -277,7 +231,7 @@ jobs:
|
|||
workingDirectory: $(Build.SourcesDirectory)
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: 7c. Extended minimal build with all optional features disabled.
|
||||
displayName: 6c. Extended minimal build with all optional features disabled.
|
||||
inputs:
|
||||
script: |
|
||||
docker run --rm \
|
||||
|
|
@ -289,7 +243,7 @@ jobs:
|
|||
-e BUILD_BUILDNUMBER \
|
||||
onnxruntimecpubuild \
|
||||
/opt/python/cp37-cp37m/bin/python3 /onnxruntime_src/tools/ci_build/build.py \
|
||||
--build_dir /build/7c \
|
||||
--build_dir /build/6c \
|
||||
--cmake_generator Ninja \
|
||||
--config MinSizeRel \
|
||||
--skip_submodule_sync \
|
||||
|
|
|
|||
|
|
@ -5,12 +5,29 @@
|
|||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
while getopts b:t:d parameter
|
||||
do case "${parameter}"
|
||||
in
|
||||
b) BUILD_DIR="${OPTARG}";;
|
||||
t) THRESHOLD_SIZE="${OPTARG}";;
|
||||
d) INCLUDE_DEBUG_INFO=1;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "${BUILD_DIR}" ]]; then
|
||||
echo "Build directory must be specified with -b."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CHECK_THRESHOLD_SIZE_ARGS=${THRESHOLD_SIZE:+"--threshold ${THRESHOLD_SIZE}"}
|
||||
BUILD_WITH_DEBUG_INFO_ARGS=${INCLUDE_DEBUG_INFO:+"--cmake_extra_defines ADD_DEBUG_INFO_TO_MINIMAL_BUILD=ON"}
|
||||
|
||||
export PATH=/opt/python/cp37-cp37m/bin:$PATH
|
||||
|
||||
BUILD_DIR=${1:?"usage: $0 <build directory>"}
|
||||
|
||||
# Create an empty file to be used with build --include_ops_by_config, which will include no operators at all
|
||||
echo -n > /home/onnxruntimedev/.test_data/include_no_operators.config
|
||||
mkdir -p ${BUILD_DIR}
|
||||
echo -n > ${BUILD_DIR}/include_no_operators.config
|
||||
|
||||
# Run a baseline minimal build of ORT Android arm64-v8a
|
||||
# Generate binary size as ${BUILD_DIR}/MinSizeRel/binary_size_data.txt
|
||||
|
|
@ -29,13 +46,11 @@ python3 /onnxruntime_src/tools/ci_build/build.py \
|
|||
--build_java \
|
||||
--disable_ml_ops \
|
||||
--disable_exceptions \
|
||||
--include_ops_by_config /home/onnxruntimedev/.test_data/include_no_operators.config
|
||||
--include_ops_by_config ${BUILD_DIR}/include_no_operators.config \
|
||||
${BUILD_WITH_DEBUG_INFO_ARGS}
|
||||
|
||||
# set current size limit to BINARY_SIZE_LIMIT_IN_BYTES.
|
||||
BINARY_SIZE_LIMIT_IN_BYTES=1306224
|
||||
echo "The current preset binary size limit is $BINARY_SIZE_LIMIT_IN_BYTES"
|
||||
python3 /onnxruntime_src/tools/ci_build/github/linux/ort_minimal/check_build_binary_size.py \
|
||||
--threshold=$BINARY_SIZE_LIMIT_IN_BYTES \
|
||||
${CHECK_THRESHOLD_SIZE_ARGS} \
|
||||
${BUILD_DIR}/MinSizeRel/libonnxruntime.so
|
||||
|
||||
echo "The content of binary_size_data.txt"
|
||||
|
|
|
|||
Loading…
Reference in a new issue