Operator UT
Description
- Test the validity of operator code and verify consistency between the desired and actual inputs and outputs.
- Ensure that the operator program can run properly. The selected scenario combination must cover all branches of the operator code (generally, the coverage rate should reach 100%), reducing the failure rate of operator code compilation in different scenarios.
MindStudio supports UT of the operator function implementation code (.py) and operator prototype definition (.h and .cc). For details about the testing method, see "Operator Development" > "UT" in MindStudio IDE User Guide .
You can obtain the dump file of the UT based on MindStudio and use the msopgen tool to generate and view the operator simulation pipeline file.
UT of operator implementation code is not supported on the command line operator development.
Viewing the Operator Simulation Pipeline
- After the operator UT is performed in MindStudio, obtain the dump file to be parsed from the following path:
- Simulator_Performance selected during MindStudio running information configuration: TBE operator project directory/out/model/ca/ {op_type}/{op_type}_ pre_static_test _{case_name}
- Simulator_TMModel selected during MindStudio running information configuration: TBE operator project directory/out/model/tm/ {op_type}/{op_type}_ pre_static_test _{case_name}
- Use the msopgen tool to generate the operator simulation pipeline file.Go to the directory where the msopgen tool is located and run the following commands. Table 1 describes the command-line arguments.
cd /usr/local/Ascend/ascend-toolkit/latest/python/site-packages/bin ./msopgen sim -c core0 -d xx/out/model/ca/add/add_pre_static_test_add_auto_case_name_1 -out ./output_data -subc cubecore0
/usr/local/Ascend is the root user's default installation path of the toolkit. Replace it with the actual path.
Table 1 Command-line options Option
Description
Required
sim
Used for operations related to performance simulation.
Yes
-c, --core-id
Core ID
Set the chip ID, for example, core0.
Yes
-d, --dump-dir
Path to the dump file. The path can be either absolute or relative.
NOTE:These options are valid for the dump file generated when Simulator_Performance or Simulator_TMModel is selected during UT in MindStudio.
Yes
-out, --output
Path to the operator simulation pipeline file. The path can be either absolute or relative. The user who runs the tool must have the read and write permissions on the path.
Yes
- View the operator simulation pipeline.
You can enter chrome://tracing in the address box of the Chrome browser, drag the obtained dump2trace_core0.json file to the blank area, and press the shortcut keys (w: zoom in; s: zoom out; a: move left; d: move right) on the keyboard to view the file, as shown in the following figure. Table 2 describes the key fields.
Figure 1 dump2trace_core0.json file
Table 2 Field description Field
Description
VECTOR
Vector unit.
SCALAR
Scalar unit.
MTE1
Data transfer flow. The transfer direction is L1 -> {L0A/L0B, UBUF}.
MTE2
Data transfer flow. The transfer direction is {DDR/GM, L2} -> {L1, L0A/B, UBUF}.
MTE3
Data transfer flow. The transfer direction is UBUF -> {DDR/GM, L2, L1}.
FLOWCTRL
Control flow instruction.
CUBE
Matrix multiplication unit.
ICmiss
Missed iCache.