Merged
fix(machine): Replace assert with abort in DEV_ASSERT marco #2676
lipeijieAdd on Apr 21
fix(machine): Replace assert with abort in DEV_ASSERT marco #2676
Merged
Merged fromarthur_morgan_hw/pyptobr_bugfixintocann/pyptomaster
Total: 6 files changed+27-27
| @@ -206,8 +206,7 @@ private: | |||
| 206 | #define COMPILER_LOGD(...) PYPTO_HOST_LOG(DLOG_DEBUG, COMPILER_MONITOR, __VA_ARGS__) | 206 | #define COMPILER_LOGD(...) PYPTO_HOST_LOG(DLOG_DEBUG, COMPILER_MONITOR, __VA_ARGS__) |
| 207 | #define COMPILER_LOGI(...) PYPTO_HOST_LOG(DLOG_INFO, COMPILER_MONITOR, __VA_ARGS__) | 207 | #define COMPILER_LOGI(...) PYPTO_HOST_LOG(DLOG_INFO, COMPILER_MONITOR, __VA_ARGS__) |
| 208 | #define COMPILER_LOGW(...) PYPTO_HOST_LOG(DLOG_WARN, COMPILER_MONITOR, __VA_ARGS__) | 208 | #define COMPILER_LOGW(...) PYPTO_HOST_LOG(DLOG_WARN, COMPILER_MONITOR, __VA_ARGS__) |
| 209 | -#define COMPILER_LOGE(...) PYPTO_HOST_LOG(DLOG_ERROR, COMPILER_MONITOR, __VA_ARGS__) | 209 | +#define COMPILER_LOGE(errCode, fmt, ...) PYPTO_HOST_LOGE(COMPILER_MONITOR, errCode, fmt, ##__VA_ARGS__) |
| 210 | -#define COMPILER_LOGE_E(errCode, fmt, ...) PYPTO_HOST_LOGE(COMPILER_MONITOR, errCode, fmt, ##__VA_ARGS__) | ||
| 211 | #define COMPILER_EVENT(...) PYPTO_HOST_LOG_WITHOUT_LEVEL_CHECK(DLOG_INFO, COMPILER_MONITOR, __VA_ARGS__) | 210 | #define COMPILER_EVENT(...) PYPTO_HOST_LOG_WITHOUT_LEVEL_CHECK(DLOG_INFO, COMPILER_MONITOR, __VA_ARGS__) |
| 212 | #define COMPILER_LOGD_FULL(...) PYPTO_HOST_SPLIT_LOG(DLOG_DEBUG, COMPILER_MONITOR, __VA_ARGS__) | 211 | #define COMPILER_LOGD_FULL(...) PYPTO_HOST_SPLIT_LOG(DLOG_DEBUG, COMPILER_MONITOR, __VA_ARGS__) |
| 213 | 212 | ||
| @@ -19,6 +19,7 @@ | |||
| 19 | 19 | ||
| 20 | #include "schema_base.h" | 20 | #include "schema_base.h" |
| 21 | #include "schema_parser.h" | 21 | #include "schema_parser.h" |
| 22 | +#include "tilefwk/error_code.h" | ||
| 22 | 23 | ||
| 23 | namespace npu::tile_fwk::schema { | 24 | namespace npu::tile_fwk::schema { |
| 24 | 25 | ||
| @@ -59,10 +60,10 @@ static inline range Range(uint64_t begin, uint64_t end) { return range(begin, en | |||
| 59 | using namespace npu::tile_fwk::schema; \ | 60 | using namespace npu::tile_fwk::schema; \ |
| 60 | DEV_WARN(DEV_TRACE_PREFIX " %s", DumpAttr(arg, ##args).c_str()); \ | 61 | DEV_WARN(DEV_TRACE_PREFIX " %s", DumpAttr(arg, ##args).c_str()); \ |
| 61 | } while (0) | 62 | } while (0) |
| 62 | -#define DEV_TRACE_ERROR(arg, args...) \ | 63 | +#define DEV_TRACE_ERROR(arg, args...) \ |
| 63 | - do { \ | 64 | + do { \ |
| 64 | - using namespace npu::tile_fwk::schema; \ | 65 | + using namespace npu::tile_fwk::schema; \ |
| 65 | - DEV_ERROR(ERROR_CODE_UNDEFINED, DEV_TRACE_PREFIX " %s", DumpAttr(arg, ##args).c_str()); \ | 66 | + DEV_ERROR(DevCommonErr::PARAM_CHECK_FAILED, DEV_TRACE_PREFIX " %s", DumpAttr(arg, ##args).c_str()); \ |
| 66 | } while (0) | 67 | } while (0) |
| 67 | #define DEV_TRACE_DEBUG_SPLIT(arg, args...) \ | 68 | #define DEV_TRACE_DEBUG_SPLIT(arg, args...) \ |
| 68 | do { \ | 69 | do { \ |
| @@ -394,7 +394,7 @@ public: | |||
| 394 | { | 394 | { |
| 395 | if (ret) { | 395 | if (ret) { |
| 396 | DEV_ERROR( | 396 | DEV_ERROR( |
| 397 | - ret, "#sche.dtask.leave.post: execute error=%d, skip rest tasks, " | 397 | + SchedErr::ABNOMAL_LAST_WORD, "#sche.dtask.leave.post: execute error=%d, skip rest tasks, " |
| 398 | "runreadyAiv=%u runreadyaic=%u, %u, %u", | 398 | "runreadyAiv=%u runreadyaic=%u, %u, %u", |
| 399 | ret, context_->coreRunReadyCnt_[0], context_->coreRunReadyCnt_[1], | 399 | ret, context_->coreRunReadyCnt_[0], context_->coreRunReadyCnt_[1], |
| 400 | context_->corePendReadyCnt_[0], context_->corePendReadyCnt_[1]); | 400 | context_->corePendReadyCnt_[0], context_->corePendReadyCnt_[1]); |
| @@ -190,7 +190,7 @@ inline void DeviceLogSplitDebug(const char* func, const char* format, Args... ar | |||
| 190 | do { \ | 190 | do { \ |
| 191 | if (!(expr)) { \ | 191 | if (!(expr)) { \ |
| 192 | DEV_ERROR(errCode, "Assertion failed (%s): " fmt, #expr, ##args); \ | 192 | DEV_ERROR(errCode, "Assertion failed (%s): " fmt, #expr, ##args); \ |
| 193 | - assert(0); \ | 193 | + abort(); \ |
| 194 | } \ | 194 | } \ |
| 195 | } while (0) | 195 | } while (0) |
| 196 | 196 | ||
| @@ -198,7 +198,7 @@ inline void DeviceLogSplitDebug(const char* func, const char* format, Args... ar | |||
| 198 | do { \ | 198 | do { \ |
| 199 | if (!(expr)) { \ | 199 | if (!(expr)) { \ |
| 200 | DEV_ERROR(errCode, "Assertion failed (%s)", #expr); \ | 200 | DEV_ERROR(errCode, "Assertion failed (%s)", #expr); \ |
| 201 | - assert(0); \ | 201 | + abort(); \ |
| 202 | } \ | 202 | } \ |
| 203 | } while (0) | 203 | } while (0) |
| 204 | 204 | ||
| @@ -224,16 +224,16 @@ inline void DeviceLogSplitDebug(const char* func, const char* format, Args... ar | |||
| 224 | #define DEV_ASSERT_MSG(errCode, expr, fmt, args...) \ | 224 | #define DEV_ASSERT_MSG(errCode, expr, fmt, args...) \ |
| 225 | do { \ | 225 | do { \ |
| 226 | if (!(expr)) { \ | 226 | if (!(expr)) { \ |
| 227 | - MACHINE_LOGE(errCode, "%s :" fmt, #expr, ##args); \ | 227 | + DEV_ERROR(errCode, "%s :" fmt, #expr, ##args); \ |
| 228 | - assert(0); \ | 228 | + abort(); \ |
| 229 | } \ | 229 | } \ |
| 230 | } while (0) | 230 | } while (0) |
| 231 | 231 | ||
| 232 | #define DEV_ASSERT(errCode, expr) \ | 232 | #define DEV_ASSERT(errCode, expr) \ |
| 233 | do { \ | 233 | do { \ |
| 234 | if (!(expr)) { \ | 234 | if (!(expr)) { \ |
| 235 | - MACHINE_LOGE(errCode, "%s", #expr); \ | 235 | + DEV_ERROR(errCode, "%s", #expr); \ |
| 236 | - assert(0); \ | 236 | + abort(); \ |
| 237 | } \ | 237 | } \ |
| 238 | } while (0) | 238 | } while (0) |
| 239 | 239 | ||
| @@ -138,9 +138,9 @@ stest: | |||
| 138 | #- DynamicControlFlowCacheTest.CheckShape | 138 | #- DynamicControlFlowCacheTest.CheckShape |
| 139 | #- DynamicControlFlowCacheTest.CheckLackMemory | 139 | #- DynamicControlFlowCacheTest.CheckLackMemory |
| 140 | #- DynamicControlFlowCacheTest.CheckGetTensorData | 140 | #- DynamicControlFlowCacheTest.CheckGetTensorData |
| 141 | - - DynamicControlFlowCacheTest.PartialCache | 141 | + #- DynamicControlFlowCacheTest.PartialCache |
| 142 | - - DynamicControlFlowCacheTest.PartialCacheValueDependData | 142 | + #- DynamicControlFlowCacheTest.PartialCacheValueDependData |
| 143 | - - DynamicControlFlowCacheTest.PartialCacheValueDependControl | 143 | + #- DynamicControlFlowCacheTest.PartialCacheValueDependControl |
| 144 | - DynamicOutcastTensorTest.TensorAllocateIntermediate | 144 | - DynamicOutcastTensorTest.TensorAllocateIntermediate |
| 145 | #=========================================================================== | 145 | #=========================================================================== |
| 146 | # parallel sort | 146 | # parallel sort |
| @@ -475,7 +475,7 @@ public: | |||
| 475 | EmulationMemoryUtils memUtils; | 475 | EmulationMemoryUtils memUtils; |
| 476 | int ret = EmulationLauncher::BuildControlFlowCache(dynFunc.get(), memUtils, inputs, {}, &ctrlCache, config); | 476 | int ret = EmulationLauncher::BuildControlFlowCache(dynFunc.get(), memUtils, inputs, {}, &ctrlCache, config); |
| 477 | if (ret != 0) { | 477 | if (ret != 0) { |
| 478 | - COMPILER_LOGE("control flow cache failed %d", ret); | 478 | + COMPILER_LOGE(CtrlErr::DEVICE_TASK_BUILD_FAILED, "control flow cache failed %d", ret); |
| 479 | return nullptr; | 479 | return nullptr; |
| 480 | } | 480 | } |
| 481 | 481 | ||
| @@ -487,7 +487,7 @@ public: | |||
| 487 | ss << x << " "; | 487 | ss << x << " "; |
| 488 | } | 488 | } |
| 489 | } | 489 | } |
| 490 | - COMPILER_LOGE("control flow cache: %p shape %s", devCache, ss.str().c_str()); | 490 | + COMPILER_LOGI("control flow cache: %p shape %s", devCache, ss.str().c_str()); |
| 491 | #endif | 491 | #endif |
| 492 | if (isOriginShape) { | 492 | if (isOriginShape) { |
| 493 | originShapeCaches.emplace_back(inputs, devCache); | 493 | originShapeCaches.emplace_back(inputs, devCache); |
| @@ -520,7 +520,7 @@ public: | |||
| 520 | auto& t = tensors[i]; | 520 | auto& t = tensors[i]; |
| 521 | auto addr = (uint64_t)t.GetAddr(); | 521 | auto addr = (uint64_t)t.GetAddr(); |
| 522 | if (unlikely(addr && disableL2List.size() && disableL2List[i])) { | 522 | if (unlikely(addr && disableL2List.size() && disableL2List[i])) { |
| 523 | - COMPILER_LOGE("mismatch tensor addr"); | 523 | + COMPILER_LOGI("mismatch tensor addr"); |
| 524 | addr += l2Offset; | 524 | addr += l2Offset; |
| 525 | } | 525 | } |
| 526 | tensorData->address = addr; | 526 | tensorData->address = addr; |
| @@ -668,7 +668,7 @@ public: | |||
| 668 | ss << s << " "; | 668 | ss << s << " "; |
| 669 | } | 669 | } |
| 670 | } | 670 | } |
| 671 | - COMPILER_LOGE("find ctrlflow cache: %p shape %s", devCache, ss.str().c_str()); | 671 | + COMPILER_LOGI("find ctrlflow cache: %p shape %s", devCache, ss.str().c_str()); |
| 672 | #endif | 672 | #endif |
| 673 | return devCache; | 673 | return devCache; |
| 674 | } | 674 | } |
| @@ -695,7 +695,7 @@ public: | |||
| 695 | kernels.push_back(kernel); | 695 | kernels.push_back(kernel); |
| 696 | if (inferCacheShape) { | 696 | if (inferCacheShape) { |
| 697 | #if ENABALE_VERBOSE_LOG | 697 | #if ENABALE_VERBOSE_LOG |
| 698 | - COMPILER_LOGE("build default cache"); | 698 | + COMPILER_LOGI("build default cache"); |
| 699 | #endif | 699 | #endif |
| 700 | BuildDefaultCache(kernel, module); | 700 | BuildDefaultCache(kernel, module); |
| 701 | } | 701 | } |
| @@ -750,7 +750,7 @@ public: | |||
| 750 | bool debugEnable = !isCaptureMode && isDebugMode; | 750 | bool debugEnable = !isCaptureMode && isDebugMode; |
| 751 | 751 | ||
| 752 | #if ENABALE_VERBOSE_LOG | 752 | #if ENABALE_VERBOSE_LOG |
| 753 | - COMPILER_LOGE("Sequence %ld workspace %p cfgcache %p", sequence.load(), workspace, ctrlFlowCache); | 753 | + COMPILER_LOGI("Sequence %ld workspace %p cfgcache %p", sequence.load(), workspace, ctrlFlowCache); |
| 754 | #endif | 754 | #endif |
| 755 | int ret = DeviceLauncher::LaunchSyncTask(aicoreStream, isCaptureMode); | 755 | int ret = DeviceLauncher::LaunchSyncTask(aicoreStream, isCaptureMode); |
| 756 | ASSERT(ret == RT_SUCCESS) << "launch pre sync failed: " << ret; | 756 | ASSERT(ret == RT_SUCCESS) << "launch pre sync failed: " << ret; |
| @@ -867,7 +867,7 @@ private: | |||
| 867 | } | 867 | } |
| 868 | } | 868 | } |
| 869 | #if ENABALE_VERBOSE_LOG | 869 | #if ENABALE_VERBOSE_LOG |
| 870 | - COMPILER_LOGE("infer_cache_shape: %d", inferCacheShape); | 870 | + COMPILER_LOGI("infer_cache_shape: %d", inferCacheShape); |
| 871 | #endif | 871 | #endif |
| 872 | } | 872 | } |
| 873 | 873 | ||
| @@ -879,7 +879,7 @@ private: | |||
| 879 | for (auto& pyshape : cfshapes) { | 879 | for (auto& pyshape : cfshapes) { |
| 880 | auto inputShapes = pyshape.cast<std::vector<std::vector<int64_t>>>(); | 880 | auto inputShapes = pyshape.cast<std::vector<std::vector<int64_t>>>(); |
| 881 | if (inputShapes.size() != tensors.size()) { | 881 | if (inputShapes.size() != tensors.size()) { |
| 882 | - COMPILER_LOGE("Invalid input size, expect: %zu, get: %zu.", tensors.size(), inputShapes.size()); | 882 | + COMPILER_LOGI("Invalid input size, expect: %zu, get: %zu.", tensors.size(), inputShapes.size()); |
| 883 | continue; | 883 | continue; |
| 884 | } | 884 | } |
| 885 | std::vector<DeviceTensorData> inputs; | 885 | std::vector<DeviceTensorData> inputs; |
| @@ -889,7 +889,7 @@ private: | |||
| 889 | if (kernel->CheckArgs(inputs)) { | 889 | if (kernel->CheckArgs(inputs)) { |
| 890 | kernel->BuildControlFlowCache(inputs, false); | 890 | kernel->BuildControlFlowCache(inputs, false); |
| 891 | } else { | 891 | } else { |
| 892 | - COMPILER_LOGE("Invalid cache shape, skip it"); | 892 | + COMPILER_LOGI("Invalid cache shape, skip it"); |
| 893 | } | 893 | } |
| 894 | } | 894 | } |
| 895 | } | 895 | } |
| @@ -1021,7 +1021,7 @@ private: | |||
| 1021 | Program::GetInstance().Reset(); | 1021 | Program::GetInstance().Reset(); |
| 1022 | AclModeGuard guard(AclMdlRICaptureMode::RELAXED); | 1022 | AclModeGuard guard(AclMdlRICaptureMode::RELAXED); |
| 1023 | #if ENABALE_VERBOSE_LOG | 1023 | #if ENABALE_VERBOSE_LOG |
| 1024 | - COMPILER_LOGE("compile kernel"); | 1024 | + COMPILER_LOGI("compile kernel"); |
| 1025 | #endif | 1025 | #endif |
| 1026 | 1026 | ||
| 1027 | return kmodule->Compile(module, torchTensors, tensorDefs); | 1027 | return kmodule->Compile(module, torchTensors, tensorDefs); |
| @@ -1041,7 +1041,7 @@ private: | |||
| 1041 | wsAddr = (int64_t*)pyalloc(wsSize).cast<int64_t>(); | 1041 | wsAddr = (int64_t*)pyalloc(wsSize).cast<int64_t>(); |
| 1042 | } | 1042 | } |
| 1043 | #if ENABALE_VERBOSE_LOG | 1043 | #if ENABALE_VERBOSE_LOG |
| 1044 | - COMPILER_LOGE("alloc workspace %ld", wsSize); | 1044 | + COMPILER_LOGI("alloc workspace %ld", wsSize); |
| 1045 | #endif | 1045 | #endif |
| 1046 | HOST_PERF_TRACE(TracePhase::LaunchAllocWorkSpace); | 1046 | HOST_PERF_TRACE(TracePhase::LaunchAllocWorkSpace); |
| 1047 | 1047 | ||