From daf78ce6138387820bb8eb141bc7747f30908e6b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 27 Aug 2025 16:20:57 +0800 Subject: [PATCH 1/6] define SUCCESS to NPU_STATUS_SUCCESS --- torch_npu/csrc/core/npu/NPUEvent.cpp | 6 +++--- torch_npu/csrc/core/npu/NPUQueue.cpp | 2 +- torch_npu/csrc/core/npu/NPUStream.cpp | 10 +++++----- torch_npu/csrc/core/npu/npu_log.h | 2 +- torch_npu/csrc/framework/NPUDefine.cpp | 4 ++-- torch_npu/csrc/framework/utils/CalcuOpUtil.cpp | 2 +- torch_npu/csrc/npu/Module.cpp | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/torch_npu/csrc/core/npu/NPUEvent.cpp b/torch_npu/csrc/core/npu/NPUEvent.cpp index d956195154..38ff632196 100644 --- a/torch_npu/csrc/core/npu/NPUEvent.cpp +++ b/torch_npu/csrc/core/npu/NPUEvent.cpp @@ -107,7 +107,7 @@ float NPUEvent::elapsed_time(const NPUEvent& other) const "Both events must be recorded before calculating elapsed time.", PTA_ERROR(ErrCode::INTERNAL)); float time_ms = 0; NPUStatus ret = c10_npu::emptyAllNPUStream(); - if (ret != SUCCESS) { + if (ret != NPU_STATUS_SUCCESS) { ASCEND_LOGE("Failed to empty NPU task queue, ret: %s", ret.c_str()); } NPU_CHECK_ERROR_WITHOUT_UCE(aclrtSynchronizeEvent(event_)); @@ -130,7 +130,7 @@ uint64_t NPUEvent::recorded_time() const { TORCH_CHECK(is_created_, "Event must be recorded before getting recorded timestamp.", PTA_ERROR(ErrCode::INTERNAL)); NPUStatus ret = c10_npu::emptyAllNPUStream(); - if (ret != SUCCESS) { + if (ret != NPU_STATUS_SUCCESS) { ASCEND_LOGE("Failed to empty NPU task queue, ret: %s", ret.c_str()); } NPU_CHECK_ERROR_WITHOUT_UCE(aclrtSynchronizeEvent(event_)); @@ -151,7 +151,7 @@ void NPUEvent::synchronize() const { if (is_created_) { NPUStatus ret = c10_npu::emptyAllNPUStream(); - if (ret != SUCCESS) { + if (ret != NPU_STATUS_SUCCESS) { ASCEND_LOGE("MakeSureQueueEmpty fail, ret: %s", ret.c_str()); } NPU_CHECK_ERROR_WITHOUT_UCE(aclrtSynchronizeEvent(event_)); diff --git a/torch_npu/csrc/core/npu/NPUQueue.cpp b/torch_npu/csrc/core/npu/NPUQueue.cpp index fb234398da..fe7fc6c3dd 100644 --- a/torch_npu/csrc/core/npu/NPUQueue.cpp +++ b/torch_npu/csrc/core/npu/NPUQueue.cpp @@ -348,7 +348,7 @@ NPUStatus Repository::MakeSureQueueEmpty(bool check_error) logger->debug("MakeSureQueueEmpty: clearing successful, device = %d, write_idx = %u, read_idx = %u, status = %d", device_idx, write_idx.idx, read_idx.idx, GetStatus()); - return SUCCESS; + return NPU_STATUS_SUCCESS; } bool Repository::WriteQueue(void *cur_paras) diff --git a/torch_npu/csrc/core/npu/NPUStream.cpp b/torch_npu/csrc/core/npu/NPUStream.cpp index e7d0e405bf..9f85bff815 100644 --- a/torch_npu/csrc/core/npu/NPUStream.cpp +++ b/torch_npu/csrc/core/npu/NPUStream.cpp @@ -339,7 +339,7 @@ aclrtStream NPUStream::stream() const AT_ASSERT(ptr, PTA_ERROR(ErrCode::PTR)); if (!this->isSyncLaunchStream() && ptr->repo->CheckInit()) { NPUStatus ret = ptr->repo->MakeSureQueueEmpty(); - if (ret != SUCCESS) { + if (ret != NPU_STATUS_SUCCESS) { ASCEND_LOGE("MakeSureQueueEmpty fail, ret: %s", ret.c_str()); return nullptr; } @@ -436,12 +436,12 @@ NPUStatus emptyAllNPUStream(bool check_error) } if (default_streamsi.stream != nullptr && default_streamsi.repo->CheckInit()) { ret = default_streamsi.repo->MakeSureQueueEmpty(check_error); - if (ret != SUCCESS) { + if (ret != NPU_STATUS_SUCCESS) { return ret; } } } - return SUCCESS; + return NPU_STATUS_SUCCESS; } std::string getRepoInfo() @@ -488,7 +488,7 @@ bool npuSynchronizeDevice(bool check_error) { if (c10_npu::option::OptionsManager::GetTaskQueueEnable()) { NPUStatus ret = c10_npu::emptyAllNPUStream(check_error); - if (ret != SUCCESS) { + if (ret != NPU_STATUS_SUCCESS) { ASCEND_LOGE("MakeSureQueueEmpty fail, ret: %s", ret.c_str()); } } @@ -516,7 +516,7 @@ bool npuSynchronizeUsedDevices(bool check_error) { if (c10_npu::option::OptionsManager::GetTaskQueueEnable()) { NPUStatus ret = c10_npu::emptyAllNPUStream(check_error); - if (ret != SUCCESS) { + if (ret != NPU_STATUS_SUCCESS) { ASCEND_LOGE("MakeSureQueueEmpty fail, ret: %s", ret.c_str()); } } diff --git a/torch_npu/csrc/core/npu/npu_log.h b/torch_npu/csrc/core/npu/npu_log.h index 9cd3e5ec55..7733656095 100644 --- a/torch_npu/csrc/core/npu/npu_log.h +++ b/torch_npu/csrc/core/npu/npu_log.h @@ -7,7 +7,7 @@ #include "torch_npu/csrc/core/npu/register/OptionsManager.h" #define NPUStatus std::string -#define SUCCESS "SUCCESS" +#define NPU_STATUS_SUCCESS "SUCCESS" #define INTERNEL_ERROR "INTERNEL_ERROR" #define PARAM_ERROR "PARAM_ERROR" #define ALLOC_ERROR "ALLOC_ERROR" diff --git a/torch_npu/csrc/framework/NPUDefine.cpp b/torch_npu/csrc/framework/NPUDefine.cpp index 2bf90fffae..5902ceb9f0 100644 --- a/torch_npu/csrc/framework/NPUDefine.cpp +++ b/torch_npu/csrc/framework/NPUDefine.cpp @@ -12,7 +12,7 @@ void ExecuteParas::Release() } DestroyConstParams(constParams); NPUStatus ret = DestroyAclParams(paras); - if (ret != SUCCESS) { + if (ret != NPU_STATUS_SUCCESS) { ASCEND_LOGE("DestroyAclParams fail, ret: %s", ret.c_str()); } hostMemory.clear(); @@ -92,7 +92,7 @@ void ExecuteParas::Release() params.input_data_buf = nullptr; params.output_desc = nullptr; params.output_data_buf = nullptr; - return SUCCESS; + return NPU_STATUS_SUCCESS; } void DestroyConstParams(CONST_PARAMS ¶ms) diff --git a/torch_npu/csrc/framework/utils/CalcuOpUtil.cpp b/torch_npu/csrc/framework/utils/CalcuOpUtil.cpp index 4400c3e757..8339bd5022 100644 --- a/torch_npu/csrc/framework/utils/CalcuOpUtil.cpp +++ b/torch_npu/csrc/framework/utils/CalcuOpUtil.cpp @@ -191,7 +191,7 @@ NPUStatus CalcuOpUtil::AclrtMemcpyAsync(const std::pair &ds NPU_CHECK_ERROR( c10_npu::queue::LaunchAsyncCopyTask(dst_ptr, dst_size, const_cast(src_ptr), src_size, kind)); - return "SUCCESS"; + return "NPU_STATUS_SUCCESS"; } aclError CalcuOpUtil::AclrtMemcpyWithModeSwitch(const StorageAndOffsetMemSizePair &dst, diff --git a/torch_npu/csrc/npu/Module.cpp b/torch_npu/csrc/npu/Module.cpp index f187a0dd8c..65da2f7d4c 100644 --- a/torch_npu/csrc/npu/Module.cpp +++ b/torch_npu/csrc/npu/Module.cpp @@ -1621,7 +1621,7 @@ PyObject* THNPModule_aclnn_reselect_static_kernel(PyObject* self, PyObject* noar { HANDLE_TH_ERRORS NPUStatus ret = c10_npu::emptyAllNPUStream(); - TORCH_CHECK(ret == SUCCESS, "Failed to empty NPU task queue, ret:", ret, PTA_ERROR(ErrCode::INTERNAL)); + TORCH_CHECK(ret == NPU_STATUS_SUCCESS, "Failed to empty NPU task queue, ret:", ret, PTA_ERROR(ErrCode::INTERNAL)); static const auto task_queue_enable = c10_npu::option::OptionsManager::GetTaskQueueEnable(); if (task_queue_enable == 2) { @@ -1631,7 +1631,7 @@ PyObject* THNPModule_aclnn_reselect_static_kernel(PyObject* self, PyObject* noar }; at_npu::native::OpCommand::RunOpApiV2("reselect_static_kernel", acl_call); NPUStatus ret = c10_npu::emptyAllNPUStream(); - TORCH_CHECK(ret == SUCCESS, "Failed to empty NPU task queue, ret:", ret, PTA_ERROR(ErrCode::INTERNAL)); + TORCH_CHECK(ret == NPU_STATUS_SUCCESS, "Failed to empty NPU task queue, ret:", ret, PTA_ERROR(ErrCode::INTERNAL)); } else { c10_npu::opapi::ReselectStaticKernel(); } -- Gitee From 758619c011ca5bd5b369ac41e69b5cc05a3e1d82 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 27 Aug 2025 16:23:40 +0800 Subject: [PATCH 2/6] define SUCCESS to NPU_STATUS_SUCCESS --- torch_npu/csrc/core/npu/NPUQueue.cpp | 2 +- torch_npu/csrc/core/npu/npu_log.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/torch_npu/csrc/core/npu/NPUQueue.cpp b/torch_npu/csrc/core/npu/NPUQueue.cpp index fe7fc6c3dd..5605f9a4d3 100644 --- a/torch_npu/csrc/core/npu/NPUQueue.cpp +++ b/torch_npu/csrc/core/npu/NPUQueue.cpp @@ -244,7 +244,7 @@ NPUStatus Repository::MakeSureQueueEmpty(bool check_error) std::string runtime_error; if (initialized == false) { ASCEND_LOGE("Task queue is not initialized, shouldn't call MakeSureQueueEmpty(). !!"); - return FAILED; + return NPU_STATUS_FAILED; } ASCEND_LOGI("Begin to makesure taskqueue empty."); // While waiting for ACL thread to launch tasks, diff --git a/torch_npu/csrc/core/npu/npu_log.h b/torch_npu/csrc/core/npu/npu_log.h index 7733656095..f511f7cb91 100644 --- a/torch_npu/csrc/core/npu/npu_log.h +++ b/torch_npu/csrc/core/npu/npu_log.h @@ -11,7 +11,7 @@ #define INTERNEL_ERROR "INTERNEL_ERROR" #define PARAM_ERROR "PARAM_ERROR" #define ALLOC_ERROR "ALLOC_ERROR" -#define FAILED "FAILED" +#define NPU_STATUS_FAILED "FAILED" #define ASCEND_LOGE(fmt, ...) \ do { \ -- Gitee From 0ee7e3736b6d0f1bafb78928f4859be221a668ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A5=E5=AE=AA=E6=9E=97?= Date: Wed, 27 Aug 2025 12:27:50 +0000 Subject: [PATCH 3/6] Revert "define SUCCESS to NPU_STATUS_SUCCESS" This reverts commit 758619c011ca5bd5b369ac41e69b5cc05a3e1d82. --- torch_npu/csrc/core/npu/NPUQueue.cpp | 2 +- torch_npu/csrc/core/npu/npu_log.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/torch_npu/csrc/core/npu/NPUQueue.cpp b/torch_npu/csrc/core/npu/NPUQueue.cpp index 5605f9a4d3..fe7fc6c3dd 100644 --- a/torch_npu/csrc/core/npu/NPUQueue.cpp +++ b/torch_npu/csrc/core/npu/NPUQueue.cpp @@ -244,7 +244,7 @@ NPUStatus Repository::MakeSureQueueEmpty(bool check_error) std::string runtime_error; if (initialized == false) { ASCEND_LOGE("Task queue is not initialized, shouldn't call MakeSureQueueEmpty(). !!"); - return NPU_STATUS_FAILED; + return FAILED; } ASCEND_LOGI("Begin to makesure taskqueue empty."); // While waiting for ACL thread to launch tasks, diff --git a/torch_npu/csrc/core/npu/npu_log.h b/torch_npu/csrc/core/npu/npu_log.h index f511f7cb91..7733656095 100644 --- a/torch_npu/csrc/core/npu/npu_log.h +++ b/torch_npu/csrc/core/npu/npu_log.h @@ -11,7 +11,7 @@ #define INTERNEL_ERROR "INTERNEL_ERROR" #define PARAM_ERROR "PARAM_ERROR" #define ALLOC_ERROR "ALLOC_ERROR" -#define NPU_STATUS_FAILED "FAILED" +#define FAILED "FAILED" #define ASCEND_LOGE(fmt, ...) \ do { \ -- Gitee From d377eedf66bb5c5ddc2ed882f7d604284f09f705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A5=E5=AE=AA=E6=9E=97?= Date: Wed, 27 Aug 2025 12:28:21 +0000 Subject: [PATCH 4/6] Revert "define SUCCESS to NPU_STATUS_SUCCESS" This reverts commit daf78ce6138387820bb8eb141bc7747f30908e6b. --- torch_npu/csrc/core/npu/NPUEvent.cpp | 6 +++--- torch_npu/csrc/core/npu/NPUQueue.cpp | 2 +- torch_npu/csrc/core/npu/NPUStream.cpp | 10 +++++----- torch_npu/csrc/core/npu/npu_log.h | 2 +- torch_npu/csrc/framework/NPUDefine.cpp | 4 ++-- torch_npu/csrc/framework/utils/CalcuOpUtil.cpp | 2 +- torch_npu/csrc/npu/Module.cpp | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/torch_npu/csrc/core/npu/NPUEvent.cpp b/torch_npu/csrc/core/npu/NPUEvent.cpp index 38ff632196..d956195154 100644 --- a/torch_npu/csrc/core/npu/NPUEvent.cpp +++ b/torch_npu/csrc/core/npu/NPUEvent.cpp @@ -107,7 +107,7 @@ float NPUEvent::elapsed_time(const NPUEvent& other) const "Both events must be recorded before calculating elapsed time.", PTA_ERROR(ErrCode::INTERNAL)); float time_ms = 0; NPUStatus ret = c10_npu::emptyAllNPUStream(); - if (ret != NPU_STATUS_SUCCESS) { + if (ret != SUCCESS) { ASCEND_LOGE("Failed to empty NPU task queue, ret: %s", ret.c_str()); } NPU_CHECK_ERROR_WITHOUT_UCE(aclrtSynchronizeEvent(event_)); @@ -130,7 +130,7 @@ uint64_t NPUEvent::recorded_time() const { TORCH_CHECK(is_created_, "Event must be recorded before getting recorded timestamp.", PTA_ERROR(ErrCode::INTERNAL)); NPUStatus ret = c10_npu::emptyAllNPUStream(); - if (ret != NPU_STATUS_SUCCESS) { + if (ret != SUCCESS) { ASCEND_LOGE("Failed to empty NPU task queue, ret: %s", ret.c_str()); } NPU_CHECK_ERROR_WITHOUT_UCE(aclrtSynchronizeEvent(event_)); @@ -151,7 +151,7 @@ void NPUEvent::synchronize() const { if (is_created_) { NPUStatus ret = c10_npu::emptyAllNPUStream(); - if (ret != NPU_STATUS_SUCCESS) { + if (ret != SUCCESS) { ASCEND_LOGE("MakeSureQueueEmpty fail, ret: %s", ret.c_str()); } NPU_CHECK_ERROR_WITHOUT_UCE(aclrtSynchronizeEvent(event_)); diff --git a/torch_npu/csrc/core/npu/NPUQueue.cpp b/torch_npu/csrc/core/npu/NPUQueue.cpp index fe7fc6c3dd..fb234398da 100644 --- a/torch_npu/csrc/core/npu/NPUQueue.cpp +++ b/torch_npu/csrc/core/npu/NPUQueue.cpp @@ -348,7 +348,7 @@ NPUStatus Repository::MakeSureQueueEmpty(bool check_error) logger->debug("MakeSureQueueEmpty: clearing successful, device = %d, write_idx = %u, read_idx = %u, status = %d", device_idx, write_idx.idx, read_idx.idx, GetStatus()); - return NPU_STATUS_SUCCESS; + return SUCCESS; } bool Repository::WriteQueue(void *cur_paras) diff --git a/torch_npu/csrc/core/npu/NPUStream.cpp b/torch_npu/csrc/core/npu/NPUStream.cpp index 9f85bff815..e7d0e405bf 100644 --- a/torch_npu/csrc/core/npu/NPUStream.cpp +++ b/torch_npu/csrc/core/npu/NPUStream.cpp @@ -339,7 +339,7 @@ aclrtStream NPUStream::stream() const AT_ASSERT(ptr, PTA_ERROR(ErrCode::PTR)); if (!this->isSyncLaunchStream() && ptr->repo->CheckInit()) { NPUStatus ret = ptr->repo->MakeSureQueueEmpty(); - if (ret != NPU_STATUS_SUCCESS) { + if (ret != SUCCESS) { ASCEND_LOGE("MakeSureQueueEmpty fail, ret: %s", ret.c_str()); return nullptr; } @@ -436,12 +436,12 @@ NPUStatus emptyAllNPUStream(bool check_error) } if (default_streamsi.stream != nullptr && default_streamsi.repo->CheckInit()) { ret = default_streamsi.repo->MakeSureQueueEmpty(check_error); - if (ret != NPU_STATUS_SUCCESS) { + if (ret != SUCCESS) { return ret; } } } - return NPU_STATUS_SUCCESS; + return SUCCESS; } std::string getRepoInfo() @@ -488,7 +488,7 @@ bool npuSynchronizeDevice(bool check_error) { if (c10_npu::option::OptionsManager::GetTaskQueueEnable()) { NPUStatus ret = c10_npu::emptyAllNPUStream(check_error); - if (ret != NPU_STATUS_SUCCESS) { + if (ret != SUCCESS) { ASCEND_LOGE("MakeSureQueueEmpty fail, ret: %s", ret.c_str()); } } @@ -516,7 +516,7 @@ bool npuSynchronizeUsedDevices(bool check_error) { if (c10_npu::option::OptionsManager::GetTaskQueueEnable()) { NPUStatus ret = c10_npu::emptyAllNPUStream(check_error); - if (ret != NPU_STATUS_SUCCESS) { + if (ret != SUCCESS) { ASCEND_LOGE("MakeSureQueueEmpty fail, ret: %s", ret.c_str()); } } diff --git a/torch_npu/csrc/core/npu/npu_log.h b/torch_npu/csrc/core/npu/npu_log.h index 7733656095..9cd3e5ec55 100644 --- a/torch_npu/csrc/core/npu/npu_log.h +++ b/torch_npu/csrc/core/npu/npu_log.h @@ -7,7 +7,7 @@ #include "torch_npu/csrc/core/npu/register/OptionsManager.h" #define NPUStatus std::string -#define NPU_STATUS_SUCCESS "SUCCESS" +#define SUCCESS "SUCCESS" #define INTERNEL_ERROR "INTERNEL_ERROR" #define PARAM_ERROR "PARAM_ERROR" #define ALLOC_ERROR "ALLOC_ERROR" diff --git a/torch_npu/csrc/framework/NPUDefine.cpp b/torch_npu/csrc/framework/NPUDefine.cpp index 5902ceb9f0..2bf90fffae 100644 --- a/torch_npu/csrc/framework/NPUDefine.cpp +++ b/torch_npu/csrc/framework/NPUDefine.cpp @@ -12,7 +12,7 @@ void ExecuteParas::Release() } DestroyConstParams(constParams); NPUStatus ret = DestroyAclParams(paras); - if (ret != NPU_STATUS_SUCCESS) { + if (ret != SUCCESS) { ASCEND_LOGE("DestroyAclParams fail, ret: %s", ret.c_str()); } hostMemory.clear(); @@ -92,7 +92,7 @@ void ExecuteParas::Release() params.input_data_buf = nullptr; params.output_desc = nullptr; params.output_data_buf = nullptr; - return NPU_STATUS_SUCCESS; + return SUCCESS; } void DestroyConstParams(CONST_PARAMS ¶ms) diff --git a/torch_npu/csrc/framework/utils/CalcuOpUtil.cpp b/torch_npu/csrc/framework/utils/CalcuOpUtil.cpp index 8339bd5022..4400c3e757 100644 --- a/torch_npu/csrc/framework/utils/CalcuOpUtil.cpp +++ b/torch_npu/csrc/framework/utils/CalcuOpUtil.cpp @@ -191,7 +191,7 @@ NPUStatus CalcuOpUtil::AclrtMemcpyAsync(const std::pair &ds NPU_CHECK_ERROR( c10_npu::queue::LaunchAsyncCopyTask(dst_ptr, dst_size, const_cast(src_ptr), src_size, kind)); - return "NPU_STATUS_SUCCESS"; + return "SUCCESS"; } aclError CalcuOpUtil::AclrtMemcpyWithModeSwitch(const StorageAndOffsetMemSizePair &dst, diff --git a/torch_npu/csrc/npu/Module.cpp b/torch_npu/csrc/npu/Module.cpp index 65da2f7d4c..f187a0dd8c 100644 --- a/torch_npu/csrc/npu/Module.cpp +++ b/torch_npu/csrc/npu/Module.cpp @@ -1621,7 +1621,7 @@ PyObject* THNPModule_aclnn_reselect_static_kernel(PyObject* self, PyObject* noar { HANDLE_TH_ERRORS NPUStatus ret = c10_npu::emptyAllNPUStream(); - TORCH_CHECK(ret == NPU_STATUS_SUCCESS, "Failed to empty NPU task queue, ret:", ret, PTA_ERROR(ErrCode::INTERNAL)); + TORCH_CHECK(ret == SUCCESS, "Failed to empty NPU task queue, ret:", ret, PTA_ERROR(ErrCode::INTERNAL)); static const auto task_queue_enable = c10_npu::option::OptionsManager::GetTaskQueueEnable(); if (task_queue_enable == 2) { @@ -1631,7 +1631,7 @@ PyObject* THNPModule_aclnn_reselect_static_kernel(PyObject* self, PyObject* noar }; at_npu::native::OpCommand::RunOpApiV2("reselect_static_kernel", acl_call); NPUStatus ret = c10_npu::emptyAllNPUStream(); - TORCH_CHECK(ret == NPU_STATUS_SUCCESS, "Failed to empty NPU task queue, ret:", ret, PTA_ERROR(ErrCode::INTERNAL)); + TORCH_CHECK(ret == SUCCESS, "Failed to empty NPU task queue, ret:", ret, PTA_ERROR(ErrCode::INTERNAL)); } else { c10_npu::opapi::ReselectStaticKernel(); } -- Gitee From ea76722967128f445ac95310f8f5b2f69886dd52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A5=E5=AE=AA=E6=9E=97?= Date: Wed, 27 Aug 2025 12:29:07 +0000 Subject: [PATCH 5/6] Revert "Revert "define SUCCESS to NPU_STATUS_SUCCESS"" This reverts commit d377eedf66bb5c5ddc2ed882f7d604284f09f705. --- torch_npu/csrc/core/npu/NPUEvent.cpp | 6 +++--- torch_npu/csrc/core/npu/NPUQueue.cpp | 2 +- torch_npu/csrc/core/npu/NPUStream.cpp | 10 +++++----- torch_npu/csrc/core/npu/npu_log.h | 2 +- torch_npu/csrc/framework/NPUDefine.cpp | 4 ++-- torch_npu/csrc/framework/utils/CalcuOpUtil.cpp | 2 +- torch_npu/csrc/npu/Module.cpp | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/torch_npu/csrc/core/npu/NPUEvent.cpp b/torch_npu/csrc/core/npu/NPUEvent.cpp index d956195154..38ff632196 100644 --- a/torch_npu/csrc/core/npu/NPUEvent.cpp +++ b/torch_npu/csrc/core/npu/NPUEvent.cpp @@ -107,7 +107,7 @@ float NPUEvent::elapsed_time(const NPUEvent& other) const "Both events must be recorded before calculating elapsed time.", PTA_ERROR(ErrCode::INTERNAL)); float time_ms = 0; NPUStatus ret = c10_npu::emptyAllNPUStream(); - if (ret != SUCCESS) { + if (ret != NPU_STATUS_SUCCESS) { ASCEND_LOGE("Failed to empty NPU task queue, ret: %s", ret.c_str()); } NPU_CHECK_ERROR_WITHOUT_UCE(aclrtSynchronizeEvent(event_)); @@ -130,7 +130,7 @@ uint64_t NPUEvent::recorded_time() const { TORCH_CHECK(is_created_, "Event must be recorded before getting recorded timestamp.", PTA_ERROR(ErrCode::INTERNAL)); NPUStatus ret = c10_npu::emptyAllNPUStream(); - if (ret != SUCCESS) { + if (ret != NPU_STATUS_SUCCESS) { ASCEND_LOGE("Failed to empty NPU task queue, ret: %s", ret.c_str()); } NPU_CHECK_ERROR_WITHOUT_UCE(aclrtSynchronizeEvent(event_)); @@ -151,7 +151,7 @@ void NPUEvent::synchronize() const { if (is_created_) { NPUStatus ret = c10_npu::emptyAllNPUStream(); - if (ret != SUCCESS) { + if (ret != NPU_STATUS_SUCCESS) { ASCEND_LOGE("MakeSureQueueEmpty fail, ret: %s", ret.c_str()); } NPU_CHECK_ERROR_WITHOUT_UCE(aclrtSynchronizeEvent(event_)); diff --git a/torch_npu/csrc/core/npu/NPUQueue.cpp b/torch_npu/csrc/core/npu/NPUQueue.cpp index fb234398da..fe7fc6c3dd 100644 --- a/torch_npu/csrc/core/npu/NPUQueue.cpp +++ b/torch_npu/csrc/core/npu/NPUQueue.cpp @@ -348,7 +348,7 @@ NPUStatus Repository::MakeSureQueueEmpty(bool check_error) logger->debug("MakeSureQueueEmpty: clearing successful, device = %d, write_idx = %u, read_idx = %u, status = %d", device_idx, write_idx.idx, read_idx.idx, GetStatus()); - return SUCCESS; + return NPU_STATUS_SUCCESS; } bool Repository::WriteQueue(void *cur_paras) diff --git a/torch_npu/csrc/core/npu/NPUStream.cpp b/torch_npu/csrc/core/npu/NPUStream.cpp index e7d0e405bf..9f85bff815 100644 --- a/torch_npu/csrc/core/npu/NPUStream.cpp +++ b/torch_npu/csrc/core/npu/NPUStream.cpp @@ -339,7 +339,7 @@ aclrtStream NPUStream::stream() const AT_ASSERT(ptr, PTA_ERROR(ErrCode::PTR)); if (!this->isSyncLaunchStream() && ptr->repo->CheckInit()) { NPUStatus ret = ptr->repo->MakeSureQueueEmpty(); - if (ret != SUCCESS) { + if (ret != NPU_STATUS_SUCCESS) { ASCEND_LOGE("MakeSureQueueEmpty fail, ret: %s", ret.c_str()); return nullptr; } @@ -436,12 +436,12 @@ NPUStatus emptyAllNPUStream(bool check_error) } if (default_streamsi.stream != nullptr && default_streamsi.repo->CheckInit()) { ret = default_streamsi.repo->MakeSureQueueEmpty(check_error); - if (ret != SUCCESS) { + if (ret != NPU_STATUS_SUCCESS) { return ret; } } } - return SUCCESS; + return NPU_STATUS_SUCCESS; } std::string getRepoInfo() @@ -488,7 +488,7 @@ bool npuSynchronizeDevice(bool check_error) { if (c10_npu::option::OptionsManager::GetTaskQueueEnable()) { NPUStatus ret = c10_npu::emptyAllNPUStream(check_error); - if (ret != SUCCESS) { + if (ret != NPU_STATUS_SUCCESS) { ASCEND_LOGE("MakeSureQueueEmpty fail, ret: %s", ret.c_str()); } } @@ -516,7 +516,7 @@ bool npuSynchronizeUsedDevices(bool check_error) { if (c10_npu::option::OptionsManager::GetTaskQueueEnable()) { NPUStatus ret = c10_npu::emptyAllNPUStream(check_error); - if (ret != SUCCESS) { + if (ret != NPU_STATUS_SUCCESS) { ASCEND_LOGE("MakeSureQueueEmpty fail, ret: %s", ret.c_str()); } } diff --git a/torch_npu/csrc/core/npu/npu_log.h b/torch_npu/csrc/core/npu/npu_log.h index 9cd3e5ec55..7733656095 100644 --- a/torch_npu/csrc/core/npu/npu_log.h +++ b/torch_npu/csrc/core/npu/npu_log.h @@ -7,7 +7,7 @@ #include "torch_npu/csrc/core/npu/register/OptionsManager.h" #define NPUStatus std::string -#define SUCCESS "SUCCESS" +#define NPU_STATUS_SUCCESS "SUCCESS" #define INTERNEL_ERROR "INTERNEL_ERROR" #define PARAM_ERROR "PARAM_ERROR" #define ALLOC_ERROR "ALLOC_ERROR" diff --git a/torch_npu/csrc/framework/NPUDefine.cpp b/torch_npu/csrc/framework/NPUDefine.cpp index 2bf90fffae..5902ceb9f0 100644 --- a/torch_npu/csrc/framework/NPUDefine.cpp +++ b/torch_npu/csrc/framework/NPUDefine.cpp @@ -12,7 +12,7 @@ void ExecuteParas::Release() } DestroyConstParams(constParams); NPUStatus ret = DestroyAclParams(paras); - if (ret != SUCCESS) { + if (ret != NPU_STATUS_SUCCESS) { ASCEND_LOGE("DestroyAclParams fail, ret: %s", ret.c_str()); } hostMemory.clear(); @@ -92,7 +92,7 @@ void ExecuteParas::Release() params.input_data_buf = nullptr; params.output_desc = nullptr; params.output_data_buf = nullptr; - return SUCCESS; + return NPU_STATUS_SUCCESS; } void DestroyConstParams(CONST_PARAMS ¶ms) diff --git a/torch_npu/csrc/framework/utils/CalcuOpUtil.cpp b/torch_npu/csrc/framework/utils/CalcuOpUtil.cpp index 4400c3e757..8339bd5022 100644 --- a/torch_npu/csrc/framework/utils/CalcuOpUtil.cpp +++ b/torch_npu/csrc/framework/utils/CalcuOpUtil.cpp @@ -191,7 +191,7 @@ NPUStatus CalcuOpUtil::AclrtMemcpyAsync(const std::pair &ds NPU_CHECK_ERROR( c10_npu::queue::LaunchAsyncCopyTask(dst_ptr, dst_size, const_cast(src_ptr), src_size, kind)); - return "SUCCESS"; + return "NPU_STATUS_SUCCESS"; } aclError CalcuOpUtil::AclrtMemcpyWithModeSwitch(const StorageAndOffsetMemSizePair &dst, diff --git a/torch_npu/csrc/npu/Module.cpp b/torch_npu/csrc/npu/Module.cpp index f187a0dd8c..65da2f7d4c 100644 --- a/torch_npu/csrc/npu/Module.cpp +++ b/torch_npu/csrc/npu/Module.cpp @@ -1621,7 +1621,7 @@ PyObject* THNPModule_aclnn_reselect_static_kernel(PyObject* self, PyObject* noar { HANDLE_TH_ERRORS NPUStatus ret = c10_npu::emptyAllNPUStream(); - TORCH_CHECK(ret == SUCCESS, "Failed to empty NPU task queue, ret:", ret, PTA_ERROR(ErrCode::INTERNAL)); + TORCH_CHECK(ret == NPU_STATUS_SUCCESS, "Failed to empty NPU task queue, ret:", ret, PTA_ERROR(ErrCode::INTERNAL)); static const auto task_queue_enable = c10_npu::option::OptionsManager::GetTaskQueueEnable(); if (task_queue_enable == 2) { @@ -1631,7 +1631,7 @@ PyObject* THNPModule_aclnn_reselect_static_kernel(PyObject* self, PyObject* noar }; at_npu::native::OpCommand::RunOpApiV2("reselect_static_kernel", acl_call); NPUStatus ret = c10_npu::emptyAllNPUStream(); - TORCH_CHECK(ret == SUCCESS, "Failed to empty NPU task queue, ret:", ret, PTA_ERROR(ErrCode::INTERNAL)); + TORCH_CHECK(ret == NPU_STATUS_SUCCESS, "Failed to empty NPU task queue, ret:", ret, PTA_ERROR(ErrCode::INTERNAL)); } else { c10_npu::opapi::ReselectStaticKernel(); } -- Gitee From c754ebfd97c7c92af03e97c9a93ff60bb2bc40ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A5=E5=AE=AA=E6=9E=97?= Date: Wed, 27 Aug 2025 12:29:26 +0000 Subject: [PATCH 6/6] Revert "Revert "define SUCCESS to NPU_STATUS_SUCCESS"" This reverts commit 0ee7e3736b6d0f1bafb78928f4859be221a668ee. --- torch_npu/csrc/core/npu/NPUQueue.cpp | 2 +- torch_npu/csrc/core/npu/npu_log.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/torch_npu/csrc/core/npu/NPUQueue.cpp b/torch_npu/csrc/core/npu/NPUQueue.cpp index fe7fc6c3dd..5605f9a4d3 100644 --- a/torch_npu/csrc/core/npu/NPUQueue.cpp +++ b/torch_npu/csrc/core/npu/NPUQueue.cpp @@ -244,7 +244,7 @@ NPUStatus Repository::MakeSureQueueEmpty(bool check_error) std::string runtime_error; if (initialized == false) { ASCEND_LOGE("Task queue is not initialized, shouldn't call MakeSureQueueEmpty(). !!"); - return FAILED; + return NPU_STATUS_FAILED; } ASCEND_LOGI("Begin to makesure taskqueue empty."); // While waiting for ACL thread to launch tasks, diff --git a/torch_npu/csrc/core/npu/npu_log.h b/torch_npu/csrc/core/npu/npu_log.h index 7733656095..f511f7cb91 100644 --- a/torch_npu/csrc/core/npu/npu_log.h +++ b/torch_npu/csrc/core/npu/npu_log.h @@ -11,7 +11,7 @@ #define INTERNEL_ERROR "INTERNEL_ERROR" #define PARAM_ERROR "PARAM_ERROR" #define ALLOC_ERROR "ALLOC_ERROR" -#define FAILED "FAILED" +#define NPU_STATUS_FAILED "FAILED" #define ASCEND_LOGE(fmt, ...) \ do { \ -- Gitee