Trap
产 品 支 持 情 况
功 能 说 明
头 文 件 路 径 为:"basic_api/kernel_operator_sys_var_intf.h"。
在Kernel侧 调 用,NPU模 式 下 会 中 断AI Core的 运 行,CPU模 式 下 等 同 于assert。可 用 于Kernel侧 异 常 场 景 的 调 试。
函 数 原 型
C++
__aicore__ inline void Trap()
参 数 说 明
无
返 回 值 说 明
无
约 束 说 明
无。
调 用 示 例
C++
AscendC::LocalTensor<half> src0Local;
AscendC::LocalTensor<half> src1Local;
AscendC::LocalTensor<half> dstLocal;
constexpr int32_t count = 512; // 参 与 计 算 的 元 素 个 数。
if (src1Local[0] == 0) { // 如 果src1Local[0]为0,则 程 序 终 止。
AscendC::Trap();
} else {
AscendC::Divs(dstLocal, src0Local, src1Local[0], count);
}