Trap
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
x |
|
√ |
|
x |
|
x |
Function Usage
Interrupts the running of the AI Core in NPU mode, and functions similarly to assert in CPU mode when called on the kernel. It can be used to debug abnormal scenarios on the kernel.
Prototype
1 | __aicore__ inline void Trap() |
Parameters
None
Returns
None
Restrictions
None
Example
1 2 3 4 5 6 7 8 9 | AscendC::LocalTensor<half> src0Local; AscendC::LocalTensor<half> src1Local; AscendC::LocalTensor<half> dstLocal; constexpr int32_t count = 512; // Number of elements involved in computation if (src1Local[0] == 0) { // If the divisor is 0, an exception is reported. AscendC::Trap(); } else { AscendC::Divs(dstLocal, src0Local, src1Local[0], 512); } |
Parent topic: Exception Detection