Trap

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

x

Atlas inference product AI Core

Atlas inference product Vector Core

x

Atlas training product

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);
}