1.0 KiB
1.0 KiB
Kneron ONNX Optimizer -Kneronnxopt
Kneron ONNX Optimizer (Kneronnxopt) is a tool that optimizes ONNX models for Kneron's AI processors. It is designed to optimize the model for Kneron's AI processors, such as 520, 720, 530, 630, 730.
Usage
Before running the optimizer, you need to install the dependencies:
pip3 install -r requirements.txt
Command line
You can use optimize models using the command line:
python3 optimize.py input.onnx -o output.onnx
For models larger than 2GiB, you can use the following command:
python3 optimize_large_model.py input.onnx -o output.onnx
Python API
You can also use the optimize after adding the kneronnxopt package under your python library.
import kneronnxopt
import onnx
model = onnx.load("input.onnx")
new_model = kneronnxopt.optimize(model)
For large models, please use the following API:
import kneronnxopt
import onnx
kneronnxopt.optimize_large_model(input_model_path, output_model_path=output_model_path)