CANN/asc-devkit Trap异常检测API
·
Trap
产品支持情况
功能说明
在Kernel侧调用,NPU模式下会中断AI Core的运行,CPU模式下等同于assert。可用于Kernel侧异常场景的调试。
函数原型
__aicore__ inline void Trap()
参数说明
无
返回值说明
无
约束说明
无。
调用示例
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);
}
更多推荐


所有评论(0)