Detecting AscendCL-Called Single Operators
After the custom operator is developed and deployed, use the single-operator API to call the operator, add detection-related compilation options, rebuild and deploy the operator, and use msSanitizer to run the executable file to detect exceptions of the operator.
Procedure
- Run the following command to generate a custom operator project and provide the operator implementation on the host and kernel:
bash install.sh -v Ascendxxxyy # xxxyy indicates the processor type.
- Compile and deploy the operator by referring to Compiling and Deploying Operators.
In the ${git_clone_path}/samples/operator/ascendc/0_introduction/1_add_frameworklaunch/CustomOp directory of the sample project, modify the op_kernel/CMakeLists.txt file and add the detection option -sanitizer to the kernel implementation to support the detection function.
1add_ops_compile_options(ALL OPTIONS -sanitizer)
- Obtain the sample project for verifying the code by referring to Prerequisite.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
├──input // Directory for storing the input data generated by the script ├──output // Directory for storing the output data and truth value generated during operator execution ├── inc // Header file directory │ ├── common.h // Common method class declaration file, used to read binary files │ ├── operator_desc.h // Operator description declaration file, including the operator input and output, operator type, input description, and output description │ ├── op_runner.h // Operator execution information declaration file, including the numbers and sizes of operator input and output ├── src │ ├── CMakeLists.txt // Compilation script │ ├── common.cpp // Common function file, used to read binary files │ ├── main.cpp // Entry for single-operator execution │ ├── operator_desc.cpp // File used to construct the input and output description of the operator │ ├── op_runner.cpp // Main process implementation file for single-operator execution ├── scripts │ ├── verify_result.py // Truth value comparison file │ ├── gen_data.py // Script file for generating the input data and truth value │ ├── acl.json // ACL configuration file
- Use the detection tool to start the operator API to run the script.
mssanitizer --tool=memcheck bash run.sh # Specify --tool=memcheck for memory check. mssanitizer --tool=racecheck bash run.sh # Specify --tool=racecheck for contention detection.
- Analyze abnormal behavior by referring to Memory Exception Report Parsing and Analyzing Contention Check Report.
Parent topic: Typical Cases