msOpST (Operator Test)

The msOpST tool is used to preliminarily test operator functions after operator development. It can be used to analyze and optimize operator performance more efficiently, improving the operator execution efficiency and reducing the development cost.

This sample generates an .om file of a single-operator based on the AscendCL API process and executes the file to verify the operator execution result.

  1. Generate ST cases.
    1. After Step 2 in "Creating an Operator Project" is complete, run the following command and replace the command path as instructed in msOpGen operator project directory:
      msopst create -i "$HOME/AddCustom/op_host/add_custom.cpp" -out ./st
    2. Generate ST cases.
      1
      2
      3
      4
      5
      2024-09-10 19:47:15 (3995495) - [INFO] Start to parse AscendC operator prototype definition in $HOME/AddCustom/op_host/add_custom.cpp.
      2024-09-10 19:47:15 (3995495) - [INFO] Start to check valid for op info.
      2024-09-10 19:47:15 (3995495) - [INFO] Finish to check valid for op info.
      2024-09-10 19:47:15 (3995495) - [INFO] Generate test case file $HOME/AddCustom/st/AddCustom_case_20240910194715.json successfully.
      2024-09-10 19:47:15 (3995495) - [INFO] Process finished!
      
    3. ST cases are generated in the ./st directory.
  2. Perform ST.
    1. Set environment variables based on the CANN package path.
      export DDK_PATH=${INSTALL_DIR}
      export NPU_HOST_LIB=${INSTALL_DIR}/{arch-os}/devlib  // In <arch-os>, arch and os indicate the OS architecture and OS of the operating environment, respectively.
    2. Perform ST and save the test result to a specified path.
      msopst run -i ./st/AddCustom_case_{TIMESTAMP}.json -soc Ascendxxxyy -out ./st/out   // xxxyy indicates the actual processor type.
      • Replace ${INSTALL_DIR} with the CANN component directory. For example, if the installation is performed by the root user, the default file storage path is /usr/local/Ascend/cann.
  3. After the test is successful, the test result is exported to the st.report.json file in the ./st/out/{TIMESTAMP}/ folder. For details, see Table 3.