Trap
产品支持情况
产品 |
是否支持 |
|---|---|
√ |
|
√ |
|
x |
|
√ |
|
x |
|
x |
功能说明
在Kernel侧调用,NPU模式下会中断AI Core的运行,CPU模式下等同于assert。可用于Kernel侧异常场景的调试。
函数原型
1 | __aicore__ inline void Trap() |
参数说明
无
返回值说明
无
约束说明
无。
调用示例
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; // 参与计算的元素个数 if (src1Local[0] == 0) { // 如果除数为0,则报异常 AscendC::Trap(); } else { AscendC::Divs(dstLocal, src0Local, src1Local[0], 512); } |
父主题: 异常检测