Skip to content

Contribution Guide

cloudhan edited this page Oct 23, 2023 · 1 revision

Development environment setup

TBD

Build

https://onnxruntime.ai/docs/build/ partially covers the common use cases for various onnxruntime build configurations. If that does not fit you purpose, please refer to tools/ci_build/build.py, specifically, the parse_arguments function in the file provides most configuration options. This file is a wrapper around cmake command to ensure the configuration is correct and functional. Additionally, cmake/CMakeLists.txt contains cmake options that may not be available from the tools/ci_build/build.py, those options can be specified directly via --cmake_extra_defines. For example:

build.sh \
    --build_dir build \
    --config RelWithDebInfo \
    --cmake_generator Ninja \
    --cmake_extra_defines \
        CMAKE_EXPORT_COMPILE_COMMANDS=ON \
    --use_cache \
    --use_cuda \
    --cuda_version 12.2 \
    --enable_cuda_profiling \
    --enable_training \
    --build_wheel \
    --skip_submodule_sync --skip_tests

Test

Building of onnxruntime produces build/Release/onnxruntime_test_all. It is an aggerated googletest binray. This is your main commandline entrypoint for most C++ tests. There might be other test binaries, run them wisely.

Building of onnxruntime also produces various file with pattern build/Release/onnxruntime_test_*.py, launch it with pytest ./build/Release/onnxruntime_test_*.py will run all python tests for you, please choose them wisely as well.

Pull request

Once PR is ready, contributors need to contact with onnxruntime team members to trigger all necessary pipelines to proceed.

All pipelines that marked as Required must pass before merge, and there is no detour for it.

To accelerate the development cycles, it is suggested that the contributors iterate and pass the CI jobs locally first. The CI command to run the specific pipeline can be retrieved from log of previous runs.

Formatting and linting

The required CI lintrunner pipeline is response for ensuring the code format. From the CI log, it is pretty weird that all the whitespace changes are stripped away. To reproduce the log locally:

pip install lintrunner lintrunner_adapters
lintrunner <file>

For example, lintrunner include/onnxruntime/core/session/onnxruntime_c_api.h

lintrunner -a include/onnxruntime/core/session/onnxruntime_c_api.h will automatically apply the change for you.