Web Analytics

Kneronnxopt

Kneronnxopt is the ONNX optimizer project for Kneron hardware platforms. It prepares tensor shapes and optimizes graph structures to improve inference and compilation flow. Currently, it supports ONNX opset 8 to 18.

1. Preparation

Before using the tool, you need to activate the conda environment for it. Required packages are already installed in the environment. You can activate the environment by running the following command:

conda activate onnx1.13

2. Usage

2.1. Standard model optimization

Use module execution for standard ONNX models:

python -m kneronnxopt.optimize <input_onnx_model> -o <output_onnx_model>

Optional arguments:

Notes:

2.2. Large model optimization (>2 GiB)

For large ONNX models, use the large-model module entry:

python -m kneronnxopt.large_model_fast_proc <input_onnx_model> -o <output_onnx_model>

Optional arguments:

2.3. Help command

To inspect full and current options from the tool directly:

python -m kneronnxopt.optimize -h
python -m kneronnxopt.large_model_fast_proc -h

3. Notes

This appendix focuses on console usage. For Python API usage, please refer to 3.1.2 ONNX Optimization.

If you want to cut the model, please use onnx.utils.extract_model from ONNX. Please check https://onnx.ai/onnx/api/utils.html