Automatically Optimizing ONNX Models by Using the msit debug surgeon Tool

The surgeon (automatic tuning) tool enables the optimization of the ONNX model on the Ascend chip and provides the ONNX-based image modification function.

Procedure

Run the following command to perform tuning. Table 1 describes the parameters.

msit debug surgeon COMMAND 
Table 1 Parameters

Parameter

Description

COMMAND

COMMAND provides five options for the surgeon tool:

  • list: lists all repositories that support automatic tuning.
  • evaluate: searches for ONNX models that can be optimized by a specified repository.
  • optimize: uses a specified repository to optimize a specified ONNX model.
  • extract: performs subgraph segmentation on the model.
  • concatenate: concatenates models.

The optional and mandatory parameters of each subtask are different. For details, see msit debug surgeon User Guide.

Optimization Instance

Figure 1 and Figure 2 show the instance of the COMMAND parameter values.

Figure 1 Value being list
Figure 2 Value being evaluate or optimize

Figure 3 shows the comparison before and after the execution. The result shows that the cast operator is eliminated after the execution.

Figure 3 Comparison before and after the execution