Model Export Tool

The algorithm package provides two model export tools, supporting the export of ONNX and HBIR models

  • tools/export_onnx.py: ONNX model export tool. The exported ONNX model is for visualization only and does not support inference.
  • tools/export_hbir.py: HBIR model export tool.

Export the ONNX Model

Usage

Run the script tools/export_onnx.py and specify the path to the configuration file. The script will automatically read the model, input, export path and other information from the configuration to complete the export of the ONNX model.

Parameters Introduction

ParameterDescription
--config, -cPath to the config file.

Usgae Example

Take the resnet50_imagenet model as an example:

python tools/export_onnx.py --config configs/classification/resnet50_imagenet.py

Export the HBIR Model

Usage

Run the script tools/export_hbir.py and specify the path to the configuration file. The script will automatically read the model, input, export path and other information from the configuration to complete the export of the HBIR model.

Attention

If you want to deploy the model provided by the reference algorithm package on nash-p, nash-b, or nash-h, you need to pass the corresponding march parameter.

Parameters Introduction

ParameterDescription
--config, -cPath to the config file.
--save-pathThe save path of HBIR.
--marchBPU march parameter, available values are nash-b-lite、nash-b、nash-b-plus、nash-e、nash-m、nash-h、nash-p.
--mawith-checkrchWhether check the mlir model forward with example input., available values are True and False. It is recommended to use the default value False.
--debugWhether to set the log level to DEBUG, options are True/False, default False is recommended.

Usgae Example

Take the resnet50_imagenet model as an example:

python export_hbir.py --config configs/classification/resnet50_imagenet.py --save-path ./output/hbir --march nash-p

For a detailed introduction to the configuration file, please refer to the [Configuration] section [config configuration] (../config/keywords).