-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Add CI build with type reduction enabled #6622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f49049c
5359994
7a1540b
7a70efd
b3d0b64
654c4bb
b35d643
18741d5
36ff642
4296bee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| # and the models from <repo root>/onnxruntime/test/testdata/, run UT, and use onnx_test_runner to | ||
| # test the ort format models generated in step 1. | ||
| # Exceptions are enabled in this step to help debugging in case of CI failure. | ||
| # This step builds and tests ORT with and without type reduction enabled. | ||
| # 4. 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 | ||
| jobs: | ||
|
|
@@ -15,11 +16,23 @@ jobs: | |
| workspace: | ||
| clean: all | ||
| pool: Linux-CPU | ||
|
|
||
| variables: | ||
| test_data_directory: $(Build.SourcesDirectory)/.test_data | ||
|
|
||
| steps: | ||
| - checkout: self | ||
| clean: true | ||
| submodules: recursive | ||
|
|
||
| - task: CmdLine@2 | ||
| displayName: Create test data directory | ||
| inputs: | ||
| script: | | ||
| # Create a folder for all test data | ||
| mkdir -p $(test_data_directory) | ||
| workingDirectory: $(Build.SourcesDirectory) | ||
|
|
||
| - template: templates/get-docker-image-steps.yml | ||
| parameters: | ||
| Dockerfile: tools/ci_build/github/linux/docker/Dockerfile.centos | ||
|
|
@@ -31,23 +44,22 @@ jobs: | |
| displayName: Build full onnxruntime and generate ORT format test files | ||
| inputs: | ||
| script: | | ||
| # Create a folder for all test data | ||
| mkdir -p $HOME/.test_data | ||
| docker run --rm \ | ||
| --volume $(Build.SourcesDirectory):/onnxruntime_src \ | ||
| --volume $(Build.BinariesDirectory):/build \ | ||
| --volume $HOME/.test_data:/home/onnxruntimedev/.test_data \ | ||
| --volume $(test_data_directory):/home/onnxruntimedev/.test_data \ | ||
| -e ALLOW_RELEASED_ONNX_OPSET_ONLY=1 \ | ||
| -e NIGHTLY_BUILD \ | ||
| -e BUILD_BUILDNUMBER \ | ||
| onnxruntimecentoscpubuild \ | ||
| /bin/bash /onnxruntime_src/tools/ci_build/github/linux/ort_minimal/build_full_ort_and_create_ort_files.sh | ||
| workingDirectory: $(Build.SourcesDirectory) | ||
|
|
||
| - task: CmdLine@2 | ||
| displayName: Build minimal onnxruntime with exceptions disabled | ||
| displayName: Build minimal onnxruntime [exceptions DISABLED, type reduction DISABLED] | ||
| inputs: | ||
| script: | | ||
| # We will try to build the ORT minimal with exception disabled | ||
| # We will try to build minimal ORT with exceptions disabled | ||
| # Only the building process is verified here, no test will be performed | ||
| docker run --rm \ | ||
| --volume $(Build.SourcesDirectory):/onnxruntime_src \ | ||
|
|
@@ -66,31 +78,59 @@ jobs: | |
| --minimal_build \ | ||
| --disable_exceptions | ||
| workingDirectory: $(Build.SourcesDirectory) | ||
|
|
||
| - task: CmdLine@2 | ||
| displayName: Build minimal onnxruntime and run tests with exceptions enabled | ||
| displayName: Build minimal onnxruntime [exceptions ENABLED, type reduction DISABLED] and run tests | ||
| inputs: | ||
| script: | | ||
| docker run --rm \ | ||
| --volume $(Build.SourcesDirectory):/onnxruntime_src \ | ||
| --volume $(Build.BinariesDirectory):/build \ | ||
| --volume $HOME/.test_data:/home/onnxruntimedev/.test_data \ | ||
| --volume $(test_data_directory):/home/onnxruntimedev/.test_data \ | ||
| -e ALLOW_RELEASED_ONNX_OPSET_ONLY=1 \ | ||
| -e NIGHTLY_BUILD \ | ||
| -e BUILD_BUILDNUMBER \ | ||
| onnxruntimecentoscpubuild \ | ||
| /bin/bash /onnxruntime_src/tools/ci_build/github/linux/ort_minimal/build_minimal_ort_and_run_tests.sh | ||
| /bin/bash /onnxruntime_src/tools/ci_build/github/linux/ort_minimal/build_minimal_ort_and_run_tests.sh \ | ||
| --build-directory /build/without_type_reduction \ | ||
| --reduced-ops-config /home/onnxruntimedev/.test_data/required_ops.ort_models.config | ||
| workingDirectory: $(Build.SourcesDirectory) | ||
|
|
||
| - script: git checkout -- . | ||
| displayName: Discard local changes to Git repository files | ||
| workingDirectory: $(Build.SourcesDirectory) | ||
|
|
||
| - task: CmdLine@2 | ||
| displayName: Build minimal onnxruntime [exceptions ENABLED, type reduction ENABLED] and run tests | ||
| inputs: | ||
| script: | | ||
| docker run --rm \ | ||
| --volume $(Build.SourcesDirectory):/onnxruntime_src \ | ||
| --volume $(Build.BinariesDirectory):/build \ | ||
| --volume $(test_data_directory):/home/onnxruntimedev/.test_data \ | ||
| -e ALLOW_RELEASED_ONNX_OPSET_ONLY=1 \ | ||
| -e NIGHTLY_BUILD \ | ||
| -e BUILD_BUILDNUMBER \ | ||
| onnxruntimecentoscpubuild \ | ||
| /bin/bash /onnxruntime_src/tools/ci_build/github/linux/ort_minimal/build_minimal_ort_and_run_tests.sh \ | ||
| --build-directory /build/with_type_reduction \ | ||
| --reduced-ops-config /home/onnxruntimedev/.test_data/required_ops_and_types.ort_models.config \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to throw away the build between having type reduction disabled and enabled, or can we just do an incremental build to save time? Not sure if running via docker supports that though.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it should be possible to do an incremental build. however, the test report files will have the same name, so need to upload them twice or somehow not overwrite them. one of these reduced minimal build steps takes about 4 minutes, so the time savings would not be huge. In reply to: 573278739 [](ancestors = 573278739) |
||
| --enable-type-reduction | ||
| workingDirectory: $(Build.SourcesDirectory) | ||
|
|
||
| - script: git checkout -- . | ||
| displayName: Discard local changes to Git repository files | ||
| workingDirectory: $(Build.SourcesDirectory) | ||
|
|
||
| - task: CmdLine@2 | ||
| displayName: Build onnxruntime minimal baseline for Android arm64-v8a and report binary size | ||
| inputs: | ||
| script: | | ||
| # Create a folder for all test data | ||
| mkdir -p $HOME/.test_data | ||
| docker run --rm \ | ||
| --volume $(Build.SourcesDirectory):/onnxruntime_src \ | ||
| --volume $(Build.BinariesDirectory):/build \ | ||
| --volume $ANDROID_HOME:/android_home \ | ||
| --volume $HOME/.test_data:/home/onnxruntimedev/.test_data \ | ||
| --volume $(test_data_directory):/home/onnxruntimedev/.test_data \ | ||
| -e ALLOW_RELEASED_ONNX_OPSET_ONLY=1 \ | ||
| -e NIGHTLY_BUILD \ | ||
| -e BUILD_BUILDNUMBER \ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,23 +2,75 @@ | |
|
|
||
| # This script will create a minimal build with the required operators for all ORT format models | ||
| # in the testdata directory. This includes E2E models generated by build_full_ort_and_create_ort_files.sh. | ||
| # The build will run the unit tests for the minimal build, followed by running onnx_test_runner | ||
| # The build will run the unit tests for the minimal build, followed by running onnx_test_runner | ||
| # for the E2E test cases. | ||
|
|
||
|
|
||
| set -e | ||
| set -x | ||
|
|
||
| USAGE_TEXT="Usage: | ||
| -b|--build-directory <build directory> | ||
| Specifies the build directory. Required. | ||
| -c|--reduced-ops-config <reduced Ops config file> | ||
| Specifies the reduced Ops configuration file path. Required. | ||
| [--enable-type-reduction] | ||
| Builds with type reduction enabled." | ||
|
|
||
| BUILD_DIR= | ||
| REDUCED_OPS_CONFIG_FILE= | ||
| ENABLE_TYPE_REDUCTION= | ||
|
|
||
| while [[ $# -gt 0 ]] | ||
| do | ||
| OPTION_KEY="$1" | ||
| case $OPTION_KEY in | ||
| -b|--build-directory) | ||
| BUILD_DIR="$2" | ||
| shift | ||
| shift | ||
| ;; | ||
| -c|--reduced-ops-config) | ||
| REDUCED_OPS_CONFIG_FILE="$2" | ||
| shift | ||
| shift | ||
| ;; | ||
| --enable-type-reduction) | ||
| ENABLE_TYPE_REDUCTION=1 | ||
| shift | ||
| ;; | ||
| *) | ||
| echo "Invalid option: $1" | ||
| echo "$USAGE_TEXT" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| if [[ -z "${BUILD_DIR}" || -z "${REDUCED_OPS_CONFIG_FILE}" ]]; then | ||
| echo "Required option was not provided." | ||
| echo "$USAGE_TEXT" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Perform a minimal build with required ops and run ORT minimal build UTs | ||
| python3 /onnxruntime_src/tools/ci_build/build.py \ | ||
| --build_dir /build --cmake_generator Ninja \ | ||
| --build_dir ${BUILD_DIR} --cmake_generator Ninja \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add something to echo the size of libonnxruntime.so post-build so that it's captured in the CI output? Will help if we ever need to manually check that a reduced ops + types build is smaller than just a reduced ops build. #Resolved |
||
| --config Debug \ | ||
| --skip_submodule_sync \ | ||
| --build_shared_lib \ | ||
| --parallel \ | ||
| --minimal_build \ | ||
| --disable_ml_ops \ | ||
| --include_ops_by_config /onnxruntime_src/onnxruntime/test/testdata/required_ops.ort_models.config | ||
| --include_ops_by_config ${REDUCED_OPS_CONFIG_FILE} \ | ||
| ${ENABLE_TYPE_REDUCTION:+"--enable_reduced_operator_type_support"} | ||
|
|
||
| # Run the e2e test cases | ||
| /build/Debug/onnx_test_runner /onnxruntime_src/onnxruntime/test/testdata/ort_minimal_e2e_test_data | ||
| ${BUILD_DIR}/Debug/onnx_test_runner /onnxruntime_src/onnxruntime/test/testdata/ort_minimal_e2e_test_data | ||
|
|
||
| # Print binary size info | ||
| python3 /onnxruntime_src/tools/ci_build/github/linux/ort_minimal/check_build_binary_size.py \ | ||
| --arch "$(uname -m)" --os "$(uname -o)" --build_config "minimal-reduced" \ | ||
| ${BUILD_DIR}/Debug/libonnxruntime.so | ||
|
|
||
| echo "Binary size info:" | ||
| cat ${BUILD_DIR}/Debug/binary_size_data.txt | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Might be easier to grok the steps if 'DISABLED' and 'ENABLED' in the displayName values was all caps. #Resolved