Browse Source

fix missing hearders

tags/v1.8.0^2
yanghaoran 2 years ago
parent
commit
0d2dfa2748
43 changed files with 465 additions and 775 deletions
  1. +1
    -1
      inc/framework/common/aicpu_op.h
  2. +54
    -36
      inc/framework/common/debug/ge_log.h
  3. +74
    -77
      inc/framework/common/debug/log.h
  4. +1
    -1
      inc/framework/common/fmk_error_codes.h
  5. +1
    -1
      inc/framework/common/fmk_types.h
  6. +1
    -1
      inc/framework/common/ge_compiler_options.h
  7. +2
    -2
      inc/framework/common/ge_format_util.h
  8. +22
    -22
      inc/framework/common/ge_inner_error_codes.h
  9. +28
    -15
      inc/framework/common/ge_types.h
  10. +1
    -1
      inc/framework/common/gflags_util.h
  11. +6
    -6
      inc/framework/common/helper/model_helper.h
  12. +9
    -5
      inc/framework/common/helper/om_file_helper.h
  13. +13
    -12
      inc/framework/common/l2_cache_optimize.h
  14. +2
    -2
      inc/framework/common/op/attr_value_util.h
  15. +10
    -10
      inc/framework/common/op/ge_op_utils.h
  16. +4
    -4
      inc/framework/common/op/op_parser_util.h
  17. +7
    -3
      inc/framework/common/op_types.h
  18. +2
    -2
      inc/framework/common/profiling/ge_profiling.h
  19. +1
    -1
      inc/framework/common/profiling/ge_runner_profiling.h
  20. +10
    -5
      inc/framework/common/scope_guard.h
  21. +4
    -4
      inc/framework/common/string_util.h
  22. +1
    -1
      inc/framework/common/taskdown_common.h
  23. +8
    -203
      inc/framework/common/types.h
  24. +116
    -113
      inc/framework/common/util.h
  25. +23
    -6
      inc/framework/engine/dnnengine.h
  26. +4
    -4
      inc/framework/executor/ge_executor.h
  27. +28
    -18
      inc/framework/generator/ge_generator.h
  28. +0
    -187
      inc/framework/generator/generator_api.h
  29. +3
    -3
      inc/framework/memory/memory_api.h
  30. +3
    -3
      inc/framework/memory/memory_assigner.h
  31. +2
    -2
      inc/framework/omg/ge_init.h
  32. +1
    -1
      inc/framework/omg/model_tool.h
  33. +6
    -5
      inc/framework/omg/omg.h
  34. +2
    -3
      inc/framework/omg/omg_inner_types.h
  35. +1
    -1
      inc/framework/omg/omg_types.h
  36. +1
    -1
      inc/framework/omg/parser/model_parser.h
  37. +2
    -2
      inc/framework/omg/parser/op_parser.h
  38. +2
    -2
      inc/framework/omg/parser/parser_api.h
  39. +1
    -1
      inc/framework/omg/parser/parser_factory.h
  40. +1
    -1
      inc/framework/omg/parser/parser_inner_ctx.h
  41. +2
    -2
      inc/framework/omg/parser/parser_types.h
  42. +1
    -1
      inc/framework/omg/parser/weights_parser.h
  43. +4
    -4
      inc/framework/omg/version.h

+ 1
- 1
inc/framework/common/aicpu_op.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.


