Integrating KONNX with ONNX Runtime
This section describes how to integrate KONNX with ONNX Runtime to enable Kunpeng operator acceleration.
KONNX does not provide open development API. Therefore, no API description is provided.
Environment Requirements
Adaptation Procedure
- Obtain the ONNX Runtime source package as instructed in Obtaining the Source Code in the ONNX Runtime Porting Guide.
- Obtain the patch file of ONNX Runtime.
- Download the ONNX Runtime patch file konnx.patch by following instructions in Table 1.
- Upload the konnx.patch patch file to the /path/to/ONNX_Runtime directory.
- Go to the /path/to/ONNX_Runtime/onnxruntime-1.19.2 directory.
1cd /path/to/ONNX_Runtime/onnxruntime-1.19.2
- Initialize the repository.
1 2 3
git init git add . git commit -m "code init"
- Apply the konnx.patch file to the repository.
1git apply ../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/ONNX_Runtime/build/RelWithDebInfo directory.
cd /path/to/ONNX_Runtime-1.19.2/build/RelWithDebInfo
- Run the following command to run onnxruntime_test_all:
./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