diff --git a/cmake/obj_func.cmake b/cmake/obj_func.cmake index e58f00a..a020204 100644 --- a/cmake/obj_func.cmake +++ b/cmake/obj_func.cmake @@ -803,7 +803,11 @@ function(add_onnx_plugin_modules) CXX_EXTENSIONS OFF ) target_include_directories(${ONNX_PLUGIN_NAME}_obj PRIVATE ${OP_PROTO_INCLUDE} ${Protobuf_INCLUDE} ${Protobuf_PATH} ${CMAKE_BINARY_DIR}/proto ${ONNX_PLUGIN_COMMON_INCLUDE} ${JSON_INCLUDE_DIR} ${ABSL_SOURCE_DIR}) - target_compile_definitions(${ONNX_PLUGIN_NAME}_obj PRIVATE OPS_UTILS_LOG_SUB_MOD_NAME="ONNX_PLUGIN" LOG_CPP) + target_compile_definitions(${ONNX_PLUGIN_NAME}_obj PRIVATE + OPS_UTILS_LOG_SUB_MOD_NAME="ONNX_PLUGIN" + OPS_UTILS_LOG_PACKAGE_TYPE=$,"[Custom]",""> + LOG_CPP + ) if(BUILD_WITH_INSTALLED_DEPENDENCY_CANN_PKG) target_compile_options( @@ -838,4 +842,4 @@ macro(add_onnx_plugin_sources) else() message(WARNING "No onnx plugin source files found in ${SOURCE_DIR}") endif() -endmacro() \ No newline at end of file +endmacro() diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 9138b8e..80b966c 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -76,6 +76,7 @@ if (BUILD_OPEN_PROJECT) target_link_libraries(${COMMON_NAME}_obj PRIVATE $ + $ tiling_api dlog ) diff --git a/common/include/cann_compat.h b/common/include/cann_compat.h deleted file mode 100644 index c04c64d..0000000 --- a/common/include/cann_compat.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include - -// B080 op_common/log/log.h stopped exposing the unqualified OP module id used -// by inherited ops-transformer tiling/error headers. Include the CANN log type -// header early so OP still comes from the active CANN version. -#if defined(__has_include) -#if __has_include("base/log_types.h") -#include "base/log_types.h" -#elif __has_include("toolchain/log_types.h") -#include "toolchain/log_types.h" -#endif -#endif - -#if !defined(LOG_TYPES_H_) && !defined(OP) -#define OP 63 -#endif - -#if defined(LOG_CPP) && !defined(DLOG_PUB_H_) -#ifdef __cplusplus -extern "C" { -#endif -int32_t CheckLogLevel(int32_t moduleId, int32_t logLevel); -void DlogRecord(int32_t moduleId, int32_t level, const char *fmt, ...); -#ifdef __cplusplus -} -#endif -#define DLOG_PUB_H_ -#endif diff --git a/common/include/err/ops_err.h b/common/include/err/ops_err.h index 9bc330e..bdc1c0b 100644 --- a/common/include/err/ops_err.h +++ b/common/include/err/ops_err.h @@ -16,17 +16,10 @@ #ifndef Xllm_COMMON_OPS_ERR_H #define Xllm_COMMON_OPS_ERR_H -#include "log/log.h" - -#define OPS_INNER_ERR_STUB(ERR_CODE_STR, OPS_DESC, FMT, ...) \ - do { \ - OpLogSub(OP, DLOG_ERROR, OPS_DESC, FMT, ##__VA_ARGS__); \ - REPORT_INNER_ERR_MSG(ERR_CODE_STR, FMT, ##__VA_ARGS__); \ - } while (0) - +#include "log/ops_log.h" /* 基础报错 */ #define OPS_REPORT_VECTOR_INNER_ERR(OPS_DESC, ...) OPS_INNER_ERR_STUB("E89999", OPS_DESC, __VA_ARGS__) #define OPS_REPORT_CUBE_INNER_ERR(OPS_DESC, ...) OPS_INNER_ERR_STUB("E69999", OPS_DESC, __VA_ARGS__) -#endif // Xllm_COMMON_OPS_ERR_H \ No newline at end of file +#endif // Xllm_COMMON_OPS_ERR_H diff --git a/common/include/fallback/fallback.h b/common/include/fallback/fallback.h index 4fb9fc6..29a7589 100644 --- a/common/include/fallback/fallback.h +++ b/common/include/fallback/fallback.h @@ -27,7 +27,7 @@ #include "fallback/fallback_comm.h" #include "mc2_log.h" #include "runtime/base.h" -#include "log/log.h" +#include "log/ops_log.h" namespace fallback { using namespace std; @@ -89,7 +89,7 @@ inline const char* GetCustOpApiLibName(void) { inline void* GetOpApiFuncAddrInLib(void* handler, const char* libName, const char* apiName) { auto funcAddr = dlsym(handler, apiName); if (funcAddr == nullptr) { - OP_LOGW("aclnnfallback", "dlsym %s from %s failed, error:%s.", apiName, libName, dlerror()); + OPS_LOG_W("aclnnfallback", "dlsym %s from %s failed, error:%s.", apiName, libName, dlerror()); } return funcAddr; } @@ -97,7 +97,7 @@ inline void* GetOpApiFuncAddrInLib(void* handler, const char* libName, const cha inline void* GetOpApiLibHandler(const char* libName) { auto handler = dlopen(libName, RTLD_LAZY); if (handler == nullptr) { - OP_LOGW("aclnnfallback", "dlopen %s failed, error:%s.", libName, dlerror()); + OPS_LOG_W("aclnnfallback", "dlopen %s failed, error:%s.", libName, dlerror()); } return handler; } @@ -114,7 +114,7 @@ inline void* GetAclnnArrdByApiName(const char *apiName) { } } } - OP_LOGE("aclnnfallback", "api %s can't find in any aclnn lib.", apiName); + OPS_LOG_E("aclnnfallback", "api %s can't find in any aclnn lib.", apiName); return nullptr; } @@ -134,7 +134,7 @@ inline void* GetOpApiFuncAddr(const char* apiName) { return funcAddr; } } - OP_LOGD("aclnnfallback", "opapi lib is not exist,will use aclnn lib."); + OPS_LOG_D("aclnnfallback", "opapi lib is not exist,will use aclnn lib."); return GetAclnnArrdByApiName(apiName); } @@ -190,14 +190,14 @@ inline aclTensor* ConvertType(const gert::Tensor* ge_tensor) { } static const auto aclCreateTensor = GET_OP_API_FUNC(aclCreateTensor); - OP_CHECK_IF(aclCreateTensor == nullptr, OP_LOGE("aclnnfallback", "aclCreateTensor nullptr"), return nullptr); + OPS_CHECK(aclCreateTensor == nullptr, OPS_LOG_E("aclnnfallback", "aclCreateTensor nullptr"), return nullptr); void* device_addr = nullptr; device_addr = const_cast(ge_tensor->GetAddr()); auto dataType = GetConvertType(ge_tensor); - OP_LOGD("aclnnfallback", "aclCreateTensor: tensor type is %d", dataType); + OPS_LOG_D("aclnnfallback", "aclCreateTensor: tensor type is %d", dataType); // convert shape auto gert_shape = ge_tensor->GetStorageShape(); @@ -216,19 +216,19 @@ inline aclTensor* ConvertType(const gert::Tensor* ge_tensor) { 0, aclFormat::ACL_FORMAT_ND, shape.data(), shape.size(), device_addr); - OP_CHECK_IF(out == nullptr, - OP_LOGE("aclnnfallback", "out nullptr"), return nullptr); + OPS_CHECK(out == nullptr, + OPS_LOG_E("aclnnfallback", "out nullptr"), return nullptr); return out; } inline aclTensorList* ConvertType(std::vector& ge_tenserList) { - OP_CHECK_IF(ge_tenserList.size() == 0, - OP_LOGE("aclnnfallback", "ge_tenserList size 0"), return nullptr); + OPS_CHECK(ge_tenserList.size() == 0, + OPS_LOG_E("aclnnfallback", "ge_tenserList size 0"), return nullptr); static const auto aclCreateTensorList = GET_OP_API_FUNC(aclCreateTensorList); - OP_CHECK_IF(aclCreateTensorList == nullptr, - OP_LOGE("aclnnfallback", "ge_tenserList size 0"), return nullptr); + OPS_CHECK(aclCreateTensorList == nullptr, + OPS_LOG_E("aclnnfallback", "ge_tenserList size 0"), return nullptr); std::vector tmp; for (size_t i = 0; i < ge_tenserList.size(); i++) { @@ -243,8 +243,8 @@ inline aclTensorList* ConvertType(std::vector& ge_tenserLis template inline aclScalar* ConvertScalarType(T value) { static const auto aclCreateScalar = GET_OP_API_FUNC(aclCreateScalar); - OP_CHECK_IF(aclCreateScalar == nullptr, - OP_LOGE("aclnnfallback", "aclCreateScalar nullptr"), return nullptr); + OPS_CHECK(aclCreateScalar == nullptr, + OPS_LOG_E("aclnnfallback", "aclCreateScalar nullptr"), return nullptr); if (typeid(value) == typeid(float)) { return aclCreateScalar(&value, aclDataType::ACL_FLOAT); } @@ -266,7 +266,7 @@ inline aclTensor* ConvertMmType(const gert::Tensor* ge_tensor, bool transpose, b } static const auto aclCreateTensor = GET_OP_API_FUNC(aclCreateTensor); - OP_CHECK_IF(aclCreateTensor == nullptr, OP_LOGE("aclnnfallback", "aclCreateTensor nullptr"), return nullptr); + OPS_CHECK(aclCreateTensor == nullptr, OPS_LOG_E("aclnnfallback", "aclCreateTensor nullptr"), return nullptr); void* device_addr = const_cast(ge_tensor->GetAddr()); // convert data type @@ -302,43 +302,43 @@ inline aclTensor* ConvertMmType(const gert::Tensor* ge_tensor, bool transpose, b } aclTensor* out = aclCreateTensor(viewShape.data(), shape.size(), dataType, strides.data(), 0, acl_format, shape.data(), shape.size(), device_addr); - OP_CHECK_IF(out == nullptr, OP_LOGE("aclnnfallback", "out nullptr"), return nullptr); + OPS_CHECK(out == nullptr, OPS_LOG_E("aclnnfallback", "out nullptr"), return nullptr); return out; } inline void Release(aclTensor* p) { static const auto aclDestroyTensor = GET_OP_API_FUNC(aclDestroyTensor); - OP_CHECK_IF(aclDestroyTensor == nullptr, - OP_LOGE("aclnnfallback", "aclDestroyTensor is null"), return); + OPS_CHECK(aclDestroyTensor == nullptr, + OPS_LOG_E("aclnnfallback", "aclDestroyTensor is null"), return); aclDestroyTensor(p); } inline void Release(aclScalar* p) { static const auto aclDestroyScalar = GET_OP_API_FUNC(aclDestroyScalar); - OP_CHECK_IF(aclDestroyScalar == nullptr, - OP_LOGE("aclnnfallback", "aclDestroyScalar is null"), return); + OPS_CHECK(aclDestroyScalar == nullptr, + OPS_LOG_E("aclnnfallback", "aclDestroyScalar is null"), return); aclDestroyScalar(p); } inline void Release(aclIntArray* p) { static const auto aclDestroyIntArray = GET_OP_API_FUNC(aclDestroyIntArray); - OP_CHECK_IF(aclDestroyIntArray == nullptr, - OP_LOGE("aclnnfallback", "aclDestroyIntArray is null"), return); + OPS_CHECK(aclDestroyIntArray == nullptr, + OPS_LOG_E("aclnnfallback", "aclDestroyIntArray is null"), return); aclDestroyIntArray(p); } inline void Release(aclBoolArray* p) { static const auto aclDestroyBoolArray = GET_OP_API_FUNC(aclDestroyBoolArray); - OP_CHECK_IF(aclDestroyBoolArray == nullptr, - OP_LOGE("aclnnfallback", "aclDestroyBoolArray is null"), return); + OPS_CHECK(aclDestroyBoolArray == nullptr, + OPS_LOG_E("aclnnfallback", "aclDestroyBoolArray is null"), return); aclDestroyBoolArray(p); } inline void Release(aclTensorList* p) { static const auto aclDestroyTensorList = GET_OP_API_FUNC(aclDestroyTensorList); - OP_CHECK_IF(aclDestroyTensorList == nullptr, - OP_LOGE("aclnnfallback", "aclDestroyTensorList is null"), return); + OPS_CHECK(aclDestroyTensorList == nullptr, + OPS_LOG_E("aclnnfallback", "aclDestroyTensorList is null"), return); aclDestroyTensorList(p); } @@ -446,7 +446,7 @@ using ResetCacheThreadLocal = void (*)(); static const auto getWorkspaceSizeFuncAddr = GetOpApiFuncAddr(#aclnn_api "GetWorkspaceSize"); \ static const auto opApiFuncAddr = GetOpApiFuncAddr(#aclnn_api); \ if (getWorkspaceSizeFuncAddr == nullptr || opApiFuncAddr == nullptr || ResetCacheThreadLocalAddr == nullptr) { \ - OP_LOGE("aclnnfallback", "%s or %s not in %s or %s or ResetCacheThreadLocal not found.", \ + OPS_LOG_E("aclnnfallback", "%s or %s not in %s or %s or ResetCacheThreadLocal not found.", \ #aclnn_api "GetWorkspaceSize", #aclnn_api, GetOpApiLibName(), GetOpApiLibName()); \ ret = GRAPH_FAILED; \ break; \ @@ -461,7 +461,7 @@ using ResetCacheThreadLocal = void (*)(); static auto getWorkspaceSizeFunc = ConvertToOpApiFunc(converted_params, getWorkspaceSizeFuncAddr); \ auto workspace_status = call(getWorkspaceSizeFunc, converted_params); \ if (workspace_status != 0) { \ - OP_LOGE("aclnnfallback", "call %s failed:", #aclnn_api); \ + OPS_LOG_E("aclnnfallback", "call %s failed:", #aclnn_api); \ ret = GRAPH_FAILED; \ break; \ } \ @@ -469,7 +469,7 @@ using ResetCacheThreadLocal = void (*)(); if (workspace_size > 0) { \ workspace_addr = host_api_ctx->MallocWorkspace(workspace_size); \ if (workspace_addr == nullptr) { \ - OP_LOGE("aclnnfallback", "call %s allocate workspace failed", #aclnn_api); \ + OPS_LOG_E("aclnnfallback", "call %s allocate workspace failed", #aclnn_api); \ ret = GRAPH_FAILED; \ break; \ } \ @@ -483,7 +483,7 @@ using ResetCacheThreadLocal = void (*)(); ReleaseConvertTypes(converted_params); \ host_api_ctx->FreeWorkspace(); \ if (api_ret_inner != 0) { \ - OP_LOGE("aclnnfallback", "call %s allocate workspace failed api_ret_inner: %d", #aclnn_api, api_ret_inner); \ + OPS_LOG_E("aclnnfallback", "call %s allocate workspace failed api_ret_inner: %d", #aclnn_api, api_ret_inner); \ return GRAPH_FAILED; \ } \ return api_ret_inner; \ diff --git a/common/include/fallback/fallback_2stages.h b/common/include/fallback/fallback_2stages.h index 8564403..ec8fb48 100644 --- a/common/include/fallback/fallback_2stages.h +++ b/common/include/fallback/fallback_2stages.h @@ -23,7 +23,7 @@ #include "fallback.h" #include "fallback_comm.h" #include "fallback_comm_2stages.h" -#include "log/log.h" +#include "log/ops_log.h" #include "mc2_log.h" namespace fallback { @@ -34,35 +34,35 @@ using namespace ge; inline void Collect(aclTensor *p, std::vector ¶ms) { static const auto aclDestroyTensor = GET_OP_API_FUNC(aclDestroyTensor); OPS_ERR_IF(aclDestroyTensor == nullptr, - OP_LOGE("aclnnfallback", "aclDestroyTensor is null"), return); + OPS_LOG_E("aclnnfallback", "aclDestroyTensor is null"), return); params.emplace_back(OpApiAnyValue{p, [](void *param) {aclDestroyTensor(static_cast(param));}}); } inline void Collect(aclScalar *p, std::vector ¶ms) { static const auto aclDestroyScalar = GET_OP_API_FUNC(aclDestroyScalar); OPS_ERR_IF(aclDestroyScalar == nullptr, - OP_LOGE("aclnnfallback", "aclDestroyScalar is null"), return); + OPS_LOG_E("aclnnfallback", "aclDestroyScalar is null"), return); params.emplace_back(OpApiAnyValue{p, [](void *param) {aclDestroyScalar(static_cast(param));}}); } inline void Collect(aclIntArray *p, std::vector ¶ms) { static const auto aclDestroyIntArray = GET_OP_API_FUNC(aclDestroyIntArray); OPS_ERR_IF(aclDestroyIntArray == nullptr, - OP_LOGE("aclnnfallback", "aclDestroyIntArray is null"), return); + OPS_LOG_E("aclnnfallback", "aclDestroyIntArray is null"), return); params.emplace_back(OpApiAnyValue{p, [](void *param) {aclDestroyIntArray(static_cast(param));}}); } inline void Collect(aclBoolArray *p, std::vector ¶ms) { static const auto aclDestroyBoolArray = GET_OP_API_FUNC(aclDestroyBoolArray); OPS_ERR_IF(aclDestroyBoolArray == nullptr, - OP_LOGE("aclnnfallback", "aclDestroyBoolArray is null"), return); + OPS_LOG_E("aclnnfallback", "aclDestroyBoolArray is null"), return); params.emplace_back(OpApiAnyValue{p, [](void *param) {aclDestroyBoolArray(static_cast(param));}}); } inline void Collect(aclTensorList *p, std::vector ¶ms) { static const auto aclDestroyTensorList = GET_OP_API_FUNC(aclDestroyTensorList); OPS_ERR_IF(aclDestroyTensorList == nullptr, - OP_LOGE("aclnnfallback", "aclDestroyTensorList is null"), return); + OPS_LOG_E("aclnnfallback", "aclDestroyTensorList is null"), return); params.emplace_back(OpApiAnyValue{p, [](void *param) {aclDestroyTensorList(static_cast(param));}}); } @@ -91,7 +91,7 @@ void CollectConvertedTypes(Tuple &t, std::vector ¶ms) { static const auto getWorkspaceSizeFuncAddr = GetOpApiFuncAddr(#aclnn_api "GetWorkspaceSize"); \ static const auto opApiFuncAddr = GetOpApiFuncAddr(#aclnn_api); \ if (getWorkspaceSizeFuncAddr == nullptr || opApiFuncAddr == nullptr || ResetCacheThreadLocalAddr == nullptr) { \ - OP_LOGE("aclnnfallback", "%s or %s not in %s or %s or ResetCacheThreadLocal not found.", \ + OPS_LOG_E("aclnnfallback", "%s or %s not in %s or %s or ResetCacheThreadLocal not found.", \ #aclnn_api "GetWorkspaceSize", #aclnn_api, GetOpApiLibName(), GetOpApiLibName()); \ ret = GRAPH_FAILED; \ break; \ @@ -112,7 +112,7 @@ void CollectConvertedTypes(Tuple &t, std::vector ¶ms) { static auto getWorkspaceSizeFunc = ConvertToOpApiFunc(converted_params, getWorkspaceSizeFuncAddr); \ auto workspace_status = call(getWorkspaceSizeFunc, converted_params); \ if (workspace_status != 0) { \ - OP_LOGE("aclnnfallback", "call %s failed:", #aclnn_api); \ + OPS_LOG_E("aclnnfallback", "call %s failed:", #aclnn_api); \ ret = GRAPH_FAILED; \ break; \ } \ diff --git a/common/include/framework/onnx_common.h b/common/include/framework/onnx_common.h index f88455e..61687f4 100644 --- a/common/include/framework/onnx_common.h +++ b/common/include/framework/onnx_common.h @@ -25,7 +25,7 @@ #include "graph/operator.h" #include "graph/graph.h" #include "base/err_msg.h" -#include "log/log.h" +#include "log/ops_log.h" #include "onnx/proto/ge_onnx.pb.h" namespace domi { @@ -65,7 +65,7 @@ inline Status ChangeFormatFromOnnx(ge::Operator& op, const int idx, ge::Format f org_tensor.SetFormat(format); auto ret = op.UpdateInputDesc(idx, org_tensor); if (ret != ge::GRAPH_SUCCESS) { - OP_LOGE(GetOpName(op).c_str(), "change input format failed."); + OPS_LOG_E(GetOpName(op).c_str(), "change input format failed."); return FAILED; } } else { @@ -74,7 +74,7 @@ inline Status ChangeFormatFromOnnx(ge::Operator& op, const int idx, ge::Format f org_tensor_y.SetFormat(format); auto ret_y = op.UpdateOutputDesc(idx, org_tensor_y); if (ret_y != ge::GRAPH_SUCCESS) { - OP_LOGE(GetOpName(op).c_str(), "change output format failed."); + OPS_LOG_E(GetOpName(op).c_str(), "change output format failed."); return FAILED; } } diff --git a/common/include/tiling_base/tiling_base.h b/common/include/tiling_base/tiling_base.h index bebbf19..32c93e6 100644 --- a/common/include/tiling_base/tiling_base.h +++ b/common/include/tiling_base/tiling_base.h @@ -20,6 +20,7 @@ #include #include "tiling/platform/platform_ascendc.h" #include "tiling_base/error_log.h" +#include "log/ops_log.h" #ifdef ASCENDC_OP_TEST #define ASCENDC_EXTERN_C extern "C" @@ -152,7 +153,7 @@ class TilingBaseClass { // 8、Dump Tiling数据 virtual void DumpTilingInfo() { - int32_t enable = CheckLogLevel(static_cast(OP), DLOG_DEBUG); + int32_t enable = AlogCheckDebugLevel(static_cast(OP), DLOG_DEBUG); if (enable != 1) { return; } @@ -164,11 +165,11 @@ class TilingBaseClass { for (size_t i = 0; i < bufLen / sizeof(uint32_t); i++) { oss << *(buf + i) << ","; if (oss.str().length() > 640) { // Split according to 640 to avoid truncation - OP_LOGD(context_, "%s", oss.str().c_str()); + OPS_LOG_D(context_, "%s", oss.str().c_str()); oss.str(""); } } - OP_LOGD(context_, "%s", oss.str().c_str()); + OPS_LOG_D(context_, "%s", oss.str().c_str()); } static uint32_t CalcTschBlockDim(uint32_t sliceNum, uint32_t aicCoreNum, uint32_t aivCoreNum) @@ -253,4 +254,4 @@ class TilingBaseClass { } // namespace OpTiling } // namespace Xllm -} // namespace Ops \ No newline at end of file +} // namespace Ops diff --git a/common/src/fallback_comm_2stages.cpp b/common/src/fallback_comm_2stages.cpp index 70de472..1cecd7e 100644 --- a/common/src/fallback_comm_2stages.cpp +++ b/common/src/fallback_comm_2stages.cpp @@ -22,7 +22,7 @@ #include "aclnn/aclnn_base.h" #include "runtime/base.h" -#include "log/log.h" +#include "log/ops_log.h" #ifdef __cplusplus extern "C" { @@ -37,15 +37,15 @@ ge::graphStatus ExecuteOpLaunch(gert::OpExecuteLaunchContext *context) { auto params = reinterpret_cast(context->GetOpApiParams()); auto workspace_sizes = context->GetWorkspaceSizes(); auto workspace_addrs = context->GetWorkspaceAddrs(); - OP_CHECK_IF((workspace_sizes->GetSize() == 0) || (workspace_addrs->GetSize() == 0), - OP_LOGE("aclnnfallback", "no workspace addrs"), return ge::GRAPH_FAILED); + OPS_CHECK((workspace_sizes->GetSize() == 0) || (workspace_addrs->GetSize() == 0), + OPS_LOG_E("aclnnfallback", "no workspace addrs"), return ge::GRAPH_FAILED); auto workspace_size = workspace_sizes->GetData()[0]; auto workspace_addr = workspace_addrs->GetData()[0]->GetAddr(); auto acl_stream = context->GetStream(); auto opApiFunc = params->op_api_func; - OP_CHECK_IF(opApiFunc == nullptr, - OP_LOGE("aclnnfallback", "opApiFunc nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(opApiFunc == nullptr, + OPS_LOG_E("aclnnfallback", "opApiFunc nullptr"), return ge::GRAPH_FAILED); auto op_api_ret = opApiFunc(workspace_addr, workspace_size, params->executor, acl_stream); for (auto &av : params->converted_params) { if (av.deleter != nullptr) { @@ -54,7 +54,7 @@ ge::graphStatus ExecuteOpLaunch(gert::OpExecuteLaunchContext *context) { } params->converted_params.clear(); if (op_api_ret != 0) { - OP_LOGE("aclnnfallback", "call %s allocate workspace failed op_api_ret: %d", context->GetNodeName(), op_api_ret); + OPS_LOG_E("aclnnfallback", "call %s allocate workspace failed op_api_ret: %d", context->GetNodeName(), op_api_ret); return ge::GRAPH_FAILED; } return ge::GRAPH_SUCCESS; diff --git a/common/src/framework/embedding_bag_onnx_plugin.cpp b/common/src/framework/embedding_bag_onnx_plugin.cpp index ef21531..e718173 100644 --- a/common/src/framework/embedding_bag_onnx_plugin.cpp +++ b/common/src/framework/embedding_bag_onnx_plugin.cpp @@ -21,7 +21,7 @@ using NodeProto = ge::onnx::NodeProto; static Status ParseParamsEmbeddingBag(const Message *op_src, ge::Operator &op_dest) { const NodeProto *node = dynamic_cast(op_src); if (node == nullptr) { - OP_LOGE(GetOpName(op_dest), "Dynamic cast op_src to NodeProto failed."); + OPS_LOG_E(GetOpName(op_dest), "Dynamic cast op_src to NodeProto failed."); return FAILED; } // set attr mode_value diff --git a/common/src/framework/fillwindowcache_onnx_plugin.cpp b/common/src/framework/fillwindowcache_onnx_plugin.cpp index 354829d..fd07909 100644 --- a/common/src/framework/fillwindowcache_onnx_plugin.cpp +++ b/common/src/framework/fillwindowcache_onnx_plugin.cpp @@ -20,7 +20,7 @@ static Status parseParamsFillWindowCache(const Message* op_src, ge::Operator& op { const ge::onnx::NodeProto *node = reinterpret_cast(op_src); if (node == nullptr) { - OP_LOGE(GetOpName(op_dest), "Dynamic fillwindowcache op_src to NodeProto failed."); + OPS_LOG_E(GetOpName(op_dest), "Dynamic fillwindowcache op_src to NodeProto failed."); return FAILED; } diff --git a/common/src/framework/multi_head_attention_onnx_plugin.cpp b/common/src/framework/multi_head_attention_onnx_plugin.cpp index 42b40f2..7371b75 100644 --- a/common/src/framework/multi_head_attention_onnx_plugin.cpp +++ b/common/src/framework/multi_head_attention_onnx_plugin.cpp @@ -21,7 +21,7 @@ static const int REQUIRED_ATTRS_NUM = 6; static Status ParseParamsMultiHeadAttention(const Message* op_src, ge::Operator& op_dest) { const NodeProto* node = dynamic_cast(op_src); if (node == nullptr) { - OP_LOGE("MultiHeadAttention", "Dynamic cast op_src to NodeProto failed."); + OPS_LOG_E("MultiHeadAttention", "Dynamic cast op_src to NodeProto failed."); return FAILED; } int attn_head_num = 0; @@ -54,7 +54,7 @@ static Status ParseParamsMultiHeadAttention(const Message* op_src, ge::Operator& } if (attr_num != REQUIRED_ATTRS_NUM) { - OP_LOGE(GetOpName(op_dest).c_str(), "Node must have attrs attn_head_num/attn_dim_per_head/" + OPS_LOG_E(GetOpName(op_dest).c_str(), "Node must have attrs attn_head_num/attn_dim_per_head/" "src_len/tgt_len/dropout_prob/softmax_use_float"); return FAILED; } diff --git a/common/src/framework/npu_fused_attention_score_fwd_onnx_plugin.cpp b/common/src/framework/npu_fused_attention_score_fwd_onnx_plugin.cpp index bcc2616..dece187 100644 --- a/common/src/framework/npu_fused_attention_score_fwd_onnx_plugin.cpp +++ b/common/src/framework/npu_fused_attention_score_fwd_onnx_plugin.cpp @@ -22,7 +22,7 @@ constexpr int ACL_FLOAT16 = 1; static Status ParseParamsNpuFusedAttentionScoreFwd(const Message *op_src, ge::Operator &op_dest) { const NodeProto *node = dynamic_cast(op_src); if (node == nullptr) { - OP_LOGE(GetOpName(op_dest), "Dynamic cast op_src to NodeProto failed."); + OPS_LOG_E(GetOpName(op_dest), "Dynamic cast op_src to NodeProto failed."); return FAILED; } @@ -57,7 +57,7 @@ static Status ParseParamsNpuFusedAttentionScoreFwd(const Message *op_src, ge::Op } if (required_attr_num != REQUIRED_ATTR) { - OP_LOGE(GetOpName(op_dest), "attr scale is required."); + OPS_LOG_E(GetOpName(op_dest), "attr scale is required."); return FAILED; } @@ -76,27 +76,27 @@ namespace{ static Status GetAttrFromOperator(const ge::Operator& op, float& scale, float& keep_prob, bool& query_transpose, bool& key_transpose, bool& bmm_score_transpose_a, bool& bmm_score_transpose_b) { if (op.GetAttr("scale", scale) != SUCCESS) { - OP_LOGE(GetOpName(op), "get scale from op failed"); + OPS_LOG_E(GetOpName(op), "get scale from op failed"); return FAILED; } if (op.GetAttr("keep_prob", keep_prob) != SUCCESS) { - OP_LOGE(GetOpName(op), "get keep_prob from op failed"); + OPS_LOG_E(GetOpName(op), "get keep_prob from op failed"); return FAILED; } if (op.GetAttr("query_transpose", query_transpose) != SUCCESS) { - OP_LOGE(GetOpName(op), "get query_transpose from op failed"); + OPS_LOG_E(GetOpName(op), "get query_transpose from op failed"); return FAILED; } if (op.GetAttr("key_transpose", key_transpose) != SUCCESS) { - OP_LOGE(GetOpName(op), "get key_transpose from op failed"); + OPS_LOG_E(GetOpName(op), "get key_transpose from op failed"); return FAILED; } if (op.GetAttr("bmm_score_transpose_a", bmm_score_transpose_a) != SUCCESS) { - OP_LOGE(GetOpName(op), "get bmm_score_transpose_a from op failed"); + OPS_LOG_E(GetOpName(op), "get bmm_score_transpose_a from op failed"); return FAILED; } if (op.GetAttr("bmm_score_transpose_b", bmm_score_transpose_b) != SUCCESS) { - OP_LOGE(GetOpName(op), "get bmm_score_transpose_b from op failed"); + OPS_LOG_E(GetOpName(op), "get bmm_score_transpose_b from op failed"); return FAILED; } return SUCCESS; @@ -106,7 +106,7 @@ static Status GetAttrFromOperator(const ge::Operator& op, float& scale, float& k static Status ParseOpToGraphNpuFusedAttentionScoreFwd(const ge::Operator& op, ge::Graph& graph) { std::string ori_name; if (op.GetAttr("name", ori_name) != SUCCESS) { - OP_LOGE(GetOpName(op), "get name from op failed."); + OPS_LOG_E(GetOpName(op), "get name from op failed."); return FAILED; } diff --git a/common/src/framework/npu_fused_attention_score_onnx_plugin.cpp b/common/src/framework/npu_fused_attention_score_onnx_plugin.cpp index 8882da5..13ecd0a 100644 --- a/common/src/framework/npu_fused_attention_score_onnx_plugin.cpp +++ b/common/src/framework/npu_fused_attention_score_onnx_plugin.cpp @@ -22,7 +22,7 @@ constexpr int ACL_FLOAT16 = 1; static Status ParseParamsNpuFusedAttentionScore(const Message *op_src, ge::Operator &op_dest) { const NodeProto *node = dynamic_cast(op_src); if (node == nullptr) { - OP_LOGE(GetOpName(op_dest).c_str(), "Dynamic cast op_src to NodeProto failed."); + OPS_LOG_E(GetOpName(op_dest).c_str(), "Dynamic cast op_src to NodeProto failed."); return FAILED; } @@ -57,7 +57,7 @@ static Status ParseParamsNpuFusedAttentionScore(const Message *op_src, ge::Opera } if (required_attr_num != REQUIRED_ATTR) { - OP_LOGE(GetOpName(op_dest).c_str(), "attr scale is required."); + OPS_LOG_E(GetOpName(op_dest).c_str(), "attr scale is required."); return FAILED; } @@ -75,15 +75,15 @@ static Status ParseParamsNpuFusedAttentionScore(const Message *op_src, ge::Opera namespace { static Status GetAttrFromPre3(const ge::Operator& op, float& scale, float& keep_prob, bool& query_transpose) { if (op.GetAttr("scale", scale) != SUCCESS) { - OP_LOGE(GetOpName(op).c_str(), "get scale from op failed"); + OPS_LOG_E(GetOpName(op).c_str(), "get scale from op failed"); return FAILED; } if (op.GetAttr("keep_prob", keep_prob) != SUCCESS) { - OP_LOGE(GetOpName(op).c_str(), "get keep_prob from op failed"); + OPS_LOG_E(GetOpName(op).c_str(), "get keep_prob from op failed"); return FAILED; } if (op.GetAttr("query_transpose", query_transpose) != SUCCESS) { - OP_LOGE(GetOpName(op).c_str(), "get query_transpose from op failed"); + OPS_LOG_E(GetOpName(op).c_str(), "get query_transpose from op failed"); return FAILED; } return SUCCESS; @@ -92,15 +92,15 @@ static Status GetAttrFromPre3(const ge::Operator& op, float& scale, float& keep_ static Status GetAttrFromLast3( const ge::Operator& op, bool& key_transpose, bool& bmm_score_transpose_a, bool& bmm_score_transpose_b) { if (op.GetAttr("key_transpose", key_transpose) != SUCCESS) { - OP_LOGE(GetOpName(op).c_str(), "get key_transpose from op failed"); + OPS_LOG_E(GetOpName(op).c_str(), "get key_transpose from op failed"); return FAILED; } if (op.GetAttr("bmm_score_transpose_a", bmm_score_transpose_a) != SUCCESS) { - OP_LOGE(GetOpName(op).c_str(), "get bmm_score_transpose_a from op failed"); + OPS_LOG_E(GetOpName(op).c_str(), "get bmm_score_transpose_a from op failed"); return FAILED; } if (op.GetAttr("bmm_score_transpose_b", bmm_score_transpose_b) != SUCCESS) { - OP_LOGE(GetOpName(op).c_str(), "get bmm_score_transpose_b from op failed"); + OPS_LOG_E(GetOpName(op).c_str(), "get bmm_score_transpose_b from op failed"); return FAILED; } return SUCCESS; @@ -110,7 +110,7 @@ static Status GetAttrFromLast3( static Status ParseOpToGraphNpuFusedAttentionScore(const ge::Operator& op, ge::Graph& graph) { std::string ori_name; if (op.GetAttr("name", ori_name) != SUCCESS) { - OP_LOGE(GetOpName(op).c_str(), "get name from op failed."); + OPS_LOG_E(GetOpName(op).c_str(), "get name from op failed."); return FAILED; } diff --git a/common/src/framework/npu_masked_softmax_with_relposbias_onnx_plugin.cpp b/common/src/framework/npu_masked_softmax_with_relposbias_onnx_plugin.cpp index c7ba48f..0a69cab 100644 --- a/common/src/framework/npu_masked_softmax_with_relposbias_onnx_plugin.cpp +++ b/common/src/framework/npu_masked_softmax_with_relposbias_onnx_plugin.cpp @@ -23,7 +23,7 @@ constexpr int OUTPUT_INDEX = 1; static Status ParseParamsNpuMaskedSoftmaxWithRelPosBias(const Message* op_src, ge::Operator& op_dest) { const NodeProto* node = dynamic_cast(op_src); if (node == nullptr) { - OP_LOGE("MaskedSoftmaxWithRelPosBias", "Dynamic cast op_src to NodeProto failed."); + OPS_LOG_E("MaskedSoftmaxWithRelPosBias", "Dynamic cast op_src to NodeProto failed."); return FAILED; } @@ -51,7 +51,7 @@ static Status ParseParamsNpuMaskedSoftmaxWithRelPosBias(const Message* op_src, g static Status ParseOpToGraphNpuMaskedSoftmaxWithRelPosBias(const ge::Operator& op, ge::Graph& graph) { std::string ori_name; if (op.GetAttr("name", ori_name) != SUCCESS) { - OP_LOGE(GetOpName(op).c_str(), "get name from op failed."); + OPS_LOG_E(GetOpName(op).c_str(), "get name from op failed."); return FAILED; } @@ -61,12 +61,12 @@ static Status ParseOpToGraphNpuMaskedSoftmaxWithRelPosBias(const ge::Operator& o int inner_precision_mode = 0; if (op.GetAttr("inner_precision_mode", inner_precision_mode) != SUCCESS) { - OP_LOGE(GetOpName(op).c_str(), "get inner_precision_mode from op failed"); + OPS_LOG_E(GetOpName(op).c_str(), "get inner_precision_mode from op failed"); return FAILED; } float scale_value = 1.0f; if (op.GetAttr("scale_value", scale_value) != SUCCESS) { - OP_LOGE(GetOpName(op).c_str(), "get scale_value from op failed"); + OPS_LOG_E(GetOpName(op).c_str(), "get scale_value from op failed"); return FAILED; } auto masked_softmax_with_relposbias = ge::op::MaskedSoftmaxWithRelPosBias((ori_name + "_MaskedSoftmaxWithRelPosBias").c_str()) diff --git a/common/src/framework/npu_scaled_masked_softmax_onnx_plugin.cpp b/common/src/framework/npu_scaled_masked_softmax_onnx_plugin.cpp index e5b8f2b..6d05f99 100644 --- a/common/src/framework/npu_scaled_masked_softmax_onnx_plugin.cpp +++ b/common/src/framework/npu_scaled_masked_softmax_onnx_plugin.cpp @@ -21,7 +21,7 @@ using NodeProto = ge::onnx::NodeProto; static Status ParseParamsNPUScaledMaskedSoftmax(const Message* op_src, ge::Operator& op_dest) { const NodeProto* node = dynamic_cast(op_src); if (node == nullptr) { - OP_LOGE(GetOpName(op_dest).c_str(), "Dynamic cast op_src to NodeProto failed!"); + OPS_LOG_E(GetOpName(op_dest).c_str(), "Dynamic cast op_src to NodeProto failed!"); return FAILED; } diff --git a/common/tiling/tiling_base.h b/common/tiling/tiling_base.h index 3c15f98..94a1763 100644 --- a/common/tiling/tiling_base.h +++ b/common/tiling/tiling_base.h @@ -19,7 +19,6 @@ #include #include #include "tiling/platform/platform_ascendc.h" -//#include "log/log.h" #ifdef ASCENDC_OP_TEST #define ASCENDC_EXTERN_C extern "C" @@ -152,10 +151,6 @@ class TilingBaseClass { // 8、Dump Tiling数据 virtual void DumpTilingInfo() { - //int32_t enable = CheckLogLevel(static_cast(OP), DLOG_DEBUG); - //if (enable != 1) { - // return; - //} auto buf = (uint32_t*)context_->GetRawTilingData()->GetData(); auto bufLen = context_->GetRawTilingData()->GetDataSize(); std::ostringstream oss; @@ -164,11 +159,9 @@ class TilingBaseClass { for (size_t i = 0; i < bufLen / sizeof(uint32_t); i++) { oss << *(buf + i) << ","; if (oss.str().length() > 640) { // Split according to 640 to avoid truncation - //OP_LOGD(context_, "%s", oss.str().c_str()); oss.str(""); } } - //OP_LOGD(context_, "%s", oss.str().c_str()); } static uint32_t CalcTschBlockDim(uint32_t sliceNum, uint32_t aicCoreNum, uint32_t aivCoreNum) diff --git a/scripts/opgen/template/add/op_host/add_example_infershape.cpp b/scripts/opgen/template/add/op_host/add_example_infershape.cpp index 58fb969..35ccf80 100644 --- a/scripts/opgen/template/add/op_host/add_example_infershape.cpp +++ b/scripts/opgen/template/add/op_host/add_example_infershape.cpp @@ -13,7 +13,7 @@ * \brief */ #include "register/op_impl_registry.h" -#include "log/log.h" +#include "log/ops_log.h" using namespace ge; @@ -22,15 +22,15 @@ static constexpr int64_t IDX_0 = 0; static ge::graphStatus InferShapeAddExample(gert::InferShapeContext* context) { - OP_LOGD(context->GetNodeName(), "Begin to do InferShapeAddExample"); + OPS_LOG_D(context->GetNodeName(), "Begin to do InferShapeAddExample"); // get input shapes const gert::Shape* xShape = context->GetInputShape(IDX_0); - OP_CHECK_NULL_WITH_CONTEXT(context, xShape); + OPS_LOG_E_IF_NULL(context, xShape, return ge::GRAPH_FAILED); // get output shapes gert::Shape* yShape = context->GetOutputShape(IDX_0); - OP_CHECK_NULL_WITH_CONTEXT(context, yShape); + OPS_LOG_E_IF_NULL(context, yShape, return ge::GRAPH_FAILED); // 填充输出shape大小 auto xShapeSize = xShape->GetDimNum(); @@ -40,7 +40,7 @@ static ge::graphStatus InferShapeAddExample(gert::InferShapeContext* context) yShape->SetDim(i, dim); } - OP_LOGD(context->GetNodeName(), "End to do InferShapeAddExample"); + OPS_LOG_D(context->GetNodeName(), "End to do InferShapeAddExample"); return GRAPH_SUCCESS; } diff --git a/scripts/opgen/template/add/op_host/add_example_tiling.cpp b/scripts/opgen/template/add/op_host/add_example_tiling.cpp index e85bce0..2274ce5 100644 --- a/scripts/opgen/template/add/op_host/add_example_tiling.cpp +++ b/scripts/opgen/template/add/op_host/add_example_tiling.cpp @@ -13,7 +13,7 @@ * \brief */ -#include "log/log.h" +#include "log/ops_log.h" #include "util/math_util.h" #include "tiling_base/tiling_util.h" #include "tiling_base/tiling_templates_registry.h" @@ -41,12 +41,12 @@ static ge::graphStatus GetPlatformInfo(gert::TilingContext* context, uint64_t& u { // 获取ubsize coreNum fe::PlatFormInfos* platformInfoPtr = context->GetPlatformInfo(); - OP_CHECK_NULL_WITH_CONTEXT(context, platformInfoPtr); + OPS_LOG_E_IF_NULL(context, platformInfoPtr, return ge::GRAPH_FAILED); auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfoPtr); coreNum = ascendcPlatform.GetCoreNumAiv(); - OP_CHECK_IF(coreNum == 0, OP_LOGE(context, "coreNum is 0"), return ge::GRAPH_FAILED); + OPS_CHECK(coreNum == 0, OPS_LOG_E(context, "coreNum is 0"), return ge::GRAPH_FAILED); ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize); - OP_CHECK_IF(ubSize == 0, OP_LOGE(context, "ubSize is 0"), return ge::GRAPH_FAILED); + OPS_CHECK(ubSize == 0, OPS_LOG_E(context, "ubSize is 0"), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; } @@ -55,21 +55,21 @@ ge::graphStatus GetShapeAttrsInfo(gert::TilingContext* context, int64_t& totalId { // 获取输入shape信息 auto inputX = context->GetInputShape(0); - OP_CHECK_NULL_WITH_CONTEXT(context, inputX); + OPS_LOG_E_IF_NULL(context, inputX, return ge::GRAPH_FAILED); // 如果输入shape 是标量 转换为{1},否则保持原 shape 不变 auto inputShapeX = EnsureNotScalar(inputX->GetStorageShape()); auto inputY = context->GetInputShape(1); - OP_CHECK_NULL_WITH_CONTEXT(context, inputY); + OPS_LOG_E_IF_NULL(context, inputY, return ge::GRAPH_FAILED); auto inputShapeY = EnsureNotScalar(inputY->GetStorageShape()); auto outZ = context->GetOutputShape(0); - OP_CHECK_NULL_WITH_CONTEXT(context, outZ); + OPS_LOG_E_IF_NULL(context, outZ, return ge::GRAPH_FAILED); auto outShapeZ = EnsureNotScalar(outZ->GetStorageShape()); // shape校验 - OP_CHECK_IF( + OPS_CHECK( inputShapeX.GetDimNum() != DIMS_LIMIT || inputShapeY.GetDimNum() != DIMS_LIMIT || outShapeZ.GetDimNum() != DIMS_LIMIT, - OP_LOGE( + OPS_LOG_E( context, "AddExample: inputx,inputy,outputz shape dim = %zu, %zu, %zu, should be equal 4", inputShapeX.GetDimNum(), inputShapeY.GetDimNum(), outShapeZ.GetDimNum()), return ge::GRAPH_FAILED); @@ -83,10 +83,10 @@ ge::graphStatus GetShapeAttrsInfo(gert::TilingContext* context, int64_t& totalId // dtype校验 const std::set supportedDtype = {ge::DT_FLOAT, ge::DT_INT32}; auto inputDesc = context->GetInputDesc(0); - OP_CHECK_NULL_WITH_CONTEXT(context, inputDesc); + OPS_LOG_E_IF_NULL(context, inputDesc, return ge::GRAPH_FAILED); dataType = inputDesc->GetDataType(); if (supportedDtype.count(dataType) == 0) { - OP_LOGE(context, "invalid dtype"); + OPS_LOG_E(context, "invalid dtype"); return ge::GRAPH_FAILED; } return ge::GRAPH_SUCCESS; @@ -95,7 +95,7 @@ ge::graphStatus GetShapeAttrsInfo(gert::TilingContext* context, int64_t& totalId ge::graphStatus GetWorkspaceSize(gert::TilingContext* context) { size_t* currentWorkspace = context->GetWorkspaceSizes(1); - OP_CHECK_NULL_WITH_CONTEXT(context, currentWorkspace); + OPS_LOG_E_IF_NULL(context, currentWorkspace, return ge::GRAPH_FAILED); currentWorkspace[0] = WS_SYS_SIZE; return ge::GRAPH_SUCCESS; } @@ -106,27 +106,27 @@ static ge::graphStatus AddExampleTilingFunc(gert::TilingContext* context) // 1、获取平台运行信息 uint64_t ubSize; int64_t coreNum; - OP_CHECK_IF( - GetPlatformInfo(context, ubSize, coreNum) != ge::GRAPH_SUCCESS, OP_LOGE(context, "GetPlatformInfo error"), + OPS_CHECK( + GetPlatformInfo(context, ubSize, coreNum) != ge::GRAPH_SUCCESS, OPS_LOG_E(context, "GetPlatformInfo error"), return ge::GRAPH_FAILED); // 2、获取shape、属性信息 int64_t totalIdx; ge::DataType dataType; - OP_CHECK_IF( + OPS_CHECK( GetShapeAttrsInfo(context, totalIdx, dataType) != ge::GRAPH_SUCCESS, - OP_LOGE(context, "GetShapeAttrsInfo error"), return ge::GRAPH_FAILED); + OPS_LOG_E(context, "GetShapeAttrsInfo error"), return ge::GRAPH_FAILED); // 3、获取WorkspaceSize信息 - OP_CHECK_IF( - GetWorkspaceSize(context) != ge::GRAPH_SUCCESS, OP_LOGE(context, "GetWorkspaceSize error"), + OPS_CHECK( + GetWorkspaceSize(context) != ge::GRAPH_SUCCESS, OPS_LOG_E(context, "GetWorkspaceSize error"), return ge::GRAPH_FAILED); // 4、设置tiling信息 AddExampleTilingData* tiling = context->GetTilingData(); - OP_CHECK_NULL_WITH_CONTEXT(context, tiling); - OP_CHECK_IF( + OPS_LOG_E_IF_NULL(context, tiling, return ge::GRAPH_FAILED); + OPS_CHECK( memset_s(tiling, sizeof(AddExampleTilingData), 0, sizeof(AddExampleTilingData)) != EOK, - OP_LOGE(context, "set tiling data error"), return ge::GRAPH_FAILED); + OPS_LOG_E(context, "set tiling data error"), return ge::GRAPH_FAILED); tiling->totalLength = totalIdx; tiling->tileNum = TILE_NUM; @@ -140,7 +140,7 @@ static ge::graphStatus AddExampleTilingFunc(gert::TilingContext* context) tilingKey = GET_TPL_TILING_KEY(ELEMENTWISE_TPL_SCH_MODE_1); context->SetTilingKey(tilingKey); } else { - OP_LOGE(context, "get dtype error"); + OPS_LOG_E(context, "get dtype error"); return ge::GRAPH_FAILED; } return ge::GRAPH_SUCCESS; diff --git a/xllm_ops/attention/compressor/op_host/compressor_tiling.cpp b/xllm_ops/attention/compressor/op_host/compressor_tiling.cpp index 090f9ab..ca9b62d 100644 --- a/xllm_ops/attention/compressor/op_host/compressor_tiling.cpp +++ b/xllm_ops/attention/compressor/op_host/compressor_tiling.cpp @@ -145,7 +145,7 @@ void CompressorTiling::ConvertRequiredParams(gert::TilingContext &context, Compr compressorContext.cmpKv.desc = context.GetOutputDesc(CMP_KV_OUTPUT_INDEX); compressorContext.cmpKv.shape = context.GetOutputShape(CMP_KV_OUTPUT_INDEX); - + compressorContext.dtype = compressorContext.x.desc->GetDataType(); auto xDimNum = compressorContext.x.shape->GetStorageShape().GetDimNum(); if (xDimNum == COMPRESSOR_DIM_NUM_3) { @@ -172,11 +172,11 @@ void CompressorTiling::ConvertOptionalParams(gert::TilingContext &context, Compr ge::graphStatus CompressorTiling::ConvertContext(gert::TilingContext &context, CompressorContext &compressorContext) { if (context.GetNodeName() == nullptr) { - OP_LOGE("Compressor", "opName got from TilingContext is nullptr"); + OPS_LOG_E("Compressor", "opName got from TilingContext is nullptr"); return ge::GRAPH_FAILED; } - OP_LOGI("Getting Context"); + OPS_LOG_I("Getting Context"); compressorContext.opName = context.GetNodeName(); compressorContext.opType = context.GetNodeType(); @@ -185,7 +185,7 @@ ge::graphStatus CompressorTiling::ConvertContext(gert::TilingContext &context, C ConvertOptionalParams(context, compressorContext); auto attrs = context.GetAttrs(); - OP_CHECK_IF(attrs == nullptr, OP_LOGE(context.GetNodeName(), "attrs got from ge is nullptr"), + OPS_CHECK(attrs == nullptr, OPS_LOG_E(context.GetNodeName(), "attrs got from ge is nullptr"), return ge::GRAPH_FAILED); compressorContext.ropeHeadDim = attrs->GetAttrPointer(ROPE_HEAD_DIM_ATTR_INDEX); compressorContext.coff = attrs->GetAttrPointer(COFF_ATTR_INDEX); @@ -193,7 +193,7 @@ ge::graphStatus CompressorTiling::ConvertContext(gert::TilingContext &context, C compressorContext.normEps = attrs->GetAttrPointer(NORM_EPS_ATTR_INDEX); compressorContext.rotaryMode = attrs->GetAttrPointer(ROTARY_MODE_ATTR_INDEX); - OP_CHECK_IF(context.GetWorkspaceSizes(1) == nullptr, + OPS_CHECK(context.GetWorkspaceSizes(1) == nullptr, OPS_REPORT_VECTOR_INNER_ERR(context.GetNodeName(), "workSpaceSize got from ge is nullptr"), return ge::GRAPH_FAILED); compressorContext.workSpaces = context.GetWorkspaceSizes(1); @@ -202,7 +202,7 @@ ge::graphStatus CompressorTiling::ConvertContext(gert::TilingContext &context, C ge::graphStatus CompressorTiling::GetNpuInfo() { - OP_CHECK_IF(context_->platformInfo == nullptr, + OPS_CHECK(context_->platformInfo == nullptr, OPS_REPORT_VECTOR_INNER_ERR(context_->opName, "GetPlatformInfo is nullptr."), return ge::GRAPH_FAILED); auto ascendcPlatform = platform_ascendc::PlatformAscendC(context_->platformInfo); @@ -219,7 +219,7 @@ ge::graphStatus CompressorTiling::GetNpuInfo() aivNum_ = ascendcPlatform.GetCoreNumAiv(); aicNum_ = ascendcPlatform.GetCoreNumAic(); - OP_CHECK_IF(aicNum_ == 0 || aivNum_ == 0, + OPS_CHECK(aicNum_ == 0 || aivNum_ == 0, OPS_REPORT_VECTOR_INNER_ERR(context_->opName, "num of core obtained is 0."), return GRAPH_FAILED); return ge::GRAPH_SUCCESS; @@ -239,7 +239,7 @@ ge::graphStatus CompressorTiling::SetBaseInfo() baseParams_->hiddenSize = context_->x.shape->GetStorageShape().GetDim(COMPRESSOR_DIM_INDEX_1); baseParams_->cgSize = context_->ropeSin.shape->GetStorageShape().GetDim(COMPRESSOR_DIM_INDEX_0); } - + baseParams_->headDim = context_->normWeight.shape->GetStorageShape().GetDim(COMPRESSOR_DIM_INDEX_0); baseParams_->cmpRatio = static_cast(*context_->cmpRatio); baseParams_->csSize = baseParams_->seqSize - (baseParams_->seqSize % baseParams_->cmpRatio); @@ -250,8 +250,8 @@ ge::graphStatus CompressorTiling::SetBaseInfo() coff = static_cast(*context_->coff); baseParams_->nSize = 2; // 2:每个核处理两个基本块后做全核同步 - OP_LOGI(context_->opName, "[TILING] bSize:%u tSize:%u cmpRatio:%u coff:%u", baseParams_->batchSize, baseParams_->tokenSize, baseParams_->cmpRatio, coff); - + OPS_LOG_I(context_->opName, "[TILING] bSize:%u tSize:%u cmpRatio:%u coff:%u", baseParams_->batchSize, baseParams_->tokenSize, baseParams_->cmpRatio, coff); + return ge::GRAPH_SUCCESS; } @@ -327,13 +327,13 @@ ge::graphStatus CompressorTiling::CalcWorkSpace() workspaceSize_ += aicNum_ * workspaceParams_->preMm1ResSize * MM1_RES_ELEM_SIZE; workspaceSize_ += aicNum_ * workspaceParams_->curMm1ResSize * MM1_RES_ELEM_SIZE; workspaceSize_ += aicNum_ * workspaceParams_->vec1ResSize * V1_RES_ELEM_SIZE; - + workspaceSize_ += 1024 * 1024 * 1024; // 1024:申请workspace大小 if (context_->workSpaces) { context_->workSpaces[0] = workspaceSize_; } - - OP_LOGI(context_->opName, "Tiling info: workspaceSize_ = %zu", workspaceSize_); + + OPS_LOG_I(context_->opName, "Tiling info: workspaceSize_ = %zu", workspaceSize_); return ge::GRAPH_SUCCESS; } @@ -357,7 +357,7 @@ ge::graphStatus CompressorTiling::CheckEmptyTensor() const return ge::GRAPH_FAILED; } context_->templateId = TemplateId::NORMAL; - OP_LOGI(context_->opName, "Only input tensor x supports empty state"); + OPS_LOG_I(context_->opName, "Only input tensor x supports empty state"); } return ge::GRAPH_SUCCESS; } @@ -408,7 +408,7 @@ ge::graphStatus CompressorTiling::RunBigKernelTiling(CompressorTilingData* tilin context_->blockDim = aicNum_; - OP_LOGI("Run big kernel"); + OPS_LOG_I("Run big kernel"); return ge::GRAPH_SUCCESS; } @@ -421,7 +421,7 @@ ge::graphStatus CompressorTiling::GenTilingKey() const uint8_t layout = 0; uint8_t rotaryMode = static_cast(*context_->rotaryMode); uint8_t templateId = static_cast(context_->templateId); - + auto xDtype = context_->x.desc->GetDataType(); if (xDtype == ge::DT_BF16) { dtype = 0; @@ -434,7 +434,7 @@ ge::graphStatus CompressorTiling::GenTilingKey() const }else { layout = 1; } - + context_->tilingKey = GET_TPL_TILING_KEY( layout, dtype, @@ -443,8 +443,8 @@ ge::graphStatus CompressorTiling::GenTilingKey() const templateId ); - OP_LOGI(context_->opName, "Compressor dtype:%hhu layout:%hhu coff:%hhu rotary_mode:%hhu, template_id:%hhu", dtype, layout, coff, rotaryMode, templateId); - OP_LOGI(context_->opName, "Compressor tilingKey:%lu", context_->tilingKey); + OPS_LOG_I(context_->opName, "Compressor dtype:%hhu layout:%hhu coff:%hhu rotary_mode:%hhu, template_id:%hhu", dtype, layout, coff, rotaryMode, templateId); + OPS_LOG_I(context_->opName, "Compressor tilingKey:%lu", context_->tilingKey); return ge::GRAPH_SUCCESS; } @@ -515,7 +515,7 @@ void CompressorTiling::LogErrorNumberSupport(const std::vector &expectNumberL } } - OP_LOGE("Compressor", "%s %s only supports %s, but got %s", + OPS_LOG_E("Compressor", "%s %s only supports %s, but got %s", name.c_str(), subName.c_str(), oss.str().c_str(), std::to_string(actualValue).c_str()); } @@ -525,7 +525,7 @@ std::string LayoutTypeToStr(LayoutType layout) { return "BSH"; case LayoutType::LAYOUT_TH: return "TH"; - default: + default: return "UNKNOWN_LAYOUT"; } } @@ -534,8 +534,8 @@ ge::graphStatus CompressorTiling::CheckDimNumInLayoutSupport(const std::string & const std::string &name) const { const auto& dimIt = LAYOUT_DIM_MAP.find(layout); - OP_CHECK_IF(shape->GetStorageShape().GetDimNum() != dimIt->second, - OP_LOGE("Compressor", "When layout is %s, %s dimension should be %zu, but it's %zu", + OPS_CHECK(shape->GetStorageShape().GetDimNum() != dimIt->second, + OPS_LOG_E("Compressor", "When layout is %s, %s dimension should be %zu, but it's %zu", layout.c_str(), name.c_str(), dimIt->second, shape->GetStorageShape().GetDimNum()), return ge::GRAPH_FAILED); @@ -547,11 +547,11 @@ ge::graphStatus CompressorTiling::CheckDtypeSupport(const gert::CompileTimeTenso { if (desc != nullptr) { const auto &it = DTYPE_SUPPORT_MAP.find(name); - OP_CHECK_IF(it == DTYPE_SUPPORT_MAP.end(), - OP_LOGE("Compressor", "%s datatype support list should be specify in DTYPE_SUPPORT_MAP", name.c_str()), + OPS_CHECK(it == DTYPE_SUPPORT_MAP.end(), + OPS_LOG_E("Compressor", "%s datatype support list should be specify in DTYPE_SUPPORT_MAP", name.c_str()), return ge::GRAPH_FAILED); auto &expectDtypeList = it->second; - OP_CHECK_IF(std::find(expectDtypeList.begin(), expectDtypeList.end(), desc->GetDataType()) == + OPS_CHECK(std::find(expectDtypeList.begin(), expectDtypeList.end(), desc->GetDataType()) == expectDtypeList.end(), LogErrorDtypeSupport(expectDtypeList, desc->GetDataType(), name), return ge::GRAPH_FAILED); } @@ -568,7 +568,7 @@ void CompressorTiling::LogErrorDtypeSupport(const std::vector &exp oss << ", "; } } - OP_LOGE("Compressor", "Tensor %s only supports dtype %s, but got %s", name.c_str(), oss.str().c_str(), + OPS_LOG_E("Compressor", "Tensor %s only supports dtype %s, but got %s", name.c_str(), oss.str().c_str(), DataTypeToSerialString(actualDtype).c_str()); } @@ -578,7 +578,7 @@ static std::string DataTypeToSerialString(ge::DataType type) if (it != DATATYPE_TO_STRING_MAP.end()) { return it->second; } else { - OP_LOGE("Compressor", "datatype %d not support", type); + OPS_LOG_E("Compressor", "datatype %d not support", type); return "UNDEFINED"; } } @@ -589,11 +589,11 @@ ge::graphStatus CompressorTiling::CheckDimNumSupport(const gert::StorageShape *s return ge::GRAPH_SUCCESS; } const auto &it = DIM_NUM_MAP.find(name); - OP_CHECK_IF(it == DIM_NUM_MAP.end(), - OP_LOGE("Compressor", "%s dim number support list should be specify in DIM_NUM_MAP", name.c_str()), + OPS_CHECK(it == DIM_NUM_MAP.end(), + OPS_LOG_E("Compressor", "%s dim number support list should be specify in DIM_NUM_MAP", name.c_str()), return ge::GRAPH_FAILED); auto &expectDimNumList = it->second; - OP_CHECK_IF(std::find(expectDimNumList.begin(), expectDimNumList.end(), shape->GetStorageShape().GetDimNum()) == + OPS_CHECK(std::find(expectDimNumList.begin(), expectDimNumList.end(), shape->GetStorageShape().GetDimNum()) == expectDimNumList.end(), LogErrorNumberSupport(expectDimNumList, static_cast(shape->GetStorageShape().GetDimNum()), name, "dimension"), @@ -804,45 +804,45 @@ ge::graphStatus CompressorTiling::CheckRequiredParaExistence() const ge::graphStatus CompressorTiling::CheckRequiredInOutExistence() const { - OP_CHECK_IF(context_->x.shape == nullptr, OP_LOGE("Compressor", "Shape of tensor x is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->x.desc == nullptr, OP_LOGE("Compressor", "Desc of tensor x is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->wkv.shape == nullptr, OP_LOGE("Compressor", "Shape of tensor wkv is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->wkv.desc == nullptr, OP_LOGE("Compressor", "Desc of tensor wkv is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->wgate.shape == nullptr, OP_LOGE("Compressor", "Shape of tensor wgate is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->wgate.desc == nullptr, OP_LOGE("Compressor", "Desc of tensor wgate is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->kvState.shape == nullptr, OP_LOGE("Compressor", "Shape of tensor kvState is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->kvState.desc == nullptr, OP_LOGE("Compressor", "Desc of tensor kvState is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->scoreState.shape == nullptr, OP_LOGE("Compressor", "Shape of tensor scoreState is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->scoreState.desc == nullptr, OP_LOGE("Compressor", "Desc of tensor scoreState is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->ape.shape == nullptr, OP_LOGE("Compressor", "Shape of tensor ape is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->ape.desc == nullptr, OP_LOGE("Compressor", "Desc of tensor ape is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->normWeight.shape == nullptr, OP_LOGE("Compressor", "Shape of tensor normWeight is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->normWeight.desc == nullptr, OP_LOGE("Compressor", "Desc of tensor normWeight is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->ropeSin.shape == nullptr, OP_LOGE("Compressor", "Shape of tensor ropeSin is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->ropeSin.desc == nullptr, OP_LOGE("Compressor", "Desc of tensor ropeSin is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->ropeCos.shape == nullptr, OP_LOGE("Compressor", "Shape of tensor ropeCos is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->ropeCos.desc == nullptr, OP_LOGE("Compressor", "Desc of tensor ropeCos is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->kvBlockTable.shape == nullptr, OP_LOGE("Compressor", "Shape of tensor kvBlockTable is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->kvBlockTable.desc == nullptr, OP_LOGE("Compressor", "Desc of tensor kvBlockTable is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->scoreBlockTable.shape == nullptr, OP_LOGE("Compressor", "Shape of tensor scoreBlockTable is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->scoreBlockTable.desc == nullptr, OP_LOGE("Compressor", "Desc of tensor scoreBlockTable is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->cmpKv.shape == nullptr, OP_LOGE("Compressor", "Shape of tensor cmpKv is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->cmpKv.desc == nullptr, OP_LOGE("Compressor", "Desc of tensor cmpKv is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->x.shape == nullptr, OPS_LOG_E("Compressor", "Shape of tensor x is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->x.desc == nullptr, OPS_LOG_E("Compressor", "Desc of tensor x is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->wkv.shape == nullptr, OPS_LOG_E("Compressor", "Shape of tensor wkv is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->wkv.desc == nullptr, OPS_LOG_E("Compressor", "Desc of tensor wkv is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->wgate.shape == nullptr, OPS_LOG_E("Compressor", "Shape of tensor wgate is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->wgate.desc == nullptr, OPS_LOG_E("Compressor", "Desc of tensor wgate is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->kvState.shape == nullptr, OPS_LOG_E("Compressor", "Shape of tensor kvState is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->kvState.desc == nullptr, OPS_LOG_E("Compressor", "Desc of tensor kvState is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->scoreState.shape == nullptr, OPS_LOG_E("Compressor", "Shape of tensor scoreState is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->scoreState.desc == nullptr, OPS_LOG_E("Compressor", "Desc of tensor scoreState is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->ape.shape == nullptr, OPS_LOG_E("Compressor", "Shape of tensor ape is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->ape.desc == nullptr, OPS_LOG_E("Compressor", "Desc of tensor ape is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->normWeight.shape == nullptr, OPS_LOG_E("Compressor", "Shape of tensor normWeight is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->normWeight.desc == nullptr, OPS_LOG_E("Compressor", "Desc of tensor normWeight is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->ropeSin.shape == nullptr, OPS_LOG_E("Compressor", "Shape of tensor ropeSin is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->ropeSin.desc == nullptr, OPS_LOG_E("Compressor", "Desc of tensor ropeSin is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->ropeCos.shape == nullptr, OPS_LOG_E("Compressor", "Shape of tensor ropeCos is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->ropeCos.desc == nullptr, OPS_LOG_E("Compressor", "Desc of tensor ropeCos is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->kvBlockTable.shape == nullptr, OPS_LOG_E("Compressor", "Shape of tensor kvBlockTable is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->kvBlockTable.desc == nullptr, OPS_LOG_E("Compressor", "Desc of tensor kvBlockTable is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->scoreBlockTable.shape == nullptr, OPS_LOG_E("Compressor", "Shape of tensor scoreBlockTable is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->scoreBlockTable.desc == nullptr, OPS_LOG_E("Compressor", "Desc of tensor scoreBlockTable is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->cmpKv.shape == nullptr, OPS_LOG_E("Compressor", "Shape of tensor cmpKv is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->cmpKv.desc == nullptr, OPS_LOG_E("Compressor", "Desc of tensor cmpKv is nullptr"), return ge::GRAPH_FAILED); if (context_->layout == LayoutType::LAYOUT_TH){ - OP_CHECK_IF(context_->cuSeqlens.desc == nullptr, - OP_LOGE("Compressor", "In TH situation, desc of tensor cuSeqlens should not be nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->cuSeqlens.shape == nullptr, - OP_LOGE("Compressor", "In TH situation, shape of tensor cuSeqlens should not be nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->cuSeqlens.desc == nullptr, + OPS_LOG_E("Compressor", "In TH situation, desc of tensor cuSeqlens should not be nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(context_->cuSeqlens.shape == nullptr, + OPS_LOG_E("Compressor", "In TH situation, shape of tensor cuSeqlens should not be nullptr"), return ge::GRAPH_FAILED); } return ge::GRAPH_SUCCESS; } ge::graphStatus CompressorTiling::CheckRequiredAttrExistence() const { - OP_CHECK_IF(context_->ropeHeadDim == nullptr, OP_LOGE("Compressor", "attr ropeHeadDim is nullptr"), + OPS_CHECK(context_->ropeHeadDim == nullptr, OPS_LOG_E("Compressor", "attr ropeHeadDim is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->cmpRatio == nullptr, OP_LOGE("Compressor", "attr cmpRatio is nullptr"), + OPS_CHECK(context_->cmpRatio == nullptr, OPS_LOG_E("Compressor", "attr cmpRatio is nullptr"), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; } @@ -852,14 +852,14 @@ ge::graphStatus CompressorTiling::CheckFeature() const if (ge::GRAPH_SUCCESS != CheckFeatureValueSupport(&baseParams_->headDim, HEAD_DIM, "headDim")) { return ge::GRAPH_FAILED; } - OP_CHECK_IF(baseParams_->hiddenSize > MAX_HIDDEN_SIZE || baseParams_->hiddenSize < MIN_HIDDEN_SIZE || + OPS_CHECK(baseParams_->hiddenSize > MAX_HIDDEN_SIZE || baseParams_->hiddenSize < MIN_HIDDEN_SIZE || baseParams_->hiddenSize % ALIGN_FACTOR_HIDDEN_SIZE != 0, - OP_LOGE("Compressor", "hiddenSize should be whthin [1k, 10k] and be 512-aligned, but got %u", + OPS_LOG_E("Compressor", "hiddenSize should be whthin [1k, 10k] and be 512-aligned, but got %u", baseParams_->hiddenSize), return ge::GRAPH_FAILED); - OP_CHECK_IF(pageAttentionParams_->blockSize > MAX_BLOCK_SIZE || pageAttentionParams_->blockSize < MIN_BLOCK_SIZE || + OPS_CHECK(pageAttentionParams_->blockSize > MAX_BLOCK_SIZE || pageAttentionParams_->blockSize < MIN_BLOCK_SIZE || pageAttentionParams_->blockSize % ALIGN_FACTOR_BLOCK_SIZE != 0, - OP_LOGE("Compressor", "blockSize should be whthin [16, 1024] and be 16-aligned, but got %u", + OPS_LOG_E("Compressor", "blockSize should be whthin [16, 1024] and be 16-aligned, but got %u", pageAttentionParams_->blockSize), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; @@ -873,8 +873,8 @@ ge::graphStatus CompressorTiling::LogErrorShapeConsistency(const std::string &na } const uint32_t actualNum = shape->GetStorageShape().GetDim(dimNum); - OP_CHECK_IF(actualNum != expectNum, - OP_LOGE("Compressor", + OPS_CHECK(actualNum != expectNum, + OPS_LOG_E("Compressor", "%s shape dim [%s] should be equal to %u, but got %u", name.c_str(), subName.c_str(), expectNum, actualNum), return ge::GRAPH_FAILED); @@ -900,7 +900,7 @@ ge::graphStatus CompressorTiling::CheckShapeConsistency() const ge::GRAPH_SUCCESS != LogErrorShapeConsistency("kvState", context_->kvState.shape, COMPRESSOR_DIM_INDEX_2, "coff*headDim", static_cast(coffD)) || ge::GRAPH_SUCCESS != LogErrorShapeConsistency("scoreState", context_->scoreState.shape, COMPRESSOR_DIM_INDEX_2, "coff*headDim", static_cast(coffD)) || ge::GRAPH_SUCCESS != LogErrorShapeConsistency("ape", context_->ape.shape, COMPRESSOR_DIM_INDEX_1, "coff*headDim", static_cast(coffD)) || - ge::GRAPH_SUCCESS != LogErrorShapeConsistency("ape", context_->ape.shape, COMPRESSOR_DIM_INDEX_0, "cmpRatio", baseParams_->cmpRatio)) { + ge::GRAPH_SUCCESS != LogErrorShapeConsistency("ape", context_->ape.shape, COMPRESSOR_DIM_INDEX_0, "cmpRatio", baseParams_->cmpRatio)) { return ge::GRAPH_FAILED; } const auto& scoreStateShape = context_->scoreState.shape->GetStorageShape(); @@ -908,8 +908,8 @@ ge::graphStatus CompressorTiling::CheckShapeConsistency() const uint32_t actualDim1 = scoreStateShape.GetDim(COMPRESSOR_DIM_INDEX_1); const uint32_t expectDim0 = pageAttentionParams_->blockNum; const uint32_t expectDim1 = pageAttentionParams_->blockSize; - OP_CHECK_IF(actualDim0 != expectDim0 || actualDim1 != expectDim1, - OP_LOGE("Compressor", "scoreState shape dim0 should be blockNum(%u), dim1 should be blockSize(%u), but got dim0=%u, dim1=%u", + OPS_CHECK(actualDim0 != expectDim0 || actualDim1 != expectDim1, + OPS_LOG_E("Compressor", "scoreState shape dim0 should be blockNum(%u), dim1 should be blockSize(%u), but got dim0=%u, dim1=%u", expectDim0, expectDim1, actualDim0, actualDim1), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; } @@ -941,9 +941,9 @@ ge::graphStatus CompressorTiling::CheckDtypeConsistencyX(const gert::CompileTime const std::string &name) const { const auto actualDtype = desc->GetDataType(); - OP_CHECK_IF( + OPS_CHECK( actualDtype != context_->dtype, - OP_LOGE("Compressor", "%s datatype should be same with x: %s, but got %s", name.c_str(), + OPS_LOG_E("Compressor", "%s datatype should be same with x: %s, but got %s", name.c_str(), DataTypeToSerialString(actualDtype).c_str(), DataTypeToSerialString(context_->dtype).c_str()), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; @@ -965,16 +965,16 @@ ge::graphStatus CompressorTiling::CheckDtypeConsistency() const ge::graphStatus CompressorTiling::CheckDimNumConsistency() const { auto xDimNum = context_->x.shape->GetStorageShape().GetDimNum(); - OP_CHECK_IF(xDimNum != context_->ropeSin.shape->GetStorageShape().GetDimNum(), - OP_LOGE("Compressor", "ropeSin dim num should be equal to x: %u, but got %u", xDimNum, + OPS_CHECK(xDimNum != context_->ropeSin.shape->GetStorageShape().GetDimNum(), + OPS_LOG_E("Compressor", "ropeSin dim num should be equal to x: %u, but got %u", xDimNum, context_->ropeSin.shape->GetStorageShape().GetDimNum()), return ge::GRAPH_FAILED); - OP_CHECK_IF(xDimNum != context_->ropeCos.shape->GetStorageShape().GetDimNum(), - OP_LOGE("Compressor", "ropeCos dim num should be equal to x: %u, but got %u", xDimNum, + OPS_CHECK(xDimNum != context_->ropeCos.shape->GetStorageShape().GetDimNum(), + OPS_LOG_E("Compressor", "ropeCos dim num should be equal to x: %u, but got %u", xDimNum, context_->ropeCos.shape->GetStorageShape().GetDimNum()), return ge::GRAPH_FAILED); - OP_CHECK_IF(xDimNum != context_->cmpKv.shape->GetStorageShape().GetDimNum(), - OP_LOGE("Compressor", "cmpKv dim num should be equal to x: %u, but got %u", xDimNum, + OPS_CHECK(xDimNum != context_->cmpKv.shape->GetStorageShape().GetDimNum(), + OPS_LOG_E("Compressor", "cmpKv dim num should be equal to x: %u, but got %u", xDimNum, context_->cmpKv.shape->GetStorageShape().GetDimNum()), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; @@ -988,8 +988,8 @@ ge::graphStatus CompressorTiling::CheckScenarioConsistency() const std::vector curScenario{curCmpratio, curCoff, curHeaddim}; const std::vector> allowdScenarios = {{4, 2, 512}, {4, 2, 128}, {128, 1, 512}}; - OP_CHECK_IF(std::find(allowdScenarios.begin(), allowdScenarios.end(), curScenario) == allowdScenarios.end(), - OP_LOGE("Compressor", "Cmpratio Coff Headdim should be equal to {4, 2, 512}, {4, 2, 128}, {128, 1, 512},\ + OPS_CHECK(std::find(allowdScenarios.begin(), allowdScenarios.end(), curScenario) == allowdScenarios.end(), + OPS_LOG_E("Compressor", "Cmpratio Coff Headdim should be equal to {4, 2, 512}, {4, 2, 128}, {128, 1, 512},\ but now cmpratio=%u, coff=%u, headdim=%u", curCmpratio, curCoff, curHeaddim), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; } @@ -1010,19 +1010,19 @@ ge::graphStatus CompressorTiling::CheckMultiParaConsistency() const CMP_EXTERN_C ge::graphStatus TilingCompressor(gert::TilingContext *context) { - OP_CHECK_IF(context == nullptr, OPS_REPORT_VECTOR_INNER_ERR("Compressor", "Context is nullptr."), + OPS_CHECK(context == nullptr, OPS_REPORT_VECTOR_INNER_ERR("Compressor", "Context is nullptr."), return ge::GRAPH_FAILED); - OP_LOGI("Getting Tiling"); + OPS_LOG_I("Getting Tiling"); CompressorContext compressorContext{}; if (CompressorTiling::ConvertContext(*context, compressorContext) != ge::GRAPH_SUCCESS) { - OP_LOGE(context->GetNodeName(), "Error occurred while converting tilingContext to Compressor context"); + OPS_LOG_E(context->GetNodeName(), "Error occurred while converting tilingContext to Compressor context"); return ge::GRAPH_FAILED; } CompressorTiling compressorTiling(&compressorContext); CompressorTilingData* tilingData = context->GetTilingData(); - OP_CHECK_IF(tilingData == nullptr, + OPS_CHECK(tilingData == nullptr, OPS_REPORT_VECTOR_INNER_ERR(context->GetNodeName(), "TilingData is nullptr."), return ge::GRAPH_FAILED); // 使用SyncAll,需要设置为batchmode模式,所有核同时启动,否则多流方式下执行可能会卡死 @@ -1030,7 +1030,7 @@ CMP_EXTERN_C ge::graphStatus TilingCompressor(gert::TilingContext *context) if (compressorTiling.RunBigKernelTiling(tilingData) == ge::SUCCESS) { context->SetTilingKey(compressorContext.tilingKey); context->SetBlockDim(compressorContext.blockDim); - OP_LOGI(context->GetNodeName(), "Compressor block dim: %u.", compressorContext.blockDim); + OPS_LOG_I(context->GetNodeName(), "Compressor block dim: %u.", compressorContext.blockDim); return ge::GRAPH_SUCCESS; } diff --git a/xllm_ops/attention/inplace_partial_rotary_mul/op_host/inplace_partial_rotary_mul_tiling.cpp b/xllm_ops/attention/inplace_partial_rotary_mul/op_host/inplace_partial_rotary_mul_tiling.cpp index 0cb54d8..b049a9e 100644 --- a/xllm_ops/attention/inplace_partial_rotary_mul/op_host/inplace_partial_rotary_mul_tiling.cpp +++ b/xllm_ops/attention/inplace_partial_rotary_mul/op_host/inplace_partial_rotary_mul_tiling.cpp @@ -14,7 +14,6 @@ */ #include "inplace_partial_rotary_mul_tiling.h" #include "register/op_def_registry.h" -// #include "log/log.h" #include "tiling/tiling_api.h" // #include "tiling_base/tiling_templates_registry.h" #include diff --git a/xllm_ops/attention/inplace_partial_rotary_mul/op_host/rope_regbase_tiling_base.cpp b/xllm_ops/attention/inplace_partial_rotary_mul/op_host/rope_regbase_tiling_base.cpp index d46f8f6..50cf579 100644 --- a/xllm_ops/attention/inplace_partial_rotary_mul/op_host/rope_regbase_tiling_base.cpp +++ b/xllm_ops/attention/inplace_partial_rotary_mul/op_host/rope_regbase_tiling_base.cpp @@ -19,7 +19,6 @@ #include "platform/platform_info.h" #include "inplace_partial_rotary_mul_tiling.h" #include -// #include "log/log.h" namespace { constexpr int64_t X_INDEX = 0; diff --git a/xllm_ops/attention/quant_lightning_indexer/op_host/quant_lightning_indexer_infershape.cpp b/xllm_ops/attention/quant_lightning_indexer/op_host/quant_lightning_indexer_infershape.cpp index c864331..0fad353 100644 --- a/xllm_ops/attention/quant_lightning_indexer/op_host/quant_lightning_indexer_infershape.cpp +++ b/xllm_ops/attention/quant_lightning_indexer/op_host/quant_lightning_indexer_infershape.cpp @@ -16,7 +16,7 @@ #include #include "err/ops_err.h" -#include "log/log.h" +#include "log/ops_log.h" using namespace ge; @@ -33,30 +33,30 @@ constexpr uint32_t DIM_NUM_4 = 4; static ge::graphStatus InferShapeQuantLightningIndexer(gert::InferShapeContext *context) { if (context == nullptr) { - OP_LOGE("QuantLightningIndexer", "context is nullptr!"); + OPS_LOG_E("QuantLightningIndexer", "context is nullptr!"); return ge::GRAPH_FAILED; } const gert::Shape *queryShape = context->GetInputShape(QUERY_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context, queryShape); + OPS_LOG_E_IF_NULL(context, queryShape, return ge::GRAPH_FAILED); const gert::Shape *keyShape = context->GetInputShape(KEY_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context, keyShape); + OPS_LOG_E_IF_NULL(context, keyShape, return ge::GRAPH_FAILED); gert::Shape *sparseIndicesShape = context->GetOutputShape(0); - OP_CHECK_NULL_WITH_CONTEXT(context, sparseIndicesShape); + OPS_LOG_E_IF_NULL(context, sparseIndicesShape, return ge::GRAPH_FAILED); gert::Shape *sparseValuesShape = context->GetOutputShape(1); auto attrs = context->GetAttrs(); - OP_CHECK_NULL_WITH_CONTEXT(context, attrs); + OPS_LOG_E_IF_NULL(context, attrs, return ge::GRAPH_FAILED); const char *inputLayoutQueryPtr = attrs->GetAttrPointer(ATTR_QUERY_LAYOUT_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context, inputLayoutQueryPtr); + OPS_LOG_E_IF_NULL(context, inputLayoutQueryPtr, return ge::GRAPH_FAILED); const char *inputLayoutKeyPtr = attrs->GetAttrPointer(ATTR_KV_LAYOUT_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context, inputLayoutKeyPtr); + OPS_LOG_E_IF_NULL(context, inputLayoutKeyPtr, return ge::GRAPH_FAILED); const int64_t *sparse_count = attrs->GetInt(ATTR_SPARSE_COUNT_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context, sparse_count); + OPS_LOG_E_IF_NULL(context, sparse_count, return ge::GRAPH_FAILED); std::string inputLayoutQueryPtrStr = std::string(inputLayoutQueryPtr); std::string inputLayoutKeyPtrStr = std::string(inputLayoutKeyPtr); if (inputLayoutQueryPtrStr != "TND" && inputLayoutQueryPtrStr != "BSND") { - OP_LOGE(context, "The input layout query should be TND or BSND, but got %s.", inputLayoutQueryPtrStr.c_str()); + OPS_LOG_E(context, "The input layout query should be TND or BSND, but got %s.", inputLayoutQueryPtrStr.c_str()); return GRAPH_FAILED; } @@ -82,21 +82,21 @@ static ge::graphStatus InferShapeQuantLightningIndexer(gert::InferShapeContext * sparseValuesShape->SetDim(0, 0); } - OP_LOGD(context->GetNodeName(), "QuantLightningIndexer InferShape end."); + OPS_LOG_D(context->GetNodeName(), "QuantLightningIndexer InferShape end."); return ge::GRAPH_SUCCESS; } static ge::graphStatus InferDataTypeQuantLightningIndexer(gert::InferDataTypeContext *context) { if (context == nullptr) { - OP_LOGE("QuantLightningIndexer", "InferDataTypeContext context is nullptr!"); + OPS_LOG_E("QuantLightningIndexer", "InferDataTypeContext context is nullptr!"); return ge::GRAPH_FAILED; } - OP_LOGD(context->GetNodeName(), "Enter QuantLightningIndexer InferDataType impl."); + OPS_LOG_D(context->GetNodeName(), "Enter QuantLightningIndexer InferDataType impl."); // default index data type is int32 ge::DataType outputType = ge::DT_INT32; context->SetOutputDataType(0, outputType); - OP_LOGD(context->GetNodeName(), "QuantLightningIndexer InferDataType end."); + OPS_LOG_D(context->GetNodeName(), "QuantLightningIndexer InferDataType end."); return GRAPH_SUCCESS; } diff --git a/xllm_ops/attention/quant_lightning_indexer/op_host/quant_lightning_indexer_tiling.cpp b/xllm_ops/attention/quant_lightning_indexer/op_host/quant_lightning_indexer_tiling.cpp index 530151a..5e51a63 100644 --- a/xllm_ops/attention/quant_lightning_indexer/op_host/quant_lightning_indexer_tiling.cpp +++ b/xllm_ops/attention/quant_lightning_indexer/op_host/quant_lightning_indexer_tiling.cpp @@ -25,49 +25,49 @@ namespace optiling { // --------------------------QLIInfoParser类成员函数定义------------------------------------- ge::graphStatus QLIInfoParser::CheckRequiredInOutExistence() const { - OP_CHECK_IF(opParamInfo_.query.shape == nullptr, OP_LOGE(opName_, "Shape of tensor query is nullptr"), + OPS_CHECK(opParamInfo_.query.shape == nullptr, OPS_LOG_E(opName_, "Shape of tensor query is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.query.desc == nullptr, OP_LOGE(opName_, "Desc of tensor query is nullptr"), + OPS_CHECK(opParamInfo_.query.desc == nullptr, OPS_LOG_E(opName_, "Desc of tensor query is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.key.shape == nullptr, OP_LOGE(opName_, "Shape of tensor key is nullptr"), + OPS_CHECK(opParamInfo_.key.shape == nullptr, OPS_LOG_E(opName_, "Shape of tensor key is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.key.desc == nullptr, OP_LOGE(opName_, "Desc of tensor key is nullptr"), + OPS_CHECK(opParamInfo_.key.desc == nullptr, OPS_LOG_E(opName_, "Desc of tensor key is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.weights.shape == nullptr, OP_LOGE(opName_, "Shape of tensor weights is nullptr"), + OPS_CHECK(opParamInfo_.weights.shape == nullptr, OPS_LOG_E(opName_, "Shape of tensor weights is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.weights.desc == nullptr, OP_LOGE(opName_, "Desc of tensor weights is nullptr"), + OPS_CHECK(opParamInfo_.weights.desc == nullptr, OPS_LOG_E(opName_, "Desc of tensor weights is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.query_dequant_scale.shape == nullptr, - OP_LOGE(opName_, "Shape of tensor query_dequant_scale is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.query_dequant_scale.desc == nullptr, - OP_LOGE(opName_, "Desc of tensor query_dequant_scale is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.key_dequant_scale.shape == nullptr, - OP_LOGE(opName_, "Shape of tensor key_dequant_scale is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.key_dequant_scale.desc == nullptr, - OP_LOGE(opName_, "Desc of tensor key_dequant_scale is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.attenOut.shape == nullptr, OP_LOGE(opName_, "Shape of tensor output is nullptr"), + OPS_CHECK(opParamInfo_.query_dequant_scale.shape == nullptr, + OPS_LOG_E(opName_, "Shape of tensor query_dequant_scale is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(opParamInfo_.query_dequant_scale.desc == nullptr, + OPS_LOG_E(opName_, "Desc of tensor query_dequant_scale is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(opParamInfo_.key_dequant_scale.shape == nullptr, + OPS_LOG_E(opName_, "Shape of tensor key_dequant_scale is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(opParamInfo_.key_dequant_scale.desc == nullptr, + OPS_LOG_E(opName_, "Desc of tensor key_dequant_scale is nullptr"), return ge::GRAPH_FAILED); + OPS_CHECK(opParamInfo_.attenOut.shape == nullptr, OPS_LOG_E(opName_, "Shape of tensor output is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.attenOut.desc == nullptr, OP_LOGE(opName_, "Desc of tensor output is nullptr"), + OPS_CHECK(opParamInfo_.attenOut.desc == nullptr, OPS_LOG_E(opName_, "Desc of tensor output is nullptr"), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; } ge::graphStatus QLIInfoParser::CheckRequiredAttrExistence() const { - OP_CHECK_IF(opParamInfo_.layOutQuery == nullptr, OP_LOGE(opName_, "attr layout_query is nullptr"), + OPS_CHECK(opParamInfo_.layOutQuery == nullptr, OPS_LOG_E(opName_, "attr layout_query is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.layOutKey == nullptr, OP_LOGE(opName_, "attr layout_key is nullptr"), + OPS_CHECK(opParamInfo_.layOutKey == nullptr, OPS_LOG_E(opName_, "attr layout_key is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.sparseCount == nullptr, OP_LOGE(opName_, "attr sparse_count is nullptr"), + OPS_CHECK(opParamInfo_.sparseCount == nullptr, OPS_LOG_E(opName_, "attr sparse_count is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.sparseMode == nullptr, OP_LOGE(opName_, "attr sparse_mode is nullptr"), + OPS_CHECK(opParamInfo_.sparseMode == nullptr, OPS_LOG_E(opName_, "attr sparse_mode is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.queryQuantMode == nullptr, OP_LOGE(opName_, "query_quant_mode is nullptr"), + OPS_CHECK(opParamInfo_.queryQuantMode == nullptr, OPS_LOG_E(opName_, "query_quant_mode is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.keyQuantMode == nullptr, OP_LOGE(opName_, "key_quant_mode is nullptr"), + OPS_CHECK(opParamInfo_.keyQuantMode == nullptr, OPS_LOG_E(opName_, "key_quant_mode is nullptr"), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; @@ -85,7 +85,7 @@ ge::graphStatus QLIInfoParser::CheckRequiredParaExistence() const ge::graphStatus QLIInfoParser::GetOpName() { if (context_->GetNodeName() == nullptr) { - OP_LOGE("QuantLightningIndexer", "opName got from TilingContext is nullptr"); + OPS_LOG_E("QuantLightningIndexer", "opName got from TilingContext is nullptr"); return ge::GRAPH_FAILED; } opName_ = context_->GetNodeName(); @@ -95,24 +95,24 @@ ge::graphStatus QLIInfoParser::GetOpName() ge::graphStatus QLIInfoParser::GetNpuInfo() { platformInfo_ = context_->GetPlatformInfo(); - OP_CHECK_IF(platformInfo_ == nullptr, OP_LOGE(opName_, "GetPlatformInfo is nullptr."), return ge::GRAPH_FAILED); + OPS_CHECK(platformInfo_ == nullptr, OPS_LOG_E(opName_, "GetPlatformInfo is nullptr."), return ge::GRAPH_FAILED); auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo_); uint32_t aivNum = ascendcPlatform.GetCoreNumAiv(); uint32_t aicNum = ascendcPlatform.GetCoreNumAic(); - OP_CHECK_IF(aicNum == 0 || aivNum == 0, OP_LOGE(opName_, "num of core obtained is 0."), return GRAPH_FAILED); + OPS_CHECK(aicNum == 0 || aivNum == 0, OPS_LOG_E(opName_, "num of core obtained is 0."), return GRAPH_FAILED); socVersion_ = ascendcPlatform.GetSocVersion(); if ((socVersion_ != platform_ascendc::SocVersion::ASCEND910B) && (socVersion_ != platform_ascendc::SocVersion::ASCEND910_93) && (socVersion_ != platform_ascendc::SocVersion::ASCEND910_95)) { - OP_LOGE(opName_, "SOC Version[%d] is not support.", static_cast(socVersion_)); + OPS_LOG_E(opName_, "SOC Version[%d] is not support.", static_cast(socVersion_)); return GRAPH_FAILED; } - OP_CHECK_IF(context_->GetWorkspaceSizes(1) == nullptr, OP_LOGE(opName_, "workSpaceSize got from ge is nullptr"), + OPS_CHECK(context_->GetWorkspaceSizes(1) == nullptr, OPS_LOG_E(opName_, "workSpaceSize got from ge is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(context_->GetRawTilingData() == nullptr, - OP_LOGE(context_->GetNodeName(), "RawTilingData got from GE context is nullptr."), + OPS_CHECK(context_->GetRawTilingData() == nullptr, + OPS_LOG_E(context_->GetNodeName(), "RawTilingData got from GE context is nullptr."), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; @@ -154,10 +154,10 @@ void QLIInfoParser::GetOutputParaInfo() ge::graphStatus QLIInfoParser::GetAttrParaInfo() { auto attrs = context_->GetAttrs(); - OP_CHECK_IF(attrs == nullptr, OP_LOGE(context_->GetNodeName(), "attrs got from ge is nullptr"), + OPS_CHECK(attrs == nullptr, OPS_LOG_E(context_->GetNodeName(), "attrs got from ge is nullptr"), return ge::GRAPH_FAILED); - OP_LOGI(context_->GetNodeName(), "GetAttrParaInfo start"); + OPS_LOG_I(context_->GetNodeName(), "GetAttrParaInfo start"); opParamInfo_.layOutQuery = attrs->GetStr(ATTR_QUERY_LAYOUT_INDEX); opParamInfo_.layOutKey = attrs->GetStr(ATTR_KEY_LAYOUT_INDEX); @@ -175,36 +175,36 @@ ge::graphStatus QLIInfoParser::GetAttrParaInfo() opParamInfo_.scaleStride = attrs->GetAttrPointer(ATTR_SCALE_STRIDE_INDEX); if (opParamInfo_.layOutQuery != nullptr) { - OP_LOGI(context_->GetNodeName(), "layout_query is:%s", opParamInfo_.layOutQuery); + OPS_LOG_I(context_->GetNodeName(), "layout_query is:%s", opParamInfo_.layOutQuery); } if (opParamInfo_.layOutKey != nullptr) { - OP_LOGI(context_->GetNodeName(), "layout_key is:%s", opParamInfo_.layOutKey); + OPS_LOG_I(context_->GetNodeName(), "layout_key is:%s", opParamInfo_.layOutKey); } if (opParamInfo_.sparseCount != nullptr) { - OP_LOGI(context_->GetNodeName(), "selscted count is:%d", *opParamInfo_.sparseCount); + OPS_LOG_I(context_->GetNodeName(), "selscted count is:%d", *opParamInfo_.sparseCount); } if (opParamInfo_.sparseMode != nullptr) { - OP_LOGI(context_->GetNodeName(), "sparse mode is:%d", *opParamInfo_.sparseMode); + OPS_LOG_I(context_->GetNodeName(), "sparse mode is:%d", *opParamInfo_.sparseMode); } if (opParamInfo_.preTokens != nullptr) { - OP_LOGI(context_->GetNodeName(), "preTokens is:%d", *opParamInfo_.preTokens); + OPS_LOG_I(context_->GetNodeName(), "preTokens is:%d", *opParamInfo_.preTokens); } if (opParamInfo_.nextTokens != nullptr) { - OP_LOGI(context_->GetNodeName(), "nextTokens is:%d", *opParamInfo_.nextTokens); + OPS_LOG_I(context_->GetNodeName(), "nextTokens is:%d", *opParamInfo_.nextTokens); } if (opParamInfo_.cmpRatio != nullptr) { - OP_LOGI(context_->GetNodeName(), "cmpRatio is:%d", *opParamInfo_.cmpRatio); + OPS_LOG_I(context_->GetNodeName(), "cmpRatio is:%d", *opParamInfo_.cmpRatio); } if (opParamInfo_.returnValues != nullptr) { - OP_LOGI(context_->GetNodeName(), "returnValues is:%s", *opParamInfo_.returnValues ? "true" : "false"); + OPS_LOG_I(context_->GetNodeName(), "returnValues is:%s", *opParamInfo_.returnValues ? "true" : "false"); } if (opParamInfo_.queryQuantMode != nullptr) { - OP_LOGI(context_->GetNodeName(), "query_quant_mode mode is:%d", *opParamInfo_.queryQuantMode); + OPS_LOG_I(context_->GetNodeName(), "query_quant_mode mode is:%d", *opParamInfo_.queryQuantMode); } if (opParamInfo_.keyQuantMode != nullptr) { - OP_LOGI(context_->GetNodeName(), "key_quant_mode mode is:%d", *opParamInfo_.keyQuantMode); + OPS_LOG_I(context_->GetNodeName(), "key_quant_mode mode is:%d", *opParamInfo_.keyQuantMode); } - OP_LOGI(context_->GetNodeName(), "GetAttrParaInfo end"); + OPS_LOG_I(context_->GetNodeName(), "GetAttrParaInfo end"); return ge::GRAPH_SUCCESS; } @@ -214,53 +214,53 @@ ge::graphStatus QLIInfoParser::CheckAttrParaInfo() std::string layout_key(opParamInfo_.layOutKey); std::string layout_query(opParamInfo_.layOutQuery); - OP_CHECK_IF( + OPS_CHECK( ((std::string(opParamInfo_.layOutKey) != "PA_BSND")), - OP_LOGE(opName_, "input attr layout_key only supported PA_BSND," + OPS_LOG_E(opName_, "input attr layout_key only supported PA_BSND," "but now layout_key is %s.", layout_key.c_str()), return ge::GRAPH_FAILED); if ((socVersion_ == platform_ascendc::SocVersion::ASCEND910B) || (socVersion_ == platform_ascendc::SocVersion::ASCEND910_93)) { - OP_CHECK_IF(!((*opParamInfo_.sparseCount > 0) && (*opParamInfo_.sparseCount <= SPARSE_LIMIT)), - OP_LOGE(opName_, "input attr sparse_count must > 0 and <= %d, but now sparse_count is %d", + OPS_CHECK(!((*opParamInfo_.sparseCount > 0) && (*opParamInfo_.sparseCount <= SPARSE_LIMIT)), + OPS_LOG_E(opName_, "input attr sparse_count must > 0 and <= %d, but now sparse_count is %d", SPARSE_LIMIT, *opParamInfo_.sparseCount),return ge::GRAPH_FAILED); - OP_CHECK_IF((*opParamInfo_.cmpRatio <= 0) || (*opParamInfo_.cmpRatio > 128) || + OPS_CHECK((*opParamInfo_.cmpRatio <= 0) || (*opParamInfo_.cmpRatio > 128) || ((*opParamInfo_.cmpRatio & (*opParamInfo_.cmpRatio - 1)) != 0), - OP_LOGE(opName_, "input attr cmpRatio must > 0 and <= 128 and should be powers of 2, but now cmpRatio is %ld.", + OPS_LOG_E(opName_, "input attr cmpRatio must > 0 and <= 128 and should be powers of 2, but now cmpRatio is %ld.", *opParamInfo_.cmpRatio), return ge::GRAPH_FAILED); } else if (socVersion_ == platform_ascendc::SocVersion::ASCEND910_95) { - OP_CHECK_IF(!((*opParamInfo_.sparseCount > 0) && (*opParamInfo_.sparseCount <= SPARSE_LIMIT)), - OP_LOGE(opName_, "input attr sparse_count must > 0 and <= %d, but now sparse_count is %d", + OPS_CHECK(!((*opParamInfo_.sparseCount > 0) && (*opParamInfo_.sparseCount <= SPARSE_LIMIT)), + OPS_LOG_E(opName_, "input attr sparse_count must > 0 and <= %d, but now sparse_count is %d", SPARSE_LIMIT, *opParamInfo_.sparseCount),return ge::GRAPH_FAILED); - OP_CHECK_IF((*opParamInfo_.cmpRatio != 1) && (*opParamInfo_.cmpRatio != 4) && (*opParamInfo_.cmpRatio != 128), - OP_LOGE(opName_, "input attr cmpRatio must be 1、4 or 128, but now cmpRatio is %ld.", + OPS_CHECK((*opParamInfo_.cmpRatio != 1) && (*opParamInfo_.cmpRatio != 4) && (*opParamInfo_.cmpRatio != 128), + OPS_LOG_E(opName_, "input attr cmpRatio must be 1、4 or 128, but now cmpRatio is %ld.", *opParamInfo_.cmpRatio), return ge::GRAPH_FAILED); } - OP_CHECK_IF(((std::string(opParamInfo_.layOutQuery) != "BSND") && (std::string(opParamInfo_.layOutQuery) != "TND")), - OP_LOGE(opName_, "input attr layout_query only supported BSND or TND."), return ge::GRAPH_FAILED); - OP_CHECK_IF( + OPS_CHECK(((std::string(opParamInfo_.layOutQuery) != "BSND") && (std::string(opParamInfo_.layOutQuery) != "TND")), + OPS_LOG_E(opName_, "input attr layout_query only supported BSND or TND."), return ge::GRAPH_FAILED); + OPS_CHECK( ((std::string(opParamInfo_.layOutKey) != "PA_BSND") && (std::string(opParamInfo_.layOutQuery)) != (std::string(opParamInfo_.layOutKey))), - OP_LOGE(opName_, "outside of PA, input attr layout_query and input attr layout_key must be the same," + OPS_LOG_E(opName_, "outside of PA, input attr layout_query and input attr layout_key must be the same," "but now layout_key is %s, layout_query is %s.", layout_key.c_str(), layout_query.c_str()), return ge::GRAPH_FAILED); - OP_CHECK_IF(!((*opParamInfo_.sparseMode == 0) || (*opParamInfo_.sparseMode == SPARSE_MODE_LOWER)), - OP_LOGE(opName_, "input attr sparse_mode only supported 0 or 3, but now sparseMode is %d.", + OPS_CHECK(!((*opParamInfo_.sparseMode == 0) || (*opParamInfo_.sparseMode == SPARSE_MODE_LOWER)), + OPS_LOG_E(opName_, "input attr sparse_mode only supported 0 or 3, but now sparseMode is %d.", *opParamInfo_.sparseMode), return ge::GRAPH_FAILED); - OP_CHECK_IF(*opParamInfo_.preTokens != 9223372036854775807, - OP_LOGE(opName_, "input attr preTokens only supported 9223372036854775807, but now preTokens is %ld.", + OPS_CHECK(*opParamInfo_.preTokens != 9223372036854775807, + OPS_LOG_E(opName_, "input attr preTokens only supported 9223372036854775807, but now preTokens is %ld.", *opParamInfo_.preTokens), return ge::GRAPH_FAILED); - OP_CHECK_IF(*opParamInfo_.nextTokens != 9223372036854775807, - OP_LOGE(opName_, "input attr nextTokens only supported 9223372036854775807, but now nextTokens is %ld.", + OPS_CHECK(*opParamInfo_.nextTokens != 9223372036854775807, + OPS_LOG_E(opName_, "input attr nextTokens only supported 9223372036854775807, but now nextTokens is %ld.", *opParamInfo_.nextTokens), return ge::GRAPH_FAILED); - - OP_CHECK_IF(*opParamInfo_.queryQuantMode != 0, OP_LOGE(opName_, "input attr query_quant_mode only supported 0."), + + OPS_CHECK(*opParamInfo_.queryQuantMode != 0, OPS_LOG_E(opName_, "input attr query_quant_mode only supported 0."), return ge::GRAPH_FAILED); - OP_CHECK_IF(*opParamInfo_.keyQuantMode != 0, OP_LOGE(opName_, "input attr key_quant_mode only supported 0."), + OPS_CHECK(*opParamInfo_.keyQuantMode != 0, OPS_LOG_E(opName_, "input attr key_quant_mode only supported 0."), return ge::GRAPH_FAILED); - OP_CHECK_IF(*opParamInfo_.returnValues, OP_LOGE(opName_, "input attr returnValues only supported False."), + OPS_CHECK(*opParamInfo_.returnValues, OPS_LOG_E(opName_, "input attr returnValues only supported False."), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; @@ -291,42 +291,42 @@ ge::graphStatus QLIInfoParser::GetAndCheckInOutDataType() auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo_); socVersion_ = ascendcPlatform.GetSocVersion(); - OP_CHECK_IF(!(inputQType_ == inputKType_), - OP_LOGE(opName_, "The data types of the input query and key must be the same."), + OPS_CHECK(!(inputQType_ == inputKType_), + OPS_LOG_E(opName_, "The data types of the input query and key must be the same."), return ge::GRAPH_FAILED); - OP_CHECK_IF( + OPS_CHECK( !(inputQueryScaleType_ == inputKeyScaleType_), - OP_LOGE(opName_, "The data types of the input query_dequant_scale and key_dequant_scale must be the same."), + OPS_LOG_E(opName_, "The data types of the input query_dequant_scale and key_dequant_scale must be the same."), return ge::GRAPH_FAILED); if ((socVersion_ == platform_ascendc::SocVersion::ASCEND910B) || (socVersion_ == platform_ascendc::SocVersion::ASCEND910_93)) { - OP_CHECK_IF(inputQType_ != ge::DT_INT8, - OP_LOGE(opName_, "The data types of the input query and key must be int8."), return ge::GRAPH_FAILED); - OP_CHECK_IF( + OPS_CHECK(inputQType_ != ge::DT_INT8, + OPS_LOG_E(opName_, "The data types of the input query and key must be int8."), return ge::GRAPH_FAILED); + OPS_CHECK( inputQueryScaleType_ != ge::DT_FLOAT16, - OP_LOGE(opName_, "The data types of the input query_dequant_scale and key_dequant_scale must be float16."), + OPS_LOG_E(opName_, "The data types of the input query_dequant_scale and key_dequant_scale must be float16."), return ge::GRAPH_FAILED); } else if (socVersion_ == platform_ascendc::SocVersion::ASCEND910_95) { - OP_CHECK_IF(inputQType_ != ge::DT_FLOAT8_E4M3FN, - OP_LOGE(opName_, "The data types of the input query and key must be float8_e4m3."), return ge::GRAPH_FAILED); - OP_CHECK_IF( + OPS_CHECK(inputQType_ != ge::DT_FLOAT8_E4M3FN, + OPS_LOG_E(opName_, "The data types of the input query and key must be float8_e4m3."), return ge::GRAPH_FAILED); + OPS_CHECK( inputQueryScaleType_ != ge::DT_FLOAT, - OP_LOGE(opName_, "The data types of the input query_dequant_scale and key_dequant_scale must be float."), + OPS_LOG_E(opName_, "The data types of the input query_dequant_scale and key_dequant_scale must be float."), return ge::GRAPH_FAILED); } if ((socVersion_ == platform_ascendc::SocVersion::ASCEND910B) || (socVersion_ == platform_ascendc::SocVersion::ASCEND910_93)) { - OP_CHECK_IF(weightsType_ != ge::DT_FLOAT16, - OP_LOGE(opName_, "The data types of the input weights must be float16."), return ge::GRAPH_FAILED); + OPS_CHECK(weightsType_ != ge::DT_FLOAT16, + OPS_LOG_E(opName_, "The data types of the input weights must be float16."), return ge::GRAPH_FAILED); } else if (socVersion_ == platform_ascendc::SocVersion::ASCEND910_95) { - OP_CHECK_IF(weightsType_ != ge::DT_FLOAT, - OP_LOGE(opName_, "The data types of the input weights must be float."), return ge::GRAPH_FAILED); + OPS_CHECK(weightsType_ != ge::DT_FLOAT, + OPS_LOG_E(opName_, "The data types of the input weights must be float."), return ge::GRAPH_FAILED); } - OP_CHECK_IF(outputType_ != ge::DT_INT32, - OP_LOGE(opName_, "The data types of the output sparse_indices must be int32."), + OPS_CHECK(outputType_ != ge::DT_INT32, + OPS_LOG_E(opName_, "The data types of the output sparse_indices must be int32."), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; @@ -358,41 +358,41 @@ ge::graphStatus QLIInfoParser::GetQueryKeyAndOutLayout() ge::graphStatus QLIInfoParser::GetAndCheckOptionalInput() { if (kLayout_ == DataLayout::PA_BSND) { - OP_CHECK_IF(opParamInfo_.blockTable.tensor == nullptr, - OP_LOGE(opName_, "key layout only supported PA_BSND, input block_table must not be null"), + OPS_CHECK(opParamInfo_.blockTable.tensor == nullptr, + OPS_LOG_E(opName_, "key layout only supported PA_BSND, input block_table must not be null"), return ge::GRAPH_FAILED); - OP_CHECK_IF( + OPS_CHECK( opParamInfo_.actualSeqLengthsK.tensor == nullptr, - OP_LOGE(opName_, "key layout only supported PA_BSND, input actual_seq_lengths_key must not be null"), + OPS_LOG_E(opName_, "key layout only supported PA_BSND, input actual_seq_lengths_key must not be null"), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.blockTable.desc->GetDataType() != ge::DT_INT32, - OP_LOGE(opName_, "input block_table data type only support int32"), return ge::GRAPH_FAILED); + OPS_CHECK(opParamInfo_.blockTable.desc->GetDataType() != ge::DT_INT32, + OPS_LOG_E(opName_, "input block_table data type only support int32"), return ge::GRAPH_FAILED); } else { - OP_CHECK_IF(opParamInfo_.blockTable.tensor != nullptr, - OP_LOGE(opName_, "key layout is not PA_BSND, input block_table must be null"), + OPS_CHECK(opParamInfo_.blockTable.tensor != nullptr, + OPS_LOG_E(opName_, "key layout is not PA_BSND, input block_table must be null"), return ge::GRAPH_FAILED); } if (kLayout_ == DataLayout::TND) { - OP_CHECK_IF(opParamInfo_.actualSeqLengthsK.tensor == nullptr, - OP_LOGE(opName_, "when layout_key is TND, input actual_seq_lengths_key must not be null"), + OPS_CHECK(opParamInfo_.actualSeqLengthsK.tensor == nullptr, + OPS_LOG_E(opName_, "when layout_key is TND, input actual_seq_lengths_key must not be null"), return ge::GRAPH_FAILED); } - OP_CHECK_IF(opParamInfo_.actualSeqLengthsK.tensor != nullptr && + OPS_CHECK(opParamInfo_.actualSeqLengthsK.tensor != nullptr && opParamInfo_.actualSeqLengthsK.desc->GetDataType() != ge::DT_INT32, - OP_LOGE(opName_, "input actual_seq_lengths_key data type only support int32"), + OPS_LOG_E(opName_, "input actual_seq_lengths_key data type only support int32"), return ge::GRAPH_FAILED); if (qLayout_ == DataLayout::TND) { - OP_CHECK_IF(opParamInfo_.actualSeqLengthsQ.tensor == nullptr, - OP_LOGE(opName_, "when layout_query is TND, input actual_seq_lengths_query must not be null"), + OPS_CHECK(opParamInfo_.actualSeqLengthsQ.tensor == nullptr, + OPS_LOG_E(opName_, "when layout_query is TND, input actual_seq_lengths_query must not be null"), return ge::GRAPH_FAILED); } - OP_CHECK_IF(opParamInfo_.actualSeqLengthsQ.tensor != nullptr && + OPS_CHECK(opParamInfo_.actualSeqLengthsQ.tensor != nullptr && opParamInfo_.actualSeqLengthsQ.desc->GetDataType() != ge::DT_INT32, - OP_LOGE(opName_, "input actual_seq_lengths_query data type only support int32"), + OPS_LOG_E(opName_, "input actual_seq_lengths_query data type only support int32"), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.metadata.tensor == nullptr, - OP_LOGE(opName_, "input metadata must not be null"), + OPS_CHECK(opParamInfo_.metadata.tensor == nullptr, + OPS_LOG_E(opName_, "input metadata must not be null"), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; @@ -400,18 +400,18 @@ ge::graphStatus QLIInfoParser::GetAndCheckOptionalInput() ge::graphStatus QLIInfoParser::CheckShapeDim() { - OP_CHECK_IF((opParamInfo_.blockTable.tensor != nullptr) && + OPS_CHECK((opParamInfo_.blockTable.tensor != nullptr) && (opParamInfo_.blockTable.tensor->GetStorageShape().GetDimNum() != DIM_NUM_TWO), - OP_LOGE(opName_, "the dim num of block_table's shape should be 2, but now is %u", + OPS_LOG_E(opName_, "the dim num of block_table's shape should be 2, but now is %u", opParamInfo_.blockTable.tensor->GetStorageShape().GetDimNum()), return ge::GRAPH_FAILED); - OP_CHECK_IF( + OPS_CHECK( ((kLayout_ == DataLayout::PA_BSND)||(kLayout_ == DataLayout::BSND)) && (opParamInfo_.key.shape->GetStorageShape().GetDimNum() != DIM_NUM_FOUR), - OP_LOGE(opName_, "the dim num of key's shape should be 4, but now is %u", + OPS_LOG_E(opName_, "the dim num of key's shape should be 4, but now is %u", opParamInfo_.key.shape->GetStorageShape().GetDimNum()), return ge::GRAPH_FAILED); - OP_CHECK_IF( + OPS_CHECK( (kLayout_ == DataLayout::TND) && (opParamInfo_.key.shape->GetStorageShape().GetDimNum() != DIM_NUM_THREE), - OP_LOGE(opName_, "the dim num of key's shape should be 3, but now is %u", + OPS_LOG_E(opName_, "the dim num of key's shape should be 3, but now is %u", opParamInfo_.key.shape->GetStorageShape().GetDimNum()), return ge::GRAPH_FAILED); uint32_t qShapeDim = opParamInfo_.query.shape->GetStorageShape().GetDimNum(); @@ -421,16 +421,16 @@ ge::graphStatus QLIInfoParser::CheckShapeDim() if (qLayout_ == DataLayout::TND) { expectShapeDim = DIM_NUM_THREE; } - OP_CHECK_IF( + OPS_CHECK( qShapeDim != expectShapeDim, - OP_LOGE(opName_, "the dim num of query's shape should be %u, but now is %u", expectShapeDim, qShapeDim), + OPS_LOG_E(opName_, "the dim num of query's shape should be %u, but now is %u", expectShapeDim, qShapeDim), return ge::GRAPH_FAILED); - OP_CHECK_IF(outShapeDim != expectShapeDim, - OP_LOGE(opName_, "the dim num of sparse_indices's shape should be %u, but now is %u", expectShapeDim, + OPS_CHECK(outShapeDim != expectShapeDim, + OPS_LOG_E(opName_, "the dim num of sparse_indices's shape should be %u, but now is %u", expectShapeDim, outShapeDim), return ge::GRAPH_FAILED); - OP_CHECK_IF(!(weightsShapeDim == expectShapeDim - 1), - OP_LOGE(opName_, "the dim num of weights's shape should be %u, but now is %u", expectShapeDim - 1, + OPS_CHECK(!(weightsShapeDim == expectShapeDim - 1), + OPS_LOG_E(opName_, "the dim num of weights's shape should be %u, but now is %u", expectShapeDim - 1, weightsShapeDim), return ge::GRAPH_FAILED); @@ -445,7 +445,7 @@ ge::graphStatus QLIInfoParser::GetN1Size() // TND n1Size_ = static_cast(opParamInfo_.query.shape->GetStorageShape().GetDim(DIM_IDX_ONE)); } - OP_LOGI(context_->GetNodeName(), "n1Size is %d", n1Size_); + OPS_LOG_I(context_->GetNodeName(), "n1Size is %d", n1Size_); return ge::GRAPH_SUCCESS; } @@ -454,7 +454,7 @@ ge::graphStatus QLIInfoParser::GetActualSeqLenSize(uint32_t &size, const gert::T { size = static_cast(tensor->GetShapeSize()); if (size <= 0) { - OP_LOGE(opName_, "%s's shape size is %u, it should be greater than 0.", actualSeqLenName.c_str(), size); + OPS_LOG_E(opName_, "%s's shape size is %u, it should be greater than 0.", actualSeqLenName.c_str(), size); return ge::GRAPH_FAILED; } return ge::GRAPH_SUCCESS; @@ -468,8 +468,8 @@ ge::graphStatus QLIInfoParser::GetAndCheckN2Size() } else { n2Size_ = static_cast(opParamInfo_.key.shape->GetStorageShape().GetDim(DIM_IDX_TWO)); } - OP_LOGI(context_->GetNodeName(), "N2 is %d", n2Size_); - OP_CHECK_IF(n2Size_ != 1, OP_LOGE(opName_, "key shape[2] is numhead, only support 1."), return ge::GRAPH_FAILED); + OPS_LOG_I(context_->GetNodeName(), "N2 is %d", n2Size_); + OPS_CHECK(n2Size_ != 1, OPS_LOG_E(opName_, "key shape[2] is numhead, only support 1."), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; } @@ -477,12 +477,12 @@ ge::graphStatus QLIInfoParser::GetAndCheckN2Size() ge::graphStatus QLIInfoParser::GetGSize() { if (n1Size_ % n2Size_ != 0) { - OP_LOGE(opName_, "input query's head_num %u can not be a multiple of key's head_num %u.", n1Size_, n2Size_); + OPS_LOG_E(opName_, "input query's head_num %u can not be a multiple of key's head_num %u.", n1Size_, n2Size_); return ge::GRAPH_FAILED; } gSize_ = n1Size_ / n2Size_; - OP_CHECK_IF(gSize_ != G_SIZE_LIMIT, - OP_LOGE(opName_, "N1 is %u, N2 is %u, N1 divided by N2 must equal 64.", n1Size_, n2Size_), + OPS_CHECK(gSize_ != G_SIZE_LIMIT, + OPS_LOG_E(opName_, "N1 is %u, N2 is %u, N1 divided by N2 must equal 64.", n1Size_, n2Size_), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; @@ -496,7 +496,7 @@ ge::graphStatus QLIInfoParser::GetBatchSize() // 3、Q为TND,K为PA_BSND时,以actual_seq_lens_k数组的长度为B轴大小 if (qLayout_ == DataLayout::BSND) { bSize_ = opParamInfo_.query.shape->GetStorageShape().GetDim(DIM_IDX_ZERO); - OP_LOGI(context_->GetNodeName(), "b: %d, s: %d, n: %d,d :%d", + OPS_LOG_I(context_->GetNodeName(), "b: %d, s: %d, n: %d,d :%d", opParamInfo_.query.shape->GetStorageShape().GetDim(DIM_IDX_ZERO), opParamInfo_.query.shape->GetStorageShape().GetDim(DIM_IDX_ONE), opParamInfo_.query.shape->GetStorageShape().GetDim(DIM_IDX_TWO), @@ -508,8 +508,8 @@ ge::graphStatus QLIInfoParser::GetBatchSize() GetActualSeqLenSize(bSizeQuery, opParamInfo_.actualSeqLengthsQ.tensor, "input actual_seq_lengths_query"); GetActualSeqLenSize(bSizeKey, opParamInfo_.actualSeqLengthsK.tensor, "input actual_seq_lengths_key"); if (kLayout_ == DataLayout::TND) { - OP_CHECK_IF(bSizeQuery != bSizeKey, - OP_LOGE(opName_, "the lengths of actual_seq_lengths_query and actual_seq_lengths_key is %u, %u respectively, they must be same.", + OPS_CHECK(bSizeQuery != bSizeKey, + OPS_LOG_E(opName_, "the lengths of actual_seq_lengths_query and actual_seq_lengths_key is %u, %u respectively, they must be same.", bSizeQuery, bSizeKey), return ge::GRAPH_FAILED); bSize_ = bSizeQuery; @@ -517,8 +517,8 @@ ge::graphStatus QLIInfoParser::GetBatchSize() if (bSizeQuery == bSizeKey + 1) { batchSupperFlag_ = true; } - OP_CHECK_IF((bSizeQuery != bSizeKey) && !batchSupperFlag_, - OP_LOGE(opName_, "the lengths of actual_seq_lengths_query and actual_seq_lengths_key is %u, %u respectively, they must be same.", + OPS_CHECK((bSizeQuery != bSizeKey) && !batchSupperFlag_, + OPS_LOG_E(opName_, "the lengths of actual_seq_lengths_query and actual_seq_lengths_key is %u, %u respectively, they must be same.", bSizeQuery, bSizeKey), return ge::GRAPH_FAILED); bSize_ = bSizeKey; // Q为TND,batch从Key中获取 @@ -542,11 +542,11 @@ ge::graphStatus QLIInfoParser::GetHeadDim() dIndex = DIM_IDX_THREE; break; default: - OP_LOGE(opName_, "unsupported layout for getting head dim."); + OPS_LOG_E(opName_, "unsupported layout for getting head dim."); return ge::GRAPH_FAILED; } headDim_ = opParamInfo_.query.shape->GetStorageShape().GetDim(dIndex); - OP_CHECK_IF(headDim_ != HEAD_DIM_LIMIT, OP_LOGE(opName_, "input query's last dim head_dim only support 128, but now is %u.", headDim_), + OPS_CHECK(headDim_ != HEAD_DIM_LIMIT, OPS_LOG_E(opName_, "input query's last dim head_dim only support 128, but now is %u.", headDim_), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; @@ -563,11 +563,11 @@ ge::graphStatus QLIInfoParser::GetS1Size() ge::graphStatus QLIInfoParser::GetAndCheckBlockSize() { blockSize_ = static_cast(opParamInfo_.key.shape->GetStorageShape().GetDim(1)); - OP_LOGI(context_->GetNodeName(), "blockSize_ is %d", blockSize_); + OPS_LOG_I(context_->GetNodeName(), "blockSize_ is %d", blockSize_); - OP_CHECK_IF( + OPS_CHECK( ((blockSize_ % BLOCK_SIZE_FACTOR != 0) || (blockSize_ == 0) || (blockSize_ > BLOCK_SIZE_LIMIT)), - OP_LOGE(opName_, "input key's block_size must be a multiple of 16 and belong to (0, 1024], but now is %d.", blockSize_), + OPS_LOG_E(opName_, "input key's block_size must be a multiple of 16 and belong to (0, 1024], but now is %d.", blockSize_), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; @@ -580,11 +580,11 @@ ge::graphStatus QLIInfoParser::GetS2SizeForPageAttention() } int32_t blockCount_ = static_cast(opParamInfo_.key.shape->GetStorageShape().GetDim(0)); - OP_CHECK_IF((blockCount_ == 0), OP_LOGE(opName_, "input key's block_count cannot be 0."), return ge::GRAPH_FAILED); + OPS_CHECK((blockCount_ == 0), OPS_LOG_E(opName_, "input key's block_count cannot be 0."), return ge::GRAPH_FAILED); maxBlockNumPerBatch_ = opParamInfo_.blockTable.tensor->GetStorageShape().GetDim(1); s2Size_ = maxBlockNumPerBatch_ * blockSize_; - OP_LOGI(context_->GetNodeName(), "maxBlockNumPerBatch_ is %d, blockSize_ is %d, s2Size_ is %d", + OPS_LOG_I(context_->GetNodeName(), "maxBlockNumPerBatch_ is %d, blockSize_ is %d, s2Size_ is %d", maxBlockNumPerBatch_, blockSize_, s2Size_); return ge::GRAPH_SUCCESS; } @@ -597,8 +597,8 @@ ge::graphStatus QLIInfoParser::GetS2SizeForBatchContinuous() } else if (kLayout_ == DataLayout::TND) { s2Size_ = opParamInfo_.key.shape->GetStorageShape().GetDim(DIM_IDX_ZERO); } - OP_CHECK_IF((kLayout_ != DataLayout::BSND) && (kLayout_ != DataLayout::TND), - OP_LOGE(opName_, "the layout of key is %s, it is unsupported.", layout_key.c_str()), + OPS_CHECK((kLayout_ != DataLayout::BSND) && (kLayout_ != DataLayout::TND), + OPS_LOG_E(opName_, "the layout of key is %s, it is unsupported.", layout_key.c_str()), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; } @@ -641,20 +641,20 @@ ge::graphStatus QLIInfoParser::ValidateInputShapesMatch() if (qLayout_ == DataLayout::TND) { // -----------------------check BatchSize------------------- // bSize_ 来源于act_seq_q - OP_CHECK_IF((kLayout_ == DataLayout::PA_BSND) && + OPS_CHECK((kLayout_ == DataLayout::PA_BSND) && ((opParamInfo_.actualSeqLengthsK.tensor->GetShapeSize() != bSize_) || (opParamInfo_.blockTable.tensor != nullptr && opParamInfo_.blockTable.tensor->GetStorageShape().GetDim(0) != bSize_)), - OP_LOGE( + OPS_LOG_E( opName_, "TND case input actual_seq_lengths_query, actual_seq_lengths_key, block_table dim 0 are %u, %u, %u " "respectively, they must be same.", bSize_, opParamInfo_.actualSeqLengthsK.tensor->GetShapeSize(), opParamInfo_.blockTable.tensor->GetStorageShape().GetDim(0)), return ge::GRAPH_FAILED); - OP_CHECK_IF((kLayout_ != DataLayout::PA_BSND) && + OPS_CHECK((kLayout_ != DataLayout::PA_BSND) && (opParamInfo_.actualSeqLengthsK.tensor->GetShapeSize() != bSize_), - OP_LOGE( + OPS_LOG_E( opName_, "TND case input actual_seq_lengths_query, actual_seq_lengths_key, are %u, %u " "respectively, they must be same.", @@ -662,9 +662,9 @@ ge::graphStatus QLIInfoParser::ValidateInputShapesMatch() return ge::GRAPH_FAILED); // -----------------------check T------------------- uint32_t qTsize = opParamInfo_.query.shape->GetStorageShape().GetDim(0); - OP_CHECK_IF((opParamInfo_.weights.shape->GetStorageShape().GetDim(0) != qTsize) || + OPS_CHECK((opParamInfo_.weights.shape->GetStorageShape().GetDim(0) != qTsize) || (opParamInfo_.attenOut.shape->GetStorageShape().GetDim(0) != qTsize), - OP_LOGE(opName_, + OPS_LOG_E(opName_, "TND case input query, weights, sparse_indices dim 0 are %u, %u, %u " "respectively, they must be same.", qTsize, opParamInfo_.weights.shape->GetStorageShape().GetDim(0), @@ -673,43 +673,43 @@ ge::graphStatus QLIInfoParser::ValidateInputShapesMatch() } else { // -----------------------check BatchSize------------------- // bSize_ 来源于query - OP_CHECK_IF((kLayout_ == DataLayout::PA_BSND) && + OPS_CHECK((kLayout_ == DataLayout::PA_BSND) && ((opParamInfo_.weights.shape->GetStorageShape().GetDim(0) != bSize_) || (opParamInfo_.blockTable.tensor != nullptr && opParamInfo_.blockTable.tensor->GetStorageShape().GetDim(0) != bSize_) || (opParamInfo_.actualSeqLengthsK.tensor->GetShapeSize() != bSize_) || (opParamInfo_.attenOut.shape->GetStorageShape().GetDim(0) != bSize_)), - OP_LOGE(opName_, + OPS_LOG_E(opName_, "BSND case input query, weight, actual_seq_lengths_key, block_table, sparse_indices dim 0 are %u, %u, %u, %u, %u respectively, they must be same.", bSize_, opParamInfo_.weights.shape->GetStorageShape().GetDim(0), opParamInfo_.actualSeqLengthsK.tensor->GetShapeSize(), opParamInfo_.blockTable.tensor->GetStorageShape().GetDim(0), opParamInfo_.attenOut.shape->GetStorageShape().GetDim(0)), return ge::GRAPH_FAILED); - OP_CHECK_IF((kLayout_ != DataLayout::PA_BSND) && + OPS_CHECK((kLayout_ != DataLayout::PA_BSND) && ((opParamInfo_.weights.shape->GetStorageShape().GetDim(0) != bSize_) || (opParamInfo_.actualSeqLengthsK.tensor != nullptr && opParamInfo_.actualSeqLengthsK.tensor->GetShapeSize() != bSize_) || (opParamInfo_.attenOut.shape->GetStorageShape().GetDim(0) != bSize_)), - OP_LOGE(opName_, + OPS_LOG_E(opName_, "BSND case input query, weight, actual_seq_lengths_key, sparse_indices dim 0 are %u, %u, %u, %u respectively, they must be same.", bSize_, opParamInfo_.weights.shape->GetStorageShape().GetDim(0), opParamInfo_.actualSeqLengthsK.tensor->GetShapeSize(), opParamInfo_.attenOut.shape->GetStorageShape().GetDim(0)), return ge::GRAPH_FAILED); - OP_CHECK_IF( + OPS_CHECK( (opParamInfo_.actualSeqLengthsQ.tensor != nullptr) && (opParamInfo_.actualSeqLengthsQ.tensor->GetShapeSize() != bSize_), - OP_LOGE( + OPS_LOG_E( opName_, "BSND case input query, actual_seq_lengths_query dim 0 are %u, %ld respectively, they must be same", bSize_, opParamInfo_.actualSeqLengthsQ.tensor->GetShapeSize()), return ge::GRAPH_FAILED); // -----------------------check S1------------------- - OP_CHECK_IF( + OPS_CHECK( (opParamInfo_.weights.shape->GetStorageShape().GetDim(1) != s1Size_) || (opParamInfo_.attenOut.shape->GetStorageShape().GetDim(1) != s1Size_), - OP_LOGE(opName_, "BSND case input query, weight, sparse_indices dim 1 are %u, %u, %u, they must be same.", + OPS_LOG_E(opName_, "BSND case input query, weight, sparse_indices dim 1 are %u, %u, %u, they must be same.", s1Size_, opParamInfo_.weights.shape->GetStorageShape().GetDim(1), opParamInfo_.attenOut.shape->GetStorageShape().GetDim(1)), return ge::GRAPH_FAILED); @@ -717,26 +717,26 @@ ge::graphStatus QLIInfoParser::ValidateInputShapesMatch() outN2Dim = DIM_IDX_TWO; } // -----------------------check N1------------------- - OP_CHECK_IF((opParamInfo_.weights.shape->GetStorageShape().GetDim(queryWeightsN1Dim) != n1Size_), - OP_LOGE(opName_, "input query, weight shape dim N1 must be same, but now are %u, %u respectively, they must be same.", + OPS_CHECK((opParamInfo_.weights.shape->GetStorageShape().GetDim(queryWeightsN1Dim) != n1Size_), + OPS_LOG_E(opName_, "input query, weight shape dim N1 must be same, but now are %u, %u respectively, they must be same.", opParamInfo_.weights.shape->GetStorageShape().GetDim(queryWeightsN1Dim), n1Size_), return ge::GRAPH_FAILED); // -----------------------check D------------------- - OP_CHECK_IF( + OPS_CHECK( ((kLayout_ != DataLayout::TND && opParamInfo_.key.shape->GetStorageShape().GetDim(DIM_IDX_THREE) != headDim_) || (kLayout_ == DataLayout::TND && opParamInfo_.key.shape->GetStorageShape().GetDim(DIM_IDX_TWO) != headDim_)), - OP_LOGE(opName_, "input query, key shape last dim must be same."), return ge::GRAPH_FAILED); + OPS_LOG_E(opName_, "input query, key shape last dim must be same."), return ge::GRAPH_FAILED); // -----------------------check N2------------------- - OP_CHECK_IF((opParamInfo_.attenOut.shape->GetStorageShape().GetDim(outN2Dim) != n2Size_), - OP_LOGE(opName_, "input query and output sparse_indices shape n2 dim must be same."), + OPS_CHECK((opParamInfo_.attenOut.shape->GetStorageShape().GetDim(outN2Dim) != n2Size_), + OPS_LOG_E(opName_, "input query and output sparse_indices shape n2 dim must be same."), return ge::GRAPH_FAILED); // -----------------------check sparse_count------------------- - OP_CHECK_IF((opParamInfo_.attenOut.shape->GetStorageShape().GetDim(outN2Dim + 1) != *opParamInfo_.sparseCount), - OP_LOGE(opName_, "output sparse_indices shape last dim must be same as attr sparse_count."), + OPS_CHECK((opParamInfo_.attenOut.shape->GetStorageShape().GetDim(outN2Dim + 1) != *opParamInfo_.sparseCount), + OPS_LOG_E(opName_, "output sparse_indices shape last dim must be same as attr sparse_count."), return ge::GRAPH_FAILED); // -----------------------check metadata------------------- - OP_CHECK_IF((opParamInfo_.metadata.tensor->GetShapeSize() != METADATA_LIMIT), - OP_LOGE(opName_, "input metadata dim 0 must be %u.", METADATA_LIMIT), + OPS_CHECK((opParamInfo_.metadata.tensor->GetShapeSize() != METADATA_LIMIT), + OPS_LOG_E(opName_, "input metadata dim 0 must be %u.", METADATA_LIMIT), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; } @@ -747,20 +747,20 @@ ge::graphStatus QLIInfoParser::CheckScaleShape() uint32_t kShapeDim = opParamInfo_.key.shape->GetStorageShape().GetDimNum(); uint32_t qDequantScaleShapeDim = opParamInfo_.query_dequant_scale.shape->GetStorageShape().GetDimNum(); uint32_t kDequantScaleShapeDim = opParamInfo_.key_dequant_scale.shape->GetStorageShape().GetDimNum(); - OP_CHECK_IF(qDequantScaleShapeDim != (qShapeDim - 1), - OP_LOGE(opName_, "the dim num of query_dequant_scale's shape should be %u, but now is %u", + OPS_CHECK(qDequantScaleShapeDim != (qShapeDim - 1), + OPS_LOG_E(opName_, "the dim num of query_dequant_scale's shape should be %u, but now is %u", qShapeDim - 1, qDequantScaleShapeDim), return ge::GRAPH_FAILED); - OP_CHECK_IF(kDequantScaleShapeDim != (kShapeDim - 1), - OP_LOGE(opName_, "the dim num of key_dequant_scale's shape should be %u, but now is %u", kShapeDim - 1, + OPS_CHECK(kDequantScaleShapeDim != (kShapeDim - 1), + OPS_LOG_E(opName_, "the dim num of key_dequant_scale's shape should be %u, but now is %u", kShapeDim - 1, kDequantScaleShapeDim), return ge::GRAPH_FAILED); // check q scale for (uint32_t i = 0; i < (qShapeDim - 1); i++) { uint32_t dimValueQueryScale = opParamInfo_.query_dequant_scale.shape->GetStorageShape().GetDim(i); uint32_t dimValueQuery = opParamInfo_.query.shape->GetStorageShape().GetDim(i); - OP_CHECK_IF(dimValueQueryScale != dimValueQuery, - OP_LOGE(opName_, "query_dequant_scale's shape[%u] %u and query's shape[%u] %u is not same", i, + OPS_CHECK(dimValueQueryScale != dimValueQuery, + OPS_LOG_E(opName_, "query_dequant_scale's shape[%u] %u and query's shape[%u] %u is not same", i, dimValueQueryScale, i, dimValueQuery), return ge::GRAPH_FAILED); } @@ -768,8 +768,8 @@ ge::graphStatus QLIInfoParser::CheckScaleShape() for (uint32_t i = 0; i < (kShapeDim - 1); i++) { uint32_t dimValueKeyScale = opParamInfo_.key_dequant_scale.shape->GetStorageShape().GetDim(i); uint32_t dimValueKey = opParamInfo_.key.shape->GetStorageShape().GetDim(i); - OP_CHECK_IF(dimValueKeyScale != dimValueKey, - OP_LOGE(opName_, "key_dequant_scale's shape[%u] %u and key's shape[%u] %u is not same", i, + OPS_CHECK(dimValueKeyScale != dimValueKey, + OPS_LOG_E(opName_, "key_dequant_scale's shape[%u] %u and key's shape[%u] %u is not same", i, dimValueKeyScale, i, dimValueKey), return ge::GRAPH_FAILED); } @@ -920,7 +920,7 @@ ge::graphStatus QuantLightningIndexerTiling::DoTiling(QLITilingInfo *tilingInfo) // --------------------------Tiling函数定义--------------------------- ge::graphStatus TilingForQuantLightningIndexer(gert::TilingContext *context) { - OP_CHECK_IF(context == nullptr, OP_LOGE("QuantLightningIndexer", "Tiling context is null."), + OPS_CHECK(context == nullptr, OPS_LOG_E("QuantLightningIndexer", "Tiling context is null."), return ge::GRAPH_FAILED); QLITilingInfo QLIInfo; QLIInfoParser QLIInfoParser(context); diff --git a/xllm_ops/attention/sparse_attn_sharedkv/op_host/sparse_attn_sharedkv_tiling.cpp b/xllm_ops/attention/sparse_attn_sharedkv/op_host/sparse_attn_sharedkv_tiling.cpp index decb775..973ed0d 100644 --- a/xllm_ops/attention/sparse_attn_sharedkv/op_host/sparse_attn_sharedkv_tiling.cpp +++ b/xllm_ops/attention/sparse_attn_sharedkv/op_host/sparse_attn_sharedkv_tiling.cpp @@ -123,7 +123,7 @@ static std::string SASDataTypeToSerialString(ge::DataType type) if (it != DATATYPE_TO_STRING_MAP.end()) { return it->second; } else { - OP_LOGE("sparseAttnSharedkv", "datatype %d not support", type); + OPS_LOG_E("sparseAttnSharedkv", "datatype %d not support", type); return "UNDEFINED"; } } @@ -131,24 +131,24 @@ static std::string SASDataTypeToSerialString(ge::DataType type) // --------------------------SASInfoParser类成员函数定义------------------------------------- ge::graphStatus SASInfoParser::CheckRequiredInOutExistence() const { - OP_CHECK_IF(opParamInfo_.q.shape == nullptr, OP_LOGE(opName_, "Shape of tensor q is nullptr"), + OPS_CHECK(opParamInfo_.q.shape == nullptr, OPS_LOG_E(opName_, "Shape of tensor q is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.q.desc == nullptr, OP_LOGE(opName_, "Desc of tensor q is nullptr"), + OPS_CHECK(opParamInfo_.q.desc == nullptr, OPS_LOG_E(opName_, "Desc of tensor q is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.oriKv.tensor == nullptr, OP_LOGE(opName_, "tensor of ori_Kv is nullptr"), + OPS_CHECK(opParamInfo_.oriKv.tensor == nullptr, OPS_LOG_E(opName_, "tensor of ori_Kv is nullptr"), return ge::GRAPH_FAILED); if (kvLayout_ == SASLayout::PA_ND) { - OP_CHECK_IF(opParamInfo_.oriBlockTable.tensor == nullptr, OP_LOGE(opName_, "tensor of ori_block_table is nullptr"), + OPS_CHECK(opParamInfo_.oriBlockTable.tensor == nullptr, OPS_LOG_E(opName_, "tensor of ori_block_table is nullptr"), return ge::GRAPH_FAILED); } if (perfMode_ == SASTemplateMode::CFA_TEMPLATE_MODE){ - OP_CHECK_IF(opParamInfo_.cmpKv.tensor == nullptr, OP_LOGE(opName_, "tensor of cmp_kv is nullptr"), + OPS_CHECK(opParamInfo_.cmpKv.tensor == nullptr, OPS_LOG_E(opName_, "tensor of cmp_kv is nullptr"), return ge::GRAPH_FAILED); } if (perfMode_ == SASTemplateMode::SCFA_TEMPLATE_MODE){ - OP_CHECK_IF(opParamInfo_.cmpKv.tensor == nullptr, OP_LOGE(opName_, "tensor of cmp_kv is nullptr"), + OPS_CHECK(opParamInfo_.cmpKv.tensor == nullptr, OPS_LOG_E(opName_, "tensor of cmp_kv is nullptr"), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.cmpSparseIndices.tensor == nullptr, OP_LOGE(opName_, "cmp_sparse_indices is nullptr"), + OPS_CHECK(opParamInfo_.cmpSparseIndices.tensor == nullptr, OPS_LOG_E(opName_, "cmp_sparse_indices is nullptr"), return ge::GRAPH_FAILED); } return ge::GRAPH_SUCCESS; @@ -171,8 +171,8 @@ ge::graphStatus SASInfoParser::CheckRequiredParaExistence() const ge::graphStatus SASInfoParser::CheckUnrequiredParaExistence() const { - OP_CHECK_IF(opParamInfo_.oriSparseIndices.tensor != nullptr || opParamInfo_.oriSparseIndices.desc != nullptr, - OP_LOGE(opName_, "Currently, ori_sparse_indices must be a nullptr"), + OPS_CHECK(opParamInfo_.oriSparseIndices.tensor != nullptr || opParamInfo_.oriSparseIndices.desc != nullptr, + OPS_LOG_E(opName_, "Currently, ori_sparse_indices must be a nullptr"), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; } @@ -180,7 +180,7 @@ ge::graphStatus SASInfoParser::CheckUnrequiredParaExistence() const ge::graphStatus SASInfoParser::GetOpName() { if (context_->GetNodeName() == nullptr) { - OP_LOGE("SparseAttnSharedkv", "opName got from TilingContext is nullptr"); + OPS_LOG_E("SparseAttnSharedkv", "opName got from TilingContext is nullptr"); return ge::GRAPH_FAILED; } opName_ = context_->GetNodeName(); @@ -190,17 +190,17 @@ ge::graphStatus SASInfoParser::GetOpName() ge::graphStatus SASInfoParser::GetNpuInfo() { platformInfo_ = context_->GetPlatformInfo(); - OP_CHECK_IF(platformInfo_ == nullptr, OP_LOGE(opName_, "GetPlatformInfo is nullptr."), return ge::GRAPH_FAILED); + OPS_CHECK(platformInfo_ == nullptr, OPS_LOG_E(opName_, "GetPlatformInfo is nullptr."), return ge::GRAPH_FAILED); auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo_); aivNum_ = ascendcPlatform.GetCoreNumAiv(); aicNum_ = ascendcPlatform.GetCoreNumAic(); - OP_CHECK_IF(aicNum_ == 0 || aivNum_ == 0, OP_LOGE(opName_, "num of core obtained is 0."), return ge::GRAPH_FAILED); + OPS_CHECK(aicNum_ == 0 || aivNum_ == 0, OPS_LOG_E(opName_, "num of core obtained is 0."), return ge::GRAPH_FAILED); socVersion_ = ascendcPlatform.GetSocVersion(); if ((socVersion_ != platform_ascendc::SocVersion::ASCEND910B) && (socVersion_ != platform_ascendc::SocVersion::ASCEND910_93)) { - OP_LOGE(opName_, "SOC Version[%d] is not support.", (int32_t)socVersion_); + OPS_LOG_E(opName_, "SOC Version[%d] is not support.", (int32_t)socVersion_); return GRAPH_FAILED; } @@ -253,9 +253,9 @@ void SASInfoParser::GetOutputParaInfo() ge::graphStatus SASInfoParser::GetAttrParaInfo() { auto attrs = context_->GetAttrs(); - OP_CHECK_IF(attrs == nullptr, OPS_REPORT_VECTOR_INNER_ERR(context_->GetNodeName(), "attrs got from ge is nullptr"), + OPS_CHECK(attrs == nullptr, OPS_REPORT_VECTOR_INNER_ERR(context_->GetNodeName(), "attrs got from ge is nullptr"), return ge::GRAPH_FAILED); - OP_LOGI(context_->GetNodeName(), "GetAttrParaInfo start"); + OPS_LOG_I(context_->GetNodeName(), "GetAttrParaInfo start"); opParamInfo_.softmaxScale = attrs->GetAttrPointer(ATTR_SOFTMAX_SCALE_INDEX); opParamInfo_.cmpRatio = attrs->GetAttrPointer(ATTR_CMP_RATIO_INDEX); opParamInfo_.oriMaskMode = attrs->GetAttrPointer(ATTR_ORI_MASK_MODE_INDEX); @@ -268,7 +268,7 @@ ge::graphStatus SASInfoParser::GetAttrParaInfo() opParamInfo_.layoutKv = attrs->GetStr(ATTR_LAYOUT_KV_INDEX); opParamInfo_.returnSoftmaxLse = attrs->GetAttrPointer(ATTR_RETURN_SOFTMAX_LSE); - OP_LOGI(context_->GetNodeName(), "GetAttrParaInfo end"); + OPS_LOG_I(context_->GetNodeName(), "GetAttrParaInfo end"); return ge::GRAPH_SUCCESS; } @@ -305,18 +305,18 @@ ge::graphStatus SASInfoParser::GetSASTemplateMode(SASTilingInfo &sasInfo) } else if (opParamInfo_.cmpKv.desc == nullptr && opParamInfo_.cmpSparseIndices.tensor == nullptr) { perfMode_ = SASTemplateMode::SWA_TEMPLATE_MODE; } else { - OP_LOGE(opName_, "When cmp_sparse_indices is not nullptr, cmp_kv cannot be nullptr."); + OPS_LOG_E(opName_, "When cmp_sparse_indices is not nullptr, cmp_kv cannot be nullptr."); return ge::GRAPH_FAILED; } if (sasInfo.perfMode == SASTemplateMode::CFA_TEMPLATE_MODE || sasInfo.perfMode == SASTemplateMode::SCFA_TEMPLATE_MODE) { if (kvLayout_ == SASLayout::TND && opParamInfo_.cuSeqLensCmpKv.tensor == nullptr) { - OP_LOGE(opName_, "the layout_kv is %s, seqlens_cmp_kv must be provided.", SASLayoutToSerialString(kvLayout_).c_str()); + OPS_LOG_E(opName_, "the layout_kv is %s, seqlens_cmp_kv must be provided.", SASLayoutToSerialString(kvLayout_).c_str()); return ge::GRAPH_FAILED; } } return ge::GRAPH_SUCCESS; } else { - OP_LOGE(opName_, "ori_kv is nullptr"); + OPS_LOG_E(opName_, "ori_kv is nullptr"); return ge::GRAPH_FAILED; } return ge::GRAPH_SUCCESS; @@ -338,17 +338,17 @@ ge::graphStatus SASInfoParser::GetQueryAndOutLayout() oriSparseIndicesLayout_ = qLayout_; cmpSparseIndicesLayout_ = qLayout_; } else { - OP_LOGE(opName_, "layout of q is %s, it is unsupported.", layout.c_str()); + OPS_LOG_E(opName_, "layout of q is %s, it is unsupported.", layout.c_str()); return ge::GRAPH_FAILED; } if (qLayout_ == SASLayout::BSND){ - OP_CHECK_IF(opParamInfo_.cuSeqLensQ.tensor != nullptr, - OP_LOGE(opName_, "when q's layout is BSND, cu_seqlens_q is null."), + OPS_CHECK(opParamInfo_.cuSeqLensQ.tensor != nullptr, + OPS_LOG_E(opName_, "when q's layout is BSND, cu_seqlens_q is null."), return ge::GRAPH_FAILED); } if (qLayout_ == SASLayout::TND){ - OP_CHECK_IF(opParamInfo_.seqUsedQ.tensor != nullptr, - OP_LOGE(opName_, "when q's layout is TND, seqused_q is null."), + OPS_CHECK(opParamInfo_.seqUsedQ.tensor != nullptr, + OPS_LOG_E(opName_, "when q's layout is TND, seqused_q is null."), return ge::GRAPH_FAILED); } return ge::GRAPH_SUCCESS; @@ -366,7 +366,7 @@ ge::graphStatus SASInfoParser::GetKvLayout() if (it != layoutKVMap.end()) { kvLayout_ = it->second; } else { - OP_LOGE(opName_, "layout_kv is %s, it is unsupported.", layout.c_str()); + OPS_LOG_E(opName_, "layout_kv is %s, it is unsupported.", layout.c_str()); return ge::GRAPH_FAILED; } return ge::GRAPH_SUCCESS; @@ -410,7 +410,7 @@ void SASInfoParser::SetSASShape() if (opParamInfo_.oriKv.tensor != nullptr) { oriKvShape_ = opParamInfo_.oriKv.tensor->GetStorageShape(); } else { - OP_LOGE(opName_, "q tensor is nullptr, please check input parameters."); + OPS_LOG_E(opName_, "q tensor is nullptr, please check input parameters."); } if (opParamInfo_.cmpKv.tensor != nullptr) { cmpKvShape_ = opParamInfo_.cmpKv.tensor->GetStorageShape(); @@ -421,7 +421,7 @@ void SASInfoParser::SetSASShape() cmpSparseIndicesShape_ = opParamInfo_.cmpSparseIndices.tensor->GetStorageShape(); uint32_t cmpSparseIndicesT = GetAxisNum(cmpSparseIndicesShape_, SASAxis::T, cmpSparseIndicesLayout_); } else { - OP_LOGE(opName_, "cmp_sparse_indices tensor is nullptr, please check input parameters."); + OPS_LOG_E(opName_, "cmp_sparse_indices tensor is nullptr, please check input parameters."); } } } @@ -436,17 +436,17 @@ ge::graphStatus SASInfoParser::GetN2Size() { if (opParamInfo_.oriKv.tensor != nullptr) { n2Size_ = GetAxisNum(oriKvShape_, SASAxis::N, kvLayout_); - } + } if (opParamInfo_.cmpKv.tensor != nullptr) { uint32_t cmpKvN2Size_ = GetAxisNum(cmpKvShape_, SASAxis::N, kvLayout_); if (perfMode_ == SASTemplateMode::SCFA_TEMPLATE_MODE){ uint32_t cmpSparseIndicesN2Size_ = GetAxisNum(cmpSparseIndicesShape_, SASAxis::N, cmpSparseIndicesLayout_); - OP_CHECK_IF(cmpKvN2Size_ != n2Size_ || n2Size_ != cmpSparseIndicesN2Size_, - OP_LOGE(opName_, "N2 size check failed! Expected ori_kv's N2(%u) == cmp_sparse_indices's N2(%u).", n2Size_, cmpSparseIndicesN2Size_), + OPS_CHECK(cmpKvN2Size_ != n2Size_ || n2Size_ != cmpSparseIndicesN2Size_, + OPS_LOG_E(opName_, "N2 size check failed! Expected ori_kv's N2(%u) == cmp_sparse_indices's N2(%u).", n2Size_, cmpSparseIndicesN2Size_), return ge::GRAPH_FAILED); } - OP_CHECK_IF(cmpKvN2Size_ != n2Size_, - OP_LOGE(opName_, "N2 size check failed! Expected cmp_kv's N2(%u) ==ori_kv's N2(%u).", cmpKvN2Size_, n2Size_), + OPS_CHECK(cmpKvN2Size_ != n2Size_, + OPS_LOG_E(opName_, "N2 size check failed! Expected cmp_kv's N2(%u) ==ori_kv's N2(%u).", cmpKvN2Size_, n2Size_), return ge::GRAPH_FAILED); n2Size_ = cmpKvN2Size_; } @@ -465,13 +465,13 @@ ge::graphStatus SASInfoParser::GetActualSeqLenSize(uint32_t &size, const gert::T SASLayout &layout, const std::string &name) const { if ((tensor == nullptr)) { - OP_LOGE(opName_, "when layout of q is %s, %s must be provided.", + OPS_LOG_E(opName_, "when layout of q is %s, %s must be provided.", SASLayoutToSerialString(layout).c_str(), name.c_str()); return ge::GRAPH_FAILED; } int64_t shapeSize = tensor->GetShapeSize(); if (shapeSize <= 0) { - OP_LOGE(opName_, "the shape size of %s is %ld, it should be greater than 0.", + OPS_LOG_E(opName_, "the shape size of %s is %ld, it should be greater than 0.", name.c_str(), shapeSize); return ge::GRAPH_FAILED; } @@ -530,13 +530,13 @@ ge::graphStatus SASInfoParser::GetS1Size() if (perfMode_ == SASTemplateMode::SCFA_TEMPLATE_MODE){ if (cmpSparseIndicesLayout_ == SASLayout::TND) { uint32_t cmpSparseIndicesT = GetAxisNum(cmpSparseIndicesShape_, SASAxis::T, cmpSparseIndicesLayout_); - OP_CHECK_IF(cmpSparseIndicesT != s1Size_, - OP_LOGE(opName_, "T size check failed !"), + OPS_CHECK(cmpSparseIndicesT != s1Size_, + OPS_LOG_E(opName_, "T size check failed !"), return ge::GRAPH_FAILED); } else{ uint32_t cmpSparseIndicesS1 = GetAxisNum(cmpSparseIndicesShape_, SASAxis::S, cmpSparseIndicesLayout_); - OP_CHECK_IF(cmpSparseIndicesS1 != s1Size_, - OP_LOGE(opName_, "s1 size check failed !"), + OPS_CHECK(cmpSparseIndicesS1 != s1Size_, + OPS_LOG_E(opName_, "s1 size check failed !"), return ge::GRAPH_FAILED); } } @@ -546,16 +546,16 @@ ge::graphStatus SASInfoParser::GetS1Size() ge::graphStatus SASInfoParser::GetMaxBlockNumPerBatch() { if (opParamInfo_.oriBlockTable.tensor == nullptr) { - OP_LOGE(opName_, "the layout_kv is %s, block_table must be provided.", SASLayoutToSerialString(kvLayout_).c_str()); + OPS_LOG_E(opName_, "the layout_kv is %s, block_table must be provided.", SASLayoutToSerialString(kvLayout_).c_str()); return ge::GRAPH_FAILED; } uint32_t oriDimNum = opParamInfo_.oriBlockTable.tensor->GetStorageShape().GetDimNum(); if (oriDimNum != DIM_NUM_TWO) { - OP_LOGE(opName_, "the dim num of ori_block_table is %u, it should be %u.", oriDimNum, DIM_NUM_TWO); + OPS_LOG_E(opName_, "the dim num of ori_block_table is %u, it should be %u.", oriDimNum, DIM_NUM_TWO); return ge::GRAPH_FAILED; } if (opParamInfo_.oriBlockTable.tensor->GetStorageShape().GetDim(1) < 0) { - OP_LOGE(opName_, "%s's second dimension(%lld) should be non-negative number.", + OPS_LOG_E(opName_, "%s's second dimension(%lld) should be non-negative number.", ORI_BLOCK_TABLE_NAME.c_str(), opParamInfo_.oriBlockTable.tensor->GetStorageShape().GetDim(1)); return ge::GRAPH_FAILED; } @@ -564,24 +564,24 @@ ge::graphStatus SASInfoParser::GetMaxBlockNumPerBatch() if (opParamInfo_.cmpBlockTable.tensor != nullptr) { uint32_t cmpDimNum = opParamInfo_.cmpBlockTable.tensor->GetStorageShape().GetDimNum(); if (cmpDimNum != DIM_NUM_TWO) { - OP_LOGE(opName_, "the dim num of cmp_block_table is %u, it should be %u.", cmpDimNum, DIM_NUM_TWO); + OPS_LOG_E(opName_, "the dim num of cmp_block_table is %u, it should be %u.", cmpDimNum, DIM_NUM_TWO); return ge::GRAPH_FAILED; } if (qLayout_ == SASLayout::TND) { if (opParamInfo_.cmpBlockTable.tensor->GetStorageShape().GetDim(0) != bSize_ - 1) { - OP_LOGE(opName_, "cmp_block_table's first dimension(%u) should be equal to query's B(%u).", + OPS_LOG_E(opName_, "cmp_block_table's first dimension(%u) should be equal to query's B(%u).", opParamInfo_.cmpBlockTable.tensor->GetStorageShape().GetDim(1), bSize_ - 1); return ge::GRAPH_FAILED; } } else if (qLayout_ == SASLayout::BSND) { if (opParamInfo_.cmpBlockTable.tensor->GetStorageShape().GetDim(0) != bSize_) { - OP_LOGE(opName_, "cmp_block_table's first dimension(%u) should be equal to query's B(%u).", + OPS_LOG_E(opName_, "cmp_block_table's first dimension(%u) should be equal to query's B(%u).", opParamInfo_.cmpBlockTable.tensor->GetStorageShape().GetDim(1), bSize_); return ge::GRAPH_FAILED; } } if (opParamInfo_.cmpBlockTable.tensor->GetStorageShape().GetDim(1) <= 0) { - OP_LOGE(opName_, "%s's second dimension(%lld) should be greater than 0", + OPS_LOG_E(opName_, "%s's second dimension(%lld) should be greater than 0", CMP_BLOCK_TABLE_NAME.c_str(), opParamInfo_.cmpBlockTable.tensor->GetStorageShape().GetDim(1)); return ge::GRAPH_FAILED; } @@ -609,11 +609,11 @@ ge::graphStatus SASInfoParser::GetS2SizeForPageAttention() ge::graphStatus SASInfoParser::GetS2SizeForTND() { if (opParamInfo_.cuSeqLensKv.tensor == nullptr) { - OP_LOGE(opName_, "the layout_kv is %s, seqlens_ori_kv must be provided.", SASLayoutToSerialString(kvLayout_).c_str()); + OPS_LOG_E(opName_, "the layout_kv is %s, seqlens_ori_kv must be provided.", SASLayoutToSerialString(kvLayout_).c_str()); return ge::GRAPH_FAILED; - } + } // if (opParamInfo_.sequsedKv.tensor == nullptr) { - // OP_LOGE(opName_, "the layout_kv is %s, sequsedKv must be provided.", SASLayoutToSerialString(kvLayout_).c_str()); + // OPS_LOG_E(opName_, "the layout_kv is %s, sequsedKv must be provided.", SASLayoutToSerialString(kvLayout_).c_str()); // return ge::GRAPH_FAILED; // } // 这里返回累加和的最大值 @@ -670,7 +670,7 @@ ge::graphStatus SASInfoParser::GetSparseBlockCount() ge::graphStatus SASInfoParser::GetSinks() { if (opParamInfo_.sinks.tensor == nullptr) { - OP_LOGE(opName_, "%s must be provided!", SINKS_NAME.c_str()); + OPS_LOG_E(opName_, "%s must be provided!", SINKS_NAME.c_str()); return ge::GRAPH_FAILED; } return ge::GRAPH_SUCCESS; @@ -682,15 +682,15 @@ ge::graphStatus SASInfoParser::GetActualseqInfo() if (qLayout_ == SASLayout::TND) { if (opParamInfo_.cuSeqLensQ.tensor != nullptr) { if (opParamInfo_.cuSeqLensQ.tensor->GetShapeSize() != bSize_) { - OP_LOGE(opName_, "cu_seqlens_q's dimension should be equal to %u.", bSize_); + OPS_LOG_E(opName_, "cu_seqlens_q's dimension should be equal to %u.", bSize_); return ge::GRAPH_FAILED; } actualLenDimsQ_ = opParamInfo_.cuSeqLensQ.tensor->GetShapeSize() - 1; // cuSeqLensQ shape is B+1 - OP_CHECK_IF(actualLenDimsQ_ == 0, - OP_LOGE(opName_, "cu_seqlens_q cannot be empty tensor."), + OPS_CHECK(actualLenDimsQ_ == 0, + OPS_LOG_E(opName_, "cu_seqlens_q cannot be empty tensor."), return ge::GRAPH_FAILED); } else { - OP_LOGE(opName_, "When layout_q is TND, input cu_seqlens_q must be provided"); + OPS_LOG_E(opName_, "When layout_q is TND, input cu_seqlens_q must be provided"); return ge::GRAPH_FAILED; } } else { @@ -699,53 +699,53 @@ ge::graphStatus SASInfoParser::GetActualseqInfo() } } if (kvLayout_ != SASLayout::PA_ND && kvLayout_ != SASLayout::BSND && kvLayout_ != SASLayout::TND) { - OP_LOGE(opName_, "ori_kv and cmp_kv only support PA_ND, BSND and TND layout."); + OPS_LOG_E(opName_, "ori_kv and cmp_kv only support PA_ND, BSND and TND layout."); return ge::GRAPH_FAILED; } if (kvLayout_ == SASLayout::PA_ND) { if (opParamInfo_.sequsedKv.tensor != nullptr) { if (qLayout_ == SASLayout::BSND){ if (opParamInfo_.sequsedKv.tensor->GetShapeSize() != bSize_) { - OP_LOGE(opName_, "seqused_kv's dimension should be equal to %u, but got %ld.", + OPS_LOG_E(opName_, "seqused_kv's dimension should be equal to %u, but got %ld.", bSize_, opParamInfo_.sequsedKv.tensor->GetShapeSize()); return ge::GRAPH_FAILED; } } else { if (opParamInfo_.sequsedKv.tensor->GetShapeSize() != (bSize_ - 1)) { - OP_LOGE(opName_, "seqused_kv's dimension should be equal to %u (bSize - 1), but got %ld.", + OPS_LOG_E(opName_, "seqused_kv's dimension should be equal to %u (bSize - 1), but got %ld.", (bSize_ - 1), opParamInfo_.sequsedKv.tensor->GetShapeSize()); return ge::GRAPH_FAILED; } } - OP_CHECK_IF(opParamInfo_.sequsedKv.desc->GetDataType() != ge::DT_INT32, - OP_LOGE(opName_, "seqused_kv's dtype must be DT_INT32."), + OPS_CHECK(opParamInfo_.sequsedKv.desc->GetDataType() != ge::DT_INT32, + OPS_LOG_E(opName_, "seqused_kv's dtype must be DT_INT32."), return ge::GRAPH_FAILED); actualLenDimsKV_ = opParamInfo_.sequsedKv.tensor->GetShapeSize(); - OP_CHECK_IF(actualLenDimsKV_ == 0, - OP_LOGE(opName_, "seqused_kv cannot be empty tensor."), + OPS_CHECK(actualLenDimsKV_ == 0, + OPS_LOG_E(opName_, "seqused_kv cannot be empty tensor."), return ge::GRAPH_FAILED); } else { - OP_LOGE(opName_, "When kv layout is PA_ND, input sequsedKv must be provided"); + OPS_LOG_E(opName_, "When kv layout is PA_ND, input sequsedKv must be provided"); return ge::GRAPH_FAILED; } } else if (kvLayout_ == SASLayout::TND) { if (opParamInfo_.cuSeqLensKv.tensor != nullptr) { if (qLayout_ == SASLayout::BSND){ if (opParamInfo_.cuSeqLensKv.tensor->GetShapeSize() != bSize_ + 1) { - OP_LOGE(opName_, "cuSeqLensKv's dimension should be equal to %u (bSize + 1), but got %ld.", + OPS_LOG_E(opName_, "cuSeqLensKv's dimension should be equal to %u (bSize + 1), but got %ld.", (bSize_ + 1), opParamInfo_.sequsedKv.tensor->GetShapeSize()); return ge::GRAPH_FAILED; } } else { if (opParamInfo_.cuSeqLensKv.tensor->GetShapeSize() != (bSize_)) { - OP_LOGE(opName_, "cuSeqLensKv's dimension should be equal to %u, but got %ld.", + OPS_LOG_E(opName_, "cuSeqLensKv's dimension should be equal to %u, but got %ld.", bSize_, opParamInfo_.sequsedKv.tensor->GetShapeSize()); return ge::GRAPH_FAILED; } } actualLenDimsKV_ = opParamInfo_.cuSeqLensKv.tensor->GetShapeSize(); } else { - OP_LOGE(opName_, "When kv layout is TND, input cuSeqLensKv must be provided"); + OPS_LOG_E(opName_, "When kv layout is TND, input cuSeqLensKv must be provided"); return ge::GRAPH_FAILED; } } @@ -820,13 +820,13 @@ void SASInfoParser::GenerateInfo(SASTilingInfo &sasInfo) ge::graphStatus SASInfoParser::Parse(SASTilingInfo &sasInfo) { if (context_ == nullptr) { - OP_LOGE("SparseFlashAttention", "tiling context is nullptr!"); + OPS_LOG_E("SparseFlashAttention", "tiling context is nullptr!"); return ge::GRAPH_FAILED; } if (ge::GRAPH_SUCCESS != GetOpName() || ge::GRAPH_SUCCESS != GetNpuInfo() || - ge::GRAPH_SUCCESS != GetOpParaInfo() || + ge::GRAPH_SUCCESS != GetOpParaInfo() || ge::GRAPH_SUCCESS != GetKvLayout() || ge::GRAPH_SUCCESS != CheckRequiredParaExistence() || ge::GRAPH_SUCCESS != CheckUnrequiredParaExistence()) { @@ -905,7 +905,7 @@ void SASTilingCheck::LogErrorDtypeSupport(const std::vector &expec oss << ", "; } } - OP_LOGE(opName_, "Tensor %s only supports dtype %s, but got %s", + OPS_LOG_E(opName_, "Tensor %s only supports dtype %s, but got %s", name.c_str(), oss.str().c_str(), SASDataTypeToSerialString(actualDtype).c_str()); } @@ -914,11 +914,11 @@ ge::graphStatus SASTilingCheck::CheckDtypeSupport(const gert::CompileTimeTensorD { if (desc != nullptr) { const auto& it = DTYPE_SUPPORT_MAP.find(name); - OP_CHECK_IF(it == DTYPE_SUPPORT_MAP.end(), - OP_LOGE(opName_, "%s datatype support list should be specify in DTYPE_SUPPORT_MAP", name.c_str()), + OPS_CHECK(it == DTYPE_SUPPORT_MAP.end(), + OPS_LOG_E(opName_, "%s datatype support list should be specify in DTYPE_SUPPORT_MAP", name.c_str()), return ge::GRAPH_FAILED); auto &expectDtypeList = it->second; - OP_CHECK_IF(std::find( + OPS_CHECK(std::find( expectDtypeList.begin(), expectDtypeList.end(), desc->GetDataType()) == expectDtypeList.end(), LogErrorDtypeSupport(expectDtypeList, desc->GetDataType(), name), return ge::GRAPH_FAILED); @@ -936,18 +936,18 @@ void SASTilingCheck::LogErrorLayoutSupport(const std::vector &expectL oss << ", "; } } - OP_LOGE(opName_, "Tensor %s only supports layout %s, but got %s", + OPS_LOG_E(opName_, "Tensor %s only supports layout %s, but got %s", name.c_str(), oss.str().c_str(), SASLayoutToSerialString(actualLayout).c_str()); } ge::graphStatus SASTilingCheck::CheckLayoutSupport(const SASLayout &actualLayout, const std::string &name) const { const auto& it = LAYOUT_SUPPORT_MAP.find(name); - OP_CHECK_IF(it == LAYOUT_SUPPORT_MAP.end(), - OP_LOGE(opName_, "%s layout support list should be specify in LAYOUT_SUPPORT_MAP", name.c_str()), + OPS_CHECK(it == LAYOUT_SUPPORT_MAP.end(), + OPS_LOG_E(opName_, "%s layout support list should be specify in LAYOUT_SUPPORT_MAP", name.c_str()), return ge::GRAPH_FAILED); auto &expectLayoutList = it->second; - OP_CHECK_IF(std::find( + OPS_CHECK(std::find( expectLayoutList.begin(), expectLayoutList.end(), actualLayout) == expectLayoutList.end(), LogErrorLayoutSupport(expectLayoutList, actualLayout, name), return ge::GRAPH_FAILED); @@ -966,11 +966,11 @@ void SASTilingCheck::LogErrorNumberSupport(const std::vector &expectNumberLis oss << ", "; } } - OP_LOGE(opName_, "%s %s only supports %s, but got %s", + OPS_LOG_E(opName_, "%s %s only supports %s, but got %s", name.c_str(), subName.c_str(), oss.str().c_str(), std::to_string(actualValue).c_str()); } -template +template void SASTilingCheck::LogErrorDimNumSupport(const std::vector &expectNumberList, const T &actualValue, const std::string &name) const { @@ -997,8 +997,8 @@ ge::graphStatus SASTilingCheck::CheckDimNumInLayoutSupport(const SASLayout &layo const gert::StorageShape *shape, const std::string &name) const { const auto& dimIt = SAS_LAYOUT_DIM_MAP.find(layout); - OP_CHECK_IF(shape->GetStorageShape().GetDimNum() != dimIt->second, - OP_LOGE(opName_, "When layout is %s, %s dimension should be %zu, but it's %zu", + OPS_CHECK(shape->GetStorageShape().GetDimNum() != dimIt->second, + OPS_LOG_E(opName_, "When layout is %s, %s dimension should be %zu, but it's %zu", SASLayoutToSerialString(layout).c_str(), name.c_str(), dimIt->second, shape->GetStorageShape().GetDimNum()), return ge::GRAPH_FAILED); @@ -1007,11 +1007,11 @@ ge::graphStatus SASTilingCheck::CheckDimNumInLayoutSupport(const SASLayout &layo ge::graphStatus SASTilingCheck::CheckSingleParaQuery() const { - OP_CHECK_IF(opParamInfo_.q.shape->GetStorageShape().GetShapeSize() == 0, - OP_LOGE(opName_, "q cannot be empty tensor."), + OPS_CHECK(opParamInfo_.q.shape->GetStorageShape().GetShapeSize() == 0, + OPS_LOG_E(opName_, "q cannot be empty tensor."), return ge::GRAPH_FAILED); if (opParamInfo_.q.desc == nullptr) { - OP_LOGE(opName_, "%s must be provided!", QUERY_NAME.c_str()); + OPS_LOG_E(opName_, "%s must be provided!", QUERY_NAME.c_str()); return ge::GRAPH_FAILED; } const std::vector queryDimNumList = {DIM_NUM_THREE, DIM_NUM_FOUR}; @@ -1040,7 +1040,7 @@ ge::graphStatus SASTilingCheck::CheckSingleParaOriKv() const ge::graphStatus SASTilingCheck::CheckSingleParaCmpKv() const { - if (sasInfo_.perfMode == SASTemplateMode::SCFA_TEMPLATE_MODE || + if (sasInfo_.perfMode == SASTemplateMode::SCFA_TEMPLATE_MODE || sasInfo_.perfMode == SASTemplateMode::CFA_TEMPLATE_MODE) { const std::vector cmpKvDimNumList = {DIM_NUM_THREE, DIM_NUM_FOUR}; if ( @@ -1067,8 +1067,8 @@ ge::graphStatus SASTilingCheck::CheckSingleParaKvHeadNums() const ge::graphStatus SASTilingCheck::CheckSingleParaCmpSparseIndices() const { if (sasInfo_.perfMode == optiling::SASTemplateMode::SCFA_TEMPLATE_MODE){ - OP_CHECK_IF(opParamInfo_.cmpSparseIndices.tensor->GetStorageShape().GetShapeSize() == 0, - OP_LOGE(opName_, "when cmp_sparse_indices is not nullptr(SCFA), cmp_sparse_indices cannot be empty tensor."), + OPS_CHECK(opParamInfo_.cmpSparseIndices.tensor->GetStorageShape().GetShapeSize() == 0, + OPS_LOG_E(opName_, "when cmp_sparse_indices is not nullptr(SCFA), cmp_sparse_indices cannot be empty tensor."), return ge::GRAPH_FAILED); const std::vector cmpSparseIndicesDimNumList = {DIM_NUM_THREE, DIM_NUM_FOUR}; if ( @@ -1079,15 +1079,15 @@ ge::graphStatus SASTilingCheck::CheckSingleParaCmpSparseIndices() const } if (cmpSparseIndicesLayout_ == SASLayout::TND) { - OP_CHECK_IF(!(opParamInfo_.cmpSparseIndices.tensor->GetStorageShape().GetDim(DIM_NUM_THREE - 1) != 512 || \ + OPS_CHECK(!(opParamInfo_.cmpSparseIndices.tensor->GetStorageShape().GetDim(DIM_NUM_THREE - 1) != 512 || \ opParamInfo_.cmpSparseIndices.tensor->GetStorageShape().GetDim(DIM_NUM_THREE - 1) != 1024), - OP_LOGE(opName_, "K should be 512 or 1024, but got: %lld ", + OPS_LOG_E(opName_, "K should be 512 or 1024, but got: %lld ", opParamInfo_.cmpSparseIndices.tensor->GetStorageShape().GetDim(DIM_NUM_THREE - 1)), return ge::GRAPH_FAILED); } else{ - OP_CHECK_IF(!(opParamInfo_.cmpSparseIndices.tensor->GetStorageShape().GetDim(DIM_NUM_THREE - 1) != 512 || \ + OPS_CHECK(!(opParamInfo_.cmpSparseIndices.tensor->GetStorageShape().GetDim(DIM_NUM_THREE - 1) != 512 || \ opParamInfo_.cmpSparseIndices.tensor->GetStorageShape().GetDim(DIM_NUM_THREE - 1) != 1024), - OP_LOGE(opName_, "K should be 512 or 1024, but got: %lld ", + OPS_LOG_E(opName_, "K should be 512 or 1024, but got: %lld ", opParamInfo_.cmpSparseIndices.tensor->GetStorageShape().GetDim(DIM_NUM_FOUR - 1)), return ge::GRAPH_FAILED); } @@ -1103,8 +1103,8 @@ ge::graphStatus SASTilingCheck::CheckSingleParaOriBlockTable() const if(kvLayout_ == SASLayout::TND) { return ge::GRAPH_SUCCESS; } - OP_CHECK_IF(opParamInfo_.oriBlockTable.tensor->GetStorageShape().GetShapeSize() == 0, - OP_LOGE(opName_, "ori_block_table cannot be empty tensor."), + OPS_CHECK(opParamInfo_.oriBlockTable.tensor->GetStorageShape().GetShapeSize() == 0, + OPS_LOG_E(opName_, "ori_block_table cannot be empty tensor."), return ge::GRAPH_FAILED); const std::vector oriBlockTableDimNumList = {DIM_NUM_TWO}; if ( @@ -1112,9 +1112,9 @@ ge::graphStatus SASTilingCheck::CheckSingleParaOriBlockTable() const ge::GRAPH_SUCCESS != CheckDimNumSupport(&opParamInfo_.oriBlockTable.tensor->GetShape(), oriBlockTableDimNumList, ORI_BLOCK_TABLE_NAME)) { return ge::GRAPH_FAILED; } - OP_CHECK_IF((oriBlockSize_ <= 0 || oriBlockSize_ > BLOCK_SIZE_LIMIT || + OPS_CHECK((oriBlockSize_ <= 0 || oriBlockSize_ > BLOCK_SIZE_LIMIT || (static_cast(oriBlockSize_) % 16 != 0UL)), - OP_LOGE(opName_, "ori_block_size should be in range [1, 1024], and be aligned to 16, but got: %d.", + OPS_LOG_E(opName_, "ori_block_size should be in range [1, 1024], and be aligned to 16, but got: %d.", oriBlockSize_), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; @@ -1137,9 +1137,9 @@ ge::graphStatus SASTilingCheck::CheckSingleParaCmpBlockTable() const cmpBlockTableDimNumList, CMP_BLOCK_TABLE_NAME)) { return ge::GRAPH_FAILED; } - OP_CHECK_IF((cmpBlockSize_ <= 0 || cmpBlockSize_ > BLOCK_SIZE_LIMIT || + OPS_CHECK((cmpBlockSize_ <= 0 || cmpBlockSize_ > BLOCK_SIZE_LIMIT || (static_cast(cmpBlockSize_) % 16 != 0UL)), - OP_LOGE(opName_, "cmp_block_size should be in [1, 1024], and be aligned to 16, but got: %d.", + OPS_LOG_E(opName_, "cmp_block_size should be in [1, 1024], and be aligned to 16, but got: %d.", cmpBlockSize_), return ge::GRAPH_FAILED); } @@ -1148,21 +1148,21 @@ ge::graphStatus SASTilingCheck::CheckSingleParaCmpBlockTable() const ge::graphStatus SASTilingCheck::CheckSingleParaSinks() const { - OP_CHECK_IF(opParamInfo_.sinks.tensor->GetStorageShape().GetShapeSize() == 0, - OP_LOGE(opName_, "sinks cannot be empty tensor."), + OPS_CHECK(opParamInfo_.sinks.tensor->GetStorageShape().GetShapeSize() == 0, + OPS_LOG_E(opName_, "sinks cannot be empty tensor."), return ge::GRAPH_FAILED); if (opParamInfo_.sinks.tensor->GetStorageShape().GetDimNum() != DIM_NUM_ONE) { - OP_LOGE(opName_, "the dim num of %s is %u, it should be %u.", SINKS_NAME.c_str(), + OPS_LOG_E(opName_, "the dim num of %s is %u, it should be %u.", SINKS_NAME.c_str(), opParamInfo_.sinks.tensor->GetStorageShape().GetDimNum(), DIM_NUM_ONE); return ge::GRAPH_FAILED; } if (opParamInfo_.sinks.tensor->GetStorageShape().GetDim(0) != n1Size_) { - OP_LOGE(opName_, "%s's dimension(%ld) should be equal to query head num(%u).", SINKS_NAME.c_str(), + OPS_LOG_E(opName_, "%s's dimension(%ld) should be equal to query head num(%u).", SINKS_NAME.c_str(), opParamInfo_.sinks.tensor->GetStorageShape().GetDim(0), n1Size_); return ge::GRAPH_FAILED; } - OP_CHECK_IF(opParamInfo_.sinks.desc->GetDataType() != ge::DT_FLOAT, - OP_LOGE(opName_, "sinks's dtype must be DT_FLOAT."), + OPS_CHECK(opParamInfo_.sinks.desc->GetDataType() != ge::DT_FLOAT, + OPS_LOG_E(opName_, "sinks's dtype must be DT_FLOAT."), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; } @@ -1170,14 +1170,14 @@ ge::graphStatus SASTilingCheck::CheckSingleParaSinks() const ge::graphStatus SASTilingCheck::CheckSingleParaMetadata() const { if (opParamInfo_.metadata.tensor == nullptr) { - OP_LOGE(opName_, "%s must be provided!", METADATA_NAME.c_str()); + OPS_LOG_E(opName_, "%s must be provided!", METADATA_NAME.c_str()); return ge::GRAPH_FAILED; } - OP_CHECK_IF((opParamInfo_.metadata.tensor->GetShapeSize() != METADATA_LIMIT), - OP_LOGE(opName_, "input metadata dim 0 must be %u.", METADATA_LIMIT), + OPS_CHECK((opParamInfo_.metadata.tensor->GetShapeSize() != METADATA_LIMIT), + OPS_LOG_E(opName_, "input metadata dim 0 must be %u.", METADATA_LIMIT), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.metadata.desc->GetDataType() != ge::DT_INT32, - OP_LOGE(opName_, "metadata's dtype must be DT_INT32."), + OPS_CHECK(opParamInfo_.metadata.desc->GetDataType() != ge::DT_INT32, + OPS_LOG_E(opName_, "metadata's dtype must be DT_INT32."), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; } @@ -1185,8 +1185,8 @@ ge::graphStatus SASTilingCheck::CheckSingleParaMetadata() const ge::graphStatus SASTilingCheck::CheckSingleParaCmpRatio() const { if (sasInfo_.perfMode == optiling::SASTemplateMode::CFA_TEMPLATE_MODE || sasInfo_.perfMode == optiling::SASTemplateMode::SCFA_TEMPLATE_MODE){ - OP_CHECK_IF(cmpRatio_ != 128 && cmpRatio_ != 4, - OP_LOGE(opName_, "cmp_ratio should be 128 or 4, but got %u", cmpRatio_), + OPS_CHECK(cmpRatio_ != 128 && cmpRatio_ != 4, + OPS_LOG_E(opName_, "cmp_ratio should be 128 or 4, but got %u", cmpRatio_), return ge::GRAPH_FAILED); } return ge::GRAPH_SUCCESS; @@ -1244,22 +1244,22 @@ ge::graphStatus SASTilingCheck::CheckSinglePara() const ge::GRAPH_SUCCESS != CheckSingleParaOriWinRight()) { return ge::GRAPH_FAILED; } - + return ge::GRAPH_SUCCESS; } ge::graphStatus SASTilingCheck::CheckExists(const void *pointer, const std::string &name) const { - OP_CHECK_IF(pointer == nullptr, - OP_LOGE(opName_, "%s should not be null", name.c_str()), + OPS_CHECK(pointer == nullptr, + OPS_LOG_E(opName_, "%s should not be null", name.c_str()), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; } ge::graphStatus SASTilingCheck::CheckNotExists(const void *pointer, const std::string &name) const { - OP_CHECK_IF(pointer != nullptr, - OP_LOGE(opName_, "%s should be null", name.c_str()), + OPS_CHECK(pointer != nullptr, + OPS_LOG_E(opName_, "%s should be null", name.c_str()), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; } @@ -1298,7 +1298,7 @@ ge::graphStatus SASTilingCheck::CheckExistenceByMap(std::map ParamExistMap = { @@ -1314,59 +1314,59 @@ ge::graphStatus SASTilingCheck::CheckParaExistence() const ge::graphStatus SASTilingCheck::CheckFeatureShape() const { - OP_CHECK_IF(bSize_ <= 0, - OP_LOGE(opName_, "batch_size should be greater than 0, but got %u", bSize_), + OPS_CHECK(bSize_ <= 0, + OPS_LOG_E(opName_, "batch_size should be greater than 0, but got %u", bSize_), return ge::GRAPH_FAILED); - - OP_CHECK_IF(qTSize_ <= 0 && (qLayout_ == SASLayout::TND), - OP_LOGE(opName_, "T_size of query should be greater than 0, but got %u", qTSize_), + + OPS_CHECK(qTSize_ <= 0 && (qLayout_ == SASLayout::TND), + OPS_LOG_E(opName_, "T_size of query should be greater than 0, but got %u", qTSize_), return ge::GRAPH_FAILED); - OP_CHECK_IF(n1Size_ % 4 != 0, - OP_LOGE(opName_, "q_head_num should be multiple of 4, but got %u", n1Size_), + OPS_CHECK(n1Size_ % 4 != 0, + OPS_LOG_E(opName_, "q_head_num should be multiple of 4, but got %u", n1Size_), return ge::GRAPH_FAILED); - OP_CHECK_IF(n2Size_ != 1, - OP_LOGE(opName_, "kv_head_num should be 1, but got %u", n2Size_), + OPS_CHECK(n2Size_ != 1, + OPS_LOG_E(opName_, "kv_head_num should be 1, but got %u", n2Size_), return ge::GRAPH_FAILED); - OP_CHECK_IF(n1Size_ % n2Size_ != 0, - OP_LOGE(opName_, "q_head_num(%u) must be divisible by kv_head_num(%u)", n1Size_, n2Size_), + OPS_CHECK(n1Size_ % n2Size_ != 0, + OPS_LOG_E(opName_, "q_head_num(%u) must be divisible by kv_head_num(%u)", n1Size_, n2Size_), return ge::GRAPH_FAILED); - OP_CHECK_IF(gSize_ % 4 != 0, - OP_LOGE(opName_, "group num should be multiple of 4, but got %u", gSize_), + OPS_CHECK(gSize_ % 4 != 0, + OPS_LOG_E(opName_, "group num should be multiple of 4, but got %u", gSize_), return ge::GRAPH_FAILED); - OP_CHECK_IF(qHeadDim_ != DIM_LIMIT, - OP_LOGE(opName_, "q_head_dim only support %u, but got %u", DIM_LIMIT, qHeadDim_), + OPS_CHECK(qHeadDim_ != DIM_LIMIT, + OPS_LOG_E(opName_, "q_head_dim only support %u, but got %u", DIM_LIMIT, qHeadDim_), return ge::GRAPH_FAILED); - OP_CHECK_IF(oriKvHeadDim_ != DIM_LIMIT, - OP_LOGE(opName_, "ori_kv_head_dim only support %u, but got %u", DIM_LIMIT, oriKvHeadDim_), + OPS_CHECK(oriKvHeadDim_ != DIM_LIMIT, + OPS_LOG_E(opName_, "ori_kv_head_dim only support %u, but got %u", DIM_LIMIT, oriKvHeadDim_), return ge::GRAPH_FAILED); if (!(sasInfo_.perfMode == SASTemplateMode::SWA_TEMPLATE_MODE)){ - OP_CHECK_IF(cmpKvHeadDim_ != DIM_LIMIT, - OP_LOGE(opName_, "cmp_kv_head_dim only support %u, but got %u", DIM_LIMIT, cmpKvHeadDim_), + OPS_CHECK(cmpKvHeadDim_ != DIM_LIMIT, + OPS_LOG_E(opName_, "cmp_kv_head_dim only support %u, but got %u", DIM_LIMIT, cmpKvHeadDim_), return ge::GRAPH_FAILED); } - OP_CHECK_IF(!(qType_ == oriKvType_), - OP_LOGE(opName_, "Head dimension data type check failed! qType[%s] must be the same with oriKvType[%s].", + OPS_CHECK(!(qType_ == oriKvType_), + OPS_LOG_E(opName_, "Head dimension data type check failed! qType[%s] must be the same with oriKvType[%s].", SASDataTypeToSerialString(qType_).c_str(), SASDataTypeToSerialString(oriKvType_).c_str()), return ge::GRAPH_FAILED); - OP_CHECK_IF(*opParamInfo_.oriMaskMode != 4, - OP_LOGE(opName_, "ori_mask_mode should be 4, but got %d", *opParamInfo_.oriMaskMode), + OPS_CHECK(*opParamInfo_.oriMaskMode != 4, + OPS_LOG_E(opName_, "ori_mask_mode should be 4, but got %d", *opParamInfo_.oriMaskMode), return ge::GRAPH_FAILED); - OP_CHECK_IF(*opParamInfo_.cmpMaskMode != 3, - OP_LOGE(opName_, "cmp_mask_mode should be 3, but got %d", *opParamInfo_.cmpMaskMode), + OPS_CHECK(*opParamInfo_.cmpMaskMode != 3, + OPS_LOG_E(opName_, "cmp_mask_mode should be 3, but got %d", *opParamInfo_.cmpMaskMode), return ge::GRAPH_FAILED); - OP_CHECK_IF(oriWinLeft_ != 127, - OP_LOGE(opName_, "ori_win_left should be 127, but got %d", oriWinLeft_), + OPS_CHECK(oriWinLeft_ != 127, + OPS_LOG_E(opName_, "ori_win_left should be 127, but got %d", oriWinLeft_), return ge::GRAPH_FAILED); - OP_CHECK_IF(oriWinRight_ != 0, - OP_LOGE(opName_, "ori_win_right should be 0, but got %d", oriWinRight_), + OPS_CHECK(oriWinRight_ != 0, + OPS_LOG_E(opName_, "ori_win_right should be 0, but got %d", oriWinRight_), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; } @@ -1378,17 +1378,17 @@ ge::graphStatus SASTilingCheck::CheckFeatureLayout() const "TND" }; std::string layoutQuery = opParamInfo_.layoutQ; - OP_CHECK_IF(std::find(layoutQuerySupportList.begin(), layoutQuerySupportList.end(), layoutQuery) == + OPS_CHECK(std::find(layoutQuerySupportList.begin(), layoutQuerySupportList.end(), layoutQuery) == layoutQuerySupportList.end(), - OP_LOGE(opName_, "layout_q only supports BSND/TND, but got %s", layoutQuery.c_str()), + OPS_LOG_E(opName_, "layout_q only supports BSND/TND, but got %s", layoutQuery.c_str()), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; } ge::graphStatus SASTilingCheck::CheckFeatureDtype() const { - OP_CHECK_IF(qType_ != ge::DT_BF16 && qType_ != ge::DT_FLOAT16, - OP_LOGE(opName_, "q dtype only support %s and %s, but got %s", + OPS_CHECK(qType_ != ge::DT_BF16 && qType_ != ge::DT_FLOAT16, + OPS_LOG_E(opName_, "q dtype only support %s and %s, but got %s", SASDataTypeToSerialString(ge::DT_BF16).c_str(), SASDataTypeToSerialString(ge::DT_FLOAT16).c_str(), SASDataTypeToSerialString(qType_).c_str()), return ge::GRAPH_FAILED); @@ -1416,7 +1416,7 @@ void SASTilingCheck::SetSASShapeCompare() queryShapeCmp_ = opParamInfo_.q.shape->GetStorageShape(); oriKvShapeCmp_= opParamInfo_.oriKv.tensor->GetShape().GetStorageShape(); attenOutShapeCmp_ = opParamInfo_.attnOut.shape->GetStorageShape(); - if (sasInfo_.perfMode == SASTemplateMode::CFA_TEMPLATE_MODE || + if (sasInfo_.perfMode == SASTemplateMode::CFA_TEMPLATE_MODE || sasInfo_.perfMode == SASTemplateMode::SCFA_TEMPLATE_MODE) { cmpKvShapeCmp_= opParamInfo_.cmpKv.tensor->GetShape().GetStorageShape(); } @@ -1429,7 +1429,7 @@ ge::graphStatus SASTilingCheck::CheckDTypeConsistency(const ge::DataType &actual const ge::DataType &expectDtype, const std::string &name) const { if (actualDtype != expectDtype) { - OP_LOGE(opName_, "%s dtype should be the same to %s, but it's %s.", name.c_str(), + OPS_LOG_E(opName_, "%s dtype should be the same to %s, but it's %s.", name.c_str(), SASDataTypeToSerialString(expectDtype).c_str(), SASDataTypeToSerialString(actualDtype).c_str()); return ge::GRAPH_FAILED; @@ -1439,15 +1439,15 @@ ge::graphStatus SASTilingCheck::CheckDTypeConsistency(const ge::DataType &actual ge::graphStatus SASTilingCheck::CheckOriAndCmpKv() const { - OP_CHECK_IF(opParamInfo_.oriKv.tensor->GetStorageShape().GetShapeSize() == 0, - OP_LOGE(opName_, "ori_kv cannot be empty tensor."), + OPS_CHECK(opParamInfo_.oriKv.tensor->GetStorageShape().GetShapeSize() == 0, + OPS_LOG_E(opName_, "ori_kv cannot be empty tensor."), return ge::GRAPH_FAILED); if (sasInfo_.perfMode == SASTemplateMode::CFA_TEMPLATE_MODE || sasInfo_.perfMode == SASTemplateMode::SCFA_TEMPLATE_MODE) { if (opParamInfo_.cmpKv.tensor->GetStorageShape().GetDim(0) != 0 ) { - OP_CHECK_IF(opParamInfo_.cmpKv.tensor->GetStorageShape().GetShapeSize() == 0, - OP_LOGE(opName_, "cmp_kv cannot be empty tensor."), + OPS_CHECK(opParamInfo_.cmpKv.tensor->GetStorageShape().GetShapeSize() == 0, + OPS_LOG_E(opName_, "cmp_kv cannot be empty tensor."), return ge::GRAPH_FAILED); } if (ge::GRAPH_SUCCESS != CheckDTypeConsistency(cmpKvType_, @@ -1461,11 +1461,11 @@ ge::graphStatus SASTilingCheck::CheckOriAndCmpKv() const ge::graphStatus SASTilingCheck::CheckAttenOut() const { if (opParamInfo_.attnOut.desc != nullptr && opParamInfo_.attnOut.shape != nullptr) { - OP_CHECK_IF(opParamInfo_.attnOut.shape->GetStorageShape().GetShapeSize() == 0, - OP_LOGE(opName_, "attn_out cannot be empty tensor."), + OPS_CHECK(opParamInfo_.attnOut.shape->GetStorageShape().GetShapeSize() == 0, + OPS_LOG_E(opName_, "attn_out cannot be empty tensor."), return ge::GRAPH_FAILED); } else{ - OP_LOGE(opName_, "attn_out cannot be nullptr."); + OPS_LOG_E(opName_, "attn_out cannot be nullptr."); } return ge::GRAPH_SUCCESS; } @@ -1473,11 +1473,11 @@ ge::graphStatus SASTilingCheck::CheckAttenOut() const ge::graphStatus SASTilingCheck::CheckActualSeqLensQ() const { if (qLayout_ == SASLayout::TND) { - OP_CHECK_IF(opParamInfo_.cuSeqLensQ.tensor->GetStorageShape().GetShapeSize() == 0, - OP_LOGE(opName_, "when q's is TND, cu_seqlens_q cannot be empty tensor."), + OPS_CHECK(opParamInfo_.cuSeqLensQ.tensor->GetStorageShape().GetShapeSize() == 0, + OPS_LOG_E(opName_, "when q's is TND, cu_seqlens_q cannot be empty tensor."), return ge::GRAPH_FAILED); - OP_CHECK_IF(opParamInfo_.cuSeqLensQ.desc->GetDataType() != ge::DT_INT32, - OP_LOGE(opName_, "when q's is TND, cu_seqlens_q's dtype msut be DT_INT32."), + OPS_CHECK(opParamInfo_.cuSeqLensQ.desc->GetDataType() != ge::DT_INT32, + OPS_LOG_E(opName_, "when q's is TND, cu_seqlens_q's dtype msut be DT_INT32."), return ge::GRAPH_FAILED); } return ge::GRAPH_SUCCESS; @@ -1500,7 +1500,7 @@ ge::graphStatus SASTilingCheck::CheckMultiParaConsistency() ge::GRAPH_SUCCESS != CheckAttenOut() || ge::GRAPH_SUCCESS != CheckActualSeqLensQ() || ge::GRAPH_SUCCESS != CheckActualSeqLens() || - ge::GRAPH_SUCCESS != CheckBlockTable()) + ge::GRAPH_SUCCESS != CheckBlockTable()) { return ge::GRAPH_FAILED; } @@ -1515,7 +1515,7 @@ ge::graphStatus SASTilingCheck::Process() CheckParaExistence() != ge::GRAPH_SUCCESS || CheckFeature() != ge::GRAPH_SUCCESS || CheckMultiParaConsistency() != ge::GRAPH_SUCCESS - ) + ) { return ge::GRAPH_FAILED; } @@ -1562,7 +1562,7 @@ ge::graphStatus SparseAttnSharedkvTiling::DoOpTiling(SASTilingInfo *tilingInfo) uint32_t aicNum = ascendcPlatform.GetCoreNumAic(); uint32_t blockDim = ascendcPlatform.CalcTschBlockDim(aivNum, aicNum, aivNum); context_->SetBlockDim(blockDim); - OP_LOGI(tilingInfo->opName, "SAS block dim: %u aiv Num: %u aic Num: %u.", blockDim, aivNum, aicNum); + OPS_LOG_I(tilingInfo->opName, "SAS block dim: %u aiv Num: %u aic Num: %u.", blockDim, aivNum, aicNum); SplitBalanced(tilingInfo); // -------------set workspacesize----------------- @@ -1633,7 +1633,7 @@ ge::graphStatus SparseAttnSharedkvTiling::DoOpTiling(SASTilingInfo *tilingInfo) // --------------------------Tiling函数定义--------------------------- ge::graphStatus TilingSparseAttnSharedkv(gert::TilingContext *context) { - OP_CHECK_IF(context == nullptr, OPS_REPORT_VECTOR_INNER_ERR("SparseAttnSharedkv", "Tiling context is null."), + OPS_CHECK(context == nullptr, OPS_REPORT_VECTOR_INNER_ERR("SparseAttnSharedkv", "Tiling context is null."), return ge::GRAPH_FAILED); SASTilingInfo sasInfo; SASInfoParser sasInfoParser(context); diff --git a/xllm_ops/attention/sparse_attn_sharedkv/op_host/sparse_attn_sharedkv_tiling.h b/xllm_ops/attention/sparse_attn_sharedkv/op_host/sparse_attn_sharedkv_tiling.h index ecd1e1d..dbec6dd 100644 --- a/xllm_ops/attention/sparse_attn_sharedkv/op_host/sparse_attn_sharedkv_tiling.h +++ b/xllm_ops/attention/sparse_attn_sharedkv/op_host/sparse_attn_sharedkv_tiling.h @@ -21,7 +21,7 @@ #include "register/tilingdata_base.h" #include "register/op_def_registry.h" #include "tiling/tiling_api.h" -#include "log/log.h" +#include "log/ops_log.h" #include "log/error_code.h" #include "err/ops_err.h" #include "platform/platform_info.h" diff --git a/xllm_ops/gamma_add_rms_norm/op_host/gamma_add_rms_norm_error_log.h b/xllm_ops/gamma_add_rms_norm/op_host/gamma_add_rms_norm_error_log.h index 0af748f..7ad10db 100644 --- a/xllm_ops/gamma_add_rms_norm/op_host/gamma_add_rms_norm_error_log.h +++ b/xllm_ops/gamma_add_rms_norm/op_host/gamma_add_rms_norm_error_log.h @@ -4,34 +4,34 @@ #pragma once -#include "log/log.h" +#include "log/ops_log.h" #ifndef OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON #define OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(opname, param, actual, reason) \ - OP_LOGE(opname, "Invalid shape for %s, actual: %s, reason: %s", param, actual, reason) + OPS_LOG_E(opname, "Invalid shape for %s, actual: %s, reason: %s", param, actual, reason) #endif #ifndef OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON #define OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON(opname, param, actual, reason) \ - OP_LOGE(opname, "Invalid shapes for %s, actual: %s, reason: %s", param, actual, reason) + OPS_LOG_E(opname, "Invalid shapes for %s, actual: %s, reason: %s", param, actual, reason) #endif #ifndef OP_LOGE_FOR_INVALID_SHAPEDIM #define OP_LOGE_FOR_INVALID_SHAPEDIM(opname, param, actual, expected) \ - OP_LOGE(opname, "Invalid shape dim for %s, actual: %s, expected: %s", param, actual, expected) + OPS_LOG_E(opname, "Invalid shape dim for %s, actual: %s, expected: %s", param, actual, expected) #endif #ifndef OP_LOGE_FOR_INVALID_SHAPEDIMS_WITH_REASON #define OP_LOGE_FOR_INVALID_SHAPEDIMS_WITH_REASON(opname, param, actual, reason) \ - OP_LOGE(opname, "Invalid shape dims for %s, actual: %s, reason: %s", param, actual, reason) + OPS_LOG_E(opname, "Invalid shape dims for %s, actual: %s, reason: %s", param, actual, reason) #endif #ifndef OP_LOGE_FOR_INVALID_VALUE #define OP_LOGE_FOR_INVALID_VALUE(opname, param, actual, expected) \ - OP_LOGE(opname, "Invalid value for %s, actual: %s, expected: %s", param, actual, expected) + OPS_LOG_E(opname, "Invalid value for %s, actual: %s, expected: %s", param, actual, expected) #endif #ifndef OP_LOGE_FOR_INVALID_VALUE_WITH_REASON #define OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(opname, param, actual, reason) \ - OP_LOGE(opname, "Invalid value for %s, actual: %s, reason: %s", param, actual, reason) + OPS_LOG_E(opname, "Invalid value for %s, actual: %s, reason: %s", param, actual, reason) #endif diff --git a/xllm_ops/gamma_add_rms_norm/op_host/gamma_add_rms_norm_infershape.cpp b/xllm_ops/gamma_add_rms_norm/op_host/gamma_add_rms_norm_infershape.cpp index 6474eed..fb152dc 100644 --- a/xllm_ops/gamma_add_rms_norm/op_host/gamma_add_rms_norm_infershape.cpp +++ b/xllm_ops/gamma_add_rms_norm/op_host/gamma_add_rms_norm_infershape.cpp @@ -13,7 +13,7 @@ * \file gamma_add_rms_norm_infershape.cpp * \brief */ -#include "log/log.h" +#include "log/ops_log.h" #include "util/shape_util.h" #include "register/op_impl_registry.h" @@ -28,20 +28,20 @@ namespace ops { static ge::graphStatus InferShape4GammaAddRmsNorm(gert::InferShapeContext* context) { - OP_LOGD(context, "Begin to do InferShape4GammaAddRmsNorm"); + OPS_LOG_D(context, "Begin to do InferShape4GammaAddRmsNorm"); // get input shapes const gert::Shape* x1Shape = context->GetInputShape(IDX_0); - OP_CHECK_NULL_WITH_CONTEXT(context, x1Shape); + OPS_LOG_E_IF_NULL(context, x1Shape, return ge::GRAPH_FAILED); const gert::Shape* gammaShape = context->GetInputShape(IDX_2); - OP_CHECK_NULL_WITH_CONTEXT(context, gammaShape); + OPS_LOG_E_IF_NULL(context, gammaShape, return ge::GRAPH_FAILED); // get output shapes gert::Shape* yShape = context->GetOutputShape(IDX_0); gert::Shape* rstdShape = context->GetOutputShape(IDX_1); gert::Shape* xShape = context->GetOutputShape(IDX_2); - OP_CHECK_NULL_WITH_CONTEXT(context, yShape); - OP_CHECK_NULL_WITH_CONTEXT(context, rstdShape); - OP_CHECK_NULL_WITH_CONTEXT(context, xShape); + OPS_LOG_E_IF_NULL(context, yShape, return ge::GRAPH_FAILED); + OPS_LOG_E_IF_NULL(context, rstdShape, return ge::GRAPH_FAILED); + OPS_LOG_E_IF_NULL(context, xShape, return ge::GRAPH_FAILED); *yShape = *x1Shape; *xShape = *x1Shape; @@ -50,12 +50,12 @@ static ge::graphStatus InferShape4GammaAddRmsNorm(gert::InferShapeContext* conte if (IsUnknownRank(*x1Shape) || IsUnknownRank(*gammaShape)) { SetUnknownRank(*rstdShape); - OP_LOGD(context, "End to do InferShape4GammaAddRmsNorm with unknown rank."); + OPS_LOG_D(context, "End to do InferShape4GammaAddRmsNorm with unknown rank."); return GRAPH_SUCCESS; } - OP_CHECK_IF( - xDimNum < gammaDimNum, OP_LOGE(context, "x dim num should not be smaller than gamma dim num."), + OPS_CHECK( + xDimNum < gammaDimNum, OPS_LOG_E(context, "x dim num should not be smaller than gamma dim num."), return GRAPH_FAILED); rstdShape->SetDimNum(xDimNum); @@ -67,17 +67,17 @@ static ge::graphStatus InferShape4GammaAddRmsNorm(gert::InferShapeContext* conte } } - OP_LOGD(context, "End to do InferShape4GammaAddRmsNorm"); + OPS_LOG_D(context, "End to do InferShape4GammaAddRmsNorm"); return GRAPH_SUCCESS; } static graphStatus InferDataType4GammaAddRmsNorm(gert::InferDataTypeContext* context) { - OP_LOGD(context, "Begin to do InferDataType4GammaAddRmsNorm"); + OPS_LOG_D(context, "Begin to do InferDataType4GammaAddRmsNorm"); context->SetOutputDataType(IDX_0, context->GetInputDataType(IDX_0)); context->SetOutputDataType(IDX_1, DT_FLOAT); context->SetOutputDataType(IDX_2, context->GetInputDataType(IDX_0)); - OP_LOGD(context, "End to do InferDataType4GammaAddRmsNorm"); + OPS_LOG_D(context, "End to do InferDataType4GammaAddRmsNorm"); return GRAPH_SUCCESS; } diff --git a/xllm_ops/gamma_add_rms_norm/op_host/gamma_add_rms_norm_tiling.cpp b/xllm_ops/gamma_add_rms_norm/op_host/gamma_add_rms_norm_tiling.cpp index 17decc1..784e4a4 100644 --- a/xllm_ops/gamma_add_rms_norm/op_host/gamma_add_rms_norm_tiling.cpp +++ b/xllm_ops/gamma_add_rms_norm/op_host/gamma_add_rms_norm_tiling.cpp @@ -109,12 +109,12 @@ static bool CheckNullptr(const gert::TilingContext* context, uint32_t& normKey) const gert::StorageShape* rstd_shape = context->GetOutputShape(RMS_OUTPUT_RSTD_INDEX); const gert::StorageShape* x_shape = context->GetOutputShape(RMS_OUTPUT_X_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context, x1_shape); - OP_CHECK_NULL_WITH_CONTEXT(context, x2_shape); - OP_CHECK_NULL_WITH_CONTEXT(context, gamma_shape); - OP_CHECK_NULL_WITH_CONTEXT(context, y_shape); - OP_CHECK_NULL_WITH_CONTEXT(context, rstd_shape); - OP_CHECK_NULL_WITH_CONTEXT(context, x_shape); + OPS_LOG_E_IF_NULL(context, x1_shape, return ge::GRAPH_FAILED); + OPS_LOG_E_IF_NULL(context, x2_shape, return ge::GRAPH_FAILED); + OPS_LOG_E_IF_NULL(context, gamma_shape, return ge::GRAPH_FAILED); + OPS_LOG_E_IF_NULL(context, y_shape, return ge::GRAPH_FAILED); + OPS_LOG_E_IF_NULL(context, rstd_shape, return ge::GRAPH_FAILED); + OPS_LOG_E_IF_NULL(context, x_shape, return ge::GRAPH_FAILED); normKey = RMS_NORM_KEY; if (rstd_shape->GetOriginShape().GetShapeSize() <= 0 && x_shape->GetOriginShape().GetShapeSize() <= 0) { @@ -140,18 +140,18 @@ static bool CheckInputOutputDim(const gert::TilingContext* context, uint32_t nor size_t rstdDimNum = rstd_shape->GetStorageShape().GetDimNum(); size_t xDimNum = x_shape->GetStorageShape().GetDimNum(); - OP_CHECK_IF( + OPS_CHECK( x1DimNum > MAX_DIM_NUM || x1DimNum < MIN_DIM_X, OP_LOGE_FOR_INVALID_SHAPEDIM( context->GetNodeName(), "x1", std::to_string(x1DimNum).c_str(), "within the range [1, 8]"), return false); if (normKey == RMS_NORM_KEY) { - OP_CHECK_IF( + OPS_CHECK( gammaDimNum > MAX_DIM_NUM || gammaDimNum < MIN_DIM_GAMMA, OP_LOGE_FOR_INVALID_SHAPEDIM( context->GetNodeName(), "gamma", std::to_string(gammaDimNum).c_str(), "within the range [1, 8]"), return false); - OP_CHECK_IF( + OPS_CHECK( x1DimNum < gammaDimNum, OP_LOGE_FOR_INVALID_SHAPEDIMS_WITH_REASON( context->GetNodeName(), "x1 and gamma", @@ -159,19 +159,19 @@ static bool CheckInputOutputDim(const gert::TilingContext* context, uint32_t nor "The shape dim of x1 should be greater than or equal to the shape dim of gamma"), return false); } else if (normKey == PRE_RMS_NORM || normKey == POST_RMS_NORM) { - OP_CHECK_IF( + OPS_CHECK( gammaDimNum != 2, OP_LOGE_FOR_INVALID_SHAPEDIM(context->GetNodeName(), "gamma", std::to_string(gammaDimNum).c_str(), "2"), return false); } - OP_CHECK_IF( + OPS_CHECK( x1DimNum != yDimNum, OP_LOGE_FOR_INVALID_SHAPEDIMS_WITH_REASON( context->GetNodeName(), "x1 and y", (std::to_string(x1DimNum) + " and " + std::to_string(yDimNum)).c_str(), "The shape dims of x1 and y should be the same"), return false); - OP_CHECK_IF( + OPS_CHECK( x1DimNum != x2DimNum, OP_LOGE_FOR_INVALID_SHAPEDIMS_WITH_REASON( context->GetNodeName(), "x1 and x2", @@ -180,7 +180,7 @@ static bool CheckInputOutputDim(const gert::TilingContext* context, uint32_t nor return false); if (normKey == RMS_NORM_KEY) { - OP_CHECK_IF( + OPS_CHECK( (yDimNum != xDimNum) || (xDimNum != x1DimNum) || (rstdDimNum != x1DimNum), OP_LOGE_FOR_INVALID_SHAPEDIMS_WITH_REASON( context->GetNodeName(), "y, x, rstd and x1", @@ -189,7 +189,7 @@ static bool CheckInputOutputDim(const gert::TilingContext* context, uint32_t nor "The shape dims of y, x, rstd and x1 should be the same"), return false); } else if (normKey == PRE_RMS_NORM) { - OP_CHECK_IF( + OPS_CHECK( (yDimNum != xDimNum) || (xDimNum != x1DimNum), OP_LOGE_FOR_INVALID_SHAPEDIMS_WITH_REASON( context->GetNodeName(), "y, x and x1", @@ -202,7 +202,7 @@ static bool CheckInputOutputDim(const gert::TilingContext* context, uint32_t nor static bool CheckInputOutputShape(const gert::TilingContext* context, uint32_t normKey) { - OP_CHECK_IF(!CheckInputOutputDim(context, normKey), OP_LOGE(context, "Input Dim invalid."), return false); + OPS_CHECK(!CheckInputOutputDim(context, normKey), OPS_LOG_E(context, "Input Dim invalid."), return false); const gert::StorageShape* x1_shape = context->GetInputShape(RMS_INPUT_X1_INDEX); const gert::StorageShape* x2_shape = context->GetInputShape(RMS_INPUT_X2_INDEX); const gert::StorageShape* gamma_shape = context->GetInputShape(RMS_INPUT_GAMMA_INDEX); @@ -214,36 +214,36 @@ static bool CheckInputOutputShape(const gert::TilingContext* context, uint32_t n size_t gammaDimNum = gamma_shape->GetStorageShape().GetDimNum(); for (uint32_t i = 0; i < x1DimNum; i++) { - OP_CHECK_IF( + OPS_CHECK( x1_shape->GetStorageShape().GetDim(i) == 0, OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON( - context->GetNodeName(), "x1", Ops::Base::ToString(x1_shape->GetStorageShape()).c_str(), + context->GetNodeName(), "x1", ops::Shape2String(x1_shape->GetStorageShape()).c_str(), "x1 cannot be an empty tensor"), return false); - OP_CHECK_IF( + OPS_CHECK( x2_shape->GetStorageShape().GetDim(i) != x1_shape->GetStorageShape().GetDim(i), OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON( context->GetNodeName(), "x2 and x1", - (Ops::Base::ToString(x2_shape->GetStorageShape()) + " and " + - Ops::Base::ToString(x1_shape->GetStorageShape())).c_str(), + (ops::Shape2String(x2_shape->GetStorageShape()) + " and " + + ops::Shape2String(x1_shape->GetStorageShape())).c_str(), "The shapes of x2 and x1 should be the same"), return false); - OP_CHECK_IF( + OPS_CHECK( (y_shape->GetStorageShape().GetDim(i) != x1_shape->GetStorageShape().GetDim(i)), OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON( context->GetNodeName(), "y and x1", - (Ops::Base::ToString(y_shape->GetStorageShape()) + " and " + - Ops::Base::ToString(x1_shape->GetStorageShape())).c_str(), + (ops::Shape2String(y_shape->GetStorageShape()) + " and " + + ops::Shape2String(x1_shape->GetStorageShape())).c_str(), "The shapes of y and x1 should be the same"), return false); // x out shape check by mode if (normKey == RMS_NORM_KEY || normKey == PRE_RMS_NORM) { - OP_CHECK_IF( + OPS_CHECK( (x_shape->GetStorageShape().GetDim(i) != x1_shape->GetStorageShape().GetDim(i)), OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON( context->GetNodeName(), "x and x1", - (Ops::Base::ToString(x_shape->GetStorageShape()) + " and " + - Ops::Base::ToString(x1_shape->GetStorageShape())).c_str(), + (ops::Shape2String(x_shape->GetStorageShape()) + " and " + + ops::Shape2String(x1_shape->GetStorageShape())).c_str(), "The shapes of x and x1 should be the same"), return false); } @@ -251,43 +251,43 @@ static bool CheckInputOutputShape(const gert::TilingContext* context, uint32_t n // rstd out shape check by mode if (normKey == RMS_NORM_KEY) { for (uint32_t i = 0; i < x1DimNum - gammaDimNum; i++) { - OP_CHECK_IF( + OPS_CHECK( rstd_shape->GetStorageShape().GetDim(i) != x2_shape->GetStorageShape().GetDim(i), OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON( context->GetNodeName(), "rstd and x1", - (Ops::Base::ToString(rstd_shape->GetStorageShape()) + " and " + - Ops::Base::ToString(x1_shape->GetStorageShape())).c_str(), + (ops::Shape2String(rstd_shape->GetStorageShape()) + " and " + + ops::Shape2String(x1_shape->GetStorageShape())).c_str(), ("The shape of rstd should be the same as the first " + std::to_string(x1DimNum - gammaDimNum) + " dim of x1").c_str()), return false); } for (uint32_t i = 0; i < gammaDimNum; i++) { - OP_CHECK_IF( + OPS_CHECK( gamma_shape->GetStorageShape().GetDim(i) != x1_shape->GetStorageShape().GetDim(x1DimNum - gammaDimNum + i), OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON( context->GetNodeName(), "gamma and x1", - (Ops::Base::ToString(gamma_shape->GetStorageShape()) + " and " + - Ops::Base::ToString(x1_shape->GetStorageShape())).c_str(), + (ops::Shape2String(gamma_shape->GetStorageShape()) + " and " + + ops::Shape2String(x1_shape->GetStorageShape())).c_str(), ("The shape of gamma should be equal to the last " + std::to_string(gammaDimNum) + " dim of x1") .c_str()), return false); - OP_CHECK_IF( + OPS_CHECK( rstd_shape->GetStorageShape().GetDim(x1DimNum - 1 - i) != 1, OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON( context->GetNodeName(), "rstd", - Ops::Base::ToString(rstd_shape->GetStorageShape()).c_str(), + ops::Shape2String(rstd_shape->GetStorageShape()).c_str(), ("The " + std::to_string(x1DimNum - 1 - i) + "th dimension of rstd must be 1").c_str()), return false); } } else if (normKey == PRE_RMS_NORM || normKey == POST_RMS_NORM) { - OP_CHECK_IF( + OPS_CHECK( (gamma_shape->GetStorageShape().GetDim(0) != 1 || gamma_shape->GetStorageShape().GetDim(gammaDimNum - 1) != x1_shape->GetStorageShape().GetDim(x1DimNum - 1)), OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON( context->GetNodeName(), "gamma and x1", - (Ops::Base::ToString(gamma_shape->GetStorageShape()) + " and " + - Ops::Base::ToString(x1_shape->GetStorageShape())).c_str(), + (ops::Shape2String(gamma_shape->GetStorageShape()) + " and " + + ops::Shape2String(x1_shape->GetStorageShape())).c_str(), "The first dim of gamma should be 1 and the last dim of gamma and x1 must be the same"), return false); } @@ -334,9 +334,9 @@ static void CalculateRowAndColParameters( static ge::graphStatus GetEpsilonParameter(gert::TilingContext* context, float& epsilon) { auto attrs = context->GetAttrs(); - OP_CHECK_NULL_WITH_CONTEXT(context, attrs); + OPS_LOG_E_IF_NULL(context, attrs, return ge::GRAPH_FAILED); epsilon = *attrs->GetFloat(0); - OP_CHECK_IF(epsilon < 0, + OPS_CHECK(epsilon < 0, OP_LOGE_FOR_INVALID_VALUE(context->GetNodeName(), "epsilon", std::to_string(epsilon).c_str(), "greater than or equal to zero"), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; @@ -345,9 +345,9 @@ static ge::graphStatus GetEpsilonParameter(gert::TilingContext* context, float& static ge::graphStatus GetAddGammaOffsetParameter(gert::TilingContext* context, uint32_t& addGammaOffset) { auto attrs = context->GetAttrs(); - OP_CHECK_NULL_WITH_CONTEXT(context, attrs); + OPS_LOG_E_IF_NULL(context, attrs, return ge::GRAPH_FAILED); const bool* addGammaOffsetPtr = attrs->GetBool(1); - OP_CHECK_NULL_WITH_CONTEXT(context, addGammaOffsetPtr); + OPS_LOG_E_IF_NULL(context, addGammaOffsetPtr, return ge::GRAPH_FAILED); addGammaOffset = *addGammaOffsetPtr ? 1U : 0U; return ge::GRAPH_SUCCESS; } @@ -467,10 +467,10 @@ static void LogTilingResults( gert::TilingContext* context, GammaAddRMSNormTilingData* tiling, uint32_t mode_key, uint32_t dtype_key, uint32_t use_core_num, float epsilon, uint32_t normKey) { - OP_LOGI(context, "Tiling Key: %u", (dtype_key * TEN + mode_key) + normKey); - OP_LOGI(context, "Block Dim: %u", use_core_num); - OP_LOGI(context, "usr Workspace: 256"); - OP_LOGI( + OPS_LOG_I(context, "Tiling Key: %u", (dtype_key * TEN + mode_key) + normKey); + OPS_LOG_I(context, "Block Dim: %u", use_core_num); + OPS_LOG_I(context, "usr Workspace: 256"); + OPS_LOG_I( context, "num_row: %d, num_col: %d, block_factor: %d, row_factor: %d, ub_factor: %d, epsilon: %f, avg_factor: %f", tiling->get_num_row(), tiling->get_num_col(), tiling->get_block_factor(), tiling->get_row_factor(), @@ -479,11 +479,11 @@ static void LogTilingResults( static ge::graphStatus Tiling4GammaAddRmsNorm(gert::TilingContext* context) { - OP_LOGI("Tiling4GammaAddRmsNorm", "Enter Tiling4GammaAddRmsNorm"); + OPS_LOG_I("Tiling4GammaAddRmsNorm", "Enter Tiling4GammaAddRmsNorm"); uint32_t normKey = RMS_NORM_KEY; - OP_CHECK_IF(!CheckNullptr(context, normKey), OP_LOGE(context, "Input shape invalid (nullptr)."), + OPS_CHECK(!CheckNullptr(context, normKey), OPS_LOG_E(context, "Input shape invalid (nullptr)."), return ge::GRAPH_FAILED); - OP_CHECK_IF(!CheckInputOutputShape(context, normKey), OP_LOGE(context, "Input shape invalid."), + OPS_CHECK(!CheckInputOutputShape(context, normKey), OPS_LOG_E(context, "Input shape invalid."), return ge::GRAPH_FAILED); GammaAddRMSNormTilingData tiling; @@ -544,11 +544,11 @@ static ge::graphStatus Tiling4GammaAddRmsNorm(gert::TilingContext* context) static ge::graphStatus TilingPrepare4GammaAddRmsNorm(gert::TilingParseContext* context) { - OP_LOGI(context, "TilingPrepare4GammaAddRmsNorm running."); + OPS_LOG_I(context, "TilingPrepare4GammaAddRmsNorm running."); auto compileInfo = context->GetCompiledInfo(); - OP_CHECK_NULL_WITH_CONTEXT(context, compileInfo); + OPS_LOG_E_IF_NULL(context, compileInfo, return ge::GRAPH_FAILED); auto platformInfo = context->GetPlatformInfo(); - OP_CHECK_NULL_WITH_CONTEXT(context, platformInfo); + OPS_LOG_E_IF_NULL(context, platformInfo, return ge::GRAPH_FAILED); auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo); compileInfo->socVersion = ascendcPlatform.GetSocVersion(); diff --git a/xllm_ops/gamma_add_rms_norm/op_host/gamma_add_rms_norm_tiling.h b/xllm_ops/gamma_add_rms_norm/op_host/gamma_add_rms_norm_tiling.h index 38bc641..5094f88 100644 --- a/xllm_ops/gamma_add_rms_norm/op_host/gamma_add_rms_norm_tiling.h +++ b/xllm_ops/gamma_add_rms_norm/op_host/gamma_add_rms_norm_tiling.h @@ -12,7 +12,7 @@ #ifndef OPS_BUILT_IN_OP_TILING_RUNTIME_GAMMA_ADD_RMS_NORM_H_ #define OPS_BUILT_IN_OP_TILING_RUNTIME_GAMMA_ADD_RMS_NORM_H_ #include "register/tilingdata_base.h" -#include "log/log.h" +#include "log/ops_log.h" #include "register/op_impl_registry.h" #include "tiling/platform/platform_ascendc.h" #include "platform/platform_infos_def.h" diff --git a/xllm_ops/gamma_add_rms_norm/op_host/gamma_add_rms_norm_tiling_arch35.cpp b/xllm_ops/gamma_add_rms_norm/op_host/gamma_add_rms_norm_tiling_arch35.cpp index ce71867..110b2be 100644 --- a/xllm_ops/gamma_add_rms_norm/op_host/gamma_add_rms_norm_tiling_arch35.cpp +++ b/xllm_ops/gamma_add_rms_norm/op_host/gamma_add_rms_norm_tiling_arch35.cpp @@ -17,7 +17,6 @@ #include "register/op_impl_registry.h" #include "gamma_add_rms_norm_tiling.h" #include "op_common/op_host/util/math_util.h" -#include "op_common/op_host/util/platform_util.h" namespace optiling { namespace gammaAddRmsNormRegbase { @@ -27,6 +26,8 @@ constexpr uint32_t DTYPE_KEY_FP32 = 2; constexpr uint32_t DTYPE_KEY_BF16 = 3; constexpr uint32_t FLOAT_BLOCK_ALIGN_NUM = 8; constexpr uint32_t FLOAT_PER_REAPEAT = 64; +constexpr uint32_t UB_BLOCK_SIZE = 32; +constexpr uint32_t VECTOR_REGISTER_SIZE = 256; constexpr uint32_t BYTE_SIZE_2_BLOCK_ALIGN_NUM = 16; constexpr uint32_t X_INDEX = 0; constexpr uint32_t GAMMA_INDEX = 2; @@ -92,7 +93,7 @@ uint32_t ComputeTotalBufSize(uint32_t bufferNum, ge::DataType dtype, uint32_t dt ge::graphStatus TilingGammaAddRmsNormRegbase(gert::TilingContext* context) { - OP_LOGD(context, " TilingGammaAddRmsNormRegbase"); + OPS_LOG_D(context, " TilingGammaAddRmsNormRegbase"); auto ptrCompileInfo = reinterpret_cast(context->GetCompileInfo()); uint32_t numCore; uint64_t ubSize; @@ -109,13 +110,13 @@ ge::graphStatus TilingGammaAddRmsNormRegbase(gert::TilingContext* context) const gert::Shape gammaShape = context->GetInputShape(GAMMA_INDEX)->GetStorageShape(); std::string opType(context->GetNodeType()); auto attrs = context->GetAttrs(); - OP_CHECK_NULL_WITH_CONTEXT(context, attrs); + OPS_LOG_E_IF_NULL(context, attrs, return ge::GRAPH_FAILED); const float* epsilon = attrs->GetFloat(0); - OP_CHECK_NULL_WITH_CONTEXT(context, epsilon); + OPS_LOG_E_IF_NULL(context, epsilon, return ge::GRAPH_FAILED); const bool* addGammaOffsetPtr = attrs->GetBool(1); - OP_CHECK_NULL_WITH_CONTEXT(context, addGammaOffsetPtr); + OPS_LOG_E_IF_NULL(context, addGammaOffsetPtr, return ge::GRAPH_FAILED); const uint32_t addGammaOffset = *addGammaOffsetPtr ? 1U : 0U; - OP_CHECK_IF( + OPS_CHECK( *epsilon < 0, OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context->GetNodeName(), "epsilon", std::to_string(*epsilon).c_str(), "epsilon should not be less than zero"), @@ -129,10 +130,10 @@ ge::graphStatus TilingGammaAddRmsNormRegbase(gert::TilingContext* context) numRow *= xShape.GetDim(i); } for (size_t i = 0; i < xDimNum; i++) { - OP_LOGD(context, " TilingGammaAddRmsNormRegbase x shape:%ld", xShape.GetDim(i)); + OPS_LOG_D(context, " TilingGammaAddRmsNormRegbase x shape:%ld", xShape.GetDim(i)); } for (size_t i = 0; i < gammaDimNum; i++) { - OP_LOGD(context, " TilingGammaAddRmsNormRegbase gama shape:%ld", gammaShape.GetDim(i)); + OPS_LOG_D(context, " TilingGammaAddRmsNormRegbase gama shape:%ld", gammaShape.GetDim(i)); } auto dataType = context->GetInputDesc(0)->GetDataType(); uint32_t dtypeKey = DTYPE_KEY_FP16; @@ -141,9 +142,9 @@ ge::graphStatus TilingGammaAddRmsNormRegbase(gert::TilingContext* context) size_t* currentWorkspace = context->GetWorkspaceSizes(1); currentWorkspace[0] = usrSize + sysWorkspaceSize; uint64_t numColAlign = 0; - uint64_t ubBlockSize = Ops::Base::GetUbBlockSize(context); + uint64_t ubBlockSize = UB_BLOCK_SIZE; uint64_t ubfp32 = ubBlockSize / sizeof(float); - uint64_t vlfp32 = Ops::Base::GetVRegSize(context) / sizeof(float); + uint64_t vlfp32 = VECTOR_REGISTER_SIZE / sizeof(float); uint64_t binaryAddElemtMaxLen = vlfp32 * vlfp32 * NUM_2 * NUM_2; uint64_t blockFactor; uint64_t ubFactor; @@ -163,8 +164,8 @@ ge::graphStatus TilingGammaAddRmsNormRegbase(gert::TilingContext* context) context->SetBlockDim(useCoreNum); auto dtypeByteIterator = dTypeByteMap.find(dataType); - OP_CHECK_IF( - dtypeByteIterator == dTypeByteMap.end(), OP_LOGE(context, "Fail to get dtype factor."), + OPS_CHECK( + dtypeByteIterator == dTypeByteMap.end(), OPS_LOG_E(context, "Fail to get dtype factor."), return ge::GRAPH_FAILED); uint32_t curElementByte = dtypeByteIterator->second; numColAlign = CeilDiv(numCol * curElementByte, ubBlockSize) * ubBlockSize / curElementByte; @@ -195,7 +196,7 @@ ge::graphStatus TilingGammaAddRmsNormRegbase(gert::TilingContext* context) tiling.set_epsilon(*epsilon); tiling.set_avgFactor(avgFactor); tiling.set_addGammaOffset(addGammaOffset); - OP_LOGI( + OPS_LOG_I( context, "TilingData numCore: %u, ubSize: %lu, numRow: %u, numCol: %u, numColAlign: %u, " "blockFactor: %u, rowFactor: %u, binAddQuotient: %u, " @@ -236,7 +237,7 @@ ge::graphStatus TilingGammaAddRmsNormRegbase(gert::TilingContext* context) tiling.set_multiNNum(multiNNum); tiling.set_isNddma(isNddma); tiling.set_addGammaOffset(addGammaOffset); - OP_LOGI( + OPS_LOG_I( context, "TilingData numCore: %u, ubSize: %lu, numRow: %u, numCol: %u, numColAlign: %u, colBuferLength: %u, " "blockFactor: %u, rowFactor: %u, ubFactor: %u, " diff --git a/xllm_ops/mla_preprocess/op_host/mla_preprocess_proto.cpp b/xllm_ops/mla_preprocess/op_host/mla_preprocess_proto.cpp index c49afd6..b35149f 100644 --- a/xllm_ops/mla_preprocess/op_host/mla_preprocess_proto.cpp +++ b/xllm_ops/mla_preprocess/op_host/mla_preprocess_proto.cpp @@ -14,7 +14,6 @@ */ #include -//#include "log/log.h" using namespace ge; namespace ops { diff --git a/xllm_ops/mla_preprocess_v2/op_host/mla_preprocess_v2_proto.cpp b/xllm_ops/mla_preprocess_v2/op_host/mla_preprocess_v2_proto.cpp index 145e450..0aaa068 100644 --- a/xllm_ops/mla_preprocess_v2/op_host/mla_preprocess_v2_proto.cpp +++ b/xllm_ops/mla_preprocess_v2/op_host/mla_preprocess_v2_proto.cpp @@ -14,7 +14,6 @@ */ #include -//#include "log/log.h" using namespace ge; namespace ops { diff --git a/xllm_ops/mla_preprocess_v2/op_host/mla_preprocess_v2_tiling.cpp b/xllm_ops/mla_preprocess_v2/op_host/mla_preprocess_v2_tiling.cpp index 1523921..caccc7b 100644 --- a/xllm_ops/mla_preprocess_v2/op_host/mla_preprocess_v2_tiling.cpp +++ b/xllm_ops/mla_preprocess_v2/op_host/mla_preprocess_v2_tiling.cpp @@ -16,7 +16,6 @@ #include "../../mla_preprocess/op_host/mla_preprocess_tiling.h" #include "../../mla_preprocess/op_host/mla_preprocess_tilingdata.h" #include "register/op_impl_registry.h" -//#include "log/log.h" #include "../../../common/tiling/tiling_base.h" #include #include diff --git a/xllm_ops/moe/add_rms_norm_bias/op_host/add_rms_norm_bias_infershape.cpp b/xllm_ops/moe/add_rms_norm_bias/op_host/add_rms_norm_bias_infershape.cpp index 8d1fbb8..24168a0 100644 --- a/xllm_ops/moe/add_rms_norm_bias/op_host/add_rms_norm_bias_infershape.cpp +++ b/xllm_ops/moe/add_rms_norm_bias/op_host/add_rms_norm_bias_infershape.cpp @@ -12,7 +12,7 @@ * \file add_rms_norm_bias_infershape.cpp * \brief */ -#include "log/log.h" +#include "log/ops_log.h" #include "util/shape_util.h" #include "register/op_impl_registry.h" @@ -27,20 +27,20 @@ namespace ops { static ge::graphStatus InferShape4AddRmsNormBias(gert::InferShapeContext* context) { - OP_LOGD(context, "Begin to do InferShape4AddRmsNormBias"); + OPS_LOG_D(context, "Begin to do InferShape4AddRmsNormBias"); // get input shapes const gert::Shape* x1Shape = context->GetInputShape(IDX_0); - OP_CHECK_NULL_WITH_CONTEXT(context, x1Shape); + OPS_LOG_E_IF_NULL(context, x1Shape, return ge::GRAPH_FAILED); const gert::Shape* gammaShape = context->GetInputShape(IDX_2); - OP_CHECK_NULL_WITH_CONTEXT(context, gammaShape); + OPS_LOG_E_IF_NULL(context, gammaShape, return ge::GRAPH_FAILED); // get output shapes gert::Shape* yShape = context->GetOutputShape(IDX_0); gert::Shape* rstdShape = context->GetOutputShape(IDX_1); gert::Shape* xShape = context->GetOutputShape(IDX_2); - OP_CHECK_NULL_WITH_CONTEXT(context, yShape); - OP_CHECK_NULL_WITH_CONTEXT(context, rstdShape); - OP_CHECK_NULL_WITH_CONTEXT(context, xShape); + OPS_LOG_E_IF_NULL(context, yShape, return ge::GRAPH_FAILED); + OPS_LOG_E_IF_NULL(context, rstdShape, return ge::GRAPH_FAILED); + OPS_LOG_E_IF_NULL(context, xShape, return ge::GRAPH_FAILED); *yShape = *x1Shape; *xShape = *x1Shape; @@ -49,12 +49,12 @@ static ge::graphStatus InferShape4AddRmsNormBias(gert::InferShapeContext* contex if (IsUnknownRank(*x1Shape) || IsUnknownRank(*gammaShape)) { SetUnknownRank(*rstdShape); - OP_LOGD(context, "End to do InferShape4AddRmsNormBias with unknown rank."); + OPS_LOG_D(context, "End to do InferShape4AddRmsNormBias with unknown rank."); return GRAPH_SUCCESS; } - OP_CHECK_IF( - xDimNum < gammaDimNum, OP_LOGE(context, "x dim num should not be smaller than gamma dim num."), + OPS_CHECK( + xDimNum < gammaDimNum, OPS_LOG_E(context, "x dim num should not be smaller than gamma dim num."), return GRAPH_FAILED); rstdShape->SetDimNum(xDimNum); @@ -66,17 +66,17 @@ static ge::graphStatus InferShape4AddRmsNormBias(gert::InferShapeContext* contex } } - OP_LOGD(context, "End to do InferShape4AddRmsNormBias"); + OPS_LOG_D(context, "End to do InferShape4AddRmsNormBias"); return GRAPH_SUCCESS; } static graphStatus InferDataType4AddRmsNormBias(gert::InferDataTypeContext* context) { - OP_LOGD(context, "Begin to do InferDataType4AddRmsNormBias"); + OPS_LOG_D(context, "Begin to do InferDataType4AddRmsNormBias"); context->SetOutputDataType(IDX_0, context->GetInputDataType(IDX_0)); context->SetOutputDataType(IDX_1, DT_FLOAT); context->SetOutputDataType(IDX_2, context->GetInputDataType(IDX_0)); - OP_LOGD(context, "End to do InferDataType4AddRmsNormBias"); + OPS_LOG_D(context, "End to do InferDataType4AddRmsNormBias"); return GRAPH_SUCCESS; } diff --git a/xllm_ops/moe/dequant_swiglu_quant/op_host/dequant_swiglu_quant_infershape.cpp b/xllm_ops/moe/dequant_swiglu_quant/op_host/dequant_swiglu_quant_infershape.cpp index da1c080..5b01f30 100644 --- a/xllm_ops/moe/dequant_swiglu_quant/op_host/dequant_swiglu_quant_infershape.cpp +++ b/xllm_ops/moe/dequant_swiglu_quant/op_host/dequant_swiglu_quant_infershape.cpp @@ -15,7 +15,7 @@ #include "register/op_impl_registry.h" #include "graph/utils/type_utils.h" #include "util/shape_util.h" -#include "log/log.h" +#include "log/ops_log.h" #include "util/math_util.h" using namespace ge; @@ -32,61 +32,61 @@ static const std::initializer_list Y_SUPPORT_DTYPE_SET = {ge::DT_F ge::DT_INT8, ge::DT_HIFLOAT8}; graphStatus InferShape4DequantSwigluQuant(gert::InferShapeContext* context) { - OP_LOGD(context, "Begin to do InferShape4DequantSwigluQuant."); + OPS_LOG_D(context, "Begin to do InferShape4DequantSwigluQuant."); const gert::Shape* xShape = context->GetInputShape(INPUT_IDX_X); - OP_CHECK_NULL_WITH_CONTEXT(context, xShape); + OPS_LOG_E_IF_NULL(context, xShape, return ge::GRAPH_FAILED); gert::Shape* yShape = context->GetOutputShape(OUTPUT_IDX_Y); - OP_CHECK_NULL_WITH_CONTEXT(context, yShape); + OPS_LOG_E_IF_NULL(context, yShape, return ge::GRAPH_FAILED); gert::Shape* scaleShape = context->GetOutputShape(OUTPUT_IDX_SCALE); - OP_CHECK_NULL_WITH_CONTEXT(context, scaleShape); + OPS_LOG_E_IF_NULL(context, scaleShape, return ge::GRAPH_FAILED); *yShape = *xShape; - OP_CHECK_IF(Ops::Base::IsUnknownRank(*xShape), - OP_LOGD(context, "End to do InferShape4DequantSwigluQuant, inputx is [-2]."), + OPS_CHECK(Ops::Base::IsUnknownRank(*xShape), + OPS_LOG_D(context, "End to do InferShape4DequantSwigluQuant, inputx is [-2]."), return GRAPH_SUCCESS); auto attrsPtr = context->GetAttrs(); - OP_CHECK_NULL_WITH_CONTEXT(context, attrsPtr); + OPS_LOG_E_IF_NULL(context, attrsPtr, return ge::GRAPH_FAILED); const int64_t *activateDim = attrsPtr->GetAttrPointer(INDEX_ATTR_ACTIVATE_DIM); const int64_t activateDimNum = (activateDim == nullptr) ? -1 : *activateDim; // 将切分轴转换为正数 int64_t xShapeRank = static_cast(xShape->GetDimNum()); int64_t selectDim = (activateDimNum >= 0) ? activateDimNum : (activateDimNum + xShapeRank); - OP_CHECK_IF(selectDim >= xShapeRank, - OP_LOGE(context, "activateDim must < xShapeRank, but is %ld, xShapeRank is %ld", selectDim, xShapeRank), + OPS_CHECK(selectDim >= xShapeRank, + OPS_LOG_E(context, "activateDim must < xShapeRank, but is %ld, xShapeRank is %ld", selectDim, xShapeRank), return ge::GRAPH_FAILED); int64_t activateShape = xShape->GetDim(selectDim); int64_t outActivateShape = activateShape == CONST_UNKNOW_SHAPE ? CONST_UNKNOW_SHAPE : activateShape / NUM_TWO; - OP_CHECK_IF((activateShape != CONST_UNKNOW_SHAPE) && (activateShape % NUM_TWO != 0), - OP_LOGE(context, "The active axis must be an even number, but is %ld", activateShape), + OPS_CHECK((activateShape != CONST_UNKNOW_SHAPE) && (activateShape % NUM_TWO != 0), + OPS_LOG_E(context, "The active axis must be an even number, but is %ld", activateShape), return ge::GRAPH_FAILED); // 设置Y的shape yShape->SetDim(selectDim, outActivateShape); // 设置Scale的shape *scaleShape = *yShape; scaleShape->SetDimNum(xShapeRank - 1); - OP_LOGD(context, "End to do InferShape4DequantSwigluQuant"); + OPS_LOG_D(context, "End to do InferShape4DequantSwigluQuant"); return ge::GRAPH_SUCCESS; } graphStatus InferDtype4DequantSwigluQuant(gert::InferDataTypeContext* context) { - OP_LOGD(context, "InferDtype4DequantSwigluQuant enter"); + OPS_LOG_D(context, "InferDtype4DequantSwigluQuant enter"); auto attrsPtr = context->GetAttrs(); - OP_CHECK_NULL_WITH_CONTEXT(context, attrsPtr); + OPS_LOG_E_IF_NULL(context, attrsPtr, return ge::GRAPH_FAILED); const int64_t *dstDtype = attrsPtr->GetAttrPointer(INDEX_ATTR_DST_TYPE); const int64_t dstDtypeNum = (dstDtype == nullptr) ? NUM_TWO : *dstDtype; ge::DataType outDtype = static_cast(dstDtypeNum); - OP_CHECK_IF(std::find(Y_SUPPORT_DTYPE_SET.begin(), Y_SUPPORT_DTYPE_SET.end(), outDtype) == Y_SUPPORT_DTYPE_SET.end(), - OP_LOGE(context, "dst_type is illegal, only supports 2(INT8) 40(FLOAT4_E2M1), 41(FLOAT4_E1M2), 35(FLOAT8E5M2), 36(FLOAT8E4M3), 34(HiFloat8)"), + OPS_CHECK(std::find(Y_SUPPORT_DTYPE_SET.begin(), Y_SUPPORT_DTYPE_SET.end(), outDtype) == Y_SUPPORT_DTYPE_SET.end(), + OPS_LOG_E(context, "dst_type is illegal, only supports 2(INT8) 40(FLOAT4_E2M1), 41(FLOAT4_E1M2), 35(FLOAT8E5M2), 36(FLOAT8E4M3), 34(HiFloat8)"), return ge::GRAPH_FAILED); context->SetOutputDataType(OUTPUT_IDX_Y, outDtype); context->SetOutputDataType(OUTPUT_IDX_SCALE, DT_FLOAT); - OP_LOGD(context, "InferDtype4DequantSwigluQuant end"); + OPS_LOG_D(context, "InferDtype4DequantSwigluQuant end"); return GRAPH_SUCCESS; } diff --git a/xllm_ops/moe/dequant_swiglu_quant/op_host/dequant_swiglu_quant_tiling.cpp b/xllm_ops/moe/dequant_swiglu_quant/op_host/dequant_swiglu_quant_tiling.cpp index f3086e7..3f1e214 100644 --- a/xllm_ops/moe/dequant_swiglu_quant/op_host/dequant_swiglu_quant_tiling.cpp +++ b/xllm_ops/moe/dequant_swiglu_quant/op_host/dequant_swiglu_quant_tiling.cpp @@ -96,7 +96,7 @@ ge::graphStatus DequantSwigluQuantDskTiling::GetPlatformInfo() { auto platformInfo = context_->GetPlatformInfo(); if (platformInfo == nullptr) { auto compileInfoPtr = context_->GetCompileInfo(); - OP_CHECK_IF(compileInfoPtr == nullptr, OP_LOGE(context_, "compile info is null"), + OPS_CHECK(compileInfoPtr == nullptr, OPS_LOG_E(context_, "compile info is null"), return ge::GRAPH_FAILED); coreNum_ = compileInfoPtr->coreNum; ubSize_ = compileInfoPtr->ubSize; @@ -115,19 +115,19 @@ ge::graphStatus DequantSwigluQuantDskTiling::GetPlatformInfo() { ge::graphStatus DequantSwigluQuantDskTiling::CheckXAndGroupIndexDtype() { auto xPtr = context_->GetInputDesc(X_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, xPtr); + OPS_LOG_E_IF_NULL(context_, xPtr, return ge::GRAPH_FAILED); auto xDtype = xPtr->GetDataType(); - OP_CHECK_IF((SUPPORT_DTYPE.find(xDtype) == SUPPORT_DTYPE.end()), + OPS_CHECK((SUPPORT_DTYPE.find(xDtype) == SUPPORT_DTYPE.end()), OP_LOGE_FOR_INVALID_DTYPE(context_->GetNodeName(), "x", ge::TypeUtils::DataTypeToSerialString(xDtype).c_str(), "int32 or bfloat16"), return ge::GRAPH_FAILED); tilingData_.set_groupIndexDtype(-1); if (hasGroupIndex_) { auto groupIndexPtr = context_->GetOptionalInputDesc(INPUT_GROUP_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, groupIndexPtr); + OPS_LOG_E_IF_NULL(context_, groupIndexPtr, return ge::GRAPH_FAILED); auto groupIndexDtype = groupIndexPtr->GetDataType(); bool dtypeInValid = groupIndexDtype != ge::DT_INT64; - OP_CHECK_IF( + OPS_CHECK( dtypeInValid, OP_LOGE_FOR_INVALID_DTYPE(context_->GetNodeName(), "group_index", ge::TypeUtils::DataTypeToSerialString(groupIndexDtype).c_str(), "int64"), @@ -141,8 +141,8 @@ ge::graphStatus DequantSwigluQuantDskTiling::CheckBias() { auto biasShapePtr = context_->GetOptionalInputShape(BIAS_INDEX); if (biasShapePtr != nullptr) { hasBias_ = true; - OP_CHECK_IF(CheckScaleShapeWithDim(BIAS_INDEX, inDimy_, "bias") != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "bias shape check failed."), + OPS_CHECK(CheckScaleShapeWithDim(BIAS_INDEX, inDimy_, "bias") != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "bias shape check failed."), return ge::GRAPH_FAILED); } else { @@ -153,7 +153,7 @@ ge::graphStatus DequantSwigluQuantDskTiling::CheckBias() { if (biasPtr != nullptr && hasBias_ == true) { auto biasDtype = biasPtr->GetDataType(); bool dtypeInValid = (biasDtype != ge::DT_INT32 && biasDtype != ge::DT_FLOAT && biasDtype != ge::DT_FLOAT16 && biasDtype != ge::DT_BF16); - OP_CHECK_IF( + OPS_CHECK( dtypeInValid, OP_LOGE_FOR_INVALID_DTYPE(context_->GetNodeName(), "bias", ge::TypeUtils::DataTypeToSerialString(biasDtype).c_str(), "bf16, fp16, float or int32"), @@ -177,15 +177,15 @@ ge::graphStatus DequantSwigluQuantDskTiling::CheckBias() { ge::graphStatus DequantSwigluQuantDskTiling::CheckWeightScale() { auto weightScalePtr = context_->GetOptionalInputDesc(WEIGHT_SCALE_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, weightScalePtr); + OPS_LOG_E_IF_NULL(context_, weightScalePtr, return ge::GRAPH_FAILED); auto weightScaleDtype = weightScalePtr->GetDataType(); bool dtypeInValid = weightScaleDtype != ge::DT_FLOAT; - OP_CHECK_IF(dtypeInValid, + OPS_CHECK(dtypeInValid, OP_LOGE_FOR_INVALID_DTYPE(context_->GetNodeName(), "weight_scale", ge::TypeUtils::DataTypeToSerialString(weightScaleDtype).c_str(), "float32"), return ge::GRAPH_FAILED); - OP_CHECK_IF(CheckScaleShapeWithDim(WEIGHT_SCALE_INDEX, inDimy_, "weight_scale") != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "weight scale shape check failed."), + OPS_CHECK(CheckScaleShapeWithDim(WEIGHT_SCALE_INDEX, inDimy_, "weight_scale") != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "weight scale shape check failed."), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; @@ -195,21 +195,21 @@ ge::graphStatus DequantSwigluQuantDskTiling::CheckActivationScale() { auto activationScaleShapePtr = context_->GetOptionalInputShape(ACTIVATION_SCALE_INDEX); if(CheckOptionalShapeExisting(activationScaleShapePtr)) { auto activationScalePtr = context_->GetOptionalInputDesc(ACTIVATION_SCALE_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, activationScalePtr); + OPS_LOG_E_IF_NULL(context_, activationScalePtr, return ge::GRAPH_FAILED); auto activationScaleDtype = activationScalePtr->GetDataType(); bool dtypeInValid = activationScaleDtype != ge::DT_FLOAT; - OP_CHECK_IF(dtypeInValid, + OPS_CHECK(dtypeInValid, OP_LOGE_FOR_INVALID_DTYPE(context_->GetNodeName(), "activation_scale", ge::TypeUtils::DataTypeToSerialString(activationScaleDtype).c_str(), "float32"), return ge::GRAPH_FAILED); - OP_CHECK_NULL_WITH_CONTEXT(context_, activationScaleShapePtr); + OPS_LOG_E_IF_NULL(context_, activationScaleShapePtr, return ge::GRAPH_FAILED); auto activationScaleShape = activationScaleShapePtr->GetStorageShape(); int64_t activationScaleNum = activationScaleShape.GetShapeSize(); - OP_CHECK_IF( + OPS_CHECK( activationScaleNum != inDimx_, - OP_LOGE( + OPS_LOG_E( context_->GetNodeName(), "activation_scale num(%ld) must be equal to the tokens num(%ld), please check.", activationScaleNum, inDimx_), @@ -226,25 +226,25 @@ ge::graphStatus DequantSwigluQuantDskTiling::CheckActivationScale() { ge::graphStatus DequantSwigluQuantDskTiling::CheckForDequant() { // check weight scale, activation scale and bias auto xPtr = context_->GetInputDesc(X_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, xPtr); + OPS_LOG_E_IF_NULL(context_, xPtr, return ge::GRAPH_FAILED); auto xDtype = xPtr->GetDataType(); if (xDtype == ge::DT_INT32) { - OP_CHECK_IF(CheckWeightScale() != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "weight scale check failed."), + OPS_CHECK(CheckWeightScale() != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "weight scale check failed."), return ge::GRAPH_FAILED); - OP_CHECK_IF(CheckActivationScale() != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "activation scale check failed."), + OPS_CHECK(CheckActivationScale() != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "activation scale check failed."), return ge::GRAPH_FAILED); - OP_CHECK_IF(CheckBias() != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "bias check failed."), + OPS_CHECK(CheckBias() != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "bias check failed."), return ge::GRAPH_FAILED); } if (xDtype == ge::DT_BF16 && hasGroupIndex_) { auto shapeGroupIndex = context_->GetOptionalInputShape(INPUT_GROUP_INDEX); const gert::Shape& inputShapeGroupIndex = shapeGroupIndex->GetStorageShape(); - OP_CHECK_IF(inputShapeGroupIndex.GetDimNum() != 1, - OP_LOGE(context_->GetNodeName(), + OPS_CHECK(inputShapeGroupIndex.GetDimNum() != 1, + OPS_LOG_E(context_->GetNodeName(), "groupIndex only support 1D Tensor now, please check."), return ge::GRAPH_FAILED); } @@ -253,13 +253,13 @@ ge::graphStatus DequantSwigluQuantDskTiling::CheckForDequant() { ge::graphStatus DequantSwigluQuantDskTiling::CheckForDynamicQuant() { auto offsetPtr = context_->GetOptionalInputShape(QUANT_OFFSET_INDEX); - OP_CHECK_IF(offsetPtr != nullptr, - OP_LOGE(context_->GetNodeName(), + OPS_CHECK(offsetPtr != nullptr, + OPS_LOG_E(context_->GetNodeName(), "quantOffSet only support None in dynamic quantization of group mode now, please check."), return ge::GRAPH_FAILED); - OP_CHECK_IF(CheckScaleShapeWithDim(QUANT_SCALE_INDEX, outDimy_, "quant_scale") != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "quant scale shape check failed."), + OPS_CHECK(CheckScaleShapeWithDim(QUANT_SCALE_INDEX, outDimy_, "quant_scale") != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "quant scale shape check failed."), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; } @@ -267,12 +267,12 @@ ge::graphStatus DequantSwigluQuantDskTiling::CheckForDynamicQuant() { ge::graphStatus DequantSwigluQuantDskTiling::CheckForStaticQuant() { // check quantOffset dtype auto quantOffsetDescPtr = context_->GetOptionalInputDesc(QUANT_OFFSET_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, quantOffsetDescPtr); + OPS_LOG_E_IF_NULL(context_, quantOffsetDescPtr, return ge::GRAPH_FAILED); auto quantScaleDescPtr = context_->GetOptionalInputDesc(QUANT_SCALE_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, quantScaleDescPtr); + OPS_LOG_E_IF_NULL(context_, quantScaleDescPtr, return ge::GRAPH_FAILED); auto quantOffsetDtype = quantOffsetDescPtr->GetDataType(); auto quantScaleDtype = quantScaleDescPtr->GetDataType(); - OP_CHECK_IF(quantOffsetDtype != quantScaleDtype, + OPS_CHECK(quantOffsetDtype != quantScaleDtype, OP_LOGE_FOR_INVALID_DTYPES_WITH_REASON( context_->GetNodeName(), "quant_offset and quant_scale", (ge::TypeUtils::DataTypeToSerialString(quantOffsetDtype) + " and " + @@ -282,15 +282,15 @@ ge::graphStatus DequantSwigluQuantDskTiling::CheckForStaticQuant() { int64_t quantScaleColLen = 0; int64_t quantOffsetColLen = 0; - OP_CHECK_IF(CheckStaticQuantShape(QUANT_SCALE_INDEX, quantScaleColLen, "quant_scale") != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "quant scale shape check failed."), + OPS_CHECK(CheckStaticQuantShape(QUANT_SCALE_INDEX, quantScaleColLen, "quant_scale") != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "quant scale shape check failed."), return ge::GRAPH_FAILED); - OP_CHECK_IF(CheckStaticQuantShape(QUANT_OFFSET_INDEX, quantOffsetColLen, "quant_offset") != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "quant offset shape check failed."), + OPS_CHECK(CheckStaticQuantShape(QUANT_OFFSET_INDEX, quantOffsetColLen, "quant_offset") != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "quant offset shape check failed."), return ge::GRAPH_FAILED); - OP_CHECK_IF(quantScaleColLen != quantOffsetColLen, - OP_LOGE(context_->GetNodeName(), "quant offset shape is different from quant scale."), + OPS_CHECK(quantScaleColLen != quantOffsetColLen, + OPS_LOG_E(context_->GetNodeName(), "quant offset shape is different from quant scale."), return ge::GRAPH_FAILED); if(quantScaleColLen == 1){ tilingData_.set_quantIsOne(1); @@ -304,20 +304,20 @@ ge::graphStatus DequantSwigluQuantDskTiling::CheckForStaticQuant() { ge::graphStatus DequantSwigluQuantDskTiling::CheckForQuant() { // check and set quant scale dtype - OP_CHECK_IF(CheckQuantScaleDtype() != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "Check QuantScale Dtype failed."), + OPS_CHECK(CheckQuantScaleDtype() != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "Check QuantScale Dtype failed."), return ge::GRAPH_FAILED); // check quant offset and quant scale shape in dynamic scenario if(quantMode_ == QUANT_MODE_DYNAMIC){ - OP_CHECK_IF(CheckForDynamicQuant() != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "Check For Dynamic Quant failed."), + OPS_CHECK(CheckForDynamicQuant() != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "Check For Dynamic Quant failed."), return ge::GRAPH_FAILED); } // // check quant offset and quant scale shape in static scenario else { - OP_CHECK_IF(CheckForStaticQuant() != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "Check For Static Quant failed."), + OPS_CHECK(CheckForStaticQuant() != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "Check For Static Quant failed."), return ge::GRAPH_FAILED); } @@ -333,12 +333,12 @@ ge::graphStatus DequantSwigluQuantDskTiling::CheckQuantScaleDtype() { tilingData_.set_needSmoothScale(0); } else { auto quantScalePtr = context_->GetOptionalInputDesc(QUANT_SCALE_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, quantScalePtr); + OPS_LOG_E_IF_NULL(context_, quantScalePtr, return ge::GRAPH_FAILED); tilingData_.set_needSmoothScale(1); auto quantScaleDtype = quantScalePtr->GetDataType(); dtypeInValid = quantScaleDtype != ge::DT_FLOAT && quantScaleDtype != ge::DT_FLOAT16 && quantScaleDtype != ge::DT_BF16; - OP_CHECK_IF( + OPS_CHECK( dtypeInValid, OP_LOGE_FOR_INVALID_DTYPE(context_->GetNodeName(), "quant_scale", ge::TypeUtils::DataTypeToSerialString(quantScaleDtype).c_str(), "float32, float16 or bfloat16"), @@ -356,13 +356,13 @@ ge::graphStatus DequantSwigluQuantDskTiling::CheckQuantScaleDtype() { ge::graphStatus DequantSwigluQuantDskTiling::GetAttr() { auto* attrs = context_->GetAttrs(); - OP_CHECK_NULL_WITH_CONTEXT(context_, attrs); + OPS_LOG_E_IF_NULL(context_, attrs, return ge::GRAPH_FAILED); auto* attrActivateLeft = attrs->GetAttrPointer(ATTR_ACTIVATE_LEFT_INDEX); actRight_ = (attrActivateLeft == nullptr || *attrActivateLeft == false) ? 1 : 0; std::string quantMode = attrs->GetAttrPointer(ATTR_QUANT_MODE_INDEX); auto it = SUPPORT_QUANT_MODE.find(quantMode); - OP_CHECK_IF(it == SUPPORT_QUANT_MODE.end(), + OPS_CHECK(it == SUPPORT_QUANT_MODE.end(), OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( context_->GetNodeName(), "quant_mode", quantMode.c_str(), "quant_mode only support dynamic(1) and static(0) currently"), @@ -379,12 +379,12 @@ ge::graphStatus DequantSwigluQuantDskTiling::GetAttr() { gluAlpha_ = gluAlpha == nullptr ? GLU_ALPHA_DEFAULT : *gluAlpha; gluBias_ = gluBias == nullptr ? GLU_BIAS_DEFAULT : *gluBias; - OP_CHECK_IF(swigluMode_ != 0 && swigluMode_ != 1, + OPS_CHECK(swigluMode_ != 0 && swigluMode_ != 1, OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( context_->GetNodeName(), "swigluMode", std::to_string(swigluMode_).c_str(), "swigluMode only support 0 or 1"), return ge::GRAPH_FAILED); - OP_CHECK_IF(!(clampLimit_ >= 0.0), + OPS_CHECK(!(clampLimit_ >= 0.0), OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( context_->GetNodeName(), "clamp_limit", std::to_string(clampLimit_).c_str(), "clamp_limit should be non-negative"), @@ -401,41 +401,41 @@ ge::graphStatus DequantSwigluQuantDskTiling::CheckScaleShapeWithDim(const int64_ return ge::GRAPH_SUCCESS; } auto scaleShape = scalePtr->GetStorageShape(); - OP_CHECK_IF(scaleShape.GetDimNum() < 1, + OPS_CHECK(scaleShape.GetDimNum() < 1, OP_LOGE_FOR_INVALID_SHAPEDIM(context_->GetNodeName(), paramName, std::to_string(scaleShape.GetDimNum()).c_str(), "greater than or equal to 1"), return ge::GRAPH_FAILED); - OP_CHECK_IF(scaleShape.GetDim(scaleShape.GetDimNum() - 1) != expectDim, + OPS_CHECK(scaleShape.GetDim(scaleShape.GetDimNum() - 1) != expectDim, OP_LOGE_FOR_INVALID_SHAPE(context_->GetNodeName(), paramName, - Ops::Base::ToString(scaleShape).c_str(), + ops::Shape2String(scaleShape).c_str(), std::to_string(expectDim).c_str()), return ge::GRAPH_FAILED); if (groupNum_ > 1) { // check with group index - OP_CHECK_IF( + OPS_CHECK( scaleShape.GetDimNum() != DIM_SIZE_2, OP_LOGE_FOR_INVALID_SHAPEDIM(context_->GetNodeName(), paramName, std::to_string(scaleShape.GetDimNum()).c_str(), "2D"), return ge::GRAPH_FAILED); - OP_CHECK_IF( + OPS_CHECK( scaleShape.GetDim(0) != groupNum_, OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON( - context_->GetNodeName(), paramName, Ops::Base::ToString(scaleShape).c_str(), + context_->GetNodeName(), paramName, ops::Shape2String(scaleShape).c_str(), ("the first dimension of " + std::string(paramName) + " (" + std::to_string(scaleShape.GetDim(0)) + ") must be equal to the first dimension of group_index (" + std::to_string(groupNum_) + ")") .c_str()), return ge::GRAPH_FAILED); } else { - OP_CHECK_IF( + OPS_CHECK( scaleShape.GetDimNum() > DIM_SIZE_2, OP_LOGE_FOR_INVALID_SHAPEDIM(context_->GetNodeName(), paramName, std::to_string(scaleShape.GetDimNum()).c_str(), "less than or equal to 2"), return ge::GRAPH_FAILED); int64_t groupNumFromScale = scaleShape.GetDimNum() <= 1 ? 1 : scaleShape.GetDim(0); - OP_CHECK_IF( + OPS_CHECK( groupNumFromScale != 1, OP_LOGE_FOR_INVALID_SHAPE(context_->GetNodeName(), paramName, - Ops::Base::ToString(scaleShape).c_str(), + ops::Shape2String(scaleShape).c_str(), ("[1," + std::to_string(expectDim) + "] or [" + std::to_string(expectDim) + "]").c_str()), return ge::GRAPH_FAILED); } @@ -449,24 +449,24 @@ ge::graphStatus DequantSwigluQuantDskTiling::CheckStaticQuantShape(const int64_t return ge::GRAPH_SUCCESS; } auto quantShape = quantPtr->GetStorageShape(); - OP_CHECK_IF(quantShape.GetDimNum() < 1, + OPS_CHECK(quantShape.GetDimNum() < 1, OP_LOGE_FOR_INVALID_SHAPEDIM(context_->GetNodeName(), paramName, std::to_string(quantShape.GetDimNum()).c_str(), "greater than or equal to 1"), return ge::GRAPH_FAILED); colLen = quantShape.GetDim(quantShape.GetDimNum() - 1); if(quantShape.GetDimNum() == 1){ - OP_CHECK_IF(colLen != groupNum_, + OPS_CHECK(colLen != groupNum_, OP_LOGE_FOR_INVALID_SHAPE(context_->GetNodeName(), paramName, - Ops::Base::ToString(quantShape).c_str(), + ops::Shape2String(quantShape).c_str(), ("[" + std::to_string(groupNum_) + ", ] or [" + std::to_string(groupNum_) + ", " + std::to_string(outDimy_) + "]").c_str()), return ge::GRAPH_FAILED); colLen = 1; } else { - OP_CHECK_IF(colLen != outDimy_ || quantShape.GetDim(0) != groupNum_, + OPS_CHECK(colLen != outDimy_ || quantShape.GetDim(0) != groupNum_, OP_LOGE_FOR_INVALID_SHAPE(context_->GetNodeName(), paramName, - Ops::Base::ToString(quantShape).c_str(), + ops::Shape2String(quantShape).c_str(), ("[" + std::to_string(groupNum_) + ", ] or [" + std::to_string(groupNum_) + ", " + std::to_string(outDimy_) + "]").c_str()), return ge::GRAPH_FAILED); @@ -482,15 +482,15 @@ ge::graphStatus DequantSwigluQuantDskTiling::GetShapeAttrsInfo() { ge::graphStatus DequantSwigluQuantDskTiling::CheckIllegalParam() { // if hasbias, speGroupType_ must be false if (hasBias_) { - OP_CHECK_IF(speGroupType_ == true, - OP_LOGE(context_->GetNodeName(), "speGroupType_ only support false when using bias"), + OPS_CHECK(speGroupType_ == true, + OPS_LOG_E(context_->GetNodeName(), "speGroupType_ only support false when using bias"), return ge::GRAPH_FAILED); } // if swigluMode is 1, speGroupType_ must be false if (swigluMode_) { - OP_CHECK_IF(speGroupType_ == true, - OP_LOGE(context_->GetNodeName(), "speGroupType_ only support false when swiglu mode is 1"), + OPS_CHECK(speGroupType_ == true, + OPS_LOG_E(context_->GetNodeName(), "speGroupType_ only support false when swiglu mode is 1"), return ge::GRAPH_FAILED); } return ge::GRAPH_SUCCESS; @@ -502,17 +502,17 @@ ge::graphStatus DequantSwigluQuantDskTiling::GetShapeAttrsInfoInner() { } // get 2H from x, get H from y, check if 2H can be divided by 64 auto shapeX = context_->GetInputShape(0); - OP_CHECK_NULL_WITH_CONTEXT(context_, shapeX); + OPS_LOG_E_IF_NULL(context_, shapeX, return ge::GRAPH_FAILED); const gert::Shape& inputShapeX = shapeX->GetStorageShape(); int64_t inputShapeXTotalNum = inputShapeX.GetShapeSize(); int64_t inputShapeXRank = inputShapeX.GetDimNum(); inDimy_ = inputShapeX.GetDim(inputShapeXRank - 1); inDimx_ = inputShapeXTotalNum / inDimy_; auto shapeY = context_->GetOutputShape(0); - OP_CHECK_NULL_WITH_CONTEXT(context_, shapeY); + OPS_LOG_E_IF_NULL(context_, shapeY, return ge::GRAPH_FAILED); const gert::Shape& outputShapeY = shapeY->GetStorageShape(); outDimy_ = outputShapeY.GetDim(inputShapeXRank - 1); - OP_CHECK_IF(inDimy_ % (BLOCK_SIZE * SWI_FACTOR) != 0, + OPS_CHECK(inDimy_ % (BLOCK_SIZE * SWI_FACTOR) != 0, OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(context_->GetNodeName(), "x", std::to_string(inDimy_).c_str(), "lastdimSize of x must be divisible by 64"), @@ -529,24 +529,24 @@ ge::graphStatus DequantSwigluQuantDskTiling::GetShapeAttrsInfoInner() { speGroupType_ = inputShapeGroupIndex.GetDimNum() == DIM_SIZE_2; } - OP_CHECK_IF(CheckXAndGroupIndexDtype() != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "dtype check failed."), + OPS_CHECK(CheckXAndGroupIndexDtype() != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "dtype check failed."), return ge::GRAPH_FAILED); - OP_CHECK_IF(GetAttr() != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "get attr failed."), + OPS_CHECK(GetAttr() != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "get attr failed."), return ge::GRAPH_FAILED); - OP_CHECK_IF(CheckForDequant() != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "check for dequant failed."), + OPS_CHECK(CheckForDequant() != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "check for dequant failed."), return ge::GRAPH_FAILED); - OP_CHECK_IF(CheckForQuant() != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "check for quant failed."), + OPS_CHECK(CheckForQuant() != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "check for quant failed."), return ge::GRAPH_FAILED); - OP_CHECK_IF(CheckIllegalParam() != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "check illegal param failed."), + OPS_CHECK(CheckIllegalParam() != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "check illegal param failed."), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; @@ -624,8 +624,8 @@ ge::graphStatus DequantSwigluQuantDskTiling::CountMaxDim(int64_t& ubFactorDimx) maxOutDimy = static_cast(numerator / denominator); maxOutDimy = maxOutDimy / BLOCK_SIZE * BLOCK_SIZE; int64_t maxInDimy = static_cast(maxOutDimy * SWI_FACTOR); - OP_LOGI(context_->GetNodeName(), "Get maxInDimy[%ld]", maxInDimy); - OP_CHECK_IF(inDimy_ > maxInDimy, + OPS_LOG_I(context_->GetNodeName(), "Get maxInDimy[%ld]", maxInDimy); + OPS_CHECK(inDimy_ > maxInDimy, OP_LOGE_FOR_INVALID_SHAPESIZE(context_->GetNodeName(), "x", std::to_string(inDimy_).c_str(), ("less than or equal to " + std::to_string(maxInDimy)).c_str()), @@ -639,7 +639,7 @@ ge::graphStatus DequantSwigluQuantDskTiling::CountMaxDim(int64_t& ubFactorDimx) outDimy_ * SWI_FACTOR * static_cast(sizeof(float)) + SweiGLUBufferX; ubFactorDimx = static_cast(numerator / denominator); ubFactorDimx = std::min(ubFactorDimx, inDimx_); - OP_LOGI(context_->GetNodeName(), "Get ubFactorDimx[%ld]", ubFactorDimx); + OPS_LOG_I(context_->GetNodeName(), "Get ubFactorDimx[%ld]", ubFactorDimx); // special ub cut for 2048 4096 if (swigluMode_ == 0 && hasBias_ == false) { @@ -655,11 +655,11 @@ ge::graphStatus DequantSwigluQuantDskTiling::DoOpTiling() { return ge::GRAPH_FAILED; } auto inputShapeX = context_->GetInputShape(0); - OP_CHECK_NULL_WITH_CONTEXT(context_, inputShapeX); + OPS_LOG_E_IF_NULL(context_, inputShapeX, return ge::GRAPH_FAILED); int64_t ubFactorDimx = 0; - OP_CHECK_IF(CountMaxDim(ubFactorDimx) != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "Count MaxDim failed."), + OPS_CHECK(CountMaxDim(ubFactorDimx) != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "Count MaxDim failed."), return ge::GRAPH_FAILED); maxPreCore_ = (inDimx_ + ubFactorDimx - 1) / ubFactorDimx; @@ -707,7 +707,7 @@ void DequantSwigluQuantDskTiling::DumpTilingInfo() { info << ", gluAlpha: " << tilingData_.get_gluAlpha(); info << ", gluBias: " << tilingData_.get_gluBias(); - OP_LOGI(context_->GetNodeName(), "%s", info.str().c_str()); + OPS_LOG_I(context_->GetNodeName(), "%s", info.str().c_str()); } ge::graphStatus DequantSwigluQuantDskTiling::DoLibApiTiling() { @@ -740,27 +740,27 @@ ge::graphStatus TilingForDequantSwigluQuant(gert::TilingContext* context) { } ge::graphStatus TilingPrepareForDequantSwigluQuant(gert::TilingParseContext* context) { - OP_LOGD(context, "TilingPrepare4DequantSwigluQuant enter."); + OPS_LOG_D(context, "TilingPrepare4DequantSwigluQuant enter."); auto compileInfo = context->GetCompiledInfo(); - OP_CHECK_NULL_WITH_CONTEXT(context, compileInfo); + OPS_LOG_E_IF_NULL(context, compileInfo, return ge::GRAPH_FAILED); auto platformInfo = context->GetPlatformInfo(); - OP_CHECK_NULL_WITH_CONTEXT(context, platformInfo); + OPS_LOG_E_IF_NULL(context, platformInfo, return ge::GRAPH_FAILED); auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo); compileInfo->coreNum = ascendcPlatform.GetCoreNumAiv(); - OP_CHECK_IF((compileInfo->coreNum <= 0), - OP_LOGE(context->GetNodeName(), "Get core num failed, core num: %u", + OPS_CHECK((compileInfo->coreNum <= 0), + OPS_LOG_E(context->GetNodeName(), "Get core num failed, core num: %u", static_cast(compileInfo->coreNum)), return ge::GRAPH_FAILED); uint64_t ubSize; ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize); compileInfo->ubSize = ubSize; - OP_CHECK_IF((compileInfo->ubSize <= 0), - OP_LOGE(context->GetNodeName(), "Get ub size failed, ub size: %u", + OPS_CHECK((compileInfo->ubSize <= 0), + OPS_LOG_E(context->GetNodeName(), "Get ub size failed, ub size: %u", static_cast(compileInfo->ubSize)), return ge::GRAPH_FAILED); - OP_LOGD(context, "TilingPrepare4DequantSwigluQuant exit."); + OPS_LOG_D(context, "TilingPrepare4DequantSwigluQuant exit."); return ge::GRAPH_SUCCESS; } diff --git a/xllm_ops/moe/dequant_swiglu_quant/op_host/dequant_swiglu_quant_tiling.h b/xllm_ops/moe/dequant_swiglu_quant/op_host/dequant_swiglu_quant_tiling.h index 36f8214..2f57c1e 100644 --- a/xllm_ops/moe/dequant_swiglu_quant/op_host/dequant_swiglu_quant_tiling.h +++ b/xllm_ops/moe/dequant_swiglu_quant/op_host/dequant_swiglu_quant_tiling.h @@ -21,7 +21,7 @@ #include #include "register/op_impl_registry.h" #include "util/math_util.h" -#include "log/log.h" +#include "log/ops_log.h" #include "tiling/platform/platform_ascendc.h" #include "platform/platform_infos_def.h" #include "register/tilingdata_base.h" diff --git a/xllm_ops/moe/dequant_swiglu_quant/op_host/dequant_swiglu_quant_tiling_arch35.cpp b/xllm_ops/moe/dequant_swiglu_quant/op_host/dequant_swiglu_quant_tiling_arch35.cpp index 0945986..cc018bd 100644 --- a/xllm_ops/moe/dequant_swiglu_quant/op_host/dequant_swiglu_quant_tiling_arch35.cpp +++ b/xllm_ops/moe/dequant_swiglu_quant/op_host/dequant_swiglu_quant_tiling_arch35.cpp @@ -100,7 +100,7 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::GetPlatformInfo() auto platformInfo = context_->GetPlatformInfo(); if (platformInfo == nullptr) { auto compileInfoPtr = context_->GetCompileInfo(); - OP_CHECK_IF(compileInfoPtr == nullptr, OP_LOGE(context_, "compile info is null"), + OPS_CHECK(compileInfoPtr == nullptr, OPS_LOG_E(context_, "compile info is null"), return ge::GRAPH_FAILED); coreNum_ = compileInfoPtr->coreNum; ubSize_ = compileInfoPtr->ubSize; @@ -120,30 +120,30 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::GetPlatformInfo() ge::graphStatus DequantSwigluQuantV35DskTiling::GetInputX() { auto xDesc = context_->GetInputDesc(X_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, xDesc); + OPS_LOG_E_IF_NULL(context_, xDesc, return ge::GRAPH_FAILED); ge::DataType xDType = xDesc->GetDataType(); // 校验x的数据类型是否合法 - OP_CHECK_IF((SUPPORT_DTYPE.find(xDType) == SUPPORT_DTYPE.end()), + OPS_CHECK((SUPPORT_DTYPE.find(xDType) == SUPPORT_DTYPE.end()), OP_LOGE_FOR_INVALID_DTYPE(context_->GetNodeName(), "x", ge::TypeUtils::DataTypeToSerialString(xDType).c_str(), "int32, float16 or bf16"), return ge::GRAPH_FAILED); auto xStorageShape = context_->GetInputShape(X_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, xStorageShape); + OPS_LOG_E_IF_NULL(context_, xStorageShape, return ge::GRAPH_FAILED); xShape_ = EnsureNotScalar(xStorageShape->GetStorageShape()); xDimNum_ = xShape_.GetDimNum(); - OP_CHECK_IF(xDimNum_ < 2, + OPS_CHECK(xDimNum_ < 2, OP_LOGE_FOR_INVALID_SHAPEDIM(context_->GetNodeName(), "x", std::to_string(xDimNum_).c_str(), "greater than or equal to 2"), return ge::GRAPH_FAILED); - OP_CHECK_IF(xDimNum_ > 8, + OPS_CHECK(xDimNum_ > 8, OP_LOGE_FOR_INVALID_SHAPEDIM(context_->GetNodeName(), "x", std::to_string(xDimNum_).c_str(), "less than or equal to 8"), return ge::GRAPH_FAILED); for (size_t i = 0; i < xDimNum_; i++) { - OP_CHECK_IF(xShape_.GetDim(i) <= 0, + OPS_CHECK(xShape_.GetDim(i) <= 0, OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(context_->GetNodeName(), "x", - Ops::Base::ToString(xShape_).c_str(), + ops::Shape2String(xShape_).c_str(), ("the dim[" + std::to_string(i) + "] of x must be positive").c_str()), return ge::GRAPH_FAILED); } @@ -155,22 +155,22 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::GetInputGroupIndex() auto groupIndexDesc = context_->GetOptionalInputDesc(INPUT_GROUP_INDEX); if (groupIndexDesc != nullptr) { ge::DataType groupIndexDType = groupIndexDesc->GetDataType(); - OP_CHECK_IF(groupIndexDType != ge::DT_INT64 && groupIndexDType != ge::DT_INT32, + OPS_CHECK(groupIndexDType != ge::DT_INT64 && groupIndexDType != ge::DT_INT32, OP_LOGE_FOR_INVALID_DTYPE(context_->GetNodeName(), "group_index", ge::TypeUtils::DataTypeToSerialString(groupIndexDType).c_str(), "int32 or int64"), return ge::GRAPH_FAILED); auto groupIndexStorageShape = context_->GetOptionalInputShape(INPUT_GROUP_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, groupIndexStorageShape); + OPS_LOG_E_IF_NULL(context_, groupIndexStorageShape, return ge::GRAPH_FAILED); groupIndexShape_ = EnsureNotScalar(groupIndexStorageShape->GetStorageShape()); auto groupIndexDimNum = groupIndexShape_.GetDimNum(); - OP_CHECK_IF((groupIndexDimNum != 1) && (groupIndexDimNum != 2), + OPS_CHECK((groupIndexDimNum != 1) && (groupIndexDimNum != 2), OP_LOGE_FOR_INVALID_SHAPEDIM(context_->GetNodeName(), "group_index", std::to_string(groupIndexDimNum).c_str(), "1 or 2"), return ge::GRAPH_FAILED); groupNum_ = groupIndexShape_.GetDim(0); - OP_CHECK_IF(groupNum_ < 1, + OPS_CHECK(groupNum_ < 1, OP_LOGE_FOR_INVALID_SHAPESIZE(context_->GetNodeName(), "group_index", std::to_string(groupNum_).c_str(), "group_index[0] must be greater than or equal to 1"), return ge::GRAPH_FAILED); @@ -187,7 +187,7 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::GetInputGroupIndex() ge::graphStatus DequantSwigluQuantV35DskTiling::GetAttrActivateDim() { auto* attrs = context_->GetAttrs(); - OP_CHECK_NULL_WITH_CONTEXT(context_, attrs); + OPS_LOG_E_IF_NULL(context_, attrs, return ge::GRAPH_FAILED); // 校验activate_dim auto* attrActivateDim = attrs->GetAttrPointer(ATTR_ACTIVATE_DIM_INDEX); // 类型校验 @@ -196,7 +196,7 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::GetAttrActivateDim() activateDim_ = activateDim_ < 0 ? activateDim_ + static_cast(xDimNum_) : activateDim_; // 判断切分轴维度合法性 - OP_CHECK_IF(activateDim_ < 0 || activateDim_ >= static_cast(xDimNum_), + OPS_CHECK(activateDim_ < 0 || activateDim_ >= static_cast(xDimNum_), OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( context_->GetNodeName(), "activate_dim", std::to_string(activateDim_).c_str(), @@ -204,24 +204,24 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::GetAttrActivateDim() std::to_string(xDimNum_ - 1) + "]").c_str()), return ge::GRAPH_FAILED); // 校验切分轴对应的shape是不是偶数 - OP_CHECK_IF(xShape_.GetDim(activateDim_) % 2 != 0, + OPS_CHECK(xShape_.GetDim(activateDim_) % 2 != 0, OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(context_->GetNodeName(), "x", - Ops::Base::ToString(xShape_).c_str(), + ops::Shape2String(xShape_).c_str(), ("the split dim(" + std::to_string(activateDim_)+ "dimension) must be even").c_str()), return ge::GRAPH_FAILED); //如果activateDim不是尾轴,则不允许输入group if (activateDim_ != static_cast(xDimNum_ - 1)) { - OP_CHECK_IF(hasGroupIndex_ == true, + OPS_CHECK(hasGroupIndex_ == true, OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context_->GetNodeName(), "group_index and activate_dim", ("group_index is not None, and activate_dim is " + std::to_string(activateDim_)).c_str(), "group_index must be None when activate_dim is not the last dim of x"), return ge::GRAPH_FAILED); } // activate_dim对应在x的轴需要是偶数 - OP_CHECK_IF((xShape_.GetDim(activateDim_) % 2) != 0, + OPS_CHECK((xShape_.GetDim(activateDim_) % 2) != 0, OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(context_->GetNodeName(), "x", - Ops::Base::ToString(xShape_).c_str(), + ops::Shape2String(xShape_).c_str(), "the x dimension of activateDim must be even"), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; @@ -230,41 +230,41 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::GetAttrActivateDim() ge::graphStatus DequantSwigluQuantV35DskTiling::CheckOutputY() { auto yDesc = context_->GetOutputDesc(Y_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, yDesc); + OPS_LOG_E_IF_NULL(context_, yDesc, return ge::GRAPH_FAILED); ge::DataType yDType = yDesc->GetDataType(); - OP_CHECK_IF(OUTPUT_SUPPORT_DTYPE.find(yDType) == OUTPUT_SUPPORT_DTYPE.end(), + OPS_CHECK(OUTPUT_SUPPORT_DTYPE.find(yDType) == OUTPUT_SUPPORT_DTYPE.end(), OP_LOGE_FOR_INVALID_DTYPE(context_->GetNodeName(), "y", ge::TypeUtils::DataTypeToSerialString(yDType).c_str(), "int8, hifloat8, float8e4m3, float8e5m2, float4e2m1 or floate1m2"), return ge::GRAPH_FAILED); auto yStorageShape = context_->GetOutputShape(Y_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, yStorageShape); + OPS_LOG_E_IF_NULL(context_, yStorageShape, return ge::GRAPH_FAILED); auto& yShape = EnsureNotScalar(yStorageShape->GetStorageShape()); const size_t yDimNum = yShape.GetDimNum(); // 输出y是fp4类型时,y的尾轴对应的shape需要是偶数 if (yDType == ge::DT_FLOAT4_E2M1 || yDType == ge::DT_FLOAT4_E1M2) { - OP_CHECK_IF((yShape.GetDim(xDimNum_ - 1) % 2) != 0, + OPS_CHECK((yShape.GetDim(xDimNum_ - 1) % 2) != 0, OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(context_->GetNodeName(), "y", - Ops::Base::ToString(yShape).c_str(), + ops::Shape2String(yShape).c_str(), "The last dim of y must be even when the type of y is FP4X2_E2M1 or FP4X2_E1M2"), return ge::GRAPH_FAILED); } - OP_CHECK_IF(yDimNum != xDimNum_, + OPS_CHECK(yDimNum != xDimNum_, OP_LOGE_FOR_INVALID_SHAPEDIM(context_->GetNodeName(), "y", std::to_string(yDimNum).c_str(), ("equal to x dimension " + std::to_string(xDimNum_)).c_str()), return ge::GRAPH_FAILED); for (size_t i = 0; i < yDimNum; i++) { if (static_cast(i) != activateDim_){ - OP_CHECK_IF(yShape.GetDim(i) != xShape_.GetDim(i), + OPS_CHECK(yShape.GetDim(i) != xShape_.GetDim(i), OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON(context_->GetNodeName(), "x and y", - (Ops::Base::ToString(xShape_) + "and" + Ops::Base::ToString(yShape)).c_str(), + (ops::Shape2String(xShape_) + "and" + ops::Shape2String(yShape)).c_str(), ("dim[" + std::to_string(i) + "] of y must be equal to dim[" + std::to_string(i) + "] of x").c_str()), return ge::GRAPH_FAILED); } else { - OP_CHECK_IF(yShape.GetDim(i) != xShape_.GetDim(i) / SWI_FACTOR, + OPS_CHECK(yShape.GetDim(i) != xShape_.GetDim(i) / SWI_FACTOR, OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON(context_->GetNodeName(), "x and y", - Ops::Base::ToString(yShape).c_str(), + ops::Shape2String(yShape).c_str(), ("dim[" + std::to_string(i) + "] of y must be equal to half of dim[" + std::to_string(i) + "] of x").c_str()), return ge::GRAPH_FAILED); } @@ -276,62 +276,62 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::CheckInputWeightScale() { auto wScaleDesc = context_->GetOptionalInputDesc(WEIGHT_SCALE_INDEX); auto xDesc = context_->GetInputDesc(X_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, xDesc); + OPS_LOG_E_IF_NULL(context_, xDesc, return ge::GRAPH_FAILED); ge::DataType xDType = xDesc->GetDataType(); // 如果输入x是bf16 or float16,则weight_scale需要为空,非法性校验 if (wScaleDesc != nullptr) { - OP_CHECK_IF(xDType == ge::DT_FLOAT16 || xDType == ge::DT_BF16, + OPS_CHECK(xDType == ge::DT_FLOAT16 || xDType == ge::DT_BF16, OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context_->GetNodeName(), "weight_scale", "not None", "weight_scale must be None when x's datatype is in [bfloat16, float16]"), return ge::GRAPH_FAILED); } // 如果输入x是int32,则weight_scale必须有值,合法性校验 - OP_CHECK_IF((xDType == ge::DT_INT32) && (wScaleDesc == nullptr), + OPS_CHECK((xDType == ge::DT_INT32) && (wScaleDesc == nullptr), OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context_->GetNodeName(), "weight_scale", "None", "weight_scale must be not None when x's datatype is int32"), return ge::GRAPH_FAILED); // weight_scale不为空,进行判断 if (wScaleDesc != nullptr) { - OP_CHECK_NULL_WITH_CONTEXT(context_, wScaleDesc); + OPS_LOG_E_IF_NULL(context_, wScaleDesc, return ge::GRAPH_FAILED); ge::DataType wScaleDType = wScaleDesc->GetDataType(); - OP_CHECK_IF(wScaleDType != ge::DT_FLOAT, + OPS_CHECK(wScaleDType != ge::DT_FLOAT, OP_LOGE_FOR_INVALID_DTYPE(context_->GetNodeName(), "weight_scale", ge::TypeUtils::DataTypeToSerialString(wScaleDType).c_str(), "float32"), return ge::GRAPH_FAILED); auto wScaleStorageShape = context_->GetOptionalInputShape(WEIGHT_SCALE_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, wScaleStorageShape); + OPS_LOG_E_IF_NULL(context_, wScaleStorageShape, return ge::GRAPH_FAILED); auto& wScaleShape = EnsureNotScalar(wScaleStorageShape->GetStorageShape()); const size_t wScaleDimNum = wScaleShape.GetDimNum(); - OP_CHECK_IF(wScaleDimNum > 2, + OPS_CHECK(wScaleDimNum > 2, OP_LOGE_FOR_INVALID_SHAPEDIM(context_->GetNodeName(), "weight_scale", std::to_string(wScaleDimNum).c_str(), "less than or equal to 2"), return ge::GRAPH_FAILED); if (wScaleDimNum == static_cast(1)) { - OP_CHECK_IF(hasGroupIndex_ == true, + OPS_CHECK(hasGroupIndex_ == true, OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context_->GetNodeName(), "group_index", "not None", "group_index should be none when weight_scale dimension is 1"), return ge::GRAPH_FAILED); - OP_CHECK_IF(wScaleShape.GetDim(0) != xShape_.GetDim(xDimNum_ - 1), + OPS_CHECK(wScaleShape.GetDim(0) != xShape_.GetDim(xDimNum_ - 1), OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(context_->GetNodeName(), "weight_scale", - Ops::Base::ToString(wScaleShape).c_str(), + ops::Shape2String(wScaleShape).c_str(), ("The first dim of weight_scale must be the same as the last dim of x: " + std::to_string(xShape_.GetDim(xDimNum_ - 1))).c_str()), return ge::GRAPH_FAILED); } if (wScaleDimNum > static_cast(1)) { if (hasGroupIndex_) { - OP_CHECK_IF(!(wScaleShape.GetDim(0) == groupIndexShape_.GetDim(0) && wScaleShape[wScaleDimNum - 1] == xShape_.GetDim(xDimNum_ - 1)), - OP_LOGE(context_->GetNodeName(), + OPS_CHECK(!(wScaleShape.GetDim(0) == groupIndexShape_.GetDim(0) && wScaleShape[wScaleDimNum - 1] == xShape_.GetDim(xDimNum_ - 1)), + OPS_LOG_E(context_->GetNodeName(), "weight_scale shape[0] must be equal to group_index shape[0], and shape[-1] must be equal to x shape[-1] " "when group_index exists, please check."), return ge::GRAPH_FAILED); } else { - OP_CHECK_IF(!(wScaleShape.GetDim(0) == 1 && wScaleShape.GetDim(wScaleDimNum - 1) == xShape_.GetDim(xDimNum_ - 1)) && + OPS_CHECK(!(wScaleShape.GetDim(0) == 1 && wScaleShape.GetDim(wScaleDimNum - 1) == xShape_.GetDim(xDimNum_ - 1)) && !(wScaleShape.GetDim(0) == xShape_.GetDim(xDimNum_ - 1) && wScaleShape.GetDim(wScaleDimNum - 1) == 1), - OP_LOGE(context_->GetNodeName(), "weight_scale shape must be in {[1, %ld], [%ld, 1]} when weight_scale dimension == 2 and group_index not exists," + OPS_LOG_E(context_->GetNodeName(), "weight_scale shape must be in {[1, %ld], [%ld, 1]} when weight_scale dimension == 2 and group_index not exists," "please check.", xShape_.GetDim(xDimNum_ - 1), xShape_.GetDim(xDimNum_ - 1)), return ge::GRAPH_FAILED); } @@ -345,27 +345,27 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::CheckInputActScale() { auto aScaleDesc = context_->GetOptionalInputDesc(ACTIVATION_SCALE_INDEX); auto xDesc = context_->GetInputDesc(X_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, xDesc); + OPS_LOG_E_IF_NULL(context_, xDesc, return ge::GRAPH_FAILED); ge::DataType xDType = xDesc->GetDataType(); // 当x:bfloat16 or float16时,activate_scale需要为空 if (aScaleDesc != nullptr) { - OP_CHECK_IF(xDType == ge::DT_FLOAT16 || xDType == ge::DT_BF16, + OPS_CHECK(xDType == ge::DT_FLOAT16 || xDType == ge::DT_BF16, OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context_->GetNodeName(), "activation_scale", "not None", "activate_scale must be None when x's datatype is in [bfloat16, float16]"), return ge::GRAPH_FAILED); ge::DataType aScaleDType = aScaleDesc->GetDataType(); - OP_CHECK_IF(aScaleDType != ge::DT_FLOAT, + OPS_CHECK(aScaleDType != ge::DT_FLOAT, OP_LOGE_FOR_INVALID_DTYPE(context_->GetNodeName(), "activation_scale", ge::TypeUtils::DataTypeToSerialString(aScaleDType).c_str(), "float32"), return ge::GRAPH_FAILED); auto aScaleStorageShape = context_->GetOptionalInputShape(ACTIVATION_SCALE_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, aScaleStorageShape); + OPS_LOG_E_IF_NULL(context_, aScaleStorageShape, return ge::GRAPH_FAILED); auto& aScaleShape = EnsureNotScalar(aScaleStorageShape->GetStorageShape()); const size_t aScaleDimNum = aScaleShape.GetDimNum(); - OP_CHECK_IF(aScaleDimNum <= 0, + OPS_CHECK(aScaleDimNum <= 0, OP_LOGE_FOR_INVALID_SHAPEDIM(context_->GetNodeName(), "activation_scale", std::to_string(aScaleDimNum).c_str(), "greater than 0"), return ge::GRAPH_FAILED); @@ -374,7 +374,7 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::CheckInputActScale() // activation_scale的shape size与x除尾轴外的shape size一致 int64_t aScaleSize = aScaleStorageShape->GetStorageShape().GetShapeSize(); int64_t xSizeWithoutLastDim = xShape_.GetShapeSize() / xShape_.GetDim(xDimNum_ - 1); - OP_CHECK_IF(aScaleSize != xSizeWithoutLastDim, + OPS_CHECK(aScaleSize != xSizeWithoutLastDim, OP_LOGE_FOR_INVALID_SHAPESIZES_WITH_REASON(context_->GetNodeName(), "activation_scale", std::to_string(aScaleSize).c_str(), ("The shape size of activation_scale should be the same as x's shape size without last dim " + std::to_string(xSizeWithoutLastDim)).c_str()), @@ -388,13 +388,13 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::CheckInputBias() { auto biasDesc = context_->GetOptionalInputDesc(BIAS_INDEX); auto xDesc = context_->GetInputDesc(X_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, xDesc); + OPS_LOG_E_IF_NULL(context_, xDesc, return ge::GRAPH_FAILED); ge::DataType xDType = xDesc->GetDataType(); // 首先判断bias不为空时,其数据类型是不是满足计算要求 if (biasDesc != nullptr) { ge::DataType biasDtype = biasDesc->GetDataType(); auto it = SUPPORT_BIAS_MODE.find(biasDtype); - OP_CHECK_IF(it == SUPPORT_BIAS_MODE.end(), + OPS_CHECK(it == SUPPORT_BIAS_MODE.end(), OP_LOGE_FOR_INVALID_DTYPE(context_->GetNodeName(), "bias", ge::TypeUtils::DataTypeToSerialString(biasDtype).c_str(), "float16, float, bf16 or int32"), return ge::GRAPH_FAILED); @@ -402,7 +402,7 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::CheckInputBias() // 当前bias支持四种数据类型,但是有些bias类型仅支持x的特定类型 // x:bf16, float16,bias不支持输入 if (xDType == ge::DT_BF16 or xDType == ge::DT_FLOAT16) { - OP_CHECK_IF(BIAS_SUPPORT_DTYPE.find(biasDtype) != BIAS_SUPPORT_DTYPE.end(), + OPS_CHECK(BIAS_SUPPORT_DTYPE.find(biasDtype) != BIAS_SUPPORT_DTYPE.end(), OP_LOGE_FOR_INVALID_DTYPE(context_->GetNodeName(), "bias", ge::TypeUtils::DataTypeToSerialString(biasDtype).c_str(), "bias not support when the type of x is bf16 or float16"), @@ -411,22 +411,22 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::CheckInputBias() // 然后判断bias的维度是不是满足要求 auto biasStorageShape = context_->GetOptionalInputShape(BIAS_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, biasStorageShape); + OPS_LOG_E_IF_NULL(context_, biasStorageShape, return ge::GRAPH_FAILED); auto& biasShape = EnsureNotScalar(biasStorageShape->GetStorageShape()); const size_t biasDimNum = biasShape.GetDimNum(); - OP_CHECK_IF(biasDimNum > static_cast(2) || biasDimNum == static_cast(0), + OPS_CHECK(biasDimNum > static_cast(2) || biasDimNum == static_cast(0), OP_LOGE_FOR_INVALID_SHAPEDIM(context_->GetNodeName(), "bias", std::to_string(biasDimNum).c_str(), "1D or 2D"), return ge::GRAPH_FAILED); // 当biasDimNum=1时 if (biasDimNum == static_cast(1)) { - OP_CHECK_IF(hasGroupIndex_ == true, + OPS_CHECK(hasGroupIndex_ == true, OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(context_->GetNodeName(), "group_index", "not None", "group_index should be none when bias dimension is 1"), return ge::GRAPH_FAILED); - OP_CHECK_IF(biasShape.GetDim(0) != xShape_.GetDim(xDimNum_ - 1), + OPS_CHECK(biasShape.GetDim(0) != xShape_.GetDim(xDimNum_ - 1), OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(context_->GetNodeName(), "bias", - Ops::Base::ToString(biasShape).c_str(), + ops::Shape2String(biasShape).c_str(), ("The last dimension of bias should be the same as the last dimension of x " + std::to_string(xShape_.GetDim(xDimNum_ - 1))).c_str()), return ge::GRAPH_FAILED); @@ -434,9 +434,9 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::CheckInputBias() // 当biasDimNum=2时 if (biasDimNum == static_cast(2)) { - OP_CHECK_IF(biasShape.GetDim(1) != xShape_.GetDim(xDimNum_ - 1), + OPS_CHECK(biasShape.GetDim(1) != xShape_.GetDim(xDimNum_ - 1), OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(context_->GetNodeName(), "bias", - Ops::Base::ToString(biasShape).c_str(), + ops::Shape2String(biasShape).c_str(), ("The last dimension of bias should be the same as the last dimension of x " + std::to_string(xShape_.GetDim(xDimNum_ - 1))).c_str()), return ge::GRAPH_FAILED); @@ -448,11 +448,11 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::CheckInputBias() ") should be equal to the first dimension of group_index (" + std::to_string(groupNum_) + "), please check"; OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON( - context_->GetNodeName(), "bias", Ops::Base::ToString(biasShape).c_str(), reason.c_str()); + context_->GetNodeName(), "bias", ops::Shape2String(biasShape).c_str(), reason.c_str()); return ge::GRAPH_FAILED; } } else { - OP_CHECK_IF(biasShape.GetDim(0) != 1, + OPS_CHECK(biasShape.GetDim(0) != 1, OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(context_->GetNodeName(), "bias", std::to_string(biasShape.GetDim(0)).c_str(), "The first dimension of bias should be 1 when the dimension of bias is 2 and group_index does not exist"), @@ -469,58 +469,58 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::CheckInputQuantScale() auto qScaleDesc = context_->GetOptionalInputDesc(QUANT_SCALE_INDEX); if (qScaleDesc != nullptr) { ge::DataType qScaleDType = qScaleDesc->GetDataType(); - OP_CHECK_IF(QUANT_SCALE_SUPPORT_DTYPE.find(qScaleDType) == QUANT_SCALE_SUPPORT_DTYPE.end(), + OPS_CHECK(QUANT_SCALE_SUPPORT_DTYPE.find(qScaleDType) == QUANT_SCALE_SUPPORT_DTYPE.end(), OP_LOGE_FOR_INVALID_DTYPE(context_->GetNodeName(), "quant_scale", ge::TypeUtils::DataTypeToSerialString(qScaleDType).c_str(), "float32"), return ge::GRAPH_FAILED); auto qScaleStorageShape = context_->GetOptionalInputShape(QUANT_SCALE_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, qScaleStorageShape); + OPS_LOG_E_IF_NULL(context_, qScaleStorageShape, return ge::GRAPH_FAILED); auto& qScaleShape = EnsureNotScalar(qScaleStorageShape->GetStorageShape()); const size_t qScaleDimNum = qScaleShape.GetDimNum(); - OP_CHECK_IF(qScaleDimNum > 2, + OPS_CHECK(qScaleDimNum > 2, OP_LOGE_FOR_INVALID_SHAPEDIM(context_->GetNodeName(), "quant_scale", std::to_string(qScaleDimNum).c_str(), "less than or equal to 2"), return ge::GRAPH_FAILED); // 获取y的shape auto yStorageShape = context_->GetOutputShape(Y_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, yStorageShape); + OPS_LOG_E_IF_NULL(context_, yStorageShape, return ge::GRAPH_FAILED); auto& yShape = EnsureNotScalar(yStorageShape->GetStorageShape()); if (hasGroupIndex_) { if (quantMode_ == 0) { - OP_CHECK_IF(qScaleShape.GetDim(0) != (groupIndexShape_.GetDim(0)), - OP_LOGE(context_->GetNodeName(), + OPS_CHECK(qScaleShape.GetDim(0) != (groupIndexShape_.GetDim(0)), + OPS_LOG_E(context_->GetNodeName(), "quant_scale shape[0] must be equal to group_index shape[0] when static_quant and group_index exists, please check."), return ge::GRAPH_FAILED); if (qScaleDimNum == DIM_TWO) { - OP_CHECK_IF(!((qScaleShape.GetDim(qScaleDimNum - 1) == yShape.GetDim(xDimNum_ - 1)) || (qScaleShape.GetDim(qScaleDimNum - 1) == 1)), - OP_LOGE(context_->GetNodeName(), + OPS_CHECK(!((qScaleShape.GetDim(qScaleDimNum - 1) == yShape.GetDim(xDimNum_ - 1)) || (qScaleShape.GetDim(qScaleDimNum - 1) == 1)), + OPS_LOG_E(context_->GetNodeName(), "quant_scale shape[-1] must be equal to or can be broadcast to y shape[-1] when static_quant and group_index exists, please check."), return ge::GRAPH_FAILED); } } else if (quantMode_ == 1) { - OP_CHECK_IF(qScaleShape.GetDim(0) != groupIndexShape_.GetDim(0) || qScaleShape.GetDim(qScaleDimNum - 1) != yShape.GetDim(xDimNum_ - 1), - OP_LOGE(context_->GetNodeName(), + OPS_CHECK(qScaleShape.GetDim(0) != groupIndexShape_.GetDim(0) || qScaleShape.GetDim(qScaleDimNum - 1) != yShape.GetDim(xDimNum_ - 1), + OPS_LOG_E(context_->GetNodeName(), "quant_scale shape must be [ group_index_shape[0], y_shape[-1] ] when dynamic quant and group_index exists, please check."), return ge::GRAPH_FAILED); } quantIsOne_ = (qScaleDimNum == DIM_TWO && qScaleShape.GetDim(qScaleDimNum - 1) == yShape.GetDim(xDimNum_ - 1)) ? 0 : 1; } else { if (qScaleDimNum == DIM_TWO) { - OP_CHECK_IF(qScaleShape.GetDim(0) != 1, - OP_LOGE(context_->GetNodeName(), + OPS_CHECK(qScaleShape.GetDim(0) != 1, + OPS_LOG_E(context_->GetNodeName(), "if dim of quant_scale is 2, shape[0] must be [1] when group_index not exists, please check."), return ge::GRAPH_FAILED); } if (quantMode_ == 0) { - OP_CHECK_IF(qScaleShape.GetDim(0) != 1 && qScaleShape.GetDim(0) != yShape.GetDim(xDimNum_ - 1), - OP_LOGE(context_->GetNodeName(), + OPS_CHECK(qScaleShape.GetDim(0) != 1 && qScaleShape.GetDim(0) != yShape.GetDim(xDimNum_ - 1), + OPS_LOG_E(context_->GetNodeName(), "quant_scale shape[0] must be or can be broadcast to y shape[-1] when static_quant and group_index not exists, please check."), return ge::GRAPH_FAILED); } else if (quantMode_ == 1) { - OP_CHECK_IF(qScaleShape.GetDim(qScaleDimNum - 1) != yShape.GetDim(xDimNum_ - 1), - OP_LOGE(context_->GetNodeName(), + OPS_CHECK(qScaleShape.GetDim(qScaleDimNum - 1) != yShape.GetDim(xDimNum_ - 1), + OPS_LOG_E(context_->GetNodeName(), "quant_scale shape[-1] must be equal to y shape[-1] when dynamic_quant and group_index not exists, please check."), return ge::GRAPH_FAILED); } @@ -529,8 +529,8 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::CheckInputQuantScale() hasQuantScale_ = true; } if (quantMode_ == 0) { - OP_CHECK_IF(!hasQuantScale_, - OP_LOGE(context_->GetNodeName(), "quant_scale must exist when static_quant, please check."), + OPS_CHECK(!hasQuantScale_, + OPS_LOG_E(context_->GetNodeName(), "quant_scale must exist when static_quant, please check."), return ge::GRAPH_FAILED); } return ge::GRAPH_SUCCESS; @@ -550,45 +550,45 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::CheckInputQuantOffset() */ if (qOffsetDesc != nullptr) { ge::DataType qOffsetDType = qOffsetDesc->GetDataType(); - OP_CHECK_IF(QUANT_OFFSET_SUPPORT_DTYPE.find(qOffsetDType) == QUANT_OFFSET_SUPPORT_DTYPE.end(), + OPS_CHECK(QUANT_OFFSET_SUPPORT_DTYPE.find(qOffsetDType) == QUANT_OFFSET_SUPPORT_DTYPE.end(), OP_LOGE_FOR_INVALID_DTYPE(context_->GetNodeName(), "quant_offset", ge::TypeUtils::DataTypeToSerialString(qOffsetDType).c_str(), "float32"), return ge::GRAPH_FAILED); - OP_CHECK_IF(quantMode_ != 0, + OPS_CHECK(quantMode_ != 0, OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context_->GetNodeName(), "quant_offset", "not None", "quant_offset only be supported when static quant, but current quant mode is dynamic quant, quant_offset should be None."), return ge::GRAPH_FAILED); auto qOffsetStorageShape = context_->GetOptionalInputShape(QUANT_OFFSET_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, qOffsetStorageShape); + OPS_LOG_E_IF_NULL(context_, qOffsetStorageShape, return ge::GRAPH_FAILED); auto& qOffsetShape = EnsureNotScalar(qOffsetStorageShape->GetStorageShape()); const size_t qOffsetDimNum = qOffsetShape.GetDimNum(); - OP_CHECK_IF(qOffsetDimNum > 2, + OPS_CHECK(qOffsetDimNum > 2, OP_LOGE_FOR_INVALID_SHAPEDIM(context_->GetNodeName(), "quant_offset", std::to_string(qOffsetDimNum).c_str(), "less than or equal to 2"), return ge::GRAPH_FAILED); auto yStorageShape = context_->GetOutputShape(Y_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, yStorageShape); + OPS_LOG_E_IF_NULL(context_, yStorageShape, return ge::GRAPH_FAILED); auto& yShape = EnsureNotScalar(yStorageShape->GetStorageShape()); if (hasGroupIndex_) { - OP_CHECK_IF(qOffsetShape.GetDim(0) != (groupIndexShape_.GetDim(0)), - OP_LOGE(context_->GetNodeName(), + OPS_CHECK(qOffsetShape.GetDim(0) != (groupIndexShape_.GetDim(0)), + OPS_LOG_E(context_->GetNodeName(), "quant_offset shape[0] must be equal to group_index shape[0] when group_index exists, please check."), return ge::GRAPH_FAILED); if (qOffsetDimNum == DIM_TWO) { - OP_CHECK_IF(qOffsetShape.GetDim(qOffsetDimNum - 1) != 1 && qOffsetShape.GetDim(qOffsetDimNum - 1) != yShape.GetDim(xDimNum_ - 1), - OP_LOGE(context_->GetNodeName(), + OPS_CHECK(qOffsetShape.GetDim(qOffsetDimNum - 1) != 1 && qOffsetShape.GetDim(qOffsetDimNum - 1) != yShape.GetDim(xDimNum_ - 1), + OPS_LOG_E(context_->GetNodeName(), "quant_offset shape[-1] must be equal to or can be broadcast to y shape[-1] when group_index exists, please check."), return ge::GRAPH_FAILED); } } else { if (qOffsetDimNum == DIM_TWO) { - OP_CHECK_IF(qOffsetShape.GetDim(0) != 1, - OP_LOGE(context_->GetNodeName(), + OPS_CHECK(qOffsetShape.GetDim(0) != 1, + OPS_LOG_E(context_->GetNodeName(), "if dim of quant_offset is 2, shape[0] must be [1] when group_index not exists, please check."), return ge::GRAPH_FAILED); } - OP_CHECK_IF(qOffsetShape.GetDim(0) != 1 && qOffsetShape.GetDim(0) != yShape.GetDim(xDimNum_ - 1), - OP_LOGE(context_->GetNodeName(), + OPS_CHECK(qOffsetShape.GetDim(0) != 1 && qOffsetShape.GetDim(0) != yShape.GetDim(xDimNum_ - 1), + OPS_LOG_E(context_->GetNodeName(), "quant_offset shape[0] must be or can be broadcast to y shape[-1] when static_quant and group_index not exists, please check."), return ge::GRAPH_FAILED); } @@ -603,13 +603,13 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::CheckForStaticQuant() // 静态 return ge::GRAPH_SUCCESS; } auto qScaleStorageShape = context_->GetOptionalInputShape(QUANT_SCALE_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, qScaleStorageShape); + OPS_LOG_E_IF_NULL(context_, qScaleStorageShape, return ge::GRAPH_FAILED); int64_t qScaleSize = qScaleStorageShape->GetStorageShape().GetShapeSize(); auto qOffsetStorageShape = context_->GetOptionalInputShape(QUANT_OFFSET_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, qOffsetStorageShape); + OPS_LOG_E_IF_NULL(context_, qOffsetStorageShape, return ge::GRAPH_FAILED); int64_t qOffsetSize = qOffsetStorageShape->GetStorageShape().GetShapeSize(); - OP_CHECK_IF(qScaleSize != qOffsetSize, - OP_LOGE(context_->GetNodeName(), "quant_scale size should be equal to quant_offset size, please check."), + OPS_CHECK(qScaleSize != qOffsetSize, + OPS_LOG_E(context_->GetNodeName(), "quant_scale size should be equal to quant_offset size, please check."), return ge::GRAPH_FAILED); return ge::GRAPH_SUCCESS; } @@ -617,30 +617,30 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::CheckForStaticQuant() // 静态 ge::graphStatus DequantSwigluQuantV35DskTiling::CheckOutputScale() { auto scaleDesc = context_->GetOutputDesc(SCALE_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, scaleDesc); + OPS_LOG_E_IF_NULL(context_, scaleDesc, return ge::GRAPH_FAILED); ge::DataType scaleDType = scaleDesc->GetDataType(); - OP_CHECK_IF(scaleDType != ge::DT_FLOAT, + OPS_CHECK(scaleDType != ge::DT_FLOAT, OP_LOGE_FOR_INVALID_DTYPE(context_->GetNodeName(), "scale", ge::TypeUtils::DataTypeToSerialString(scaleDType).c_str(), "float32"), return ge::GRAPH_FAILED); auto scaleStorageShape = context_->GetOutputShape(SCALE_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, scaleStorageShape); + OPS_LOG_E_IF_NULL(context_, scaleStorageShape, return ge::GRAPH_FAILED); auto& scaleShape = EnsureNotScalar(scaleStorageShape->GetStorageShape()); const size_t scaleDimNum = scaleShape.GetDimNum(); auto yStorageShape = context_->GetOutputShape(Y_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, yStorageShape); + OPS_LOG_E_IF_NULL(context_, yStorageShape, return ge::GRAPH_FAILED); auto& yShape = EnsureNotScalar(yStorageShape->GetStorageShape()); const size_t yDimNum = yShape.GetDimNum(); - OP_CHECK_IF(scaleDimNum != (yDimNum - 1), - OP_LOGE(context_->GetNodeName(), + OPS_CHECK(scaleDimNum != (yDimNum - 1), + OPS_LOG_E(context_->GetNodeName(), "scale dimension should be only 1 less than y dimension, please check."), return ge::GRAPH_FAILED); for (size_t i = 0; i < scaleDimNum; i++) { - OP_CHECK_IF(scaleShape[i] != yShape[i], - OP_LOGE(context_->GetNodeName(), + OPS_CHECK(scaleShape[i] != yShape[i], + OPS_LOG_E(context_->GetNodeName(), "scale shape[%zu] must be equal to y shape[%zu], please check.", i, i), return ge::GRAPH_FAILED); } @@ -650,14 +650,14 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::CheckOutputScale() ge::graphStatus DequantSwigluQuantV35DskTiling::GetAttr() { auto* attrs = context_->GetAttrs(); - OP_CHECK_NULL_WITH_CONTEXT(context_, attrs); + OPS_LOG_E_IF_NULL(context_, attrs, return ge::GRAPH_FAILED); auto* attrActivateLeft = attrs->GetAttrPointer(ATTR_ACTIVATE_LEFT_INDEX); actRight_ = (attrActivateLeft == nullptr || *attrActivateLeft == false) ? 1 : 0; const char* attrQuantMode = attrs->GetAttrPointer(ATTR_QUANT_MODE_INDEX); std::string quantMode = attrQuantMode == nullptr ? "static" : attrQuantMode; auto it = SUPPORT_QUANT_MODE.find(quantMode); - OP_CHECK_IF(it == SUPPORT_QUANT_MODE.end(), + OPS_CHECK(it == SUPPORT_QUANT_MODE.end(), OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( context_->GetNodeName(), "quant_mode", quantMode.c_str(), "quant_mode only support [dynamic] or [static]"), @@ -667,7 +667,7 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::GetAttr() auto* attrDstType = attrs->GetAttrPointer(ATTR_DST_TYPE_INDEX); // 类型校验,防止空指针 dstType_ = (attrDstType != nullptr) ? *attrDstType : 2; // 默认是2,也即对应输出类型为int8 - OP_CHECK_IF(dstType_ != 2 && dstType_ != 34 && dstType_ != 35 && dstType_ != 36 && dstType_ != 40 && dstType_ != 41, + OPS_CHECK(dstType_ != 2 && dstType_ != 34 && dstType_ != 35 && dstType_ != 36 && dstType_ != 40 && dstType_ != 41, OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( context_->GetNodeName(), "dst_type", std::to_string(dstType_).c_str(), "dst_type only support [2, 34, 35, 36, 40, 41]"), @@ -676,7 +676,7 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::GetAttr() const char* attrRoundMode = attrs->GetAttrPointer(ATTR_ROUND_MODE_INDEX); std::string roundMode = attrRoundMode == nullptr ? "rint" : attrRoundMode; auto roundModeIt = SUPPORT_ROUND_MODE.find(roundMode); - OP_CHECK_IF(roundModeIt == SUPPORT_ROUND_MODE.end(), + OPS_CHECK(roundModeIt == SUPPORT_ROUND_MODE.end(), OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( context_->GetNodeName(), "round_mode", roundMode.c_str(), "round_mode only support [rint, round, floor, ceil, trunc]"), @@ -684,18 +684,18 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::GetAttr() roundMode_ = roundModeIt->second; // y:[int8, float8],仅支持rint,y:[float4],五种类型都支持 auto yDesc = context_->GetOutputDesc(Y_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, yDesc); + OPS_LOG_E_IF_NULL(context_, yDesc, return ge::GRAPH_FAILED); ge::DataType yDType = yDesc->GetDataType(); // 校验y属于int8和float8时,roundMode是不是rint if (yDType != ge::DT_HIFLOAT8) { - OP_CHECK_IF((yDType == ge::DT_INT8 || yDType == ge::DT_FLOAT8_E5M2 || yDType == ge::DT_FLOAT8_E4M3FN) && roundMode_ != 0, + OPS_CHECK((yDType == ge::DT_INT8 || yDType == ge::DT_FLOAT8_E5M2 || yDType == ge::DT_FLOAT8_E4M3FN) && roundMode_ != 0, OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( context_->GetNodeName(), "round_mode", roundMode.c_str(), "round_mode only support [rint] when the type of y in [int8, float8]"), return ge::GRAPH_FAILED); } else { // 校验y属于hifloat8时,roundMode是不是round - OP_CHECK_IF(roundMode_ != 1, + OPS_CHECK(roundMode_ != 1, OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( context_->GetNodeName(), "round_mode", roundMode.c_str(), "round_mode only support [round] when the type of y in [hifloat8]"), @@ -703,14 +703,14 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::GetAttr() } auto* attrSwigluMode = attrs->GetAttrPointer(ATTR_SWIGLU_MODE_INDEX); swigluMode_ = (attrSwigluMode == nullptr) ? 0 : *attrSwigluMode; - OP_CHECK_IF(swigluMode_ != 0 && swigluMode_ != 1, + OPS_CHECK(swigluMode_ != 0 && swigluMode_ != 1, OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( context_->GetNodeName(), "swigluMode", std::to_string(swigluMode_).c_str(), "swigluMode only support [0, 1]"), return ge::GRAPH_FAILED); auto* attrClampLimit = attrs->GetAttrPointer(ATTR_CLAMP_LIMIT_INDEX); clampLimit_ = (attrClampLimit == nullptr) ? CLAMP_LIMIT_DEFAULT : *attrClampLimit; - OP_CHECK_IF(!(clampLimit_ >= 0.0), + OPS_CHECK(!(clampLimit_ >= 0.0), OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( context_->GetNodeName(), "clamp_limit", std::to_string(clampLimit_).c_str(), "clamp_limit should be non-negative"), @@ -723,34 +723,34 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::GetAttr() } ge::graphStatus DequantSwigluQuantV35DskTiling::GetShapeAttrsInfo() { - OP_CHECK_IF(context_ == nullptr, OP_LOGE("DequantSwigluQuant", "context is null."), return ge::GRAPH_FAILED); - OP_CHECK_IF(GetInputX() != ge::GRAPH_SUCCESS, OP_LOGE(context_->GetNodeName(), "get input x failed."), + OPS_CHECK(context_ == nullptr, OPS_LOG_E("DequantSwigluQuant", "context is null."), return ge::GRAPH_FAILED); + OPS_CHECK(GetInputX() != ge::GRAPH_SUCCESS, OPS_LOG_E(context_->GetNodeName(), "get input x failed."), return ge::GRAPH_FAILED); - OP_CHECK_IF(GetInputGroupIndex() != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "get input group_index failed."), return ge::GRAPH_FAILED); - OP_CHECK_IF(GetAttrActivateDim() != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "get attr activate_dim failed."), return ge::GRAPH_FAILED); - OP_CHECK_IF(GetAttr() != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "get attr failed."), return ge::GRAPH_FAILED); - OP_CHECK_IF(CheckOutputY() != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "check output y failed."), return ge::GRAPH_FAILED); - OP_CHECK_IF(CheckInputWeightScale() != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "check input weight_scale failed."), return ge::GRAPH_FAILED); - OP_CHECK_IF(CheckInputActScale() != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "check input activation_scale failed."), return ge::GRAPH_FAILED); - OP_CHECK_IF(CheckInputBias() != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "check input bias failed."), return ge::GRAPH_FAILED); - OP_CHECK_IF(CheckInputQuantScale() != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "check input quant_scale failed."), return ge::GRAPH_FAILED); - OP_CHECK_IF(CheckInputQuantOffset() != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "check input quant_offset failed."), return ge::GRAPH_FAILED); + OPS_CHECK(GetInputGroupIndex() != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "get input group_index failed."), return ge::GRAPH_FAILED); + OPS_CHECK(GetAttrActivateDim() != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "get attr activate_dim failed."), return ge::GRAPH_FAILED); + OPS_CHECK(GetAttr() != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "get attr failed."), return ge::GRAPH_FAILED); + OPS_CHECK(CheckOutputY() != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "check output y failed."), return ge::GRAPH_FAILED); + OPS_CHECK(CheckInputWeightScale() != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "check input weight_scale failed."), return ge::GRAPH_FAILED); + OPS_CHECK(CheckInputActScale() != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "check input activation_scale failed."), return ge::GRAPH_FAILED); + OPS_CHECK(CheckInputBias() != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "check input bias failed."), return ge::GRAPH_FAILED); + OPS_CHECK(CheckInputQuantScale() != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "check input quant_scale failed."), return ge::GRAPH_FAILED); + OPS_CHECK(CheckInputQuantOffset() != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "check input quant_offset failed."), return ge::GRAPH_FAILED); if (quantMode_ == 0) { - OP_CHECK_IF(CheckForStaticQuant() != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "check input quant_scale and quant_offset size failed."), + OPS_CHECK(CheckForStaticQuant() != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "check input quant_scale and quant_offset size failed."), return ge::GRAPH_FAILED); } - OP_CHECK_IF(CheckOutputScale() != ge::GRAPH_SUCCESS, - OP_LOGE(context_->GetNodeName(), "check output scale failed."), return ge::GRAPH_FAILED); + OPS_CHECK(CheckOutputScale() != ge::GRAPH_SUCCESS, + OPS_LOG_E(context_->GetNodeName(), "check output scale failed."), return ge::GRAPH_FAILED); int64_t xTotalNum = xShape_.GetShapeSize(); inDimy_ = xShape_.GetDim(xDimNum_ - 1); @@ -766,7 +766,7 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::GetShapeAttrsInfo() { isSpecialCoreCut_ = 1; } auto shapeY = context_->GetOutputShape(0); - OP_CHECK_NULL_WITH_CONTEXT(context_, shapeY); + OPS_LOG_E_IF_NULL(context_, shapeY, return ge::GRAPH_FAILED); const gert::Shape& outputShapeY = shapeY->GetStorageShape(); outDimy_ = outputShapeY.GetDim(xDimNum_ - 1); // 输出y的-1轴对应的shape return ge::GRAPH_SUCCESS; @@ -774,7 +774,7 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::GetShapeAttrsInfo() { bool DequantSwigluQuantV35DskTiling::IsCapable() { if (static_cast(activateDim_) != xDimNum_ - static_cast(1)) { - OP_LOGI(context_->GetNodeName(), "transform tiling template 2!"); + OPS_LOG_I(context_->GetNodeName(), "transform tiling template 2!"); return false; } return true; @@ -915,14 +915,14 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::DoOpTilingNotFull() { tilingData_.set_gluAlpha(gluAlpha_); tilingData_.set_gluBias(gluBias_); - OP_LOGI(context_->GetNodeName(), "inDimx is %ld, inDimy is %ld, outDimy is %ld, UbFactorDimx is %ld, UbFactorDimy is %ld, usedCoreNum is %ld, maxCoreNum is %ld, \ + OPS_LOG_I(context_->GetNodeName(), "inDimx is %ld, inDimy is %ld, outDimy is %ld, UbFactorDimx is %ld, UbFactorDimy is %ld, usedCoreNum is %ld, maxCoreNum is %ld, \ inGroupNum is %ld, quantMode is %ld, actRight is %ld, dstType is %ld, roundMode is %ld, activateDim is %ld, loopTimesPerRow is %ld, \ tailPerRow is %ld, swiGluMode is %ld, biasMode is %ld, groupIndexMode is %ld, quantIsOne is %ld, clampLimit is %f, gluAlpha is %f, gluBias is %f", \ tilingData_.get_inDimx(), tilingData_.get_inDimy(), tilingData_.get_outDimy(), tilingData_.get_UbFactorDimx(), tilingData_.get_UbFactorDimy(), \ tilingData_.get_usedCoreNum(), tilingData_.get_maxCoreNum(), tilingData_.get_inGroupNum(), tilingData_.get_quantMode(), tilingData_.get_actRight(), tilingData_.get_dstType(), \ tilingData_.get_roundMode(), tilingData_.get_activateDim(), tilingData_.get_loopTimesPerRow(), tilingData_.get_tailPerRow(), tilingData_.get_swiGluMode(), \ tilingData_.get_biasMode(), tilingData_.get_groupIndexMode(), tilingData_.get_quantIsOne(), tilingData_.get_clampLimit(), tilingData_.get_gluAlpha(), tilingData_.get_gluBias()); - OP_LOGI(context_->GetNodeName(), "tilingKey_ is %ld, speGroupType is %ld, isSpecialCoreCut is %ld", tilingKey_, speGroupType_, isSpecialCoreCut_); + OPS_LOG_I(context_->GetNodeName(), "tilingKey_ is %ld, speGroupType is %ld, isSpecialCoreCut is %ld", tilingKey_, speGroupType_, isSpecialCoreCut_); return ge::GRAPH_SUCCESS; } @@ -1004,14 +1004,14 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::DoOpTiling() { // ubFactorDimX: ub最多可以处理多少行数据 int64_t ubFactorDimx = ubAvailable / denominator; ubFactorDimx = std::min(ubFactorDimx, inDimx_); - OP_CHECK_IF(ubFactorDimx < 1, - OP_LOGE(context_->GetNodeName(), "x last dim:%ld is too large to full load", inDimy_), + OPS_CHECK(ubFactorDimx < 1, + OPS_LOG_E(context_->GetNodeName(), "x last dim:%ld is too large to full load", inDimy_), return ge::GRAPH_FAILED); maxPreCore_ = std::min(maxPreCore_, (inDimx_ + ubFactorDimx - 1) / ubFactorDimx); - OP_LOGI(context_->GetNodeName(), "start maxPreCore_ is %ld ", maxPreCore_); + OPS_LOG_I(context_->GetNodeName(), "start maxPreCore_ is %ld ", maxPreCore_); if (isSpecialCoreCut_ == static_cast(1)) { maxPreCore_ = std::min(static_cast(coreNum_), static_cast(inDimx_)); - OP_LOGI(context_->GetNodeName(), "after maxPreCore_ is %ld ", maxPreCore_); + OPS_LOG_I(context_->GetNodeName(), "after maxPreCore_ is %ld ", maxPreCore_); } auto quantScaleDesc = context_->GetOptionalInputDesc(QUANT_SCALE_INDEX); @@ -1051,14 +1051,14 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::DoOpTiling() { tilingData_.set_gluBias(gluBias_); tilingData_.set_speGroupType(speGroupType_); tilingData_.set_isSpecialCoreCut(isSpecialCoreCut_); - OP_LOGI(context_->GetNodeName(), "inDimx is %ld, inDimy is %ld, outDimy is %ld, UbFactorDimx is %ld, UbFactorDimy is %ld, usedCoreNum is %ld, maxCoreNum is %ld, \ + OPS_LOG_I(context_->GetNodeName(), "inDimx is %ld, inDimy is %ld, outDimy is %ld, UbFactorDimx is %ld, UbFactorDimy is %ld, usedCoreNum is %ld, maxCoreNum is %ld, \ inGroupNum is %ld, quantMode is %ld, actRight is %ld, dstType is %ld, roundMode is %ld, activateDim is %ld, swiGluMode is %ld, \ biasMode is %ld, groupIndexMode is %ld, biasMode is %ld, groupIndexMode is %ld, quantIsOne is %ld, clampLimit is %f, gluAlpha is %f, gluBias is %f", \ tilingData_.get_inDimx(), tilingData_.get_inDimy(), tilingData_.get_outDimy(), tilingData_.get_UbFactorDimx(), tilingData_.get_UbFactorDimy(), \ tilingData_.get_usedCoreNum(), tilingData_.get_maxCoreNum(), tilingData_.get_inGroupNum(), tilingData_.get_quantMode(), tilingData_.get_actRight(), tilingData_.get_dstType(), \ tilingData_.get_roundMode(), tilingData_.get_activateDim(), tilingData_.get_swiGluMode(), tilingData_.get_biasMode(), tilingData_.get_groupIndexMode(), \ tilingData_.get_biasMode(), tilingData_.get_groupIndexMode(), tilingData_.get_quantIsOne(), tilingData_.get_clampLimit(), tilingData_.get_gluAlpha(), tilingData_.get_gluBias()); - OP_LOGI(context_->GetNodeName(), "tilingKey_ is %ld, speGroupType is %ld, isSpecialCoreCut is %ld", tilingKey_, speGroupType_, isSpecialCoreCut_); + OPS_LOG_I(context_->GetNodeName(), "tilingKey_ is %ld, speGroupType is %ld, isSpecialCoreCut is %ld", tilingKey_, speGroupType_, isSpecialCoreCut_); return ge::GRAPH_SUCCESS; } @@ -1077,7 +1077,7 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::GetWorkspaceSize() { if (outDimy_ > Y_LAST_DIM_FULL_LOAD_MAX_VALUE && quantMode_ == 1) { usrSize = maxPreCore_ * outDimy_ * sizeof(float); } - OP_LOGI(context_->GetNodeName(), "usrSize is %u", usrSize); + OPS_LOG_I(context_->GetNodeName(), "usrSize is %u", usrSize); workspaceSize_ = SYS_WORK_SPACE_SIZE + usrSize; return ge::GRAPH_SUCCESS; } @@ -1086,9 +1086,9 @@ ge::graphStatus DequantSwigluQuantV35DskTiling::PostTiling() { context_->SetTilingKey(GetTilingKey()); context_->SetBlockDim(maxPreCore_); size_t* workspaces = context_->GetWorkspaceSizes(1); - OP_CHECK_NULL_WITH_CONTEXT(context_, workspaces); + OPS_LOG_E_IF_NULL(context_, workspaces, return ge::GRAPH_FAILED); workspaces[0] = workspaceSize_; - OP_LOGI(context_->GetNodeName(), "workspace is %lu, SetBlockDim is %ld", workspaceSize_, maxPreCore_); + OPS_LOG_I(context_->GetNodeName(), "workspace is %lu, SetBlockDim is %ld", workspaceSize_, maxPreCore_); tilingData_.SaveToBuffer(context_->GetRawTilingData()->GetData(), context_->GetRawTilingData()->GetCapacity()); context_->GetRawTilingData()->SetDataSize(tilingData_.GetDataSize()); return ge::GRAPH_SUCCESS; @@ -1099,7 +1099,7 @@ ge::graphStatus DequantSwigluQuantV35NlastTiling::GetPlatformInfo() auto platformInfo = context_->GetPlatformInfo(); if (platformInfo == nullptr) { auto compileInfoPtr = static_cast(context_->GetCompileInfo()); - OP_CHECK_IF(compileInfoPtr == nullptr, OP_LOGE(context_, "compile info is null"), + OPS_CHECK(compileInfoPtr == nullptr, OPS_LOG_E(context_, "compile info is null"), return ge::GRAPH_FAILED); coreNum_ = compileInfoPtr->coreNum; ubSize_ = compileInfoPtr->ubSize; @@ -1135,11 +1135,11 @@ void DequantSwigluQuantV35NlastTiling::FusedShape() ge::graphStatus DequantSwigluQuantV35NlastTiling::GetShapeAttrsInfo() { auto xStorageShape = context_->GetInputShape(X_INDEX); - OP_CHECK_NULL_WITH_CONTEXT(context_, xStorageShape); + OPS_LOG_E_IF_NULL(context_, xStorageShape, return ge::GRAPH_FAILED); xShape_ = EnsureNotScalar(xStorageShape->GetStorageShape()); auto* attrs = context_->GetAttrs(); - OP_CHECK_NULL_WITH_CONTEXT(context_, attrs); + OPS_LOG_E_IF_NULL(context_, attrs, return ge::GRAPH_FAILED); auto* attrActivateLeft = attrs->GetAttrPointer(ATTR_ACTIVATE_LEFT_INDEX); actRight_ = (attrActivateLeft == nullptr || *attrActivateLeft == false) ? 1 : 0; @@ -1238,7 +1238,7 @@ ge::graphStatus DequantSwigluQuantV35NlastTiling::DoOpTiling() { DoBlockSplit(); if (!DoUbSplit()) { - OP_LOGE(context_->GetNodeName(), "UB size cannot load last dim of input x, return failed."); + OPS_LOG_E(context_->GetNodeName(), "UB size cannot load last dim of input x, return failed."); return ge::GRAPH_FAILED; } int64_t ubLoopOfFormerBlock0 = (blockFormer0_ + ubFormer0_ - 1) / ubFormer0_; @@ -1304,9 +1304,9 @@ ge::graphStatus DequantSwigluQuantV35NlastTiling::PostTiling() { context_->SetTilingKey(GetTilingKey()); context_->SetBlockDim(blockNum_); size_t* workspaces = context_->GetWorkspaceSizes(1); - OP_CHECK_NULL_WITH_CONTEXT(context_, workspaces); + OPS_LOG_E_IF_NULL(context_, workspaces, return ge::GRAPH_FAILED); workspaces[0] = workspaceSize_; - OP_LOGI(context_->GetNodeName(), "SetBlockDim is %ld", blockNum_); + OPS_LOG_I(context_->GetNodeName(), "SetBlockDim is %ld", blockNum_); tilingData_.SaveToBuffer(context_->GetRawTilingData()->GetData(), context_->GetRawTilingData()->GetCapacity()); context_->GetRawTilingData()->SetDataSize(tilingData_.GetDataSize()); return ge::GRAPH_SUCCESS; diff --git a/xllm_ops/moe/dequant_swiglu_quant/op_host/dequant_swiglu_quant_tiling_base.cpp b/xllm_ops/moe/dequant_swiglu_quant/op_host/dequant_swiglu_quant_tiling_base.cpp index 612ff81..e67e72f 100644 --- a/xllm_ops/moe/dequant_swiglu_quant/op_host/dequant_swiglu_quant_tiling_base.cpp +++ b/xllm_ops/moe/dequant_swiglu_quant/op_host/dequant_swiglu_quant_tiling_base.cpp @@ -24,7 +24,7 @@ #define CHECK_FAIL(cont, cond, ...) \ do { \ if (cond) { \ - OP_LOGE(cont->GetNodeName(), ##__VA_ARGS__); \ + OPS_LOG_E(cont->GetNodeName(), ##__VA_ARGS__); \ return ge::GRAPH_FAILED; \ } \ } while (0) @@ -189,7 +189,7 @@ void DequantSwigluQuantTiling::Reset() ge::graphStatus DequantSwigluQuantTiling::GetPlatformInfo() { auto platformInfo = context_->GetPlatformInfo(); - OP_CHECK_IF(platformInfo == nullptr, OP_LOGE(opName, "fail to get platform info"), return ge::GRAPH_FAILED); + OPS_CHECK(platformInfo == nullptr, OPS_LOG_E(opName, "fail to get platform info"), return ge::GRAPH_FAILED); auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo); curShortSocName_ = ascendcPlatform.GetSocVersion(); totalCore = ascendcPlatform.GetCoreNumAiv(); @@ -228,18 +228,18 @@ ge::graphStatus DequantSwigluQuantTiling::checkWeightBiasActivate(gert::TilingCo auto biasShapeShapePtr = context->GetOptionalInputShape(3); if (biasShapeShapePtr != nullptr) { auto biasInputDesc = context->GetOptionalInputDesc(3); - OP_CHECK_NULL_WITH_CONTEXT(context, biasInputDesc); + OPS_LOG_E_IF_NULL(context, biasInputDesc, return ge::GRAPH_FAILED); biasDataType = biasInputDesc->GetDataType(); bool checkBiasRes = biasDataType != ge::DT_INT32 && biasDataType != ge::DT_FLOAT && biasDataType != ge::DT_FLOAT16 && biasDataType != ge::DT_BF16; - OP_CHECK_IF(checkBiasRes, + OPS_CHECK(checkBiasRes, OP_LOGE_FOR_INVALID_DTYPE(context->GetNodeName(), "bias", ge::TypeUtils::DataTypeToSerialString(biasDataType).c_str(), "int32, float, fp16 or bf16"), return ge::GRAPH_FAILED); uint64_t biasShapeSize = biasShapeShapePtr->GetStorageShape().GetShapeSize(); - OP_CHECK_IF(biasShapeSize != tilingData.get_colLen() * 2, + OPS_CHECK(biasShapeSize != tilingData.get_colLen() * 2, OP_LOGE_FOR_INVALID_SHAPESIZE(context->GetNodeName(), "bias", std::to_string(biasShapeSize).c_str(), (std::to_string(tilingData.get_colLen() * 2)).c_str()), @@ -248,18 +248,18 @@ ge::graphStatus DequantSwigluQuantTiling::checkWeightBiasActivate(gert::TilingCo tilingData.set_biasIsEmpty(biasShapeShapePtr == nullptr); // int32时 weight_scale为必选项 auto weightScaleShapePtr = context->GetOptionalInputShape(1); - OP_CHECK_NULL_WITH_CONTEXT(context, weightScaleShapePtr); + OPS_LOG_E_IF_NULL(context, weightScaleShapePtr, return ge::GRAPH_FAILED); auto weightScaleInputDesc = context->GetOptionalInputDesc(1); - OP_CHECK_NULL_WITH_CONTEXT(context, weightScaleInputDesc); + OPS_LOG_E_IF_NULL(context, weightScaleInputDesc, return ge::GRAPH_FAILED); ge::DataType weightScaleDataType = weightScaleInputDesc->GetDataType(); - OP_CHECK_IF(weightScaleDataType != ge::DT_FLOAT, + OPS_CHECK(weightScaleDataType != ge::DT_FLOAT, OP_LOGE_FOR_INVALID_DTYPE(context->GetNodeName(), "weight_scale", ge::TypeUtils::DataTypeToSerialString(weightScaleDataType).c_str(), "float32"), return ge::GRAPH_FAILED); uint64_t weightScaleShapeSize = weightScaleShapePtr->GetStorageShape().GetShapeSize(); - OP_CHECK_IF(weightScaleShapeSize != tilingData.get_colLen() * 2, + OPS_CHECK(weightScaleShapeSize != tilingData.get_colLen() * 2, OP_LOGE_FOR_INVALID_SHAPESIZES_WITH_REASON(context->GetNodeName(), "weight_scale", std::to_string(weightScaleShapeSize).c_str(), ("The shapesize of the weight scale is not equal to the last dimension of the xshape " @@ -270,15 +270,15 @@ ge::graphStatus DequantSwigluQuantTiling::checkWeightBiasActivate(gert::TilingCo auto activateScaleShapePtr = context->GetOptionalInputShape(2); if (activateScaleShapePtr != nullptr) { auto activateScaleInputDesc = context->GetOptionalInputDesc(2); - OP_CHECK_NULL_WITH_CONTEXT(context, activateScaleInputDesc); + OPS_LOG_E_IF_NULL(context, activateScaleInputDesc, return ge::GRAPH_FAILED); ge::DataType activateScaleDataType = activateScaleInputDesc->GetDataType(); - OP_CHECK_IF(activateScaleDataType != ge::DT_FLOAT, + OPS_CHECK(activateScaleDataType != ge::DT_FLOAT, OP_LOGE_FOR_INVALID_DTYPE(context->GetNodeName(), "activation_scale", ge::TypeUtils::DataTypeToSerialString(activateScaleDataType).c_str(), "float32"), return ge::GRAPH_FAILED); uint64_t activateScaleShapeSize = activateScaleShapePtr->GetStorageShape().GetShapeSize(); - OP_CHECK_IF(activateScaleShapeSize != tilingData.get_rowLen(), + OPS_CHECK(activateScaleShapeSize != tilingData.get_rowLen(), OP_LOGE_FOR_INVALID_SHAPESIZE(context->GetNodeName(), "activation_scale", std::to_string(activateScaleShapeSize).c_str(), ("equal to " + std::to_string(tilingData.get_rowLen())).c_str()), @@ -302,15 +302,15 @@ ge::graphStatus DequantSwigluQuantTiling::checkInputShape(gert::TilingContext* c return ge::GRAPH_SUCCESS; } auto quantScaleInputDesc = context->GetOptionalInputDesc(4); - OP_CHECK_NULL_WITH_CONTEXT(context, quantScaleInputDesc); + OPS_LOG_E_IF_NULL(context, quantScaleInputDesc, return ge::GRAPH_FAILED); ge::DataType quantScaleDataType = quantScaleInputDesc->GetDataType(); - OP_CHECK_IF(quantScaleDataType != ge::DT_FLOAT, + OPS_CHECK(quantScaleDataType != ge::DT_FLOAT, OP_LOGE_FOR_INVALID_DTYPE(context->GetNodeName(), "quant_scale", ge::TypeUtils::DataTypeToSerialString(quantScaleDataType).c_str(), "float32"), return ge::GRAPH_FAILED); quantScaleShapeSize = quantScaleShapePtr->GetStorageShape().GetShapeSize(); bool checkQuantScaleSize = (quantScaleShapeSize != tilingData.get_colLen()) && (quantScaleShapeSize != 1); - OP_CHECK_IF(checkQuantScaleSize, + OPS_CHECK(checkQuantScaleSize, OP_LOGE_FOR_INVALID_SHAPESIZE(context->GetNodeName(), "quant_scale", std::to_string(quantScaleShapeSize).c_str(), (std::to_string(tilingData.get_colLen()) + " or 1").c_str()), @@ -318,15 +318,15 @@ ge::graphStatus DequantSwigluQuantTiling::checkInputShape(gert::TilingContext* c if (quantMode == 0) { auto quantOffsetShapePtr = context->GetOptionalInputShape(5); auto quantOffsetInputDesc = context->GetOptionalInputDesc(5); - OP_CHECK_NULL_WITH_CONTEXT(context, quantOffsetInputDesc); + OPS_LOG_E_IF_NULL(context, quantOffsetInputDesc, return ge::GRAPH_FAILED); ge::DataType quantOffsetDataType = quantOffsetInputDesc->GetDataType(); - OP_CHECK_IF(quantOffsetDataType != ge::DT_FLOAT, + OPS_CHECK(quantOffsetDataType != ge::DT_FLOAT, OP_LOGE_FOR_INVALID_DTYPE(context->GetNodeName(), "quant_offset", ge::TypeUtils::DataTypeToSerialString(quantOffsetDataType).c_str(), "float32"), return ge::GRAPH_FAILED); uint64_t quantOffsetShapeSize = quantOffsetShapePtr->GetStorageShape().GetShapeSize(); bool checkQuantOffsetSize = (quantOffsetShapeSize != tilingData.get_colLen()) && (quantOffsetShapeSize != 1); - OP_CHECK_IF(checkQuantOffsetSize, + OPS_CHECK(checkQuantOffsetSize, OP_LOGE_FOR_INVALID_SHAPESIZE(context->GetNodeName(), "quant_offset", std::to_string(quantOffsetShapeSize).c_str(), (std::to_string(tilingData.get_colLen()) + " or 1").c_str()), @@ -397,11 +397,11 @@ bool DequantSwigluQuantTiling::CalcUbMaxTileLen(uint64_t ubSize, int32_t dtype, // get buffernum and maxTileLen uint64_t maxTileLenPerUB = 1; if (!GetBufferNumAndDataLenPerUB(ubSize, dtype, maxTileLenPerUB)) { - OP_LOGE("DequantSwigluQuant", "CalcTiling Get maxTileLenPerUB %lu failed", maxTileLenPerUB); + OPS_LOG_E("DequantSwigluQuant", "CalcTiling Get maxTileLenPerUB %lu failed", maxTileLenPerUB); return false; } optTiling.maxTileLen = AlignDown(maxTileLenPerUB, ALIGN_UINT_IN_CACHE_32B); // 32个元素对齐 - OP_LOGI("DequantSwigluQuant", "CalcTiling ubSize:%lu, maxTileLenPerUB:%u", ubSize, optTiling.maxTileLen); + OPS_LOG_I("DequantSwigluQuant", "CalcTiling ubSize:%lu, maxTileLenPerUB:%u", ubSize, optTiling.maxTileLen); return true; } @@ -429,7 +429,7 @@ void DequantSwigluQuantTiling::SaveOptBaseShape( std::min(static_cast(tilingData.get_rowLen()), static_cast(totalAvailableCore)); uint64_t baseSize = static_cast(baseRowLen_ * baseColLen_); if (static_cast(baseRowLen_) == 0 || static_cast(baseColLen_) == 0) { - OP_LOGI("SaveOptBaseShape", "baseRowLen_:%u or baseColLen:%u is zero.", baseRowLen_, baseColLen_); + OPS_LOG_I("SaveOptBaseShape", "baseRowLen_:%u or baseColLen:%u is zero.", baseRowLen_, baseColLen_); return; } uint64_t baseTileNum = (baseRowLen_ == 0 ? 0 : (tilingData.get_rowLen() / baseRowLen_)) * @@ -481,13 +481,13 @@ bool DequantSwigluQuantTiling::CalcTiling( { totalAvailableCore = totalCores; if (!GetLengthByType(xInputDataType, inputDTypeLen)) { - OP_LOGI("DequantSwigluQuant", "CalcTiling Unsupported input data type %d", xInputDataType); + OPS_LOG_I("DequantSwigluQuant", "CalcTiling Unsupported input data type %d", xInputDataType); return false; } ubMinBlockLen = ALIGN_UINT_IN_CACHE_32B / inputDTypeLen; // min block size cacheLineLen = PACK_UINT_IN_CACHE_512B / inputDTypeLen; // bandwidth max efficiency alignPackLen = cacheLineLen; // 默认512对齐,策略可调整 - OP_LOGI( + OPS_LOG_I( "DequantSwigluQuant", "CalcTiling GetLengthByType:%u ubMinBlockLen:%u cacheLineLen:%u alignPackLen:%u", inputDTypeLen, ubMinBlockLen, cacheLineLen, alignPackLen); // Is 32-byte aligned for split colLen? @@ -511,7 +511,7 @@ bool DequantSwigluQuantTiling::CalcTiling( tilingData.set_baseColLen(optTiling->optBaseColLen); totalUsedCoreNum = optTiling->totalUsedCoreNum; tilingData.set_usedCoreNum(totalUsedCoreNum); - OP_LOGI( + OPS_LOG_I( "DequantSwigluQuant", "CalcTilingRES baseRowLen:%u baseColLen:%u", optTiling->optBaseRowLen, optTiling->optBaseColLen); return true; @@ -527,10 +527,10 @@ ge::graphStatus DequantSwigluQuantTiling::GetShapeAttrsInfoInner() opName = context_->GetNodeName(); // 获取输入shape auto xShapePtr = context_->GetInputShape(0); - OP_CHECK_NULL_WITH_CONTEXT(context_, xShapePtr); + OPS_LOG_E_IF_NULL(context_, xShapePtr, return ge::GRAPH_FAILED); const gert::Shape xShape = xShapePtr->GetStorageShape(); auto inputDesc = context_->GetInputDesc(0); - OP_CHECK_NULL_WITH_CONTEXT(context_, inputDesc); + OPS_LOG_E_IF_NULL(context_, inputDesc, return ge::GRAPH_FAILED); xInputDataType = inputDesc->GetDataType(); if (SetTotalShape(context_, xShape) == ge::GRAPH_FAILED) { return ge::GRAPH_FAILED; @@ -538,7 +538,7 @@ ge::graphStatus DequantSwigluQuantTiling::GetShapeAttrsInfoInner() // 获取输入属性 const gert::RuntimeAttrs* attrs = context_->GetAttrs(); - OP_CHECK_NULL_WITH_CONTEXT(context_, attrs); + OPS_LOG_E_IF_NULL(context_, attrs, return ge::GRAPH_FAILED); if (!SetAttr(attrs)) { return ge::GRAPH_FAILED; @@ -549,7 +549,7 @@ ge::graphStatus DequantSwigluQuantTiling::GetShapeAttrsInfoInner() } auto yShapePtr = context_->GetOutputShape(0); - OP_CHECK_NULL_WITH_CONTEXT(context_, yShapePtr); + OPS_LOG_E_IF_NULL(context_, yShapePtr, return ge::GRAPH_FAILED); const gert::Shape yShape = yShapePtr->GetStorageShape(); int32_t dimNum = xShape.GetDimNum(); @@ -568,7 +568,7 @@ ge::graphStatus DequantSwigluQuantTiling::GetShapeAttrsInfoInner() } auto scaleShapePtr = context_->GetOutputShape(1); - OP_CHECK_NULL_WITH_CONTEXT(context_, scaleShapePtr); + OPS_LOG_E_IF_NULL(context_, scaleShapePtr, return ge::GRAPH_FAILED); const gert::Shape scaleShape = scaleShapePtr->GetStorageShape(); if (static_cast(scaleShape.GetShapeSize()) != tilingData.get_rowLen()) { @@ -719,7 +719,7 @@ ge::graphStatus DequantSwigluQuantTiling::PostTiling() context_->SetBlockDim(totalCore); size_t* currentWorkspace = context_->GetWorkspaceSizes(1); currentWorkspace[0] = workspaceSize_; - OP_CHECK_NULL_WITH_CONTEXT(context_, context_->GetRawTilingData()); + OPS_LOG_E_IF_NULL(context_, context_->GetRawTilingData(), return ge::GRAPH_FAILED); tilingData.SaveToBuffer(context_->GetRawTilingData()->GetData(), context_->GetRawTilingData()->GetCapacity()); context_->GetRawTilingData()->SetDataSize(tilingData.GetDataSize()); diff --git a/xllm_ops/moe/dequant_swiglu_quant/op_host/swi_glu_tiling.h b/xllm_ops/moe/dequant_swiglu_quant/op_host/swi_glu_tiling.h index 1bdedfe..7d1d505 100644 --- a/xllm_ops/moe/dequant_swiglu_quant/op_host/swi_glu_tiling.h +++ b/xllm_ops/moe/dequant_swiglu_quant/op_host/swi_glu_tiling.h @@ -18,7 +18,7 @@ #include #include "register/op_impl_registry.h" #include "util/math_util.h" -#include "log/log.h" +#include "log/ops_log.h" #include "tiling/platform/platform_ascendc.h" #include "platform/platform_infos_def.h" #include "register/tilingdata_base.h" diff --git a/xllm_ops/moe/dequant_swiglu_quant/tiling_base/error_log.h b/xllm_ops/moe/dequant_swiglu_quant/tiling_base/error_log.h index 1b09d20..f90fdab 100644 --- a/xllm_ops/moe/dequant_swiglu_quant/tiling_base/error_log.h +++ b/xllm_ops/moe/dequant_swiglu_quant/tiling_base/error_log.h @@ -10,54 +10,54 @@ #pragma once -#include "log/log.h" +#include "log/ops_log.h" #ifndef OP_LOGE_FOR_INVALID_DTYPE #define OP_LOGE_FOR_INVALID_DTYPE(opname, param, actual, expected) \ - OP_LOGE(opname, "Invalid dtype for %s, actual: %s, expected: %s", param, actual, expected) + OPS_LOG_E(opname, "Invalid dtype for %s, actual: %s, expected: %s", param, actual, expected) #endif #ifndef OP_LOGE_FOR_INVALID_DTYPES_WITH_REASON #define OP_LOGE_FOR_INVALID_DTYPES_WITH_REASON(opname, param, actual, reason) \ - OP_LOGE(opname, "Invalid dtype for %s, actual: %s, reason: %s", param, actual, reason) + OPS_LOG_E(opname, "Invalid dtype for %s, actual: %s, reason: %s", param, actual, reason) #endif #ifndef OP_LOGE_FOR_INVALID_SHAPE #define OP_LOGE_FOR_INVALID_SHAPE(opname, param, actual, expected) \ - OP_LOGE(opname, "Invalid shape for %s, actual: %s, expected: %s", param, actual, expected) + OPS_LOG_E(opname, "Invalid shape for %s, actual: %s, expected: %s", param, actual, expected) #endif #ifndef OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON #define OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(opname, param, actual, reason) \ - OP_LOGE(opname, "Invalid shape for %s, actual: %s, reason: %s", param, actual, reason) + OPS_LOG_E(opname, "Invalid shape for %s, actual: %s, reason: %s", param, actual, reason) #endif #ifndef OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON #define OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON(opname, param, actual, reason) \ - OP_LOGE(opname, "Invalid shapes for %s, actual: %s, reason: %s", param, actual, reason) + OPS_LOG_E(opname, "Invalid shapes for %s, actual: %s, reason: %s", param, actual, reason) #endif #ifndef OP_LOGE_FOR_INVALID_SHAPEDIM #define OP_LOGE_FOR_INVALID_SHAPEDIM(opname, param, actual, expected) \ - OP_LOGE(opname, "Invalid shape dim for %s, actual: %s, expected: %s", param, actual, expected) + OPS_LOG_E(opname, "Invalid shape dim for %s, actual: %s, expected: %s", param, actual, expected) #endif #ifndef OP_LOGE_FOR_INVALID_SHAPEDIMS_WITH_REASON #define OP_LOGE_FOR_INVALID_SHAPEDIMS_WITH_REASON(opname, param, actual, reason) \ - OP_LOGE(opname, "Invalid shape dims for %s, actual: %s, reason: %s", param, actual, reason) + OPS_LOG_E(opname, "Invalid shape dims for %s, actual: %s, reason: %s", param, actual, reason) #endif #ifndef OP_LOGE_FOR_INVALID_SHAPESIZE #define OP_LOGE_FOR_INVALID_SHAPESIZE(opname, param, actual, expected) \ - OP_LOGE(opname, "Invalid shape size for %s, actual: %s, expected: %s", param, actual, expected) + OPS_LOG_E(opname, "Invalid shape size for %s, actual: %s, expected: %s", param, actual, expected) #endif #ifndef OP_LOGE_FOR_INVALID_SHAPESIZES_WITH_REASON #define OP_LOGE_FOR_INVALID_SHAPESIZES_WITH_REASON(opname, param, actual, reason) \ - OP_LOGE(opname, "Invalid shape size for %s, actual: %s, reason: %s", param, actual, reason) + OPS_LOG_E(opname, "Invalid shape size for %s, actual: %s, reason: %s", param, actual, reason) #endif #ifndef OP_LOGE_FOR_INVALID_VALUE_WITH_REASON #define OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(opname, param, actual, reason) \ - OP_LOGE(opname, "Invalid value for %s, actual: %s, reason: %s", param, actual, reason) + OPS_LOG_E(opname, "Invalid value for %s, actual: %s, reason: %s", param, actual, reason) #endif diff --git a/xllm_ops/moe/dequant_swiglu_quant/tiling_base/tiling_base.h b/xllm_ops/moe/dequant_swiglu_quant/tiling_base/tiling_base.h index d6bc7e4..b8761eb 100644 --- a/xllm_ops/moe/dequant_swiglu_quant/tiling_base/tiling_base.h +++ b/xllm_ops/moe/dequant_swiglu_quant/tiling_base/tiling_base.h @@ -21,7 +21,7 @@ #include #include "tiling/platform/platform_ascendc.h" #include "platform/soc_spec.h" -#include "log/log.h" +#include "log/ops_log.h" #include "error_log.h" #ifdef ASCENDC_OP_TEST @@ -130,7 +130,7 @@ class TilingBaseClass // 8、Dump Tiling数据 virtual void DumpTilingInfo() { - int32_t enable = CheckLogLevel(static_cast(OP), DLOG_DEBUG); + int32_t enable = AlogCheckDebugLevel(static_cast(OP), DLOG_DEBUG); if (enable != 1) { return; } @@ -142,11 +142,11 @@ class TilingBaseClass for (size_t i = 0; i < bufLen / sizeof(uint32_t); i++) { oss << *(buf + i) << ","; if (oss.str().length() > 640) { // Split according to 640 to avoid truncation - OP_LOGD(context_, "%s", oss.str().c_str()); + OPS_LOG_D(context_, "%s", oss.str().c_str()); oss.str(""); } } - OP_LOGD(context_, "%s", oss.str().c_str()); + OPS_LOG_D(context_, "%s", oss.str().c_str()); } static uint32_t CalcTschBlockDim(uint32_t sliceNum, uint32_t aicCoreNum, uint32_t aivCoreNum) diff --git a/xllm_ops/moe/dequant_swiglu_quant/tiling_base/tiling_templates_registry.h b/xllm_ops/moe/dequant_swiglu_quant/tiling_base/tiling_templates_registry.h index aacd06f..9326faa 100644 --- a/xllm_ops/moe/dequant_swiglu_quant/tiling_base/tiling_templates_registry.h +++ b/xllm_ops/moe/dequant_swiglu_quant/tiling_base/tiling_templates_registry.h @@ -22,7 +22,7 @@ #include "exe_graph/runtime/tiling_context.h" #include "tiling_base.h" #include "static_register_symbol.h" -#include "log/log.h" +#include "log/ops_log.h" namespace Ops { namespace NN { @@ -45,12 +45,12 @@ class TilingCases template void AddTiling(int32_t priority) { - OP_CHECK_IF( - cases_.find(priority) != cases_.end(), OP_LOGE(op_type_, "There are duplicate registrations."), return); + OPS_CHECK( + cases_.find(priority) != cases_.end(), OPS_LOG_E(op_type_, "There are duplicate registrations."), return); cases_[priority] = TILING_CLASS; - OP_CHECK_IF( + OPS_CHECK( cases_[priority] == nullptr, - OP_LOGE(op_type_, "Register op tiling func failed, please check the class name."), return); + OPS_LOG_E(op_type_, "Register op tiling func failed, please check the class name."), return); } const std::map& GetTilingCases() @@ -91,8 +91,8 @@ class TilingRegistryArch { } } - OP_CHECK_IF(registryMap_[arch][opType] == nullptr, - OP_LOGE(opType, "Register tiling func failed, please check the class name."), return nullptr); + OPS_CHECK(registryMap_[arch][opType] == nullptr, + OPS_LOG_E(opType, "Register tiling func failed, please check the class name."), return nullptr); return registryMap_[arch][opType]; } @@ -102,14 +102,14 @@ class TilingRegistryArch { const char* opType = context->GetNodeType(); fe::PlatFormInfos* platformInfoPtr = context->GetPlatformInfo(); if (platformInfoPtr == nullptr) { - OP_LOGE(opType, "Do op tiling failed, cannot get platformInfo."); + OPS_LOG_E(opType, "Do op tiling failed, cannot get platformInfo."); return ge::GRAPH_FAILED; } else { auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfoPtr); arch = static_cast(ascendcPlatform.GetCurNpuArch()); - OP_LOGD(context, "npu arch is %d", arch); + OPS_LOG_D(context, "npu arch is %d", arch); if (arch == (int32_t)NpuArch::DAV_RESV) { - OP_LOGE(opType, "Do op tiling failed, cannot find npu arch."); + OPS_LOG_E(opType, "Do op tiling failed, cannot find npu arch."); return ge::GRAPH_FAILED; } } @@ -119,25 +119,25 @@ class TilingRegistryArch { if (tilingTemplate != nullptr) { ge::graphStatus status = tilingTemplate->DoTiling(); if (status != ge::GRAPH_PARAM_INVALID) { - OP_LOGD(context, "Do general op tiling success priority=%d", it->first); + OPS_LOG_D(context, "Do general op tiling success priority=%d", it->first); return status; } - OP_LOGD(context, "Ignore general op tiling priority=%d", it->first); + OPS_LOG_D(context, "Ignore general op tiling priority=%d", it->first); } } - OP_LOGE(opType, "Do op tiling failed, no valid template is found."); + OPS_LOG_E(opType, "Do op tiling failed, no valid template is found."); return ge::GRAPH_FAILED; } const std::map& GetTilingTemplates(const std::string& opType, int32_t arch) { auto archIter = registryMap_.find(arch); - OP_CHECK_IF(archIter == registryMap_.end(), - OP_LOGE(opType, "Get op tiling func failed, please check the npu arch %d", arch), + OPS_CHECK(archIter == registryMap_.end(), + OPS_LOG_E(opType, "Get op tiling func failed, please check the npu arch %d", arch), return emptyTilingCase_); auto opIter = archIter->second.find(opType); - OP_CHECK_IF( - opIter == archIter->second.end(), OP_LOGE(opType, "Get op tiling func failed, please check the op name."), + OPS_CHECK( + opIter == archIter->second.end(), OPS_LOG_E(opType, "Get op tiling func failed, please check the op name."), return emptyTilingCase_); return opIter->second->GetTilingCases(); } @@ -156,8 +156,8 @@ class RegisterArch { RegisterArch& tiling(int32_t priority, int32_t arch) { auto tilingCases = TilingRegistryArch::GetInstance().RegisterOp(opType_, arch); - OP_CHECK_IF( - tilingCases == nullptr, OP_LOGE(opType_, "Register op tiling failed, please check the op name."), + OPS_CHECK( + tilingCases == nullptr, OPS_LOG_E(opType_, "Register op tiling failed, please check the op name."), return *this); tilingCases->AddTiling(priority); return *this; @@ -168,8 +168,8 @@ class RegisterArch { { for (int32_t arch : archs) { auto tilingCases = TilingRegistryArch::GetInstance().RegisterOp(opType_, arch); - OP_CHECK_IF( - tilingCases == nullptr, OP_LOGE(opType_, "Register op tiling failed, please check the op name."), + OPS_CHECK( + tilingCases == nullptr, OPS_LOG_E(opType_, "Register op tiling failed, please check the op name."), return *this); tilingCases->AddTiling(priority); } @@ -209,9 +209,9 @@ class TilingRegistryNew } } - OP_CHECK_IF( + OPS_CHECK( registry_map_[soc_version][op_type] == nullptr, - OP_LOGE(op_type, "Register tiling func failed, please check the class name."), return nullptr); + OPS_LOG_E(op_type, "Register tiling func failed, please check the class name."), return nullptr); return registry_map_[soc_version][op_type]; } @@ -222,16 +222,16 @@ class TilingRegistryNew fe::PlatFormInfos* platformInfoPtr = context->GetPlatformInfo(); if (platformInfoPtr == nullptr) { auto compileInfoPtr = context->GetCompileInfo(); - OP_CHECK_IF( - compileInfoPtr == nullptr, OP_LOGE(op_type, "compileInfoPtr is null."), return ge::GRAPH_FAILED); + OPS_CHECK( + compileInfoPtr == nullptr, OPS_LOG_E(op_type, "compileInfoPtr is null."), return ge::GRAPH_FAILED); soc_version = compileInfoPtr->socVersion; - OP_LOGD(context, "soc version in compileInfo is %d", soc_version); + OPS_LOG_D(context, "soc version in compileInfo is %d", soc_version); } else { auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfoPtr); soc_version = static_cast(ascendcPlatform.GetSocVersion()); - OP_LOGD(context, "soc version is %d", soc_version); + OPS_LOG_D(context, "soc version is %d", soc_version); if (soc_version == (int32_t)platform_ascendc::SocVersion::RESERVED_VERSION) { - OP_LOGE(op_type, "Do op tiling failed, cannot find soc version."); + OPS_LOG_E(op_type, "Do op tiling failed, cannot find soc version."); return ge::GRAPH_FAILED; } } @@ -241,13 +241,13 @@ class TilingRegistryNew if (tilingTemplate != nullptr) { ge::graphStatus status = tilingTemplate->DoTiling(); if (status != ge::GRAPH_PARAM_INVALID) { - OP_LOGD(context, "Do general op tiling success priority=%d", it->first); + OPS_LOG_D(context, "Do general op tiling success priority=%d", it->first); return status; } - OP_LOGD(context, "Ignore general op tiling priority=%d", it->first); + OPS_LOG_D(context, "Ignore general op tiling priority=%d", it->first); } } - OP_LOGE(op_type, "Do op tiling failed, no valid template is found."); + OPS_LOG_E(op_type, "Do op tiling failed, no valid template is found."); return ge::GRAPH_FAILED; } @@ -258,14 +258,14 @@ class TilingRegistryNew auto platformInfoPtr = context->GetPlatformInfo(); if (platformInfoPtr == nullptr) { auto compileInfoPtr = context->GetCompileInfo(); - OP_CHECK_IF( - compileInfoPtr == nullptr, OP_LOGE(op_type, "compileInfoPtr is null."), return ge::GRAPH_FAILED); + OPS_CHECK( + compileInfoPtr == nullptr, OPS_LOG_E(op_type, "compileInfoPtr is null."), return ge::GRAPH_FAILED); soc_version = compileInfoPtr->socVersion; - OP_LOGD(context, "soc version in compileInfo is %d", soc_version); + OPS_LOG_D(context, "soc version in compileInfo is %d", soc_version); } else { auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfoPtr); soc_version = static_cast(ascendcPlatform.GetSocVersion()); - OP_LOGD(context, "soc version is %d", soc_version); + OPS_LOG_D(context, "soc version is %d", soc_version); } auto tilingTemplateRegistryMap = GetTilingTemplates(op_type, soc_version); @@ -276,10 +276,10 @@ class TilingRegistryNew if (templateFunc != nullptr) { ge::graphStatus status = templateFunc->DoTiling(); if (status == ge::GRAPH_SUCCESS) { - OP_LOGD(context, "Do general op tiling success priority=%d", priority_id); + OPS_LOG_D(context, "Do general op tiling success priority=%d", priority_id); return status; } - OP_LOGD(context, "Ignore general op tiling priority=%d", priority_id); + OPS_LOG_D(context, "Ignore general op tiling priority=%d", priority_id); } } } @@ -289,13 +289,13 @@ class TilingRegistryNew const std::map& GetTilingTemplates(const std::string& op_type, int32_t soc_version) { auto soc_iter = registry_map_.find(soc_version); - OP_CHECK_IF( + OPS_CHECK( soc_iter == registry_map_.end(), - OP_LOGE(op_type, "Get op tiling func failed, please check the soc version %d", soc_version), + OPS_LOG_E(op_type, "Get op tiling func failed, please check the soc version %d", soc_version), return empty_tiling_case_); auto op_iter = soc_iter->second.find(op_type); - OP_CHECK_IF( - op_iter == soc_iter->second.end(), OP_LOGE(op_type, "Get op tiling func failed, please check the op name."), + OPS_CHECK( + op_iter == soc_iter->second.end(), OPS_LOG_E(op_type, "Get op tiling func failed, please check the op name."), return empty_tiling_case_); return op_iter->second->GetTilingCases(); } @@ -315,8 +315,8 @@ class RegisterNew RegisterNew& tiling(int32_t priority, int32_t soc_version) { auto tilingCases = TilingRegistryNew::GetInstance().RegisterOp(op_type_, soc_version); - OP_CHECK_IF( - tilingCases == nullptr, OP_LOGE(op_type_, "Register op tiling failed, please the op name."), return *this); + OPS_CHECK( + tilingCases == nullptr, OPS_LOG_E(op_type_, "Register op tiling failed, please the op name."), return *this); tilingCases->AddTiling(priority); return *this; } @@ -326,8 +326,8 @@ class RegisterNew { for (int32_t soc_version : soc_versions) { auto tilingCases = TilingRegistryNew::GetInstance().RegisterOp(op_type_, soc_version); - OP_CHECK_IF( - tilingCases == nullptr, OP_LOGE(op_type_, "Register op tiling failed, please the op name."), + OPS_CHECK( + tilingCases == nullptr, OPS_LOG_E(op_type_, "Register op tiling failed, please the op name."), return *this); tilingCases->AddTiling(priority); } @@ -359,9 +359,9 @@ class TilingRegistry if (registry_map_.find(op_type) == registry_map_.end()) { registry_map_[op_type] = std::shared_ptr(new (std::nothrow) TilingCases(op_type)); } - OP_CHECK_IF( + OPS_CHECK( registry_map_[op_type] == nullptr, - OP_LOGE(op_type, "Register tiling func failed, please check the class name."), return nullptr); + OPS_LOG_E(op_type, "Register tiling func failed, please check the class name."), return nullptr); return registry_map_[op_type]; } @@ -374,13 +374,13 @@ class TilingRegistry if (tilingTemplate != nullptr) { ge::graphStatus status = tilingTemplate->DoTiling(); if (status != ge::GRAPH_PARAM_INVALID) { - OP_LOGD(context, "Do general op tiling success priority=%d", it->first); + OPS_LOG_D(context, "Do general op tiling success priority=%d", it->first); return status; } - OP_LOGD(context, "Ignore general op tiling priority=%d", it->first); + OPS_LOG_D(context, "Ignore general op tiling priority=%d", it->first); } } - OP_LOGE(op_type, "Do op tiling failed, no valid template is found."); + OPS_LOG_E(op_type, "Do op tiling failed, no valid template is found."); return ge::GRAPH_FAILED; } @@ -393,25 +393,25 @@ class TilingRegistry if (templateFunc != nullptr) { ge::graphStatus status = templateFunc->DoTiling(); if (status == ge::GRAPH_SUCCESS) { - OP_LOGD(context, "Do general op tiling success priority=%d", priorityId); + OPS_LOG_D(context, "Do general op tiling success priority=%d", priorityId); return status; } if (status != ge::GRAPH_PARAM_INVALID) { - OP_LOGD(context, "Do op tiling failed"); + OPS_LOG_D(context, "Do op tiling failed"); return status; } - OP_LOGD(context, "Ignore general op tiling priority=%d", priorityId); + OPS_LOG_D(context, "Ignore general op tiling priority=%d", priorityId); } } - OP_LOGE(op_type, "Do op tiling failed, no valid template is found."); + OPS_LOG_E(op_type, "Do op tiling failed, no valid template is found."); return ge::GRAPH_FAILED; } const std::map& GetTilingTemplates(const std::string& op_type) { - OP_CHECK_IF( + OPS_CHECK( registry_map_.find(op_type) == registry_map_.end(), - OP_LOGE(op_type, "Get op tiling func failed, please check the op name."), return empty_tiling_case_); + OPS_LOG_E(op_type, "Get op tiling func failed, please check the op name."), return empty_tiling_case_); return registry_map_[op_type]->GetTilingCases(); } @@ -430,8 +430,8 @@ class Register Register& tiling(int32_t priority) { auto tilingCases = TilingRegistry::GetInstance().RegisterOp(op_type_); - OP_CHECK_IF( - tilingCases == nullptr, OP_LOGE(op_type_, "Register op tiling failed, please the op name."), return *this); + OPS_CHECK( + tilingCases == nullptr, OPS_LOG_E(op_type_, "Register op tiling failed, please the op name."), return *this); tilingCases->AddTiling(priority); return *this; } diff --git a/xllm_ops/moe/dequant_swiglu_quant/tiling_base/tiling_util.h b/xllm_ops/moe/dequant_swiglu_quant/tiling_base/tiling_util.h index d72b6cf..4bee666 100644 --- a/xllm_ops/moe/dequant_swiglu_quant/tiling_base/tiling_util.h +++ b/xllm_ops/moe/dequant_swiglu_quant/tiling_base/tiling_util.h @@ -18,7 +18,7 @@ #include "register/op_impl_registry.h" #include "platform/platform_ascendc.h" #include "platform/soc_spec.h" -#include "log/log.h" +#include "log/ops_log.h" namespace Ops { namespace NN { @@ -37,7 +37,7 @@ static inline bool IsRegbaseSocVersion(const gert::TilingParseContext* context) { auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo()); auto npuArch = ascendcPlatform.GetCurNpuArch(); - OP_LOGI(context, "Current NpuArch is %u", static_cast(npuArch)); + OPS_LOG_I(context, "Current NpuArch is %u", static_cast(npuArch)); return IsRegbaseNpuArch(npuArch); } @@ -45,7 +45,7 @@ static inline bool IsRegbaseSocVersion(const gert::TilingContext* context) { auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo()); auto npuArch = ascendcPlatform.GetCurNpuArch(); - OP_LOGI(context, "Current NpuArch is %u", static_cast(npuArch)); + OPS_LOG_I(context, "Current NpuArch is %u", static_cast(npuArch)); return IsRegbaseNpuArch(npuArch); } diff --git a/xllm_ops/moe/moe_gating_top_k/tiling_base/tiling_base.h b/xllm_ops/moe/moe_gating_top_k/tiling_base/tiling_base.h index f0bbbdc..9c52789 100644 --- a/xllm_ops/moe/moe_gating_top_k/tiling_base/tiling_base.h +++ b/xllm_ops/moe/moe_gating_top_k/tiling_base/tiling_base.h @@ -20,6 +20,7 @@ #include #include "tiling/platform/platform_ascendc.h" #include "error_log.h" +#include "log/ops_log.h" #ifdef ASCENDC_OP_TEST #define ASCENDC_EXTERN_C extern "C" @@ -152,7 +153,7 @@ class TilingBaseClass { // 8. Dump Tiling data virtual void DumpTilingInfo() { - int32_t enable = CheckLogLevel(static_cast(OP), DLOG_DEBUG); + int32_t enable = AlogCheckDebugLevel(static_cast(OP), DLOG_DEBUG); if (enable != 1) { return; } @@ -164,11 +165,11 @@ class TilingBaseClass { for (size_t i = 0; i < bufLen / sizeof(uint32_t); i++) { oss << *(buf + i) << ","; if (oss.str().length() > 640) { // Split according to 640 to avoid truncation - OP_LOGD(context_, "%s", oss.str().c_str()); + OPS_LOG_D(context_, "%s", oss.str().c_str()); oss.str(""); } } - OP_LOGD(context_, "%s", oss.str().c_str()); + OPS_LOG_D(context_, "%s", oss.str().c_str()); } static uint32_t CalcTschBlockDim(uint32_t sliceNum, uint32_t aicCoreNum, uint32_t aivCoreNum) @@ -253,4 +254,4 @@ class TilingBaseClass { } // namespace OpTiling } // namespace Transformer -} // namespace Ops \ No newline at end of file +} // namespace Ops diff --git a/xllm_ops/moe/scatter_nd_update_v2/op_host/scatter_nd_update_infershape.cpp b/xllm_ops/moe/scatter_nd_update_v2/op_host/scatter_nd_update_infershape.cpp index 51fec7c..979e3b0 100644 --- a/xllm_ops/moe/scatter_nd_update_v2/op_host/scatter_nd_update_infershape.cpp +++ b/xllm_ops/moe/scatter_nd_update_v2/op_host/scatter_nd_update_infershape.cpp @@ -13,34 +13,34 @@ * \brief */ #include "register/op_impl_registry.h" -#include "log/log.h" +#include "log/ops_log.h" #include "util/shape_util.h" using namespace ge; namespace ops { static graphStatus InferDataType4ScatterNdUpdateV2(gert::InferDataTypeContext* context) { - OP_LOGD(context->GetNodeName(), "Begin to do ScatterNdUpdateV2InferDtype."); + OPS_LOG_D(context->GetNodeName(), "Begin to do ScatterNdUpdateV2InferDtype."); auto var_dtype = context->GetInputDataType(0); context->SetOutputDataType(0, var_dtype); - OP_LOGD(context->GetNodeName(), "End to do ScatterNdUpdateV2InferDtype."); + OPS_LOG_D(context->GetNodeName(), "End to do ScatterNdUpdateV2InferDtype."); return GRAPH_SUCCESS; } static ge::graphStatus InferShape4ScatterNdUpdateV2(gert::InferShapeContext* context) { - OP_LOGD(context->GetNodeName(), "Begin to do ScatterNdUpdateV2InferShape."); + OPS_LOG_D(context->GetNodeName(), "Begin to do ScatterNdUpdateV2InferShape."); const gert::Shape* var_in_shape = context->GetInputShape(0); gert::Shape* var_out_shape = context->GetOutputShape(0); - OP_CHECK_NULL_WITH_CONTEXT(context, var_in_shape); - OP_CHECK_NULL_WITH_CONTEXT(context, var_out_shape); + OPS_LOG_E_IF_NULL(context, var_in_shape, return ge::GRAPH_FAILED); + OPS_LOG_E_IF_NULL(context, var_out_shape, return ge::GRAPH_FAILED); if (Ops::Base::IsUnknownRank(*var_in_shape)) { - OP_LOGD(context->GetNodeName(), "input shape is UnknownRank, set output shape to (-2, )"); + OPS_LOG_D(context->GetNodeName(), "input shape is UnknownRank, set output shape to (-2, )"); Ops::Base::SetUnknownRank(*var_out_shape); return ge::GRAPH_SUCCESS; } *var_out_shape = *var_in_shape; - OP_LOGD(context->GetNodeName(), "End to do ScatterNdUpdateV2InferShape."); + OPS_LOG_D(context->GetNodeName(), "End to do ScatterNdUpdateV2InferShape."); return ge::GRAPH_SUCCESS; } diff --git a/xllm_ops/moe/scatter_nd_update_v2/op_host/scatter_nd_update_v2_tiling.cpp b/xllm_ops/moe/scatter_nd_update_v2/op_host/scatter_nd_update_v2_tiling.cpp index 6a9a652..78a3369 100644 --- a/xllm_ops/moe/scatter_nd_update_v2/op_host/scatter_nd_update_v2_tiling.cpp +++ b/xllm_ops/moe/scatter_nd_update_v2/op_host/scatter_nd_update_v2_tiling.cpp @@ -16,7 +16,7 @@ #include "register/op_impl_registry.h" #include "util/math_util.h" #include "platform/platform_infos_def.h" -#include "log/log.h" +#include "log/ops_log.h" #include "tiling/platform/platform_ascendc.h" #include "tiling_base/tiling_util.h" #include "tiling_base/tiling_key.h" @@ -105,7 +105,7 @@ inline void ScatterNdUpdateV2Tiling::SetTilingKeyMode() tilingKey_ = indexType * 10 + sortFlag; tilingContext_->SetTilingKey(tilingKey_); - OP_LOGD(tilingContext_, "isLinearIndex=%lu, isSort=%lu, isInt64Indices=%lu, needLargeIndexKernel=%lu, tilingKey=%lu (indexType=%lu, sortFlag=%lu)", + OPS_LOG_D(tilingContext_, "isLinearIndex=%lu, isSort=%lu, isInt64Indices=%lu, needLargeIndexKernel=%lu, tilingKey=%lu (indexType=%lu, sortFlag=%lu)", isLinearIndex_, isSort_, isInt64Indices_, needLargeIndexKernel_, tilingKey_, indexType, sortFlag); } @@ -121,7 +121,7 @@ inline bool ScatterNdUpdateV2Tiling::IsSort(uint64_t totalLength, uint64_t index inline void ScatterNdUpdateV2Tiling::Tiling4LinearIndex(uint64_t indexRow, uint64_t indexDim) { - OP_LOGD(tilingContext_, "linearIndexTiling start"); + OPS_LOG_D(tilingContext_, "linearIndexTiling start"); auto attrs = tilingContext_->GetAttrs(); auto stridesPtr = attrs->GetListInt(ATTR_STRIDE); for (uint64_t i = 0; i < indexDim; ++i) { @@ -145,12 +145,12 @@ inline void ScatterNdUpdateV2Tiling::Tiling4LinearIndex(uint64_t indexRow, uint6 frontCoreNum_ = blockNum_ % coreNum_; tailCoreNum_ = tailBlockNum_ == 0 ? 0 : coreNum_ - frontCoreNum_; } - OP_LOGD(tilingContext_, "linearIndexTiling finish"); + OPS_LOG_D(tilingContext_, "linearIndexTiling finish"); } inline void ScatterNdUpdateV2Tiling::Tiling4Scatter(uint64_t totalLength, uint64_t indexRow) { - OP_LOGD(tilingContext_, "scatterTiling start new"); + OPS_LOG_D(tilingContext_, "scatterTiling start new"); uint64_t scatterAlignNum = ALIGNED_SIZE / dataTypeSize_; tailRow_ = totalLength / coreNum_; frontRow_ = tailRow_ + 1; @@ -173,7 +173,7 @@ inline void ScatterNdUpdateV2Tiling::Tiling4Scatter(uint64_t totalLength, uint64 } else { copyRow_ = formDim_ == 0 ? ubLengthForUpdates_ / scatterAlignLength_ : 1; } - OP_LOGD(tilingContext_, "scatterTiling finish"); + OPS_LOG_D(tilingContext_, "scatterTiling finish"); } inline void ScatterNdUpdateV2Tiling::GetDtypeSize() @@ -265,43 +265,43 @@ inline size_t ScatterNdUpdateV2Tiling::CalcWorkSpaceSize(uint64_t indexRow) void ScatterNdUpdateV2Tiling::TilingDataPrint() const { - OP_LOGD(tilingContext_, "coreNum: %lu", coreNum_); - OP_LOGD(tilingContext_, "tilingKey: %lu", tilingKey_); - OP_LOGD(tilingContext_, "isInt64Indices: %lu", isInt64Indices_); - OP_LOGD(tilingContext_, "needLargeIndexKernel: %lu", needLargeIndexKernel_); - OP_LOGD(tilingContext_, "tiling for LinearIndex--------"); - OP_LOGD(tilingContext_, "indexDim: %lu", indexDim_); - OP_LOGD(tilingContext_, "ubSize: %lu", ubSize_); - OP_LOGD(tilingContext_, "blockLength: %lu", blockLength_); - OP_LOGD(tilingContext_, "blockNum: %lu", blockNum_); - OP_LOGD(tilingContext_, "blockRemainLength: %lu", blockRemainLength_); - OP_LOGD(tilingContext_, "tailBlockNum: %lu", tailBlockNum_); - OP_LOGD(tilingContext_, "frontBlockNum: %lu", frontBlockNum_); - OP_LOGD(tilingContext_, "frontCoreNum: %lu", frontCoreNum_); - OP_LOGD(tilingContext_, "tailCoreNum: %lu", tailCoreNum_); - OP_LOGD(tilingContext_, "sortWorkspace: %lu", sortWorkspace_); + OPS_LOG_D(tilingContext_, "coreNum: %lu", coreNum_); + OPS_LOG_D(tilingContext_, "tilingKey: %lu", tilingKey_); + OPS_LOG_D(tilingContext_, "isInt64Indices: %lu", isInt64Indices_); + OPS_LOG_D(tilingContext_, "needLargeIndexKernel: %lu", needLargeIndexKernel_); + OPS_LOG_D(tilingContext_, "tiling for LinearIndex--------"); + OPS_LOG_D(tilingContext_, "indexDim: %lu", indexDim_); + OPS_LOG_D(tilingContext_, "ubSize: %lu", ubSize_); + OPS_LOG_D(tilingContext_, "blockLength: %lu", blockLength_); + OPS_LOG_D(tilingContext_, "blockNum: %lu", blockNum_); + OPS_LOG_D(tilingContext_, "blockRemainLength: %lu", blockRemainLength_); + OPS_LOG_D(tilingContext_, "tailBlockNum: %lu", tailBlockNum_); + OPS_LOG_D(tilingContext_, "frontBlockNum: %lu", frontBlockNum_); + OPS_LOG_D(tilingContext_, "frontCoreNum: %lu", frontCoreNum_); + OPS_LOG_D(tilingContext_, "tailCoreNum: %lu", tailCoreNum_); + OPS_LOG_D(tilingContext_, "sortWorkspace: %lu", sortWorkspace_); for (size_t i = 0; i < indexDim_; i++) { - OP_LOGD(tilingContext_, "indicesMask[%lu]: %lu", i, indicesMask_[i]); + OPS_LOG_D(tilingContext_, "indicesMask[%lu]: %lu", i, indicesMask_[i]); } - OP_LOGD(tilingContext_, "tiling for Scatter------------"); - OP_LOGD(tilingContext_, "scatterLength: %lu", scatterLength_); - OP_LOGD(tilingContext_, "tailRow: %lu", tailRow_); - OP_LOGD(tilingContext_, "frontRow: %lu", frontRow_); - OP_LOGD(tilingContext_, "frontNum: %lu", frontNum_); - OP_LOGD(tilingContext_, "tailNum: %lu", tailNum_); - OP_LOGD(tilingContext_, "ubLengthForUpdates: %lu", ubLengthForUpdates_); - OP_LOGD(tilingContext_, "scatterAlignLength: %lu", scatterAlignLength_); - OP_LOGD(tilingContext_, "formDim: %lu", formDim_); - OP_LOGD(tilingContext_, "copyRow: %lu", copyRow_); - OP_LOGD(tilingContext_, "scatterTileNum: %lu", scatterTileNum_); - OP_LOGD(tilingContext_, "scatterTileLength: %lu", scatterTileLength_); - OP_LOGD(tilingContext_, "scatterTileTail: %lu", scatterTileTail_); - OP_LOGD(tilingContext_, "scatterTileAlignLength: %lu", scatterTileAlignLength_); + OPS_LOG_D(tilingContext_, "tiling for Scatter------------"); + OPS_LOG_D(tilingContext_, "scatterLength: %lu", scatterLength_); + OPS_LOG_D(tilingContext_, "tailRow: %lu", tailRow_); + OPS_LOG_D(tilingContext_, "frontRow: %lu", frontRow_); + OPS_LOG_D(tilingContext_, "frontNum: %lu", frontNum_); + OPS_LOG_D(tilingContext_, "tailNum: %lu", tailNum_); + OPS_LOG_D(tilingContext_, "ubLengthForUpdates: %lu", ubLengthForUpdates_); + OPS_LOG_D(tilingContext_, "scatterAlignLength: %lu", scatterAlignLength_); + OPS_LOG_D(tilingContext_, "formDim: %lu", formDim_); + OPS_LOG_D(tilingContext_, "copyRow: %lu", copyRow_); + OPS_LOG_D(tilingContext_, "scatterTileNum: %lu", scatterTileNum_); + OPS_LOG_D(tilingContext_, "scatterTileLength: %lu", scatterTileLength_); + OPS_LOG_D(tilingContext_, "scatterTileTail: %lu", scatterTileTail_); + OPS_LOG_D(tilingContext_, "scatterTileAlignLength: %lu", scatterTileAlignLength_); } ge::graphStatus ScatterNdUpdateV2Tiling::Init() { - OP_LOGD(tilingContext_, "Tiling initing"); + OPS_LOG_D(tilingContext_, "Tiling initing"); auto compileInfo = static_cast(tilingContext_->GetCompileInfo()); auto varRefShape = tilingContext_->GetInputShape(0)->GetStorageShape(); auto indicesShape = tilingContext_->GetInputShape(1)->GetStorageShape(); @@ -311,7 +311,7 @@ ge::graphStatus ScatterNdUpdateV2Tiling::Init() auto indicesDtype = tilingContext_->GetInputDesc(1)->GetDataType(); isInt64Indices_ = (indicesDtype == ge::DT_INT64); - OP_LOGD(tilingContext_, "indicesDtype=%d, isInt64Indices=%lu", indicesDtype, isInt64Indices_); + OPS_LOG_D(tilingContext_, "indicesDtype=%d, isInt64Indices=%lu", indicesDtype, isInt64Indices_); uint64_t totalLength = 1; for (uint64_t i = 0; i < indexDim_; ++i) { @@ -355,44 +355,44 @@ ge::graphStatus ScatterNdUpdateV2Tiling::Init() Tiling4Scatter(totalPhysicalRange, indexRow); size_t* currentWorkSpace = tilingContext_->GetWorkspaceSizes(1); currentWorkSpace[0] = CalcWorkSpaceSize(indexRow); - OP_LOGD(tilingContext_, "Tiling inited"); + OPS_LOG_D(tilingContext_, "Tiling inited"); return ge::GRAPH_SUCCESS; } ge::graphStatus Tiling4ScatterNdUpdateV2(gert::TilingContext* context) { if (context == nullptr) { - OP_LOGE("ScatterNdUpdateV2", "The context is nullptr."); + OPS_LOG_E("ScatterNdUpdateV2", "The context is nullptr."); return ge::GRAPH_FAILED; } - OP_LOGD(context, "Tiling for ScatterNdUpdateV2 start."); + OPS_LOG_D(context, "Tiling for ScatterNdUpdateV2 start."); ScatterNdUpdateV2Tiling tilingOp(context); if (tilingOp.Init() != ge::GRAPH_SUCCESS) { - OP_LOGE(context, "Tiling init fail"); + OPS_LOG_E(context, "Tiling init fail"); return ge::GRAPH_FAILED; } - OP_LOGD(context, "Tiling for ScatterNdUpdateV2 end."); + OPS_LOG_D(context, "Tiling for ScatterNdUpdateV2 end."); return tilingOp.SetKernelTiling(); } ge::graphStatus TilingPrepare4ScatterNdUpdateV2(gert::TilingParseContext* context) { - OP_LOGD(context, "Tiling Prepare For ScatterNdUpdateV2 start."); + OPS_LOG_D(context, "Tiling Prepare For ScatterNdUpdateV2 start."); auto compileInfo = context->GetCompiledInfo(); - OP_CHECK_NULL_WITH_CONTEXT(context, compileInfo); + OPS_LOG_E_IF_NULL(context, compileInfo, return ge::GRAPH_FAILED); auto platformInfo = context->GetPlatformInfo(); - OP_CHECK_NULL_WITH_CONTEXT(context, platformInfo); + OPS_LOG_E_IF_NULL(context, platformInfo, return ge::GRAPH_FAILED); auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo); compileInfo->totalCoreNum = ascendcPlatform.GetCoreNumAiv(); if (compileInfo->totalCoreNum == 0) { - OP_LOGE(context, "coreNum %lu", compileInfo->totalCoreNum); + OPS_LOG_E(context, "coreNum %lu", compileInfo->totalCoreNum); return ge::GRAPH_FAILED; } uint64_t ubSizePlatForm; ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSizePlatForm); compileInfo->ubSizePlatForm = ubSizePlatForm; - OP_LOGD(context, "ubSizePlatForm is %lu.", compileInfo->ubSizePlatForm); - OP_LOGD(context, "Tiling Prepare For ScatterNdUpdateV2 end."); + OPS_LOG_D(context, "ubSizePlatForm is %lu.", compileInfo->ubSizePlatForm); + OPS_LOG_D(context, "Tiling Prepare For ScatterNdUpdateV2 end."); return ge::GRAPH_SUCCESS; } diff --git a/xllm_ops/recurrent_gated_delta_rule/op_host/tiling_base.h b/xllm_ops/recurrent_gated_delta_rule/op_host/tiling_base.h index 72de89d..9f5cfa4 100644 --- a/xllm_ops/recurrent_gated_delta_rule/op_host/tiling_base.h +++ b/xllm_ops/recurrent_gated_delta_rule/op_host/tiling_base.h @@ -20,6 +20,7 @@ #include #include "tiling/platform/platform_ascendc.h" #include "tiling_base/error_log.h" +#include "log/ops_log.h" #ifdef ASCENDC_OP_TEST #define ASCENDC_EXTERN_C extern "C" @@ -152,7 +153,7 @@ class TilingBaseClass { // 8. Dump Tiling data virtual void DumpTilingInfo() { - int32_t enable = CheckLogLevel(static_cast(OP), DLOG_DEBUG); + int32_t enable = AlogCheckDebugLevel(static_cast(OP), DLOG_DEBUG); if (enable != 1) { return; } @@ -164,11 +165,11 @@ class TilingBaseClass { for (size_t i = 0; i < bufLen / sizeof(uint32_t); i++) { oss << *(buf + i) << ","; if (oss.str().length() > 640) { // Split according to 640 to avoid truncation - OP_LOGD(context_, "%s", oss.str().c_str()); + OPS_LOG_D(context_, "%s", oss.str().c_str()); oss.str(""); } } - OP_LOGD(context_, "%s", oss.str().c_str()); + OPS_LOG_D(context_, "%s", oss.str().c_str()); } static uint32_t CalcTschBlockDim(uint32_t sliceNum, uint32_t aicCoreNum, uint32_t aivCoreNum) @@ -253,4 +254,4 @@ class TilingBaseClass { } // namespace OpTiling } // namespace Transformer -} // namespace Ops \ No newline at end of file +} // namespace Ops