|
|
|
@ -19,15 +19,12 @@
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
#include "cce/cce_def.hpp"
|
|
|
|
|
#include "runtime/rt.h"
|
|
|
|
|
#include "common/string_util.h"
|
|
|
|
|
#include "common/util.h"
|
|
|
|
|
#include "framework/common/debug/ge_log.h"
|
|
|
|
|
#include "ge/ge_api_error_codes.h"
|
|
|
|
|
|
|
|
|
|
using cce::CC_STATUS_SUCCESS;
|
|
|
|
|
using cce::ccStatus_t;
|
|
|
|
|
|
|
|
|
|
#if !defined(__ANDROID__) && !defined(ANDROID)
|
|
|
|
|
#define DOMI_LOGE(...) GE_LOG_ERROR(GE_MODULE_NAME, ge::FAILED, __VA_ARGS__)
|
|
|
|
|
#else
|
|
|
|
@ -102,17 +99,13 @@ using cce::ccStatus_t;
|
|
|
|
|
} while (0);
|
|
|
|
|
|
|
|
|
|
// If expr is not true, print the log and return the specified status
|
|
|
|
|
#define GE_CHK_BOOL_RET_STATUS(expr, _status, ...) \
|
|
|
|
|
do { \
|
|
|
|
|
bool b = (expr); \
|
|
|
|
|
if (!b) { \
|
|
|
|
|
std::string msg; \
|
|
|
|
|
(void)msg.append(ge::StringUtils::FormatString(__VA_ARGS__)); \
|
|
|
|
|
(void)msg.append( \
|
|
|
|
|
ge::StringUtils::FormatString(" Error Code:0x%X(%s)", _status, GET_ERRORNO_STR(_status).c_str())); \
|
|
|
|
|
DOMI_LOGE("%s", msg.c_str()); \
|
|
|
|
|
return _status; \
|
|
|
|
|
} \
|
|
|
|
|
#define GE_CHK_BOOL_RET_STATUS(expr, _status, ...) \
|
|
|
|
|
do { \
|
|
|
|
|
bool b = (expr); \
|
|
|
|
|
if (!b) { \
|
|
|
|
|
GELOGE(_status, __VA_ARGS__); \
|
|
|
|
|
return _status; \
|
|
|
|
|
} \
|
|
|
|
|
} while (0);
|
|
|
|
|
|
|
|
|
|
// If expr is not true, print the log and return the specified status
|
|
|
|
@ -132,7 +125,7 @@ using cce::ccStatus_t;
|
|
|
|
|
DOMI_LOGE(__VA_ARGS__); \
|
|
|
|
|
exec_expr; \
|
|
|
|
|
} \
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If expr is not true, print the log and execute a custom statement
|
|
|
|
|
#define GE_CHK_BOOL_EXEC_WARN(expr, exec_expr, ...) \
|
|
|
|
@ -142,7 +135,7 @@ using cce::ccStatus_t;
|
|
|
|
|
GELOGW(__VA_ARGS__); \
|
|
|
|
|
exec_expr; \
|
|
|
|
|
} \
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
// If expr is not true, print the log and execute a custom statement
|
|
|
|
|
#define GE_CHK_BOOL_EXEC_INFO(expr, exec_expr, ...) \
|
|
|
|
|
{ \
|
|
|
|
@ -151,7 +144,7 @@ using cce::ccStatus_t;
|
|
|
|
|
GELOGI(__VA_ARGS__); \
|
|
|
|
|
exec_expr; \
|
|
|
|
|
} \
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If expr is not true, print the log and execute a custom statement
|
|
|
|
|
#define GE_CHK_BOOL_TRUE_EXEC_INFO(expr, exec_expr, ...) \
|
|
|
|
@ -161,7 +154,7 @@ using cce::ccStatus_t;
|
|
|
|
|
GELOGI(__VA_ARGS__); \
|
|
|
|
|
exec_expr; \
|
|
|
|
|
} \
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If expr is true, print logs and execute custom statements
|
|
|
|
|
#define GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(expr, exec_expr, ...) \
|
|
|
|
@ -171,7 +164,7 @@ using cce::ccStatus_t;
|
|
|
|
|
DOMI_LOGE(__VA_ARGS__); \
|
|
|
|
|
exec_expr; \
|
|
|
|
|
} \
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
// If expr is true, print the Information log and execute a custom statement
|
|
|
|
|
#define GE_CHK_TRUE_EXEC_INFO(expr, exec_expr, ...) \
|
|
|
|
|
{ \
|
|
|
|
@ -180,7 +173,7 @@ using cce::ccStatus_t;
|
|
|
|
|
GELOGI(__VA_ARGS__); \
|
|
|
|
|
exec_expr; \
|
|
|
|
|
} \
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If expr is not SUCCESS, print the log and execute the expression + return
|
|
|
|
|
#define GE_CHK_BOOL_TRUE_RET_VOID(expr, exec_expr, ...) \
|
|
|
|
@ -191,7 +184,7 @@ using cce::ccStatus_t;
|
|
|
|
|
exec_expr; \
|
|
|
|
|
return; \
|
|
|
|
|
} \
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If expr is not SUCCESS, print the log and execute the expression + return _status
|
|
|
|
|
#define GE_CHK_BOOL_TRUE_EXEC_RET_STATUS(expr, _status, exec_expr, ...) \
|
|
|
|
@ -202,7 +195,7 @@ using cce::ccStatus_t;
|
|
|
|
|
exec_expr; \
|
|
|
|
|
return _status; \
|
|
|
|
|
} \
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If expr is not true, execute a custom statement
|
|
|
|
|
#define GE_CHK_BOOL_EXEC_NOLOG(expr, exec_expr) \
|
|
|
|
@ -211,7 +204,7 @@ using cce::ccStatus_t;
|
|
|
|
|
if (!b) { \
|
|
|
|
|
exec_expr; \
|
|
|
|
|
} \
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// -----------------runtime related macro definitions-------------------------------
|
|
|
|
|
// If expr is not RT_ERROR_NONE, print the log
|
|
|
|
@ -231,7 +224,7 @@ using cce::ccStatus_t;
|
|
|
|
|
DOMI_LOGE("Call rt api failed, ret: 0x%X", _rt_ret); \
|
|
|
|
|
exec_expr; \
|
|
|
|
|
} \
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If expr is not RT_ERROR_NONE, print the log and return
|
|
|
|
|
#define GE_CHK_RT_RET(expr) \
|
|
|
|
@ -239,27 +232,17 @@ using cce::ccStatus_t;
|
|
|
|
|
rtError_t _rt_ret = (expr); \
|
|
|
|
|
if (_rt_ret != RT_ERROR_NONE) { \
|
|
|
|
|
DOMI_LOGE("Call rt api failed, ret: 0x%X", _rt_ret); \
|
|
|
|
|
return ge::RT_FAILED; \
|
|
|
|
|
return RT_ERROR_TO_GE_STATUS(_rt_ret); \
|
|
|
|
|
} \
|
|
|
|
|
} while (0);
|
|
|
|
|
|
|
|
|
|
// ------------------------cce related macro definitions----------------------------
|
|
|
|
|
// If expr is not CC_STATUS_SUCCESS, print the log
|
|
|
|
|
#define GE_CHK_CCE(expr) \
|
|
|
|
|
do { \
|
|
|
|
|
ccStatus_t _cc_ret = (expr); \
|
|
|
|
|
if (_cc_ret != CC_STATUS_SUCCESS) { \
|
|
|
|
|
DOMI_LOGE("Call cce api failed, ret: 0x%X", _cc_ret); \
|
|
|
|
|
} \
|
|
|
|
|
} while (0);
|
|
|
|
|
|
|
|
|
|
// If expr is true, execute exec_expr without printing logs
|
|
|
|
|
#define GE_IF_BOOL_EXEC(expr, exec_expr) \
|
|
|
|
|
{ \
|
|
|
|
|
if (expr) { \
|
|
|
|
|
exec_expr; \
|
|
|
|
|
} \
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If make_shared is abnormal, print the log and execute the statement
|
|
|
|
|
#define GE_MAKE_SHARED(exec_expr0, exec_expr1) \
|
|
|
|
|