From 3c5efd5f19a3a6e03cf23a0848bf35aa8d5c6754 Mon Sep 17 00:00:00 2001 From: wangchao Date: Thu, 4 Sep 2025 14:13:51 +0800 Subject: [PATCH 1/2] fix log print with taskqueue exec func --- torch_npu/csrc/framework/OpParamMaker.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/torch_npu/csrc/framework/OpParamMaker.cpp b/torch_npu/csrc/framework/OpParamMaker.cpp index 3abd06421a..9e5f8eb9ae 100644 --- a/torch_npu/csrc/framework/OpParamMaker.cpp +++ b/torch_npu/csrc/framework/OpParamMaker.cpp @@ -347,10 +347,13 @@ int ExecFunc(c10_npu::queue::QueueParas *in, aclrtStream stream) ret = ACL_ERROR_INVALID_PARAM; LOG(ERROR) << e.what(); } - ASCEND_LOGE("Custom hand error:%s", e.what()); + // Keep only 512 characters to avoid failure of copying and inability to print. + std::string errorMsg = std::string(e.what()).substr(0, 512); + ASCEND_LOGE("Custom hand error:%s", errorMsg.c_str()); + logger->long_info("ExecFunc: Op %s Run, Custom hand error:%s.", cur_paras->opType, e.what()); } if (ret != ACL_ERROR_NONE) { - ASCEND_LOGE("Custom hand fail! name=%s, ret=0x%#x", cur_paras->opType, ret); + ASCEND_LOGE("Custom hand fail! name=%s, ret=%d", cur_paras->opType, ret); } logger->debug("ExecFunc: Op %s Run with customHandler, ret = %d.", cur_paras->opType, ret); return ret; @@ -438,10 +441,13 @@ int ExecFuncOpApi(c10_npu::queue::QueueParas *in, aclrtStream stream) ret = ACL_ERROR_INVALID_PARAM; LOG(ERROR) << e.what(); } - ASCEND_LOGE("Custom hand error:%s", e.what()); + // Keep only 512 characters to avoid failure of copying and inability to print. + std::string errorMsg = std::string(e.what()).substr(0, 512); + ASCEND_LOGE("Custom hand error:%s", errorMsg.c_str()); + logger->long_info("ExecFunc: Op %s Run, Custom hand error:%s.", cur_paras->opType, e.what()); } if (ret != ACL_ERROR_NONE) { - ASCEND_LOGE("Custom hand fail! name=%s, ret=0x%#x", cur_paras->opType, ret); + ASCEND_LOGE("Custom hand fail! name=%s, ret=%d", cur_paras->opType, ret); } logger->debug("ExecFuncOpApi: Op %s Run, ret = %d.", cur_paras->opType, ret); return ret; -- Gitee From 9d71452f120d13da4186c563a99fff1daef035ff Mon Sep 17 00:00:00 2001 From: wangchao Date: Thu, 4 Sep 2025 16:11:25 +0800 Subject: [PATCH 2/2] fix log print --- torch_npu/csrc/framework/OpParamMaker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torch_npu/csrc/framework/OpParamMaker.cpp b/torch_npu/csrc/framework/OpParamMaker.cpp index 9e5f8eb9ae..11a39af085 100644 --- a/torch_npu/csrc/framework/OpParamMaker.cpp +++ b/torch_npu/csrc/framework/OpParamMaker.cpp @@ -444,7 +444,7 @@ int ExecFuncOpApi(c10_npu::queue::QueueParas *in, aclrtStream stream) // Keep only 512 characters to avoid failure of copying and inability to print. std::string errorMsg = std::string(e.what()).substr(0, 512); ASCEND_LOGE("Custom hand error:%s", errorMsg.c_str()); - logger->long_info("ExecFunc: Op %s Run, Custom hand error:%s.", cur_paras->opType, e.what()); + logger->long_info("ExecFuncOpApi: Op %s Run, Custom hand error:%s.", cur_paras->opType, e.what()); } if (ret != ACL_ERROR_NONE) { ASCEND_LOGE("Custom hand fail! name=%s, ret=%d", cur_paras->opType, ret); -- Gitee