Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions cmake/obj_func.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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=$<IF:$<BOOL:${BUILD_OPEN_PROJECT}>,"[Custom]","">
LOG_CPP
)

if(BUILD_WITH_INSTALLED_DEPENDENCY_CANN_PKG)
target_compile_options(
Expand Down Expand Up @@ -838,4 +842,4 @@ macro(add_onnx_plugin_sources)
else()
message(WARNING "No onnx plugin source files found in ${SOURCE_DIR}")
endif()
endmacro()
endmacro()
1 change: 1 addition & 0 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ if (BUILD_OPEN_PROJECT)
target_link_libraries(${COMMON_NAME}_obj
PRIVATE
$<BUILD_INTERFACE:intf_pub_cxx17>
$<BUILD_INTERFACE:ops_xllm_utils_tiling_headers>
tiling_api
dlog
)
Expand Down
30 changes: 0 additions & 30 deletions common/include/cann_compat.h

This file was deleted.

11 changes: 2 additions & 9 deletions common/include/err/ops_err.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
#endif // Xllm_COMMON_OPS_ERR_H
62 changes: 31 additions & 31 deletions common/include/fallback/fallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -89,15 +89,15 @@ 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;
}

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;
}
Expand All @@ -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;
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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<void*>(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();
Expand All @@ -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<const gert::Tensor*>& 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<aclTensor*> tmp;
for (size_t i = 0; i < ge_tenserList.size(); i++) {
Expand All @@ -243,8 +243,8 @@ inline aclTensorList* ConvertType(std::vector<const gert::Tensor*>& ge_tenserLis
template <typename T>
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);
}
Expand All @@ -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<void*>(ge_tensor->GetAddr());
// convert data type
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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; \
Expand All @@ -461,15 +461,15 @@ 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; \
} \
void* workspace_addr = nullptr; \
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; \
} \
Expand All @@ -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; \
Expand Down
16 changes: 8 additions & 8 deletions common/include/fallback/fallback_2stages.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -34,35 +34,35 @@ using namespace ge;
inline void Collect(aclTensor *p, std::vector<OpApiAnyValue> &params) {
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<aclTensor *>(param));}});
}

inline void Collect(aclScalar *p, std::vector<OpApiAnyValue> &params) {
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<aclScalar *>(param));}});
}

inline void Collect(aclIntArray *p, std::vector<OpApiAnyValue> &params) {
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<aclIntArray *>(param));}});
}

inline void Collect(aclBoolArray *p, std::vector<OpApiAnyValue> &params) {
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<aclBoolArray *>(param));}});
}

inline void Collect(aclTensorList *p, std::vector<OpApiAnyValue> &params) {
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<aclTensorList *>(param));}});
}

Expand Down Expand Up @@ -91,7 +91,7 @@ void CollectConvertedTypes(Tuple &t, std::vector<OpApiAnyValue> &params) {
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; \
Expand All @@ -112,7 +112,7 @@ void CollectConvertedTypes(Tuple &t, std::vector<OpApiAnyValue> &params) {
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; \
} \
Expand Down
6 changes: 3 additions & 3 deletions common/include/framework/onnx_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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;
}
}
Expand Down
Loading