Analyzing Comparison Results Using a Script Tool
Script Tool Introduction
Advisor provides the mscmp_advisor.py script tool. The following table describes the functionality and path of the tool.
Script Name |
Functionality |
Path |
|---|---|---|
mscmp_advisor.py |
Analyzes tensor comparison results and provides tuning suggestions. |
${INSTALL_DIR}/tools/operator_cmp/compare. Replace ${INSTALL_DIR} with the actual CANN component directory. If the Ascend-CANN-Toolkit package is installed as the root user, the CANN component directory is /usr/local/Ascend/ascend-toolkit/latest. |
Command Syntax
The mscmp_advisor.py script tool directly analyzes the comparison results in .csv files. Therefore, you need to obtain the .csv files through accuracy comparison before performing this operation.
The command syntax is as follows:
python3 mscmp_advisor.py -i input_file [-input_nodes node_name] [-o out_path]
Option |
Description |
Mandatory (Yes/No) |
|---|---|---|
-i --input_file |
Specifies the comparison result file in .csv format, Example: $HOME/result/result_*.csv The maximum size of a .csv file supported by this option is 100 MB. |
Yes |
-input_nodes |
Specifies the input nodes of the network model. Separate multiple nodes with semicolons (;), for example, "node_name1;node_name2;node_name3". |
No If this option is not set, input detection is not performed. |
-o --out_path |
Specifies the output path of the analysis result. The result file is named advisor_summary.txt. You are not advised to configure directories that are different from those of the current user to avoid privilege escalation risks. |
No If this option is not set, the result file is not flushed to the disk. |
Procedure
- Log in to the CANN tool installation environment.
- Generate a .json file.
atc --mode=1 --om=$HOME/data/resnet50.om --json=$HOME/data/resnet50.json
- Set environment variables.
export PYTHONPATH=${INSTALL_DIR}/tools/operator_cmp/compare:$PYTHONPATH - Run the accuracy comparison command.
python3 msaccucmp.py compare -m $HOME/MyApp_mind/resnet50 -g $HOME/Standard_caffe/resnet50 -f $HOME/data/resnet50.json -out $HOME/result -overflow_detection
You need to configure the -overflow_detection option here to identify overflow/underflow operators. After the comparison is complete, the result file result_*.csv is generated.
- Perform analysis using Advisor.
python3 mscmp_advisor.py -i $HOME/result/result_*.csv -input_nodes "node_name1;node_name2;node_name3" -o $HOME/result
- After the command is executed, Advisor directly analyzes the comparison result and outputs the analysis result. For details about the command output, see Output Results and Tuning Suggestions.