47 lines
1.0 KiB
Markdown
47 lines
1.0 KiB
Markdown
# 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:
|
|
|
|
```bash
|
|
pip3 install -r requirements.txt
|
|
```
|
|
|
|
### Command line
|
|
|
|
You can use optimize models using the command line:
|
|
|
|
```bash
|
|
python3 optimize.py input.onnx -o output.onnx
|
|
```
|
|
|
|
For models larger than 2GiB, you can use the following command:
|
|
|
|
```bash
|
|
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.
|
|
|
|
```python
|
|
import kneronnxopt
|
|
import onnx
|
|
|
|
model = onnx.load("input.onnx")
|
|
new_model = kneronnxopt.optimize(model)
|
|
```
|
|
|
|
For large models, please use the following API:
|
|
|
|
```python
|
|
import kneronnxopt
|
|
import onnx
|
|
|
|
kneronnxopt.optimize_large_model(input_model_path, output_model_path=output_model_path)
|
|
```
|