已合并
refactor: 去除显式CheckLogLevel调用,改为使用OP_LOGD正式日志接口 (9.1.0) #7052
refactor: 去除显式CheckLogLevel调用,改为使用OP_LOGD正式日志接口 (9.1.0) #7052
已合并
huang-chuhong创建于 6月16日
7 个文件变更+29-29
Mattention/flash_attention_score/op_host/arch22/flash_attention_score_tiling_general.cpp+9-10
@@ -434,8 +434,8 @@ protected:
434 virtual bool SetSparseStartIdx(const std::vector<int64_t> &sparseValidArray, MultiCoreParams &multiCoreParams);434 virtual bool SetSparseStartIdx(const std::vector<int64_t> &sparseValidArray, MultiCoreParams &multiCoreParams);
435 void SetPrefixSparseStartIdx(const std::vector<std::vector<int64_t>> &sparseValidArray,435 void SetPrefixSparseStartIdx(const std::vector<std::vector<int64_t>> &sparseValidArray,
436 MultiCoreParams &multiCoreParams);436 MultiCoreParams &multiCoreParams);
437- void PrintSparseMaxMinLoadPerCore(const std::vector<int64_t> &sparseValidArray, int64_t *sparseStartIdx,437+ int64_t PrintSparseMaxMinLoadPerCore(const std::vector<int64_t> &sparseValidArray, int64_t *sparseStartIdx,
438- int32_t validAivNum, int64_t avgLoadSize);438+ int32_t validAivNum, int64_t avgLoadSize);
439 bool PartitionSparseData(const std::vector<int64_t> &sparseRollingArray, int64_t sparseRollingArraySum,439 bool PartitionSparseData(const std::vector<int64_t> &sparseRollingArray, int64_t sparseRollingArraySum,
440 int64_t sparseArraySize, int64_t loadMaxEachCore, std::vector<int64_t> &partitionResult);440 int64_t sparseArraySize, int64_t loadMaxEachCore, std::vector<int64_t> &partitionResult);
441 SparseEnum GetPrefixNList(std::ostringstream &failReason);441 SparseEnum GetPrefixNList(std::ostringstream &failReason);
@@ -2468,23 +2468,21 @@ bool FlashAttentionScoreTilingBase::SetSparseStartIdx(const std::vector<int64_t>
2468 sparseStartIdx[idx] = lastValidPartitionResult[idx];2468 sparseStartIdx[idx] = lastValidPartitionResult[idx];
2469 }2469 }
2470 2470 
2471- if (CheckLogLevel(OP, DLOG_DEBUG) == 1) {2471+ OP_LOGD(context_, "%ld", PrintSparseMaxMinLoadPerCore(sparseValidArray, sparseStartIdx, validCoreNum,
2472- PrintSparseMaxMinLoadPerCore(sparseValidArray, sparseStartIdx, validCoreNum,2472+ CeilDivision(loadTotal, validCoreNum)));
2473- CeilDivision(loadTotal, validCoreNum));
2474- }
2475 return true;2473 return true;
2476}2474}
2477 2475 
2478-void FlashAttentionScoreTilingBase::PrintSparseMaxMinLoadPerCore(const std::vector<int64_t> &sparseValidArray,2476+int64_t FlashAttentionScoreTilingBase::PrintSparseMaxMinLoadPerCore(const std::vector<int64_t> &sparseValidArray,
2479- int64_t *sparseStartIdx, int32_t validAivNum,2477+ int64_t *sparseStartIdx, int32_t validAivNum,
2480- int64_t avgLoadSize)2478+ int64_t avgLoadSize)
2481{2479{
2482 int64_t maxLoadSize = 0;2480 int64_t maxLoadSize = 0;
2483 int64_t minLoadSize = std::numeric_limits<int64_t>::max();2481 int64_t minLoadSize = std::numeric_limits<int64_t>::max();
2484 int64_t totalSize = tilingData->multiCoreParams.get_totalSize();2482 int64_t totalSize = tilingData->multiCoreParams.get_totalSize();
2485 int64_t s1OuterSize = tilingData->coreParams.get_s1OuterSize();2483 int64_t s1OuterSize = tilingData->coreParams.get_s1OuterSize();
2486 if (s1OuterSize == 0) {2484 if (s1OuterSize == 0) {
2487- return;2485+ return 0;
2488 }2486 }
2489 for (int64_t idx = 0; idx < validAivNum; ++idx) {2487 for (int64_t idx = 0; idx < validAivNum; ++idx) {
2490 int64_t startIdx = sparseStartIdx[idx];2488 int64_t startIdx = sparseStartIdx[idx];
@@ -2524,6 +2522,7 @@ void FlashAttentionScoreTilingBase::PrintSparseMaxMinLoadPerCore(const std::vect
2524 2522 
2525 OP_LOGD(context_, "[%s]each core load: max[%ld], min[%ld], avg[%ld]", templateName, maxLoadSize, minLoadSize,2523 OP_LOGD(context_, "[%s]each core load: max[%ld], min[%ld], avg[%ld]", templateName, maxLoadSize, minLoadSize,
2526 avgLoadSize);2524 avgLoadSize);
2525+ return 0;
2527}2526}
2528 2527 
2529void FlashAttentionScoreTilingBase::SetSparseParams()2528void FlashAttentionScoreTilingBase::SetSparseParams()
Mattention/flash_attention_score/op_host/arch35/flash_attention_score_tiling_regbase.cpp+7-8
@@ -1752,23 +1752,21 @@ bool FlashAttentionScoreTilingRegbase::SetSparseStartIdx(const std::vector<int64
1752 sparseStartIdx[idx] = lastValidPartitionResult[idx];1752 sparseStartIdx[idx] = lastValidPartitionResult[idx];
1753 }1753 }
1754 1754 
1755- if (CheckLogLevel(OP, DLOG_DEBUG) == 1) {1755+ OP_LOGD(context_, "%ld", PrintSparseMaxMinLoadPerCore(sparseValidArray, sparseStartIdx, validAivNum,
1756- PrintSparseMaxMinLoadPerCore(sparseValidArray, sparseStartIdx, validAivNum,1756+ CeilDivision(loadTotal, validAivNum)));
1757- CeilDivision(loadTotal, validAivNum));
1758- }
1759 return true;1757 return true;
1760}1758}
1761 1759 
1762-void FlashAttentionScoreTilingRegbase::PrintSparseMaxMinLoadPerCore(const std::vector<int64_t> &sparseValidArray,1760+int64_t FlashAttentionScoreTilingRegbase::PrintSparseMaxMinLoadPerCore(const std::vector<int64_t> &sparseValidArray,
1763- int64_t *sparseStartIdx, int32_t validAivNum,1761+ int64_t *sparseStartIdx, int32_t validAivNum,
1764- int64_t avgLoadSize)1762+ int64_t avgLoadSize)
1765{1763{
1766 int64_t maxLoadSize = 0;1764 int64_t maxLoadSize = 0;
1767 int64_t minLoadSize = std::numeric_limits<int64_t>::max();1765 int64_t minLoadSize = std::numeric_limits<int64_t>::max();
1768 int64_t totalSize = multiCoreParamsRegbase_->get_totalSize();1766 int64_t totalSize = multiCoreParamsRegbase_->get_totalSize();
1769 int64_t s1OuterSize = multiCoreParamsRegbase_->get_s1OuterSize();1767 int64_t s1OuterSize = multiCoreParamsRegbase_->get_s1OuterSize();
1770 if (s1OuterSize == 0) {1768 if (s1OuterSize == 0) {
1771- return;1769+ return 0;
1772 }1770 }
1773 for (int64_t idx = 0; idx < validAivNum; ++idx) {1771 for (int64_t idx = 0; idx < validAivNum; ++idx) {
1774 int64_t startIdx = sparseStartIdx[idx];1772 int64_t startIdx = sparseStartIdx[idx];
@@ -1808,6 +1806,7 @@ void FlashAttentionScoreTilingRegbase::PrintSparseMaxMinLoadPerCore(const std::v
1808 1806 
1809 OP_LOGD(context_, "[%s]each core load: max[%ld], min[%ld], avg[%ld]", templateName, maxLoadSize, minLoadSize,1807 OP_LOGD(context_, "[%s]each core load: max[%ld], min[%ld], avg[%ld]", templateName, maxLoadSize, minLoadSize,
1810 avgLoadSize);1808 avgLoadSize);
1809+ return 0;
1811}1810}
1812 1811 
1813 1812 
Mattention/flash_attention_score/op_host/arch35/flash_attention_score_tiling_regbase.h+2-2
@@ -409,8 +409,8 @@ protected:
409 int64_t maxCoreNum);409 int64_t maxCoreNum);
410 void SetPrefixSparseStartIdx(const std::vector<std::vector<int64_t>> &sparseValidArray,410 void SetPrefixSparseStartIdx(const std::vector<std::vector<int64_t>> &sparseValidArray,
411 MultiCoreParamsRegbase &multiCoreParamsRegbase, int64_t maxCoreNum);411 MultiCoreParamsRegbase &multiCoreParamsRegbase, int64_t maxCoreNum);
412- void PrintSparseMaxMinLoadPerCore(const std::vector<int64_t> &sparseValidArray, int64_t *sparseStartIdx,412+ int64_t PrintSparseMaxMinLoadPerCore(const std::vector<int64_t> &sparseValidArray, int64_t *sparseStartIdx,
413- int32_t validAivNum, int64_t avgLoadSize);413+ int32_t validAivNum, int64_t avgLoadSize);
414 bool PartitionSparseData(const std::vector<int64_t> &sparseRollingArray, int64_t sparseRollingArraySum,414 bool PartitionSparseData(const std::vector<int64_t> &sparseRollingArray, int64_t sparseRollingArraySum,
415 int64_t sparseArraySize, int64_t loadMaxEachCore, std::vector<int64_t> &partitionResult);415 int64_t sparseArraySize, int64_t loadMaxEachCore, std::vector<int64_t> &partitionResult);
416 SparseEnum GetPrefixNList(std::ostringstream &failReason);416 SparseEnum GetPrefixNList(std::ostringstream &failReason);
Mcmake/obj_func.cmake+1-1
@@ -474,7 +474,7 @@ function(add_opbase_modules)
474 474 
475 if(OPS_BASE_UTIL_SRC)475 if(OPS_BASE_UTIL_SRC)
476 add_library(opbase_util_objs OBJECT ${OPS_BASE_UTIL_SRC})476 add_library(opbase_util_objs OBJECT ${OPS_BASE_UTIL_SRC})
477- target_include_directories(opbase_util_objs PRIVATE ${OP_TILING_INCLUDE})477+ target_include_directories(opbase_util_objs PRIVATE ${OP_TILING_INCLUDE} ${ASCEND_DIR}/pkg_inc)
478 target_compile_options(opbase_util_objs478 target_compile_options(opbase_util_objs
479 PRIVATE479 PRIVATE
480 $<$<NOT:$<BOOL:${ENABLE_TEST}>>:-DDISABLE_COMPILE_V1> -Dgoogle=ascend_private480 $<$<NOT:$<BOOL:${ENABLE_TEST}>>:-DDISABLE_COMPILE_V1> -Dgoogle=ascend_private
Mcommon/include/err/ops_err.h+3-1
@@ -18,9 +18,11 @@
18 18 
19#include "log/log.h"19#include "log/log.h"
20 20 
21+constexpr int32_t OP_TRANSFORMER_MODULE_ID = 63;
22+ 
21#define OPS_INNER_ERR_STUB(ERR_CODE_STR, OPS_DESC, FMT, ...) \23#define OPS_INNER_ERR_STUB(ERR_CODE_STR, OPS_DESC, FMT, ...) \
22 do { \24 do { \
23- OpLogSub(OP, DLOG_ERROR, OPS_DESC, FMT, ##__VA_ARGS__); \25+ OpLogSub(OP_TRANSFORMER_MODULE_ID, DLOG_ERROR, OPS_DESC, FMT, ##__VA_ARGS__); \
24 REPORT_INNER_ERR_MSG(ERR_CODE_STR, FMT, ##__VA_ARGS__); \26 REPORT_INNER_ERR_MSG(ERR_CODE_STR, FMT, ##__VA_ARGS__); \
25 } while (0)27 } while (0)
26 28 
Mcommon/include/op_host/tiling_base.h+6-4
@@ -155,10 +155,11 @@ protected:
155 // 8、Dump Tiling数据155 // 8、Dump Tiling数据
156 virtual void DumpTilingInfo()156 virtual void DumpTilingInfo()
157 {157 {
158- int32_t enable = CheckLogLevel(static_cast<int32_t>(OP), DLOG_DEBUG);158+ OP_LOGD(context_, "%ld", DefaultTilingInfoDump());
159- if (enable != 1) {159+ }
160- return;160+ 
161- }161+ int64_t DefaultTilingInfoDump()
162+ {
162 auto buf = (uint32_t*)context_->GetRawTilingData()->GetData();163 auto buf = (uint32_t*)context_->GetRawTilingData()->GetData();
163 auto bufLen = context_->GetRawTilingData()->GetDataSize();164 auto bufLen = context_->GetRawTilingData()->GetDataSize();
164 std::ostringstream oss;165 std::ostringstream oss;
@@ -172,6 +173,7 @@ protected:
172 }173 }
173 }174 }
174 OP_LOGD(context_, "%s", oss.str().c_str());175 OP_LOGD(context_, "%s", oss.str().c_str());
176+ return 0;
175 }177 }
176 178 
177 static uint32_t CalcTschBlockDim(uint32_t sliceNum, uint32_t aicCoreNum, uint32_t aivCoreNum)179 static uint32_t CalcTschBlockDim(uint32_t sliceNum, uint32_t aicCoreNum, uint32_t aivCoreNum)
Mtests/ut/framework_special/utils/inc/tests/utils/log.h+1-3
@@ -34,9 +34,7 @@ bool ChkLogErrCnt();
34 34 
35#define LOG_DBG(fmt, args...) \35#define LOG_DBG(fmt, args...) \
36 do { \36 do { \
37- if (CheckLogLevel(OP, DLOG_DEBUG) == 1) { \37+ OP_LOGD(stdout, "%s:%d [DEBUG] " fmt "\n", __FILE__, __LINE__, ##args); \
38- fprintf(stdout, "%s:%d [DEBUG] " fmt "\n", __FILE__, __LINE__, ##args); \
39- } \
40 } while (0)38 } while (0)
41 39 
42#define LOG_IF(COND, LOG_FUNC) \40#define LOG_IF(COND, LOG_FUNC) \