+ 54
- 36
inc/framework/common/debug/ge_log.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@
extern "C" {
#endif

#define GE_MODULE_NAME static_cast<int>(GE)
#define GE_MODULE_NAME static_cast<int32_t>(GE)

// trace status of log
enum TraceStatus { TRACE_INIT = 0, TRACE_RUNNING, TRACE_WAITING, TRACE_STOP };
@@ -51,43 +51,61 @@ class GE_FUNC_VISIBILITY GeLog {
};

inline bool IsLogEnable(int module_name, int log_level) {
int32_t enable = CheckLogLevel(module_name, log_level);
const int32_t enable = CheckLogLevel(module_name, log_level);
// 1:enable, 0:disable
return (enable == 1);
}

#define GELOGE(ERROR_CODE, fmt, ...) \
dlog_error(GE_MODULE_NAME, "%lu %s: ErrorNo: %d(%s) %s" fmt, GeLog::GetTid(), __FUNCTION__, ERROR_CODE, \
((GE_GET_ERRORNO_STR(ERROR_CODE)).c_str()), ErrorManager::GetInstance().GetLogHeader().c_str(), \
##__VA_ARGS__)
#define GELOGW(fmt, ...) \
if (IsLogEnable(GE_MODULE_NAME, DLOG_WARN)) \
dlog_warn(GE_MODULE_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__)
#define GELOGI(fmt, ...) \
if (IsLogEnable(GE_MODULE_NAME, DLOG_INFO)) \
dlog_info(GE_MODULE_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__)
#define GELOGD(fmt, ...) \
if (IsLogEnable(GE_MODULE_NAME, DLOG_DEBUG)) \
dlog_debug(GE_MODULE_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__)

#define GEEVENT(fmt, ...) dlog_event(GE_MODULE_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__)

#define GELOGT(VALUE, fmt, ...) \
do { \
TraceStatus stat = VALUE; \
const char *const TraceStatStr[] = {"INIT", "RUNNING", "WAITING", "STOP"}; \
int idx = static_cast<int>(stat); \
char *k = const_cast<char *>("status"); \
char *v = const_cast<char *>(TraceStatStr[idx]); \
KeyValue kv = {k, v}; \
DlogWithKV(static_cast<int>(GE_MODULE_NAME), DLOG_TRACE, &kv, 1, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, \
##__VA_ARGS__); \
} while (0)

#define GE_LOG_ERROR(MOD_NAME, ERROR_CODE, fmt, ...) \
dlog_error(MOD_NAME, "%lu %s: ErrorNo: %d(%s) %s" fmt, GeLog::GetTid(), __FUNCTION__, ERROR_CODE, \
((GE_GET_ERRORNO_STR(ERROR_CODE)).c_str()), ErrorManager::GetInstance().GetLogHeader().c_str(), \
##__VA_ARGS__)
#define GELOGE(ERROR_CODE, fmt, ...) \
do { \
dlog_error(GE_MODULE_NAME, "%lu %s: ErrorNo: %u(%s) %s" fmt, GeLog::GetTid(), &__FUNCTION__[0], ERROR_CODE, \
((GE_GET_ERRORNO_STR(ERROR_CODE)).c_str()), ErrorManager::GetInstance().GetLogHeader().c_str(), \
##__VA_ARGS__); \
} while (false)

#define GELOGW(fmt, ...) \
do { \
if (IsLogEnable(GE_MODULE_NAME, DLOG_WARN)) { \
dlog_warn(GE_MODULE_NAME, "%lu %s:" fmt, GeLog::GetTid(), &__FUNCTION__[0], ##__VA_ARGS__); \
} \
} while (false)

#define GELOGI(fmt, ...) \
do { \
if (IsLogEnable(GE_MODULE_NAME, DLOG_INFO)) { \
dlog_info(GE_MODULE_NAME, "%lu %s:" fmt, GeLog::GetTid(), &__FUNCTION__[0], ##__VA_ARGS__); \
} \
} while (false)

#define GELOGD(fmt, ...) \
do { \
if (IsLogEnable(GE_MODULE_NAME, DLOG_DEBUG)) { \
dlog_debug(GE_MODULE_NAME, "%lu %s:" fmt, GeLog::GetTid(), &__FUNCTION__[0], ##__VA_ARGS__); \
} \
} while (false)

#define GEEVENT(fmt, ...) \
do { \
dlog_event(GE_MODULE_NAME, "%lu %s:" fmt, GeLog::GetTid(), &__FUNCTION__[0], ##__VA_ARGS__); \
} while (false)

#define GELOGT(VALUE, fmt, ...) \
do { \
TraceStatus stat = VALUE; \
const char *const TraceStatStr[] = {"INIT", "RUNNING", "WAITING", "STOP"}; \
const int32_t idx = static_cast<int32_t>(stat); \
char *k = const_cast<char *>("status"); \
char *v = const_cast<char *>(TraceStatStr[idx]); \
KeyValue kv = {k, v}; \
DlogWithKV(GE_MODULE_NAME, DLOG_TRACE, &kv, 1, "%lu %s:" fmt, GeLog::GetTid(), &__FUNCTION__[0], ##__VA_ARGS__); \
} while (false)

#define GE_LOG_ERROR(MOD_NAME, ERROR_CODE, fmt, ...) \
do { \
dlog_error(MOD_NAME, "%lu %s: ErrorNo: %u(%s) %s" fmt, GeLog::GetTid(), &__FUNCTION__[0], ERROR_CODE, \
((GE_GET_ERRORNO_STR(ERROR_CODE)).c_str()), ErrorManager::GetInstance().GetLogHeader().c_str(), \
##__VA_ARGS__); \
} while (false)

// print memory when it is greater than 1KB.
#define GE_PRINT_DYNAMIC_MEMORY(FUNC, PURPOSE, SIZE) \
@@ -95,7 +113,7 @@ inline bool IsLogEnable(int module_name, int log_level) {
if ((SIZE) > 1024) { \
GELOGI("MallocMemory, func=%s, size=%zu, purpose=%s", (#FUNC), static_cast<size_t>(SIZE), (PURPOSE)); \
} \
} while (0);
} while (false)
#ifdef __cplusplus
}
#endif


+ 74
- 77
inc/framework/common/debug/log.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,14 +19,11 @@

#include <string>
#include <sstream>
#include <securec.h>

#include "runtime/rt.h"
#include "common/string_util.h"
#include "common/util.h"
#include "common/util/error_manager/error_manager.h"
#include "framework/common/string_util.h"
#include "framework/common/util.h"
#include "framework/common/debug/ge_log.h"
#include "ge/ge_api_error_codes.h"
#include "external/ge/ge_api_error_codes.h"

#if !defined(__ANDROID__) && !defined(ANDROID)
#define DOMI_LOGE(fmt, ...) GE_LOG_ERROR(GE_MODULE_NAME, ge::FAILED, fmt, ##__VA_ARGS__)
@@ -52,82 +49,82 @@
GELOGW(__VA_ARGS__); \
}

#define GE_LOGE_IF(condition, ...) \
if ((condition)) { \
DOMI_LOGE(__VA_ARGS__); \
#define GE_LOGE_IF(condition, ...) \
if ((condition)) { \
GELOGE(ge::FAILED, __VA_ARGS__); \
}

// If expr is not SUCCESS, print the log and return the same value
#define GE_CHK_STATUS_RET(expr, ...) \
do { \
const ge::Status _status = (expr); \
if (_status != ge::SUCCESS) { \
DOMI_LOGE(__VA_ARGS__); \
return _status; \
} \
} while (0);
#define GE_CHK_STATUS_RET(expr, ...) \
do { \
const ge::Status _chk_status = (expr); \
if (_chk_status != ge::SUCCESS) { \
GELOGE(ge::FAILED, __VA_ARGS__); \
return _chk_status; \
} \
} while (false)

// If expr is not SUCCESS, print the log and do not execute return
#define GE_CHK_STATUS(expr, ...) \
do { \
const ge::Status _status = (expr); \
if (_status != ge::SUCCESS) { \
DOMI_LOGE(__VA_ARGS__); \
} \
} while (0);
#define GE_CHK_STATUS(expr, ...) \
do { \
const ge::Status _chk_status = (expr); \
if (_chk_status != ge::SUCCESS) { \
GELOGE(ge::FAILED, __VA_ARGS__); \
} \
} while (false)

// If expr is not SUCCESS, return the same value
#define GE_CHK_STATUS_RET_NOLOG(expr) \
do { \
const ge::Status _status = (expr); \
if (_status != ge::SUCCESS) { \
return _status; \
} \
} while (0);
#define GE_CHK_STATUS_RET_NOLOG(expr) \
do { \
const ge::Status _chk_status = (expr); \
if (_chk_status != ge::SUCCESS) { \
return _chk_status; \
} \
} while (false)

// If expr is not GRAPH_SUCCESS, print the log and return FAILED
#define GE_CHK_GRAPH_STATUS_RET(expr, ...) \
do { \
if ((expr) != ge::GRAPH_SUCCESS) { \
REPORT_CALL_ERROR("E19999", "Operator graph failed"); \
DOMI_LOGE(__VA_ARGS__); \
GELOGE(ge::FAILED, __VA_ARGS__); \
return FAILED; \
} \
} while (0);
} while (false)

// If expr is not SUCCESS, print the log and execute a custom statement
#define GE_CHK_STATUS_EXEC(expr, exec_expr, ...) \
do { \
const ge::Status _status = (expr); \
GE_CHK_BOOL_EXEC(_status == SUCCESS, exec_expr, __VA_ARGS__); \
} while (0);
#define GE_CHK_STATUS_EXEC(expr, exec_expr, ...) \
do { \
const ge::Status _chk_status = (expr); \
GE_CHK_BOOL_EXEC(_chk_status == SUCCESS, exec_expr, __VA_ARGS__); \
} while (false)

// 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); \
const bool b = (expr); \
if (!b) { \
REPORT_INNER_ERROR("E19999", __VA_ARGS__); \
GELOGE(_status, __VA_ARGS__); \
return _status; \
} \
} while (0);
} while (false)

// If expr is not true, print the log and return the specified status
#define GE_CHK_BOOL_RET_STATUS_NOLOG(expr, _status, ...) \
do { \
bool b = (expr); \
const bool b = (expr); \
if (!b) { \
return _status; \
} \
} while (0);
} while (false)

// If expr is not true, print the log and execute a custom statement
#define GE_CHK_BOOL_EXEC(expr, exec_expr, ...) \
{ \
bool b = (expr); \
const bool b = (expr); \
if (!b) { \
DOMI_LOGE(__VA_ARGS__); \
GELOGE(ge::FAILED, __VA_ARGS__); \
exec_expr; \
} \
}
@@ -135,7 +132,7 @@
// If expr is not true, print the log and execute a custom statement
#define GE_CHK_BOOL_EXEC_WARN(expr, exec_expr, ...) \
{ \
bool b = (expr); \
const bool b = (expr); \
if (!b) { \
GELOGW(__VA_ARGS__); \
exec_expr; \
@@ -144,7 +141,7 @@
// If expr is not true, print the log and execute a custom statement
#define GE_CHK_BOOL_EXEC_INFO(expr, exec_expr, ...) \
{ \
bool b = (expr); \
const bool b = (expr); \
if (!b) { \
GELOGI(__VA_ARGS__); \
exec_expr; \
@@ -154,7 +151,7 @@
// If expr is not true, print the log and execute a custom statement
#define GE_CHK_BOOL_TRUE_EXEC_INFO(expr, exec_expr, ...) \
{ \
bool b = (expr); \
const bool b = (expr); \
if (b) { \
GELOGI(__VA_ARGS__); \
exec_expr; \
@@ -164,16 +161,16 @@
// If expr is true, print logs and execute custom statements
#define GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(expr, exec_expr, ...) \
{ \
bool b = (expr); \
const bool b = (expr); \
if (b) { \
DOMI_LOGE(__VA_ARGS__); \
GELOGE(ge::FAILED, __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, ...) \
{ \
bool b = (expr); \
const bool b = (expr); \
if (b) { \
GELOGI(__VA_ARGS__); \
exec_expr; \
@@ -183,9 +180,9 @@
// If expr is not SUCCESS, print the log and execute the expression + return
#define GE_CHK_BOOL_TRUE_RET_VOID(expr, exec_expr, ...) \
{ \
bool b = (expr); \
const bool b = (expr); \
if (b) { \
DOMI_LOGE(__VA_ARGS__); \
GELOGE(ge::FAILED, __VA_ARGS__); \
exec_expr; \
return; \
} \
@@ -194,10 +191,10 @@
// 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, ...) \
{ \
bool b = (expr); \
const bool b = (expr); \
if (b) { \
REPORT_INNER_ERROR("E19999", __VA_ARGS__); \
DOMI_LOGE(__VA_ARGS__); \
GELOGE(ge::FAILED, __VA_ARGS__); \
exec_expr; \
return _status; \
} \
@@ -206,7 +203,7 @@
// If expr is not true, execute a custom statement
#define GE_CHK_BOOL_EXEC_NOLOG(expr, exec_expr) \
{ \
bool b = (expr); \
const bool b = (expr); \
if (!b) { \
exec_expr; \
} \
@@ -214,34 +211,34 @@

// -----------------runtime related macro definitions-------------------------------
// If expr is not RT_ERROR_NONE, print the log
#define GE_CHK_RT(expr) \
do { \
rtError_t _rt_ret = (expr); \
if (_rt_ret != RT_ERROR_NONE) { \
DOMI_LOGE("Call rt api failed, ret: 0x%X", _rt_ret); \
} \
} while (0);
#define GE_CHK_RT(expr) \
do { \
const rtError_t _rt_ret = (expr); \
if (_rt_ret != RT_ERROR_NONE) { \
GELOGE(ge::FAILED, "Call rt api failed, ret: 0x%X", _rt_ret); \
} \
} while (false)

// If expr is not RT_ERROR_NONE, print the log and execute the exec_expr expression
#define GE_CHK_RT_EXEC(expr, exec_expr) \
{ \
rtError_t _rt_ret = (expr); \
if (_rt_ret != RT_ERROR_NONE) { \
DOMI_LOGE("Call rt api failed, ret: 0x%X", _rt_ret); \
exec_expr; \
} \
}
#define GE_CHK_RT_EXEC(expr, exec_expr) \
do { \
const rtError_t _rt_ret = (expr); \
if (_rt_ret != RT_ERROR_NONE) { \
GELOGE(ge::FAILED, "Call rt api failed, ret: 0x%X", _rt_ret); \
exec_expr; \
} \
} while (false)

// If expr is not RT_ERROR_NONE, print the log and return
#define GE_CHK_RT_RET(expr) \
do { \
rtError_t _rt_ret = (expr); \
const rtError_t _rt_ret = (expr); \
if (_rt_ret != RT_ERROR_NONE) { \
REPORT_CALL_ERROR("E19999", "Call %s fail, ret: 0x%X", #expr, _rt_ret); \
DOMI_LOGE("Call rt api failed, ret: 0x%X", _rt_ret); \
GELOGE(ge::FAILED, "Call rt api failed, ret: 0x%X", _rt_ret); \
return RT_ERROR_TO_GE_STATUS(_rt_ret); \
} \
} while (0);
} while (false)

// If expr is true, execute exec_expr without printing logs
#define GE_IF_BOOL_EXEC(expr, exec_expr) \
@@ -256,7 +253,7 @@
try { \
exec_expr0; \
} catch (const std::bad_alloc &) { \
DOMI_LOGE("Make shared failed"); \
GELOGE(ge::FAILED, "Make shared failed"); \
exec_expr1; \
}

@@ -274,13 +271,13 @@

#define GE_CHK_LOG_AND_ERRORMSG(expr, _status, errormsg) \
do { \
bool b = (expr); \
const bool b = (expr); \
if (!b) { \
GELOGE(_status, "%s", errormsg); \
ErrorManager::GetInstance().ATCReportErrMessage("E19021", {"reason"}, {errormsg}); \
return _status; \
} \
} while (0)
} while (false)

template <typename T>
GE_FUNC_VISIBILITY std::string FmtToStr(const T &t) {


+ 1
- 1
inc/framework/common/fmk_error_codes.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.


+ 1
- 1
inc/framework/common/fmk_types.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.


+ 1
- 1
inc/framework/common/ge_compiler_options.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.


+ 2
- 2
inc/framework/common/ge_format_util.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@

#include <vector>

#include "common/ge_inner_error_codes.h"
#include "framework/common/ge_inner_error_codes.h"
#include "graph/tensor.h"

namespace ge {


+ 22
- 22
inc/framework/common/ge_inner_error_codes.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -61,29 +61,29 @@ enum ErrorLevel {
CRITICAL_LEVEL = 0b100,
};

// Each module defines error codes using the following macros
// Each module defines error codes using the following macros, name can not be modified to (name)
#define GE_ERRORNO_COMMON(name, value, desc) \
GE_ERRORNO(RT_HOST, ERROR_CODE, COMMON_LEVEL, SYSID_GE, COMMON_MODULE, name, value, desc)
GE_ERRORNO(RT_HOST, ERROR_CODE, COMMON_LEVEL, SYSID_GE, COMMON_MODULE, name, (value), (desc))
#define GE_ERRORNO_CLIENT(name, value, desc) \
GE_ERRORNO(RT_HOST, ERROR_CODE, COMMON_LEVEL, SYSID_GE, CLIENT_MODULE, name, value, desc)
GE_ERRORNO(RT_HOST, ERROR_CODE, COMMON_LEVEL, SYSID_GE, CLIENT_MODULE, name, (value), (desc))
#define GE_ERRORNO_INIT(name, value, desc) \
GE_ERRORNO(RT_HOST, ERROR_CODE, COMMON_LEVEL, SYSID_GE, INIT_MODULE, name, value, desc)
GE_ERRORNO(RT_HOST, ERROR_CODE, COMMON_LEVEL, SYSID_GE, INIT_MODULE, name, (value), (desc))
#define GE_ERRORNO_SESSION(name, value, desc) \
GE_ERRORNO(RT_HOST, ERROR_CODE, COMMON_LEVEL, SYSID_GE, SESSION_MODULE, name, value, desc)
GE_ERRORNO(RT_HOST, ERROR_CODE, COMMON_LEVEL, SYSID_GE, SESSION_MODULE, name, (value), (desc))
#define GE_ERRORNO_GRAPH(name, value, desc) \
GE_ERRORNO(RT_HOST, ERROR_CODE, COMMON_LEVEL, SYSID_GE, GRAPH_MODULE, name, value, desc)
GE_ERRORNO(RT_HOST, ERROR_CODE, COMMON_LEVEL, SYSID_GE, GRAPH_MODULE, name, (value), (desc))
#define GE_ERRORNO_ENGINE(name, value, desc) \
GE_ERRORNO(RT_HOST, ERROR_CODE, COMMON_LEVEL, SYSID_GE, ENGINE_MODULE, name, value, desc)
GE_ERRORNO(RT_HOST, ERROR_CODE, COMMON_LEVEL, SYSID_GE, ENGINE_MODULE, name, (value), (desc))
#define GE_ERRORNO_OPS(name, value, desc) \
GE_ERRORNO(RT_HOST, ERROR_CODE, COMMON_LEVEL, SYSID_GE, OPS_MODULE, name, value, desc)
GE_ERRORNO(RT_HOST, ERROR_CODE, COMMON_LEVEL, SYSID_GE, OPS_MODULE, name, (value), (desc))
#define GE_ERRORNO_PLUGIN(name, value, desc) \
GE_ERRORNO(RT_HOST, ERROR_CODE, COMMON_LEVEL, SYSID_GE, PLUGIN_MODULE, name, value, desc)
GE_ERRORNO(RT_HOST, ERROR_CODE, COMMON_LEVEL, SYSID_GE, PLUGIN_MODULE, name, (value), (desc))
#define GE_ERRORNO_RUNTIME(name, value, desc) \
GE_ERRORNO(RT_HOST, ERROR_CODE, COMMON_LEVEL, SYSID_GE, RUNTIME_MODULE, name, value, desc)
GE_ERRORNO(RT_HOST, ERROR_CODE, COMMON_LEVEL, SYSID_GE, RUNTIME_MODULE, name, (value), (desc))
#define GE_ERRORNO_EXECUTOR(name, value, desc) \
GE_ERRORNO(RT_DEVICE, ERROR_CODE, COMMON_LEVEL, SYSID_GE, EXECUTOR_MODULE, name, value, desc)
GE_ERRORNO(RT_DEVICE, ERROR_CODE, COMMON_LEVEL, SYSID_GE, EXECUTOR_MODULE, name, (value), (desc))
#define GE_ERRORNO_GENERATOR(name, value, desc) \
GE_ERRORNO(RT_HOST, ERROR_CODE, COMMON_LEVEL, SYSID_GE, GENERATOR_MODULE, name, value, desc)
GE_ERRORNO(RT_HOST, ERROR_CODE, COMMON_LEVEL, SYSID_GE, GENERATOR_MODULE, name, (value), (desc))

// Get error code description
#define GE_GET_ERRORNO_STR(value) ge::StatusFactory::Instance()->GetErrDesc(value)
@@ -125,13 +125,13 @@ GE_ERRORNO_CLIENT(GE_CLI_GE_ALREADY_INITIALIZED, 10, "GE is already initialized.
GE_ERRORNO_CLIENT(GE_CLI_GE_NOT_INITIALIZED, 11, "GE is not yet initialized or is finalized."); // 1343229963

// Init module error code definition
GE_ERRORNO_INIT(GE_MULTI_INIT, 0, "Multiple initializations are not supported."); // 1343234048
GE_ERRORNO_INIT(GE_FINALIZE_NOT_INIT, 1, "Finalize is not allowed before initialization."); // 1343234049
GE_ERRORNO_INIT(GE_MULTI_FINALIZE, 2, "Multiple finalizations are not supported."); // 1343234050
GE_ERRORNO_INIT(GE_PROF_MULTI_INIT, 3, "Multiple profiling initializations are not supported."); // 1343234051
GE_ERRORNO_INIT(GE_PROF_NOT_INIT, 4, "Profing initializations have not been done."); // 1343234052
GE_ERRORNO_INIT(GE_MULTI_INIT, 0, "Multiple initializations are not supported."); // 1343234048
GE_ERRORNO_INIT(GE_FINALIZE_NOT_INIT, 1, "Finalize is not allowed before initialization."); // 1343234049
GE_ERRORNO_INIT(GE_MULTI_FINALIZE, 2, "Multiple finalizations are not supported."); // 1343234050
GE_ERRORNO_INIT(GE_PROF_MULTI_INIT, 3, "Multiple profiling initializations are not supported."); // 1343234051
GE_ERRORNO_INIT(GE_PROF_NOT_INIT, 4, "Profing initializations have not been done."); // 1343234052
GE_ERRORNO_INIT(GE_PROF_MODE_CONFLICT, 5,
"Profiling command mode which is preferred is running, the api mode will not work."); // 1343234053
"Profiling command mode which is preferred is running, the api mode will not work."); // 1343234053

// Session module error code definition
GE_ERRORNO_SESSION(GE_SESS_INIT_FAILED, 0, "Failed to initialize session."); // 1343238144
@@ -216,8 +216,8 @@ GE_ERRORNO_ENGINE(GE_ENG_FINALIZE_FAILED, 1, "Engine finalize failed.");
GE_ERRORNO_ENGINE(GE_ENG_MEMTYPE_ERROR, 2, "Memory type HBM is necessary when engine is in device"); // 1343246338

// Optimize errocode
GE_ERRORNO_GRAPH(TO_BE_DELETED, 63, "The node of the graph to be deleted."); // 1343242303
GE_ERRORNO_GRAPH(NOT_CHANGED, 64, "The node of the graph no changed."); // 1343242304
GE_ERRORNO_GRAPH(TO_BE_DELETED, 63, "The node of the graph to be deleted."); // 1343242303
GE_ERRORNO_GRAPH(NOT_CHANGED, 64, "The node of the graph no changed."); // 1343242304

// Ops module error code definition
GE_ERRORNO_OPS(GE_OPS_KERNEL_STORE_INIT_FAILED, 0, "Failed to initialize OpsKernelInfoStore."); // 1343250432
@@ -313,7 +313,7 @@ GE_ERRORNO_GENERATOR(GE_GENERATOR_GRAPH_MANAGER_BUILD_GRAPH_FAILED, 3, "Graph ma
GE_ERRORNO_GENERATOR(GE_GENERATOR_GRAPH_MANAGER_FINALIZE_FAILED, 4, "Graph manager finalize failed.");
GE_ERRORNO_GENERATOR(GE_GENERATOR_GRAPH_MANAGER_SAVE_MODEL_FAILED, 5, "Graph manager save model failed.");

#define RT_ERROR_TO_GE_STATUS(RT_ERROR) static_cast<Status>(RT_ERROR)
#define RT_ERROR_TO_GE_STATUS(RT_ERROR) static_cast<const Status>(RT_ERROR)
} // namespace ge

#endif // INC_FRAMEWORK_COMMON_GE_INNER_ERROR_CODES_H_

+ 28
- 15
inc/framework/common/ge_types.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,13 +17,13 @@
#ifndef INC_FRAMEWORK_COMMON_GE_TYPES_H_
#define INC_FRAMEWORK_COMMON_GE_TYPES_H_

#include <stdint.h>
#include <cstdint>

#include <string>
#include <vector>

#include "framework/common/fmk_error_codes.h"
#include "ge/ge_api_error_codes.h"
#include "external/ge/ge_api_error_codes.h"
#include "external/graph/types.h"
#include "external/ge/ge_api_types.h"

@@ -60,6 +60,7 @@ const char *const GE_OPTION_EXEC_PLACEMENT = "ge.exec.placement";
const std::string kTaskTypeAicore = "AI_CORE";
const std::string kTaskTypeAicpu = "AI_CPU";
const std::string kTaskTypeInvalid = "TASK_TYPE_INVALID";
const std::string kTaskTypeFftsPlus = "FFTS_PLUS";

// dynamic execute mode
const char *const kLazyRecompile = "lazy_recompile";
@@ -70,11 +71,11 @@ struct DataBuffer {
void *data; // Data address
uint64_t length; // Data length
bool isDataSupportMemShare = false;
uint32_t placement = 0;
DataBuffer(void *dataIn, uint64_t len, bool isSupportMemShare, uint32_t placement = 0)
: data(dataIn), length(len), isDataSupportMemShare(isSupportMemShare), placement(placement) {}
uint32_t placement = 0U;
DataBuffer(void *data_in, uint64_t data_len, bool is_support_mem_share, uint32_t placement = 0U)
: data(data_in), length(data_len), isDataSupportMemShare(is_support_mem_share), placement(placement) {}

DataBuffer() : data(nullptr), length(0), isDataSupportMemShare(false) {}
DataBuffer() : data(nullptr), length(0U), isDataSupportMemShare(false) {}
};

///
@@ -86,7 +87,7 @@ struct InputData {
uint32_t timestamp; // Data creation time
uint32_t timeout; // Processing timeout
uint32_t model_id; // Model ID required for data processing
uint64_t request_id = 0; // Request ID
uint64_t request_id = 0U; // Request ID
std::vector<DataBuffer> blobs; // Actual input data, currently only supports one input
bool is_dynamic_batch = false; // Whether is dynamic batch size scene, default:false
std::string batch_label; // Gear used for current inference in dynamic batch scene
@@ -202,7 +203,7 @@ struct AippConfigInfo {
// The structure of offline Modeldata
struct ModelData {
void *model_data = nullptr; // Model binary data start addr
uint32_t model_len = 0; // Model binary data length
uint32_t model_len = 0U; // Model binary data length
int32_t priority = 0; // Model priority
std::string key; // Key path for encrypt model, Empty for unencrypt
std::string om_name; // om file name, used for data dump
@@ -210,12 +211,12 @@ struct ModelData {

// The definition of Model information
struct ModelInfo {
uint32_t version = 0;
uint32_t version = 0U;
std::string name;
bool is_encrypt = 0; // 0:unencrypt, 1:encrypt
bool is_encrypt = false; // 0:unencrypt, 1:encrypt
std::vector<ShapeDescription> input_desc;
std::vector<ShapeDescription> output_desc;
uint8_t reserved[3] = {0}; // 3-byte reserved field
uint8_t reserved[3] = {0U}; // 3-byte reserved field
};

// Asynchronous callback interface, implemented by the caller
@@ -231,8 +232,10 @@ class GE_FUNC_VISIBILITY ModelListener {
virtual Status OnComputeDone(uint32_t model_id, uint32_t data_index, uint32_t result_code,
std::vector<ge::Tensor> &outputs) = 0;

virtual void SetCallback(const RunAsyncCallback &callback){};

virtual uint32_t GetResultCode() {
return 0;
return 0U;
};

virtual Status ResetResult() {
@@ -276,13 +279,23 @@ struct TaskDescInfo {
std::vector<Format> output_format;
std::vector<std::vector<int64_t>> output_shape;
std::vector<DataType> output_data_type;
uint32_t context_id;
};

struct OpDescInfo {
std::string op_name;
std::string op_type;
uint32_t task_id;
uint32_t stream_id;
uint32_t task_id = 0U;
uint32_t stream_id = 0U;
uint32_t imply_type = 0U;
uint32_t block_dim = 0U;
std::string op_file_path;
std::string dev_func;
std::string tvm_magic;
uint32_t tiling_key = 0U;
std::string tiling_data;
std::string node_info;
std::vector<int64_t> workspace_bytes;
std::vector<Format> input_format;
std::vector<std::vector<int64_t>> input_shape;
std::vector<DataType> input_data_type;


+ 1
- 1
inc/framework/common/gflags_util.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.


+ 6
- 6
inc/framework/common/helper/model_helper.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,11 +20,11 @@
#include <memory>
#include <string>

#include "common/fmk_types.h"
#include "common/helper/om_file_helper.h"
#include "framework/common/fmk_types.h"
#include "framework/common/helper/om_file_helper.h"
#include "common/model/ge_model.h"
#include "common/model/ge_root_model.h"
#include "common/types.h"
#include "framework/common/types.h"
#include "graph/model.h"

namespace ge {
@@ -35,8 +35,8 @@ class GE_FUNC_VISIBILITY ModelHelper {

Status SaveToOmModel(const GeModelPtr &ge_model, const SaveParam &save_param, const std::string &output_file,
ge::ModelBufferData &model);
Status SaveToOmRootModel(const GeRootModelPtr &ge_root_model, const SaveParam &save_param, const string &output_file,
ModelBufferData &model, bool is_unknown_shape);
Status SaveToOmRootModel(const GeRootModelPtr &ge_root_model, const SaveParam &save_param,
const std::string &output_file, ModelBufferData &model, bool is_unknown_shape);
Status SaveOriginalGraphToOmModel(const ge::Graph &graph, const std::string &output_file);
Status LoadModel(const ge::ModelData &model_data);
Status LoadRootModel(const ge::ModelData &model_data);


+ 9
- 5
inc/framework/common/helper/om_file_helper.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -65,7 +65,7 @@ class GE_FUNC_VISIBILITY OmFileLoadHelper {

OmFileContext context_;

vector<OmFileContext> model_contexts_;
std::vector<OmFileContext> model_contexts_;

private:
Status CheckModelValid(const ge::ModelData &model) const;
@@ -79,9 +79,13 @@ class GE_FUNC_VISIBILITY OmFileLoadHelper {

class GE_FUNC_VISIBILITY OmFileSaveHelper {
public:
ModelFileHeader &GetModelFileHeader() { return model_header_; }
ModelFileHeader &GetModelFileHeader() {
return model_header_;
}

uint32_t GetModelDataSize() const { return context_.model_data_len_; }
uint32_t GetModelDataSize() const {
return context_.model_data_len_;
}

ModelPartitionTable *GetPartitionTable();

@@ -96,7 +100,7 @@ class GE_FUNC_VISIBILITY OmFileSaveHelper {

Status SaveModelToFile(const char *output_file, ge::ModelBufferData &model, bool is_offline = true);

vector<OmFileContext> model_contexts_;
std::vector<OmFileContext> model_contexts_;

ModelFileHeader model_header_;
OmFileContext context_;


+ 13
- 12
inc/framework/common/l2_cache_optimize.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,15 +17,15 @@
#ifndef INC_FRAMEWORK_COMMON_L2_CACHE_OPTIMIZE_H_
#define INC_FRAMEWORK_COMMON_L2_CACHE_OPTIMIZE_H_

#include <stdint.h>
#include <cstdint>

#include <algorithm>
#include <functional>
#include <string>
#include <vector>

#include "common/types.h"
#include "common/util.h"
#include "framework/common/types.h"
#include "framework/common/util.h"
#include "graph/compute_graph.h"

using std::vector;
@@ -53,7 +53,7 @@ enum MemType { INPUT_TENSOR, OUTPUT_TENSOR, WEIGHT, WORKSPACE };

// Memory usage information < node, type, number >
struct NodeInfo {
string nodeName;
std::string nodeName;
MemType memType;
size_t index;
};
@@ -81,26 +81,27 @@ class GE_FUNC_VISIBILITY L2CacheOptimize {
ge::ComputeGraphPtr graph_;

// Save RC block information list
vector<RCMemoryBlock> weightRCs;
vector<RCMemoryBlock> opRCs;
std::vector<RCMemoryBlock> weightRCs;
std::vector<RCMemoryBlock> opRCs;

// Extract RC information generated by FE from compiled graph
void RetirveRCinfo();

// Take the maximum common divisor of RC values for the duplicate address
void Merge(vector<RCMemoryBlock> &blocks);
void Merge(std::vector<RCMemoryBlock> &blocks);

// The RC information is aligned with the 2m address
void Align(vector<RCMemoryBlock> &blocks);
void Align(std::vector<RCMemoryBlock> &blocks);

// Weight of l2loss operator, output of gradient aggregation output, RC value set to 0
void HandleOutputZeroRC(RCType type, ge::NodePtr node, vector<int64_t> &outputList, vector<RCMemoryBlock> &blocks);
void HandleOutputZeroRC(RCType type, ge::NodePtr node, std::vector<int64_t> &outputList,
std::vector<RCMemoryBlock> &blocks);

// Processing operator input Tensor's RC
void HandOPInput(ge::NodePtr node, vector<int64_t> &inputList, vector<RCMemoryBlock> &blocks);
void HandOPInput(ge::NodePtr node, std::vector<int64_t> &inputList, std::vector<RCMemoryBlock> &blocks);

// Processing operator output Tensor's RC
void HandOPoutput(ge::NodePtr node, vector<int64_t> &outputList, vector<RCMemoryBlock> &blocks);
void HandOPoutput(ge::NodePtr node, std::vector<int64_t> &outputList, std::vector<RCMemoryBlock> &blocks);

// maximum common divisor
uint32_t Measure(uint32_t x, uint32_t y) {


+ 2
- 2
inc/framework/common/op/attr_value_util.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -169,6 +169,6 @@ GE_FUNC_VISIBILITY bool GetAttrDefListValue(const std::string &key, int idx, int
GE_FUNC_VISIBILITY bool GetAttrDefListValue(const std::string &key, int idx, uint32_t *value, const AttrDefMap &attr);
GE_FUNC_VISIBILITY bool GetAttrDefListValue(const std::string &key, int idx, float *value, const AttrDefMap &attr);
GE_FUNC_VISIBILITY bool GetAttrDefListValue(const std::string &key, int idx, double *value, const AttrDefMap &attr);
}
} // namespace ge

#endif // INC_FRAMEWORK_COMMON_OP_ATTR_VALUE_UTIL_H_

+ 10
- 10
inc/framework/common/op/ge_op_utils.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,10 +20,10 @@
#include <memory>
#include <vector>

#include "common/op/attr_value_util.h"
#include "framework/common/op/attr_value_util.h"
#include "register/register_types.h"
#include "register/register_error_codes.h"
#include "common/util.h"
#include "framework/common/util.h"
#include "graph/attr_value.h"
#include "graph/ge_tensor.h"
#include "graph/node.h"
@@ -95,7 +95,7 @@ class GE_FUNC_VISIBILITY OpUtils {
/// @param [out] aipp_params aipp parameters
/// @return enum of tagCCAippInputFormat
///
static Status ConvertAippParams(const GeAttrValue::NamedAttrs &aipp_attr, domi::AippOpParams *aipp_params);
static Status ConvertAippParams(const NamedAttrs &aipp_attr, domi::AippOpParams *aipp_params);
static Status TransferDim(const std::vector<int64_t> &dim, std::vector<int64_t> &dim_vector);
template <typename T>
static void SliceData(const std::vector<char *> &input, int64_t chunk_size, std::vector<char *> &output,
@@ -134,12 +134,12 @@ class GE_FUNC_VISIBILITY OpUtils {
///
static void TransDataKCHW2HWCK(const void *input, int64_t K, int64_t C, int64_t H, int64_t W, void *output);

static vector<ConstGeTensorPtr> GetWeights(const ge::Node &node);
static vector<ConstGeTensorPtr> GetWeights(ge::ConstNodePtr node);
static vector<GeTensorPtr> MutableWeights(const ge::Node &node);
static vector<GeTensorPtr> MutableWeights(const ge::NodePtr node);
static Status SetWeights(ge::Node &node, const vector<ge::GeTensorPtr> &weights);
static Status SetWeights(ge::NodePtr node, const vector<ge::GeTensorPtr> &weights);
static std::vector<ConstGeTensorPtr> GetWeights(const ge::Node &node);
static std::vector<ConstGeTensorPtr> GetWeights(ge::ConstNodePtr node);
static std::vector<GeTensorPtr> MutableWeights(const ge::Node &node);
static std::vector<GeTensorPtr> MutableWeights(const ge::NodePtr node);
static Status SetWeights(ge::Node &node, const std::vector<ge::GeTensorPtr> &weights);
static Status SetWeights(ge::NodePtr node, const std::vector<ge::GeTensorPtr> &weights);
static Status GetShapeDataFromConstTensor(const ConstGeTensorPtr &tensor, DataType type, std::vector<int64_t> &dims);

private:


+ 4
- 4
inc/framework/common/op/op_parser_util.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,9 +17,9 @@
#ifndef INC_FRAMEWORK_COMMON_OP_OP_PARSER_UTIL_H_
#define INC_FRAMEWORK_COMMON_OP_OP_PARSER_UTIL_H_

#include <limits.h>
#include <math.h>
#include <stdint.h>
#include <climits>
#include <cmath>
#include <cstdint>

namespace ge {
// general


+ 7
- 3
inc/framework/common/op_types.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,9 @@ class GE_FUNC_VISIBILITY OpTypeContainer {
}
~OpTypeContainer() = default;

void Register(const std::string &op_type) { op_type_list_.insert(op_type); }
void Register(const std::string &op_type) {
op_type_list_.insert(op_type);
}

bool IsExisting(const std::string &op_type) {
auto iter_find = op_type_list_.find(op_type);
@@ -45,7 +47,9 @@ class GE_FUNC_VISIBILITY OpTypeContainer {

class GE_FUNC_VISIBILITY OpTypeRegistrar {
public:
explicit OpTypeRegistrar(const std::string &op_type) { OpTypeContainer::Instance()->Register(op_type); }
explicit OpTypeRegistrar(const std::string &op_type) {
OpTypeContainer::Instance()->Register(op_type);
}
~OpTypeRegistrar() {}
};



+ 2
- 2
inc/framework/common/profiling/ge_profiling.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
#ifndef INC_FRAMEWORK_COMMON_GE_PROFILING_H_
#define INC_FRAMEWORK_COMMON_GE_PROFILING_H_

#include "ge/ge_api_error_codes.h"
#include "external/ge/ge_api_error_codes.h"
#include "runtime/base.h"

///


+ 1
- 1
inc/framework/common/profiling/ge_runner_profiling.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.


+ 10
- 5
inc/framework/common/scope_guard.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +25,9 @@
/// MAKE_GUARD([&] { Release Resource 1 })
/// Acquire Resource 2
// MAKE_GUARD([&] { Release Resource 2 })
#define GE_MAKE_GUARD(var, callback) ScopeGuard make_guard_##var(callback)
#define GE_MAKE_GUARD(var, callback) const ScopeGuard const_guard_##var(callback)

#define GE_DISMISSABLE_GUARD(var, callback) ScopeGuard make_guard_##var(callback)
#define GE_DISMISS_GUARD(var) make_guard_##var.Dismiss()

namespace ge {
@@ -42,13 +44,16 @@ class GE_FUNC_VISIBILITY ScopeGuard {
if (on_exit_scope_ != nullptr) {
try {
on_exit_scope_();
} catch (std::bad_function_call &e) { }
catch (...) { }
} catch (std::bad_function_call &e) {
} catch (...) {
}
}
}
}

void Dismiss() { dismissed_ = true; }
void Dismiss() {
dismissed_ = true;
}

private:
std::function<void()> on_exit_scope_;


+ 4
- 4
inc/framework/common/string_util.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,7 +54,7 @@ class GE_FUNC_VISIBILITY StringUtils {
// lint -esym(551,*)
static std::string &Rtrim(std::string &s) { /*lint !e618*/
#if __cplusplus >= 201103L
(void)s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int c) { return std::isspace(c) == 0; }));
(void)s.erase(std::find_if(s.rbegin(), s.rend(), [](int c) { return std::isspace(c) == 0; }).base(), s.end());
#else
(void)s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
#endif
@@ -78,8 +78,8 @@ class GE_FUNC_VISIBILITY StringUtils {
/// @param [in] delim separator
/// @return string array after segmentation
///
static std::vector<std::string> Split(const std::string &str, char delim) {
std::vector<std::string> elems;
static std::vector<std::string, std::allocator<std::string>> Split(const std::string &str, char delim) {
std::vector<std::string, std::allocator<std::string>> elems;

if (str.empty()) {
elems.emplace_back("");


+ 1
- 1
inc/framework/common/taskdown_common.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.


+ 8
- 203
inc/framework/common/types.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,8 +17,8 @@
#ifndef INC_FRAMEWORK_COMMON_TYPES_H_
#define INC_FRAMEWORK_COMMON_TYPES_H_

#include <limits.h>
#include <stdint.h>
#include <climits>
#include <cstdint>
#include <algorithm>
#include <map>
#include <memory>
@@ -31,14 +31,6 @@
#include "framework/common/op_types.h"
#include "register/register_types.h"

#if !defined(__ANDROID__) && !defined(ANDROID)
#define DOMI_DYNAMIC_CAST static_cast
#define DOMI_DYNAMIC_POINTER_CAST std::static_pointer_cast
#else
#define DOMI_DYNAMIC_CAST static_cast
#define DOMI_DYNAMIC_POINTER_CAST std::static_pointer_cast
#endif

namespace ge {
// dump
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string DUMP_MODEL;
@@ -51,24 +43,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string OP_DEB
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string OP_DEBUG_ATOMIC;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string OP_DEBUG_ALL;

// Supported public properties name
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string PROP_OME_START_TIME; // Start time
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string PROP_OME_DUMP_PATH; // Dump path
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string PROP_OME_LOG_PATH; // Log path

// Profile-related constants
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t CCE_PROFILE_ON;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t CCE_PROFILE_OFF;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string OME_PROFILE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string CCE_PROFILE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string RTS_PROFILE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string PROFILER_JOBCTX;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string PROFILER_TARGET_PATH;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string RTS_PROFILE_PATH;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string PROFILE_STOP_KEY;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string PROFILE_STOP_VALUE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::map<std::string, std::string> PROFILE_COMPONENT_MAP;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string PROFILE_CONFIG;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string PROFILE_MODEL_ID;

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string MODEL_ATTR_TASKS;
@@ -76,14 +54,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string MODEL_
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string MODEL_ATTR_TASK_GEN_WEIGHT_ADDR;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string MODEL_ATTR_FUSION_MODEL_DEF;

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const int MODEL_MAX_SIZE; // Max size of 2 GB minus 1 byte.
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint64_t FILE_HEADER_MAX_SIZE; // Max size of 3 GB.

#if !defined(__ANDROID__) && !defined(ANDROID)
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint64_t ALLOC_MEMORY_MAX_SIZE; // Max size of 8 GB.
#else
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint64_t ALLOC_MEMORY_MAX_SIZE; // Max size of 512M.
#endif

template <typename K, typename V>
static std::pair<V, K> flip_pair(const std::pair<K, V> &p) {
@@ -167,6 +138,8 @@ REGISTER_OPTYPE_DECLARE(SLICED, "SliceD");
REGISTER_OPTYPE_DECLARE(FLOORDIV, "FloorDiv");
REGISTER_OPTYPE_DECLARE(SQUEEZE, "Squeeze");
REGISTER_OPTYPE_DECLARE(UNSQUEEZE, "Unsqueeze");
REGISTER_OPTYPE_DECLARE(SQUEEZEV2, "SqueezeV2");
REGISTER_OPTYPE_DECLARE(UNSQUEEZEV2, "UnsqueezeV2");
REGISTER_OPTYPE_DECLARE(STRIDEDSLICE, "StridedSlice");
REGISTER_OPTYPE_DECLARE(RANGE, "Range");
REGISTER_OPTYPE_DECLARE(RPNPROPOSALS, "GenerateRpnProposals");
@@ -339,6 +312,8 @@ REGISTER_OPTYPE_DECLARE(PLACEHOLDER, "PlaceHolder");
REGISTER_OPTYPE_DECLARE(END, "End");
REGISTER_OPTYPE_DECLARE(BASICLSTMCELL, "BasicLSTMCell");
REGISTER_OPTYPE_DECLARE(GETNEXT, "GetNext");
REGISTER_OPTYPE_DECLARE(ITERATOR, "Iterator");
REGISTER_OPTYPE_DECLARE(ITERATORV2, "IteratorV2");
REGISTER_OPTYPE_DECLARE(INITDATA, "InitData");
REGISTER_OPTYPE_DECLARE(TRANSSHAPE, "TransShape")
REGISTER_OPTYPE_DECLARE(REFIDENTITY, "RefIdentity");
@@ -616,34 +591,6 @@ static constexpr uint32_t MODEL_FILE_CHECKSUM_LENGTH = 64;
///
static constexpr uint32_t MODEL_FILE_RESERVED_LENGTH = 75;

///
/// @ingroup domi_omg
/// @brief INPUT node type
///
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string INPUT_TYPE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string DUMMY_DATA;

///
/// @ingroup domi_omg
/// @brief AIPP flag, indicating the aipp conv operator
///
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string AIPP_CONV_FLAG;

///
/// @ingroup domi_omg
/// @brief AIPP flag, indicating the aipp data operator
///
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string AIPP_DATA_FLAG;

// flag of the Data operator, indicating that the input will be input to the dynamic AIPP operator
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string INPUT_TO_DYNAMIC_AIPP;

// records the W dimension of the model input corresponding to the dynamic AIPP
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string AIPP_RELATED_DATA_DIM_W;

// H dimension of the model input corresponding to the dynamic AIPP
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string AIPP_RELATED_DATA_DIM_H;

// DATA node type
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string DATA_TYPE;

@@ -655,10 +602,6 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string FRAMEW

// DATA node type
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string ANN_DATA_TYPE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string ANN_NETOUTPUT_TYPE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string ANN_DEPTHCONV_TYPE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string ANN_CONV_TYPE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string ANN_FC_TYPE;
// convolution node type
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_NET_OUTPUT;

@@ -667,161 +610,31 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_N
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_OP_DEBUG;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string OP_TYPE_OP_DEBUG;

// convolution node type
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string OP_TYPE_CONVOLUTION;
// adds a convolutional node name for the hard AIPP
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string AIPP_CONV_OP_NAME;
// delimiter of operator configuration items
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string OP_CONF_DELIMITER;

// op attr name
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string ATTR_NAME_VALUE1;

// op attr name, used to 6d_2_4d C channel
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string ATTR_NAME_INPUT_CVALUE;

// op attr name
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string ATTR_NAME_VALUE1;

// alpha default value
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const float ALPHA_DEFAULT_VALUE;

// beta default value
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const float BETA_DEFAULT_VALUE;

// coef default value
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const float COEF_DEFAULT_VALUE;

// coef value of Relu6
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const float RELU6_COEF;

// stride default value
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t STRIDE_DEFAULT_VALUE;

// pad default value
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t PAD_DEFAULT_VALUE;

// dilation default value
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const int DILATION_DEFAULT_VALUE;

// kernel default value
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t KERNEL_DEFAULT_VALUE;

// default conv Group Size
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t DEFAULT_CONV_GROUP;

// default deconv adj
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t DEFAULT_DECONV_ADJ;

// indicate num 1
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t NUM_ONE;

// dim default size value
static const int32_t DIM_DEFAULT_SIZE = 4;

// the shape of c must be the mutiply of 16 for depthwise
static const uint32_t DEPTHWISE_DIM_C_BASE_NUM = 16;

// C1HWNCoC0 dim size
static const int32_t DIM_C1HWNCoC0_SIZE = 6;
// C1HWNCoC0 C0 value
static const int C1HWCOC_C0_VALUE = 16;
// spatial default dim size
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const int32_t SPATIAL_DIM_DEFAULT_SIZE;

// dim extension default value
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const int32_t DIM_DEFAULT_VALUE;

// the first item in the weight list of opdef is filter
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const int32_t WEIGHT_FILTER_INDEX;

// the second item in the weight list of opdef is bias.
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const int32_t WEIGHT_BIAS_INDEX;

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const int32_t TENSOR_ND_SUPPORT_SIZE;

// default NCHW index
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t NCHW_DIM_N;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t NCHW_DIM_C;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t NCHW_DIM_H;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t NCHW_DIM_W;

// default C1HWNCoC0 index
static const uint32_t C1HWNCoC0_DIM_C1 = 0;
static const uint32_t C1HWNCoC0_DIM_H = 1;
static const uint32_t C1HWNCoC0_DIM_W = 2;
static const uint32_t C1HWNCoC0_DIM_N = 3;
static const uint32_t C1HWNCoC0_DIM_Co = 4;
static const uint32_t C1HWNCoC0_DIM_C0 = 5;

// default KCHW index
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t KCHW_DIM_K;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t KCHW_DIM_C;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t KCHW_DIM_H;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t KCHW_DIM_W;

// default HWCK index
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t HWCK_DIM_H;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t HWCK_DIM_W;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t HWCK_DIM_C;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t HWCK_DIM_K;

// default NHWC index
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t NHWC_DIM_N;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t NHWC_DIM_H;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t NHWC_DIM_W;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t NHWC_DIM_C;

// default CHWN index
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t CHWN_DIM_N;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t CHWN_DIM_C;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t CHWN_DIM_H;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t CHWN_DIM_W;

// default CHW index
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t CHW_DIM_C;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t CHW_DIM_H;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t CHW_DIM_W;

// default HWC index
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t HWC_DIM_H;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t HWC_DIM_W;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t HWC_DIM_C;
// default Pad index
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t PAD_H_HEAD;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t PAD_H_TAIL;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t PAD_W_HEAD;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t PAD_W_TAIL;

// default window index
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t WINDOW_H;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t WINDOW_W;

// default stride index
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t STRIDE_H;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t STRIDE_W;

// default dilation index
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t DILATION_H;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t DILATION_W;

// the num of XRBG channel
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t XRGB_CHN_NUM;

// default tensor format
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const int DEFAULT_FORMAT;

// default global pooling
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const bool DEFAULT_GLOBAL_POOLING;

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t MODEL_VERSION; // model version 1.0

// Number of inputs of the Eltwise operator
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const int ELTWISE_MIN_INPUT_SIZE;

// flowctrl
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_STREAM_SWITCH;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_STREAM_ACTIVE;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_FLOWCTRL_LOOP_PER_ITER;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_FLOWCTRL_LOOP_COND;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_FLOWCTRL_LOOP_INCREMENT;
@@ -833,9 +646,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t TRUE_STRE
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t STREAM_SWITCH_INPUT_NUM;

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_GLOBAL_STEP;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_GLOBAL_STEP_ASSIGNADD;

static const int PLATFORM_VERSION_LEN = 20;
static const uint32_t PLATFORM_VERSION_LEN = 20;

// Definition of the file header of the model file
struct ModelFileHeader {
@@ -860,11 +672,6 @@ struct ModelFileHeader {

static constexpr uint8_t TARGET_TYPE_LTTE_8BIT = 0;
static constexpr uint8_t TARGET_TYPE_MINI_8BIT = 1;
static constexpr uint8_t TARGET_TYPE_TINY_8BIT = 2;

static constexpr int32_t PARTITION_TYPE_MODEL_DEF = 0;
static constexpr int32_t PARTITION_TYPE_WEIGHTS = 1;
static constexpr int32_t PARTITION_TYPE_TASK_INFO = 2;

// number of partitions in the current model
static constexpr uint32_t PARTITION_SIZE = 5;
@@ -884,8 +691,6 @@ struct ModelPartitionTable {

#define SIZE_OF_MODEL_PARTITION_TABLE(table) (sizeof(ModelPartitionTable) + sizeof(ModelPartitionMemInfo) * (table).num)

static constexpr int32_t PTHREAD_CREAT_SUCCESS = 0; // pthread_creat success

// Filter format
typedef enum tagDomiFilterFormat {
DOMI_FILTER_KCHW, // KCHW


+ 116
- 113
inc/framework/common/util.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,30 +17,28 @@
#ifndef INC_FRAMEWORK_COMMON_UTIL_H_
#define INC_FRAMEWORK_COMMON_UTIL_H_

#include <google/protobuf/text_format.h>
#include <limits.h>
#include <math.h>
#include <climits>
#include <cmath>
#include <sstream>
#include <string>
#include <vector>

#include "framework/common/debug/ge_log.h"
#include <google/protobuf/text_format.h>
#include "framework/common/debug/log.h"
#include "framework/common/scope_guard.h"
#include "framework/common/ge_inner_error_codes.h"
#include "mmpa/mmpa_api.h"

#define GE_CHECK_POSITIVE_SIZE_RANGE(size) \
do { \
if (size <= 0) { \
DOMI_LOGE("param[%s] is not a positive number", #size); \
return PARAM_INVALID; \
} \
} while (0)
#define GE_CHECK_POSITIVE_SIZE_RANGE(size) \
do { \
if (size <= 0) { \
GELOGE(ge::FAILED, "param[%s] is not a positive number", #size); \
return PARAM_INVALID; \
} \
} while (false)

#define CHECK_FALSE_EXEC(expr, exec_expr, ...) \
{ \
bool b = (expr); \
const bool b = (expr); \
if (!b) { \
exec_expr; \
} \
@@ -59,131 +57,133 @@
});

// For propagating errors when calling a function.
#define GE_RETURN_IF_ERROR(expr) \
do { \
const ::ge::Status _status = (expr); \
if (_status) return _status; \
} while (0)
#define GE_RETURN_IF_ERROR(expr) \
do { \
const ge::Status _chk_status = (expr); \
if (_chk_status != ge::SUCCESS) { \
return _chk_status; \
} \
} while (false)

#define GE_RETURN_WITH_LOG_IF_ERROR(expr, ...) \
do { \
const ::ge::Status _status = (expr); \
if (_status) { \
DOMI_LOGE(__VA_ARGS__); \
return _status; \
const ge::Status _chk_status = (expr); \
if (_chk_status != ge::SUCCESS) { \
GELOGE(ge::FAILED, __VA_ARGS__); \
return _chk_status; \
} \
} while (0)
} while (false)

// check whether the parameter is true. If it is, return FAILED and record the error log
#define GE_RETURN_WITH_LOG_IF_TRUE(condition, ...) \
do { \
if (condition) { \
DOMI_LOGE(__VA_ARGS__); \
GELOGE(ge::FAILED, __VA_ARGS__); \
return ge::FAILED; \
} \
} while (0)
} while (false)

// Check if the parameter is false. If yes, return FAILED and record the error log
#define GE_RETURN_WITH_LOG_IF_FALSE(condition, ...) \
do { \
bool _condition = (condition); \
const bool _condition = (condition); \
if (!_condition) { \
DOMI_LOGE(__VA_ARGS__); \
GELOGE(ge::FAILED, __VA_ARGS__); \
return ge::FAILED; \
} \
} while (0)
} while (false)

// Checks whether the parameter is true. If so, returns PARAM_INVALID and records the error log
#define GE_RT_PARAM_INVALID_WITH_LOG_IF_TRUE(condition, ...) \
do { \
if (condition) { \
DOMI_LOGE(__VA_ARGS__); \
GELOGE(ge::FAILED, __VA_ARGS__); \
return ge::PARAM_INVALID; \
} \
} while (0)
} while (false)

// Check if the parameter is false. If yes, return PARAM_INVALID and record the error log
#define GE_RT_PARAM_INVALID_WITH_LOG_IF_FALSE(condition, ...) \
do { \
bool _condition = (condition); \
const bool _condition = (condition); \
if (!_condition) { \
DOMI_LOGE(__VA_ARGS__); \
GELOGE(ge::FAILED, __VA_ARGS__); \
return ge::PARAM_INVALID; \
} \
} while (0)
} while (false)

// Check if the parameter is null. If yes, return PARAM_INVALID and record the error
#define GE_CHECK_NOTNULL(val) \
do { \
if (val == nullptr) { \
REPORT_INNER_ERROR("E19999", "Param:%s is nullptr, check invalid", #val); \
DOMI_LOGE("[Check][Param:%s]null is invalid.", #val); \
GELOGE(ge::FAILED, "[Check][Param:%s]null is invalid.", #val); \
return ge::PARAM_INVALID; \
} \
} while (0)
} while (false)

// Check if the parameter is null. If yes, just return and record the error
#define GE_CHECK_NOTNULL_JUST_RETURN(val) \
do { \
if (val == nullptr) { \
DOMI_LOGE("param[%s] must not be null.", #val); \
return; \
} \
} while (0)
#define GE_CHECK_NOTNULL_JUST_RETURN(val) \
do { \
if (val == nullptr) { \
GELOGE(ge::FAILED, "param[%s] must not be null.", #val); \
return; \
} \
} while (false)

// Check whether the parameter is null. If so, execute the exec_expr expression and record the error log
#define GE_CHECK_NOTNULL_EXEC(val, exec_expr) \
do { \
if (val == nullptr) { \
DOMI_LOGE("param[%s] must not be null.", #val); \
exec_expr; \
} \
} while (0)
#define GE_CHECK_NOTNULL_EXEC(val, exec_expr) \
do { \
if (val == nullptr) { \
GELOGE(ge::FAILED, "param[%s] must not be null.", #val); \
exec_expr; \
} \
} while (false)

// Check whether the parameter is null. If yes, return directly and record the error log
#define GE_RT_VOID_CHECK_NOTNULL(val) \
do { \
if (val == nullptr) { \
DOMI_LOGE("param[%s] must not be null.", #val); \
return; \
} \
} while (0)
#define GE_RT_VOID_CHECK_NOTNULL(val) \
do { \
if (val == nullptr) { \
GELOGE(ge::FAILED, "param[%s] must not be null.", #val); \
return; \
} \
} while (false)

// Check if the parameter is null. If yes, return false and record the error log
#define GE_RT_FALSE_CHECK_NOTNULL(val) \
do { \
if (val == nullptr) { \
DOMI_LOGE("param[%s] must not be null.", #val); \
return false; \
} \
} while (0)
#define GE_RT_FALSE_CHECK_NOTNULL(val) \
do { \
if (val == nullptr) { \
GELOGE(ge::FAILED, "param[%s] must not be null.", #val); \
return false; \
} \
} while (false)

// Check if the parameter is out of bounds
#define GE_CHECK_SIZE(size) \
do { \
if (size == 0) { \
DOMI_LOGE("param[%s] is out of range", #size); \
return ge::PARAM_INVALID; \
} \
} while (0)
#define GE_CHECK_SIZE(size) \
do { \
if (size == 0) { \
GELOGE(ge::FAILED, "param[%s] is out of range", #size); \
return ge::PARAM_INVALID; \
} \
} while (false)

// Check if the value on the left is greater than or equal to the value on the right
#define GE_CHECK_GE(lhs, rhs) \
do { \
if (lhs < rhs) { \
DOMI_LOGE("param[%s] is less than[%s]", #lhs, #rhs); \
return ge::PARAM_INVALID; \
} \
} while (0)
#define GE_CHECK_GE(lhs, rhs) \
do { \
if (lhs < rhs) { \
GELOGE(ge::FAILED, "param[%s] is less than[%s]", #lhs, #rhs); \
return ge::PARAM_INVALID; \
} \
} while (false)

// Check if the value on the left is less than or equal to the value on the right
#define GE_CHECK_LE(lhs, rhs) \
do { \
if (lhs > rhs) { \
DOMI_LOGE("param[%s] is greater than[%s]", #lhs, #rhs); \
return ge::PARAM_INVALID; \
} \
} while (0)
#define GE_CHECK_LE(lhs, rhs) \
do { \
if (lhs > rhs) { \
GELOGE(ge::FAILED, "param[%s] is greater than[%s]", #lhs, #rhs); \
return ge::PARAM_INVALID; \
} \
} while (false)

#define GE_DELETE_NEW_SINGLE(var) \
do { \
@@ -191,7 +191,7 @@
delete var; \
var = nullptr; \
} \
} while (0)
} while (false)

#define GE_DELETE_NEW_ARRAY(var) \
do { \
@@ -199,18 +199,18 @@
delete[] var; \
var = nullptr; \
} \
} while (0)
} while (false)

#define GE_FREE_RT_LOG(addr) \
do { \
if (addr != nullptr) { \
rtError_t error = rtFree(addr); \
const rtError_t error = rtFree(addr); \
if (error != RT_ERROR_NONE) { \
GELOGE(RT_FAILED, "Call rtFree failed, error: %#x", error); \
} \
addr = nullptr; \
} \
} while (0)
} while (false)

/**
* @ingroup domi_common
@@ -226,12 +226,6 @@ static constexpr int32_t OM_PROTO_VERSION = 2;
namespace ge {
using google::protobuf::Message;

///
/// @ingroup domi_common
/// @brief Maximum file path length
///
const int32_t DOMI_MAX_PATH_LEN = 256;

///
/// @ingroup domi_common
/// @brief Reads the proto structure from an array.
@@ -253,8 +247,6 @@ GE_FUNC_VISIBILITY bool ReadProtoFromArray(const void *data, int size, Message *
///
GE_FUNC_VISIBILITY bool ReadProtoFromText(const char *file, google::protobuf::Message *message);

GE_FUNC_VISIBILITY bool ReadProtoFromMem(const char *data, int size, google::protobuf::Message *message);

///
/// @ingroup: domi_common
/// @brief: get length of file
@@ -306,10 +298,10 @@ GE_FUNC_VISIBILITY std::string ToString(std::vector<T> &v) {
ss << x;
ss << ", ";
}
std::string strRet =
ss.str().substr(0, ss.str().length() - 2); // Delete the two extra characters at the end of the line.
strRet += "]";
return strRet;
// Delete the two extra characters at the end of the line.
std::string str = ss.str().substr(0U, ss.str().length() - 2U);
str += "]";
return str;
}

///
@@ -326,10 +318,29 @@ GE_FUNC_VISIBILITY std::string ToString(const google::protobuf::RepeatedField<T>
ss << x;
ss << ", ";
}
std::string strRet =
ss.str().substr(0, ss.str().length() - 2); // Delete the two extra characters at the end of the line.
strRet += "]";
return strRet;
// Delete the two extra characters at the end of the line.
std::string str = ss.str().substr(0U, ss.str().length() - 2U);
str += "]";
return str;
}

///
/// @ingroup ge_ir_utils
/// @brief RepeatedPtrField->String
/// @param [in] const rpd_field RepeatedPtrField
/// @return String
///
template <typename T>
GE_FUNC_VISIBILITY std::string ToString(const google::protobuf::RepeatedPtrField<T> &rpd_ptr_field) {
std::stringstream ss;
ss << "[";
for (const T &x : rpd_ptr_field) {
ss << x;
ss << ", ";
}
std::string str_ret = ss.str().substr(0U, ss.str().length() - 2U);
str_ret += "]";
return str_ret;
}

///
@@ -392,14 +403,6 @@ GE_FUNC_VISIBILITY bool CheckOutputPathValid(const std::string &file_path, const
///
GE_FUNC_VISIBILITY bool ValidateStr(const std::string &filePath, const std::string &mode);

///
/// @ingroup domi_common
/// @brief Check whether the file is normal file.
/// @param [in] file_path file path
/// @param [out] result
///
GE_FUNC_VISIBILITY bool IsValidFile(const char *file_path);

///
/// @ingroup domi_common
/// @brief Check path invalid


+ 23
- 6
inc/framework/engine/dnnengine.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,8 +21,8 @@
#include <string>
#include <vector>

#include "common/ge_inner_error_codes.h"
#include "common/ge_types.h"
#include "framework/common/ge_inner_error_codes.h"
#include "framework/common/ge_types.h"
#include "graph/types.h"

namespace ge {
@@ -43,14 +43,31 @@ struct DNNEngineAttribute {
// If engine input format must be specific, set this attribute, else set FORMAT_RESERVED
Format engine_input_format;
Format engine_output_format;
bool atomic_engine_flag;
};

class GE_FUNC_VISIBILITY DNNEngine {
public:
DNNEngine() = default;
explicit DNNEngine(const DNNEngineAttribute &attrs) {
engine_attribute_ = attrs;
}
virtual ~DNNEngine() = default;
virtual Status Initialize(const std::map<std::string, std::string> &options) = 0;
virtual Status Finalize() = 0;
virtual void GetAttributes(DNNEngineAttribute &attr) const = 0;
Status Initialize(const std::map<std::string, std::string> &options) {
return SUCCESS;
}
Status Finalize() {
return SUCCESS;
}
void GetAttributes(DNNEngineAttribute &attr) const {
attr = engine_attribute_;
}
bool IsAtomic() const {
return engine_attribute_.atomic_engine_flag;
}

protected:
DNNEngineAttribute engine_attribute_;
};
} // namespace ge



+ 4
- 4
inc/framework/executor/ge_executor.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,9 +22,9 @@
#include <vector>

#include "common/dynamic_aipp.h"
#include "common/ge_inner_error_codes.h"
#include "common/ge_types.h"
#include "common/types.h"
#include "framework/common/ge_inner_error_codes.h"
#include "framework/common/ge_types.h"
#include "framework/common/types.h"
#include "graph/tensor.h"
#include "graph/ge_tensor.h"
#include "runtime/base.h"


+ 28
- 18
inc/framework/generator/ge_generator.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,26 +21,29 @@
#include <memory>
#include <string>
#include <vector>
#include "ge/ge_ir_build.h"
#include "common/ge_inner_error_codes.h"
#include "common/ge_types.h"
#include "external/ge/ge_ir_build.h"
#include "framework/common/ge_inner_error_codes.h"
#include "framework/common/ge_types.h"
#include "graph/ge_tensor.h"
#include "graph/graph.h"
#include "graph/op_desc.h"
#include "graph/detail/attributes_holder.h"
#include "omg/omg_inner_types.h"
#include "framework/omg/omg_inner_types.h"

namespace ge {
class GeRootModel;
class GE_FUNC_VISIBILITY GeGenerator {
public:
using InOutTensorRef = std::pair<const std::vector<ge::GeTensor> &, const std::vector<ge::GeTensor> &>;
static GeGenerator &GetInstance() {
static GeGenerator Instance;
return Instance;
}
GeGenerator() = default;

~GeGenerator() { (void)Finalize(); }
~GeGenerator() {
(void)Finalize();
}

GeGenerator(const GeGenerator &) = delete;

@@ -54,7 +57,7 @@ class GE_FUNC_VISIBILITY GeGenerator {
Status GenerateOfflineModel(const Graph &graph, const std::string &file_name_prefix,
const std::vector<GeTensor> &inputs = std::vector<GeTensor>());

Status GenerateOnlineModel(const Graph &graph, const vector<GeTensor> &inputs, ge::ModelBufferData &model);
Status GenerateOnlineModel(const Graph &graph, const std::vector<GeTensor> &inputs, ge::ModelBufferData &model);

Status GenerateInfershapeGraph(const Graph &graph);

@@ -81,10 +84,12 @@ class GE_FUNC_VISIBILITY GeGenerator {
/// @param [in] compile_flag: op build flag, accurate build is 0, fuzz build is 1
/// @param [out] model_buff: model buff of op.
/// @return SUCCESS or FAILED
Status BuildSingleOpModel(OpDescPtr &op_desc, const vector<GeTensor> &inputs, const vector<GeTensor> &outputs,
OpEngineType engine_type, ModelBufferData &model_buff);
Status BuildSingleOpModel(OpDescPtr &op_desc, const vector<GeTensor> &inputs, const vector<GeTensor> &outputs,
OpEngineType engine_type, int32_t compile_flag, ModelBufferData &model_buff);
Status BuildSingleOpModel(OpDescPtr &op_desc, const std::vector<GeTensor> &inputs,
const std::vector<GeTensor> &outputs, OpEngineType engine_type,
ModelBufferData &model_buff);
Status BuildSingleOpModel(OpDescPtr &op_desc, const std::vector<GeTensor> &inputs,
const std::vector<GeTensor> &outputs, OpEngineType engine_type, int32_t compile_flag,
ModelBufferData &model_buff);
///
/// @ingroup ge
/// @brief: Build single Op into model buff.
@@ -94,22 +99,27 @@ class GE_FUNC_VISIBILITY GeGenerator {
/// @param [in] graph_name: graph name.
/// @param [out] graph: graph of single op.
/// @return SUCCESS or FAILED
Status BuildSingleOpGraph(OpDescPtr &op_desc, const vector<GeTensor> &inputs, const vector<GeTensor> &outputs,
std::string graph_name, Graph &graph);
Status BuildSingleOpGraph(OpDescPtr &op_desc, const InOutTensorRef &inputs_outputs, std::string graph_name,
Graph &graph, std::vector<std::pair<std::string, std::string>> &inputs_name_type);

private:
Status GenerateModel(const Graph &graph, const string &file_name_prefix, const vector<GeTensor> &inputs,
Status GenerateModel(const Graph &graph, const std::string &file_name_prefix, const std::vector<GeTensor> &inputs,
ge::ModelBufferData &model, bool is_offline = true);
Status BuildSingleOp(OpDescPtr &op_desc, const vector<GeTensor> &inputs, const vector<GeTensor> &outputs,
const string &model_file_name, OpEngineType engine_type, ModelBufferData &model_buff,
Status BuildSingleOp(OpDescPtr &op_desc, const std::vector<GeTensor> &inputs, const std::vector<GeTensor> &outputs,
const std::string &model_file_name, OpEngineType engine_type, ModelBufferData &model_buff,
bool is_offline = true, int32_t compile_flag = 0);
bool CheckNoAicore(const ComputeGraphPtr &graph);
void RemoveConst(const vector<GeTensor> &inputs, vector<GeTensor> &outputs);
Status CheckForSingleOp(OpDescPtr &op_desc, const vector<GeTensor> &inputs, const vector<GeTensor> &outputs);
void RemoveConst(const std::vector<GeTensor> &inputs, std::vector<GeTensor> &outputs);
Status CheckForSingleOp(OpDescPtr &op_desc, const std::vector<GeTensor> &inputs,
const std::vector<GeTensor> &outputs);
Status InferFormatForSingleOp(OpDescPtr &op_desc, Graph &graph);

using GeRootModelPtr = std::shared_ptr<ge::GeRootModel>;
Status SetModelNameForDump(const GeRootModelPtr &ge_root_model);
Status CreateGeneralizedBuildAttrs(const GeRootModelPtr &ge_root_model, const std::vector<GeTensor> &inputs,
const std::vector<GeTensor> &outputs,
const std::vector<std::pair<std::string, std::string>> &inputs_name_type,
std::vector<ge::NamedAttrs> &generalized_build_attrs);

class Impl;



+ 0
- 187
inc/framework/generator/generator_api.h View File

@@ -1,187 +0,0 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef INC_FRAMEWORK_GENERATOR_GENERATOR_API_H_
#define INC_FRAMEWORK_GENERATOR_GENERATOR_API_H_

#if defined(_MSC_VER)
#ifdef FUNC_VISIBILITY
#define GE_FUNC_VISIBILITY _declspec(dllexport)
#else
#define GE_FUNC_VISIBILITY
#endif
#else
#ifdef FUNC_VISIBILITY
#define GE_FUNC_VISIBILITY __attribute__((visibility("default")))
#else
#define GE_FUNC_VISIBILITY
#endif
#endif

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef uint32_t Status_t;

typedef void *OpAttr_t;
typedef void *OpTensor_t;

///
/// @ingroup ge
/// @brief Generate offline model for the op.
/// @param [in] op_type: type name of the op.
/// @param [in] in_tensor: input description array (created by OpTensorCreate).
/// @param [in] in_num: number of in_tensor.
/// @param [in] out_tensor: output description array (created by OpTensorCreate).
/// @param [in] out_num: number of out_tensor.
/// @param [in] attr: the attributes of the op (created by OpAttrCreate).
/// @param [in] om_file: file name for the om to save.
/// @return 0 for success / others for fail
///
GE_FUNC_VISIBILITY extern Status_t OpTaskGernerator(const char *op_type, const OpTensor_t *in_tensor, int in_num,
const OpTensor_t *out_tensor, int out_num, const OpAttr_t attr,
const char *om_file);

///
/// @ingroup ge
/// @brief Create Tensor Description.
/// @param [in] format: tensor format of the data.
/// @param [in] datatype: tensor type of the data.
/// @param [in] shape: tensor shape array.
/// @param [in] num: number of shape.
/// @return OpTensor_t for success / nullptr for failure
///
GE_FUNC_VISIBILITY extern OpTensor_t OpTensorCreate(int format, int datatype, const int64_t *shape, int num);

///
/// @ingroup ge
/// @brief Destroy Tensor Description.
/// @param [in] OpTensor_t tensor: created by OpTensorCreate.
/// @param [out] none
/// @return 0 for success / others for failure.
///
GE_FUNC_VISIBILITY extern Status_t OpTensorDestroy(OpTensor_t tensor);

///
/// @ingroup ge
/// @brief Create an attribute holder.
/// @param [in] none
/// @param [out] none
/// @return OpAttr_t for success / nullptr for failure.
///
GE_FUNC_VISIBILITY extern OpAttr_t OpAttrCreate();

///
/// @ingroup ge
/// @brief Destroy Attribute holder.
/// @param [in] OpAttr_t attr: created by OpAttrCreate.
/// @param [out] none
/// @return 0 for success / others for failure.
///
GE_FUNC_VISIBILITY extern Status_t OpAttrDestroy(OpAttr_t attr);

///
/// @ingroup ge
/// @brief Set a boolean attribute to the attribute holder.
/// @param [in] attr: attribute holder (created by OpAttrCreate).
/// @param [in] name: attribute name (can`t be nullptr, end with '\0').
/// @param [in] value: attributed value.
/// @return 0 for success / others for failure.
///
GE_FUNC_VISIBILITY extern Status_t SetAttrBool(OpAttr_t attr, const char *name, bool value);

///
/// @ingroup ge
/// @brief Set an integer attribute to the attribute holder.
/// @param [in] attr: attribute holder (created by OpAttrCreate).
/// @param [in] name: attribute name (can`t be nullptr, end with '\0').
/// @param [in] value: attribute value.
/// @return 0 for success / others for failure.
///
GE_FUNC_VISIBILITY extern Status_t SetAttrInt(OpAttr_t attr, const char *name, int64_t value);

///
/// @ingroup ge
/// @brief Set a float attribute to the attribute holder.
/// @param [in] attr: attribute holder (created by OpAttrCreate).
/// @param [in] name: attribute name (can`t be nullptr, end with '\0').
/// @param [in] value: attribute value.
/// @return 0 for success / others for failure.
///
GE_FUNC_VISIBILITY extern Status_t SetAttrFloat(OpAttr_t attr, const char *name, float value);

///
/// @ingroup ge
/// @brief Set a string attribute to the attribute holder.
/// @param [in] attr: attribute holder (created by OpAttrCreate).
/// @param [in] name: attribute name (can`t be nullptr, end with '\0').
/// @param [in] value: attribute value (can`t be nullptr, end with '\0').
/// @return 0 for success / others for failure.
///
GE_FUNC_VISIBILITY extern Status_t SetAttrString(OpAttr_t attr, const char *name, const char *value);

///
/// @ingroup ge
/// @brief Set a boolean array attribute to the attribute holder.
/// @param [in] attr: attribute holder (created by OpAttrCreate).
/// @param [in] name: attribute name (can`t be nullptr, end with '\0').
/// @param [in] value: attribute value array.
/// @param [in] num: number of value array.
/// @return 0 for success / others for failure.
///
GE_FUNC_VISIBILITY extern Status_t SetAttrBoolList(OpAttr_t attr, const char *name, const bool *value, int num);

///
/// @ingroup ge
/// @brief Set an integer array attribute to the attribute holder.
/// @param [in] attr: attribute holder (created by OpAttrCreate).
/// @param [in] name: attribute name (can`t be nullptr, end with '\0').
/// @param [in] value: attribute value array.
/// @param [in] num: number of value array.
/// @return 0 for success / others for failure.
///
GE_FUNC_VISIBILITY extern Status_t SetAttrIntList(OpAttr_t attr, const char *name, const int64_t *value, int num);

///
/// @ingroup ge
/// @brief Set a float array attribute to the attribute holder.
/// @param [in] attr: attribute holder (created by OpAttrCreate).
/// @param [in] name: attribute name (can`t be nullptr, end with '\0').
/// @param [in] value: attribute value array.
/// @param [in] num: number of value array.
/// @return 0 for success / others for failure.
///
GE_FUNC_VISIBILITY extern Status_t SetAttrFloatList(OpAttr_t attr, const char *name, const float *value, int num);

///
/// @ingroup ge
/// @brief Set a string array attribute to the attribute holder.
/// @param [in] attr: attribute holder (created by OpAttrCreate).
/// @param [in] name: attribute name (can`t be nullptr, end with '\0').
/// @param [in] value: attribute value array (each value can`t be nullptr, end with '\0').
/// @param [in] num: number of value array.
/// @return 0 for success / others for failure.
///
GE_FUNC_VISIBILITY extern Status_t SetAttrStringList(OpAttr_t attr, const char *name, const char **value, int num);

#ifdef __cplusplus
}
#endif

#endif // INC_FRAMEWORK_GENERATOR_GENERATOR_API_H_

+ 3
- 3
inc/framework/memory/memory_api.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,8 +20,8 @@
#include <string>
#include <vector>

#include "ge/ge_api_error_codes.h"
#include "graph//types.h"
#include "external/ge/ge_api_error_codes.h"
#include "graph/types.h"
#include "runtime/mem.h"

namespace ge {


+ 3
- 3
inc/framework/memory/memory_assigner.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@

#include <utility>

#include "common/ge_inner_error_codes.h"
#include "framework/common/ge_inner_error_codes.h"
#include "graph/node.h"

namespace ge {
@@ -33,7 +33,7 @@ class GE_FUNC_VISIBILITY MemoryAssigner {

MemoryAssigner &operator=(const MemoryAssigner &) = delete;

Status AssignMemory(bool is_loop_graph, map<uint64_t, size_t> &mem_offset, size_t &zero_copy_mem_size);
Status AssignMemory(bool is_loop_graph, std::map<uint64_t, size_t> &mem_offset, size_t &zero_copy_mem_size);

private:
ge::ComputeGraphPtr compute_graph_;


+ 2
- 2
inc/framework/omg/ge_init.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
#define INC_FRAMEWORK_OMG_GE_INIT_H_
#include <map>
#include <string>
#include "common/ge_inner_error_codes.h"
#include "framework/common/ge_inner_error_codes.h"

namespace ge {
class GE_FUNC_VISIBILITY GEInit {


+ 1
- 1
inc/framework/omg/model_tool.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.


+ 6
- 5
inc/framework/omg/omg.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,8 +43,8 @@ namespace ge {
* @brief init omg context
* @return void
*/
GE_FUNC_VISIBILITY Status InitDomiOmgContext(const string &input_shape, const string &input_format,
const string &net_format, bool is_dynamic_input);
GE_FUNC_VISIBILITY Status InitDomiOmgContext(const std::string &input_shape, const std::string &input_format,
const std::string &net_format, bool is_dynamic_input);

/**
* @ingroup domi_omg
@@ -61,7 +61,7 @@ GE_FUNC_VISIBILITY Status InitDomiOmgContext(const string &input_shape, const st
* @param [in] atc_params multiply atc params
* @return Status result code
*/
GE_FUNC_VISIBILITY Status ParseGraph(ge::Graph &graph, const std::map<string, string> &atc_params,
GE_FUNC_VISIBILITY Status ParseGraph(ge::Graph &graph, const std::map<std::string, std::string> &atc_params,
const char *model_file, const char *weights_file, domi::FrameworkType type,
const char *op_conf = nullptr, const char *target = nullptr,
RunMode run_mode = GEN_OM_MODEL, bool is_dynamic_input = false);
@@ -91,7 +91,8 @@ GE_FUNC_VISIBILITY Status ConvertFwkModelToJson(domi::FrameworkType framework, c

GE_FUNC_VISIBILITY void GetGroupName(ge::proto::ModelDef &model);

GE_FUNC_VISIBILITY void FindParserSo(const string &path, vector<string> &fileList, string &caffe_parser_path);
GE_FUNC_VISIBILITY void FindParserSo(const std::string &path, std::vector<std::string> &fileList,
std::string &caffe_parser_path);

GE_FUNC_VISIBILITY Status DumpInfershapeJson(const ge::Graph &graph, const char *json_file);



+ 2
- 3
inc/framework/omg/omg_inner_types.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -120,14 +120,13 @@ struct OmgContext {
std::string dynamic_image_size;
std::string dynamic_dims;
std::string dynamic_node_type;
std::vector<std::vector<int64_t>> user_real_input_dims;
std::vector<int64_t> cur_dynamic_dims;
bool need_multi_batch = false;
std::vector<NodePtr> data_nodes;
std::vector<NodePtr> getnext_nosink_nodes;
bool fuzz_compile_flag = false;
std::string atc_cmdline;
bool user_attr_index_valid = false;
bool is_online_model = false;
};
} // namespace ge



+ 1
- 1
inc/framework/omg/omg_types.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.


+ 1
- 1
inc/framework/omg/parser/model_parser.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.


+ 2
- 2
inc/framework/omg/parser/op_parser.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@

#include <google/protobuf/text_format.h>
#include "framework/omg/parser/parser_types.h"
#include "omg/omg_inner_types.h"
#include "framework/omg/omg_inner_types.h"
#include "proto/om.pb.h"
#include "graph/ge_tensor.h"
#include "graph/op_desc.h"


+ 2
- 2
inc/framework/omg/parser/parser_api.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
#include <iostream>
#include <map>
#include <string>
#include "ge/ge_api_error_codes.h"
#include "external/ge/ge_api_error_codes.h"

namespace ge {
// Initialize parser


+ 1
- 1
inc/framework/omg/parser/parser_factory.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.


+ 1
- 1
inc/framework/omg/parser/parser_inner_ctx.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.


+ 2
- 2
inc/framework/omg/parser/parser_types.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
#ifndef PARSER_COMMON_TYPES_H_
#define PARSER_COMMON_TYPES_H_

#include <stdint.h>
#include <cstdint>
#include <string>

#include "register/register_types.h"


+ 1
- 1
inc/framework/omg/parser/weights_parser.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.


+ 4
- 4
inc/framework/omg/version.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,8 +22,8 @@
#include <string>
#include <vector>

#include "common/debug/log.h"
#include "common/string_util.h"
#include "framework/common/debug/log.h"
#include "framework/common/string_util.h"
#include "framework/common/debug/ge_log.h"

namespace ge {
@@ -33,7 +33,7 @@ class GE_FUNC_VISIBILITY PlatformVersionManager {
~PlatformVersionManager() = delete;
static Status GetPlatformVersion(std::string &ver) {
ver = "1.11.z";
std::vector<std::string> version_splits = StringUtils::Split(ver, '.');
const std::vector<std::string> version_splits = StringUtils::Split(ver, '.');
GE_IF_BOOL_EXEC(version_splits.size() < 3, GELOGW("Read platform version error!"); return FAILED;);

GELOGI("Read current platform version: %s.", ver.c_str());


Loading…
Cancel
Save