Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.
HarmonyOS
When the tool is used for operator debugging, the assert function is supported. It is used to interrupt the running process immediately and print related information when the condition in the kernel code is false, facilitating quick fault locating.
The maximum available space allocated to each core for printing data is fixed at 1 MB. If the printing size exceeds 1 MB, the printed content will not be displayed. Therefore, the amount of data to be printed needs to be controlled.
In the kernel function code, call the assert API at the target position as required. For details, see the API description. The following is an example:
int32_t x = 31; assert(x < 0, "Invalid input_num: %d\n", x);
In the simulator debugging scenario, run the following command to enable the dump function:
ascendebug kernel --backend simulator --dump-mode normal ... {other simulator debugging parameters} --Set dump-mode to normal to enable the general printing Scalar mode. Set other parameters by referring to NPU Debugging Parameters.
View the assertion result.
If the judgment condition is false, the program is interrupted and the assertion (with the file name and line number) is displayed on the screen. The following is an example:
[ASSERT] /home/.../add_custom.cpp:94: Assertion `x < 0' Invalid input_num: 31
The assert API is described as follows:
Prototype: __aicore__ inline void assert(bool assertFlag, __gm__ const char* fmt, Args&&...args);
Function usage: Debugs programs. Checks whether a condition is true when the program is running. If the condition is false, the program is interrupted immediately and the information is printed.
Parameter (IN):
Parameter (OUT): N/A
Return value: N/A
Restrictions:
Calling example:
assert(input_num > 0, "Invalid input_num: %d ", input_num);
Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
Quick start
Helps you find desired resources with ease.