Top Overflow/Underflow Operator Parsing

Operator overflow or underflow may occur during AI service running. In this case, if accuracy comparison is directly performed, the comparison result will be inaccurate. Instead, you can perform Viewing Data of Overflowed/Underflowed Operators to detect and collect information about overflow/underflow operators, and generate the operator overflow/underflow data file and the dump file of the overflow/underflow operators.

If the time when the operator overflow/underflow data file and the dump file of the overflow/underflow operators are flushed to a disk is inconsistent with the overflow/underflow time of the operators, the first overflow/underflow operator cannot be located in the two files in a timely manner.

To help quickly locate overflow/underflow operators, the top overflow/underflow operator parsing function described in this section can analyze the generated debug file and the dump file of the overflow/underflow operators and display the key information about the top N overflow/underflow operators.

Command Syntax

The command line for operator overflow/underflow detection is as follows:

python3 msaccucmp.py overflow -d dump_path -out output_path [-n topn]

Table 1 describes the command-line options.

This function is implemented through the msaccucmp.py script, which is stored in ${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..

Table 1 Command-line options of operator overflow/underflow detection

Option

Description

Mandatory (Yes/No)

-d

--dump_path

Directory for storing the debug file and the dump file of overflow/underflow operators.

Refer to Viewing Data of Overflowed/Underflowed Operators to obtain the file directory.

If the dump file does not exist in the directory, the .npy file will be missing in the -out output. If the debug file does not exist in the directory, no overflow/underflow occurs.

Yes

-out

--output_path

Output directory for storing result files of operator overflow/underflow analysis.

The output files are as follows:

  • .json file generated by the debug file. It is a process file used to extract the names and overflow/underflow information of the top N overflow/underflow operators from the result file.
  • .npy file generated by the dump data of the overflow/underflow operators, including the input and output data of operators. It is a process file used to extract key information about overflow/underflow from the result file.
  • Result file of operator overflow/underflow detection analysis, which summarizes information about top N overflow/underflow operators. The result file is named in the format of overflow_summary_{timestamp}.txt.

If the .npy file is missing, the result file cannot parse the input and output information of the overflow/underflow operators.

You are not advised to configure directories that are different from those of the current user to avoid privilege escalation risks.

Yes

-n

--topn

Parses the first N operators that are overflowed/underflowed. The value ranges from 1 to 5. The default value is 1.

No

Procedure

Before conducting operator overflow/underflow analysis, perform operator overflow/underflow detection on the dump file and generate the debug file and the dump file of the overflow/underflow operators. For details, see Viewing Data of Overflowed/Underflowed Operators.

To detect operator overflow/underflow using the CLI, perform the following steps:

Ensure that the operation user has the read and write permissions on the result file path specified by --out.

  1. Log in to the CANN tool installation environment.
  2. Go to the ${INSTALL_DIR}/tools/operator_cmp/compare directory. 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..
  3. Run the operator overflow/underflow detection command.
    python3 msaccucmp.py overflow -d /MyApp20/dump -out /MyApp20/out -n 3

    Figure 1 shows the content of the overflow_summary_{timestamp}.txt file generated after operator overflow/underflow detection.

    Figure 1 Overflow/Underflow operator result information

    In the result file, the following information is displayed from top to bottom:

    • 1 to n indicate the first overflow/underflow operator to the nth overflow/underflow operator that are parsed.
    • Type and name of each overflow/underflow operator.
    • Overflow/Underflow information of each operator, including the overflow/underflow type, overflow/underflow task ID, stream ID, and overflow/underflow error code.
    • timestamp: overflow/underflow timestamp of each operator.
    • *.input.*.npy: .npy file of the input data of the overflow/underflow operators.
    • Below the *.input.*.npy file name, key input information about operator overflow/underflow in the file is displayed, including the data format, data dimension, data type, maximum value, minimum value, and average value.
    • *.output.*.npy: .npy file of the output data of the overflow/underflow operators.
    • Below the *.output.*.npy file name, key output information about operator overflow/underflow in the file is displayed, including the data format, data dimension, data type, maximum value, minimum value, and average value.