Integrating KONNX with ONNX Runtime
This section describes how to integrate KONNX with ONNX Runtime to enable Kunpeng operator acceleration.
Environment Requirements
Adaptation Procedure
- Obtain the ONNX Runtime source code.
git clone -b v1.19.2 https://github.com/microsoft/onnxruntime.git
- Obtain the patch file of ONNX Runtime.
git clone -b v1.1.0 https://atomgit.com/openeuler/sra_onnxruntime_adapter.git
- Go to the /path/to/onnxruntime directory.
1cd /path/to/onnxruntime
- Apply the konnx.patch file to the repository.
1git apply /path/to/sra_onnxruntime_adapter/konnx.patch
- Check whether the files are modified as shown in the following figure. If yes, the patch is successfully installed.
1 2
git add . git status

- Compile and install ONNX Runtime. For details, see Compiling the Source Code in the ONNX Runtime Porting Guide.
Verification After Adaptation
After ONNX Runtime is compiled and installed, use the official unit test (UT) program onnxruntime_test_all to run and verify ONNX Runtime. This program, automatically built during CMake compilation, executes comprehensive tests validating functionality including: core operators, executors, serialization/deserialization, model loading, and hardware accelerator integrations.
- Set environment variables.
export ONNX_INTRA_NUM=6 export ONNX_INTER_NUM=6
- ONNX_INTRA_NUM: intra-operator parallel thread count, controlling thread parallelism within an operator
- ONNX_INTER_NUM: inter-operator parallel thread count, controlling concurrent execution across multiple operators
The thread count can be set as required.
- Go to the /path/to/onnxruntime/build/RelWithDebInfo directory.
cd /path/to/onnxruntime/build/RelWithDebInfo
- Run the following command to run public unit tests (onnxruntime_test_all) for ONNX Runtime:
./onnxruntime_test_all
If the following information is displayed and no error is reported during the test, the ONNX Runtime verification is complete.

Parent topic: Using SRA_Inference