需要打桩的代码文件可以分为编译阶段和链接阶段。
Add算子可执行文件的构建命令示例如下:
bash run.sh add_custom <soc_version> VectorCore npu
一键式编译运行脚本完成后,在工程目录下生成NPU侧可执行文件add_custom_npu。
mssanitizer --tool=memcheck --leak-check=yes ./add_custom_npu
单算子可执行文件add_custom_npu所在路径可配置为绝对路径或相对路径,请根据实际环境配置。
__aicore__ inline void CopyOut(int32_t progress) { // deque output tensor from VECOUT queue LocalTensor<half> zLocal = outQueueZ.DeQue<half>(); // copy progress_th tile from local tensor to global tensor // 构建非法读写场景 DataCopy(zGm[progress * TILE_LENGTH], zLocal, 2 * TILE_LENGTH); // free output tensor for reuse outQueueZ.FreeTensor(zLocal); }
$ mssanitizer --tool=memcheck --leak-check=yes ./add_custom_npu [mssanitizer] logging to file: ./mssanitizer_20240124182331_37743.log ====== ERROR: illegel read of size 256 ====== at 0x124080022f00 on GM ====== code in add_custom.cpp:63