From 0d2dfa274852b0015c58df5474588c6714bdd5ca Mon Sep 17 00:00:00 2001 From: yanghaoran Date: Sat, 6 Nov 2021 11:46:52 +0800 Subject: [PATCH] fix missing hearders --- inc/framework/common/aicpu_op.h | 2 +- inc/framework/common/debug/ge_log.h | 90 ++++--- inc/framework/common/debug/log.h | 151 ++++++------ inc/framework/common/fmk_error_codes.h | 2 +- inc/framework/common/fmk_types.h | 2 +- inc/framework/common/ge_compiler_options.h | 2 +- inc/framework/common/ge_format_util.h | 4 +- inc/framework/common/ge_inner_error_codes.h | 44 ++-- inc/framework/common/ge_types.h | 43 ++-- inc/framework/common/gflags_util.h | 2 +- inc/framework/common/helper/model_helper.h | 12 +- inc/framework/common/helper/om_file_helper.h | 14 +- inc/framework/common/l2_cache_optimize.h | 25 +- inc/framework/common/op/attr_value_util.h | 4 +- inc/framework/common/op/ge_op_utils.h | 20 +- inc/framework/common/op/op_parser_util.h | 8 +- inc/framework/common/op_types.h | 10 +- inc/framework/common/profiling/ge_profiling.h | 4 +- .../common/profiling/ge_runner_profiling.h | 2 +- inc/framework/common/scope_guard.h | 15 +- inc/framework/common/string_util.h | 8 +- inc/framework/common/taskdown_common.h | 2 +- inc/framework/common/types.h | 211 +--------------- inc/framework/common/util.h | 229 +++++++++--------- inc/framework/engine/dnnengine.h | 29 ++- inc/framework/executor/ge_executor.h | 8 +- inc/framework/generator/ge_generator.h | 46 ++-- inc/framework/generator/generator_api.h | 187 -------------- inc/framework/memory/memory_api.h | 6 +- inc/framework/memory/memory_assigner.h | 6 +- inc/framework/omg/ge_init.h | 4 +- inc/framework/omg/model_tool.h | 2 +- inc/framework/omg/omg.h | 11 +- inc/framework/omg/omg_inner_types.h | 5 +- inc/framework/omg/omg_types.h | 2 +- inc/framework/omg/parser/model_parser.h | 2 +- inc/framework/omg/parser/op_parser.h | 4 +- inc/framework/omg/parser/parser_api.h | 4 +- inc/framework/omg/parser/parser_factory.h | 2 +- inc/framework/omg/parser/parser_inner_ctx.h | 2 +- inc/framework/omg/parser/parser_types.h | 4 +- inc/framework/omg/parser/weights_parser.h | 2 +- inc/framework/omg/version.h | 8 +- 43 files changed, 465 insertions(+), 775 deletions(-) delete mode 100644 inc/framework/generator/generator_api.h diff --git a/inc/framework/common/aicpu_op.h b/inc/framework/common/aicpu_op.h index 850ceca3..773d42fd 100644 --- a/inc/framework/common/aicpu_op.h +++ b/inc/framework/common/aicpu_op.h @@ -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. diff --git a/inc/framework/common/debug/ge_log.h b/inc/framework/common/debug/ge_log.h index 3e646440..dbd6f875 100644 --- a/inc/framework/common/debug/ge_log.h +++ b/inc/framework/common/debug/ge_log.h @@ -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(GE) +#define GE_MODULE_NAME static_cast(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(stat); \ - char *k = const_cast("status"); \ - char *v = const_cast(TraceStatStr[idx]); \ - KeyValue kv = {k, v}; \ - DlogWithKV(static_cast(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(stat); \ + char *k = const_cast("status"); \ + char *v = const_cast(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), (PURPOSE)); \ } \ - } while (0); + } while (false) #ifdef __cplusplus } #endif diff --git a/inc/framework/common/debug/log.h b/inc/framework/common/debug/log.h index f06faa1b..3b11ce57 100644 --- a/inc/framework/common/debug/log.h +++ b/inc/framework/common/debug/log.h @@ -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 #include -#include -#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 GE_FUNC_VISIBILITY std::string FmtToStr(const T &t) { diff --git a/inc/framework/common/fmk_error_codes.h b/inc/framework/common/fmk_error_codes.h index 188809bd..139785ae 100644 --- a/inc/framework/common/fmk_error_codes.h +++ b/inc/framework/common/fmk_error_codes.h @@ -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. diff --git a/inc/framework/common/fmk_types.h b/inc/framework/common/fmk_types.h index f84390da..906e2a69 100644 --- a/inc/framework/common/fmk_types.h +++ b/inc/framework/common/fmk_types.h @@ -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. diff --git a/inc/framework/common/ge_compiler_options.h b/inc/framework/common/ge_compiler_options.h index 6876740e..075c9403 100644 --- a/inc/framework/common/ge_compiler_options.h +++ b/inc/framework/common/ge_compiler_options.h @@ -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. diff --git a/inc/framework/common/ge_format_util.h b/inc/framework/common/ge_format_util.h index dfceefb8..3c621576 100644 --- a/inc/framework/common/ge_format_util.h +++ b/inc/framework/common/ge_format_util.h @@ -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 -#include "common/ge_inner_error_codes.h" +#include "framework/common/ge_inner_error_codes.h" #include "graph/tensor.h" namespace ge { diff --git a/inc/framework/common/ge_inner_error_codes.h b/inc/framework/common/ge_inner_error_codes.h index 3697a526..9e9b5d1d 100644 --- a/inc/framework/common/ge_inner_error_codes.h +++ b/inc/framework/common/ge_inner_error_codes.h @@ -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(RT_ERROR) +#define RT_ERROR_TO_GE_STATUS(RT_ERROR) static_cast(RT_ERROR) } // namespace ge #endif // INC_FRAMEWORK_COMMON_GE_INNER_ERROR_CODES_H_ diff --git a/inc/framework/common/ge_types.h b/inc/framework/common/ge_types.h index 83d01c1f..dcfb4961 100644 --- a/inc/framework/common/ge_types.h +++ b/inc/framework/common/ge_types.h @@ -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 +#include #include #include #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 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 input_desc; std::vector 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 &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 output_format; std::vector> output_shape; std::vector 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 workspace_bytes; std::vector input_format; std::vector> input_shape; std::vector input_data_type; diff --git a/inc/framework/common/gflags_util.h b/inc/framework/common/gflags_util.h index 6e9ea41b..5d374261 100644 --- a/inc/framework/common/gflags_util.h +++ b/inc/framework/common/gflags_util.h @@ -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. diff --git a/inc/framework/common/helper/model_helper.h b/inc/framework/common/helper/model_helper.h index 2a63291c..b3cf19a4 100644 --- a/inc/framework/common/helper/model_helper.h +++ b/inc/framework/common/helper/model_helper.h @@ -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 #include -#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); diff --git a/inc/framework/common/helper/om_file_helper.h b/inc/framework/common/helper/om_file_helper.h index 34509b39..45d61395 100644 --- a/inc/framework/common/helper/om_file_helper.h +++ b/inc/framework/common/helper/om_file_helper.h @@ -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 model_contexts_; + std::vector 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 model_contexts_; + std::vector model_contexts_; ModelFileHeader model_header_; OmFileContext context_; diff --git a/inc/framework/common/l2_cache_optimize.h b/inc/framework/common/l2_cache_optimize.h index e3606582..39bc1d13 100644 --- a/inc/framework/common/l2_cache_optimize.h +++ b/inc/framework/common/l2_cache_optimize.h @@ -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 +#include #include #include #include #include -#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 weightRCs; - vector opRCs; + std::vector weightRCs; + std::vector 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 &blocks); + void Merge(std::vector &blocks); // The RC information is aligned with the 2m address - void Align(vector &blocks); + void Align(std::vector &blocks); // Weight of l2loss operator, output of gradient aggregation output, RC value set to 0 - void HandleOutputZeroRC(RCType type, ge::NodePtr node, vector &outputList, vector &blocks); + void HandleOutputZeroRC(RCType type, ge::NodePtr node, std::vector &outputList, + std::vector &blocks); // Processing operator input Tensor's RC - void HandOPInput(ge::NodePtr node, vector &inputList, vector &blocks); + void HandOPInput(ge::NodePtr node, std::vector &inputList, std::vector &blocks); // Processing operator output Tensor's RC - void HandOPoutput(ge::NodePtr node, vector &outputList, vector &blocks); + void HandOPoutput(ge::NodePtr node, std::vector &outputList, std::vector &blocks); // maximum common divisor uint32_t Measure(uint32_t x, uint32_t y) { diff --git a/inc/framework/common/op/attr_value_util.h b/inc/framework/common/op/attr_value_util.h index 28d48c1d..cc4e0fcf 100644 --- a/inc/framework/common/op/attr_value_util.h +++ b/inc/framework/common/op/attr_value_util.h @@ -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_ diff --git a/inc/framework/common/op/ge_op_utils.h b/inc/framework/common/op/ge_op_utils.h index bc965d13..1d12c05b 100644 --- a/inc/framework/common/op/ge_op_utils.h +++ b/inc/framework/common/op/ge_op_utils.h @@ -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 #include -#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 &dim, std::vector &dim_vector); template static void SliceData(const std::vector &input, int64_t chunk_size, std::vector &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 GetWeights(const ge::Node &node); - static vector GetWeights(ge::ConstNodePtr node); - static vector MutableWeights(const ge::Node &node); - static vector MutableWeights(const ge::NodePtr node); - static Status SetWeights(ge::Node &node, const vector &weights); - static Status SetWeights(ge::NodePtr node, const vector &weights); + static std::vector GetWeights(const ge::Node &node); + static std::vector GetWeights(ge::ConstNodePtr node); + static std::vector MutableWeights(const ge::Node &node); + static std::vector MutableWeights(const ge::NodePtr node); + static Status SetWeights(ge::Node &node, const std::vector &weights); + static Status SetWeights(ge::NodePtr node, const std::vector &weights); static Status GetShapeDataFromConstTensor(const ConstGeTensorPtr &tensor, DataType type, std::vector &dims); private: diff --git a/inc/framework/common/op/op_parser_util.h b/inc/framework/common/op/op_parser_util.h index 43254ca9..12ce6980 100644 --- a/inc/framework/common/op/op_parser_util.h +++ b/inc/framework/common/op/op_parser_util.h @@ -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 -#include -#include +#include +#include +#include namespace ge { // general diff --git a/inc/framework/common/op_types.h b/inc/framework/common/op_types.h index fa41c1b6..4e4d4dda 100644 --- a/inc/framework/common/op_types.h +++ b/inc/framework/common/op_types.h @@ -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() {} }; diff --git a/inc/framework/common/profiling/ge_profiling.h b/inc/framework/common/profiling/ge_profiling.h index 0a7c9181..f0ecc5d1 100644 --- a/inc/framework/common/profiling/ge_profiling.h +++ b/inc/framework/common/profiling/ge_profiling.h @@ -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" /// diff --git a/inc/framework/common/profiling/ge_runner_profiling.h b/inc/framework/common/profiling/ge_runner_profiling.h index 1c594c5b..b0a666ce 100644 --- a/inc/framework/common/profiling/ge_runner_profiling.h +++ b/inc/framework/common/profiling/ge_runner_profiling.h @@ -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. diff --git a/inc/framework/common/scope_guard.h b/inc/framework/common/scope_guard.h index 62ae4b6d..4ec4cfa7 100644 --- a/inc/framework/common/scope_guard.h +++ b/inc/framework/common/scope_guard.h @@ -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 on_exit_scope_; diff --git a/inc/framework/common/string_util.h b/inc/framework/common/string_util.h index 677b1971..4d808e2e 100644 --- a/inc/framework/common/string_util.h +++ b/inc/framework/common/string_util.h @@ -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(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 Split(const std::string &str, char delim) { - std::vector elems; + static std::vector> Split(const std::string &str, char delim) { + std::vector> elems; if (str.empty()) { elems.emplace_back(""); diff --git a/inc/framework/common/taskdown_common.h b/inc/framework/common/taskdown_common.h index 81a532dd..1417677c 100644 --- a/inc/framework/common/taskdown_common.h +++ b/inc/framework/common/taskdown_common.h @@ -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. diff --git a/inc/framework/common/types.h b/inc/framework/common/types.h index 811d5eed..053a3423 100644 --- a/inc/framework/common/types.h +++ b/inc/framework/common/types.h @@ -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 -#include +#include +#include #include #include #include @@ -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 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 static std::pair flip_pair(const std::pair &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 diff --git a/inc/framework/common/util.h b/inc/framework/common/util.h index a3989b9d..c854e016 100644 --- a/inc/framework/common/util.h +++ b/inc/framework/common/util.h @@ -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 -#include -#include +#include +#include #include #include #include -#include "framework/common/debug/ge_log.h" +#include #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 &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 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 +GE_FUNC_VISIBILITY std::string ToString(const google::protobuf::RepeatedPtrField &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 diff --git a/inc/framework/engine/dnnengine.h b/inc/framework/engine/dnnengine.h index 8a0f3b65..84d5705a 100644 --- a/inc/framework/engine/dnnengine.h +++ b/inc/framework/engine/dnnengine.h @@ -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 #include -#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 &options) = 0; - virtual Status Finalize() = 0; - virtual void GetAttributes(DNNEngineAttribute &attr) const = 0; + Status Initialize(const std::map &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 diff --git a/inc/framework/executor/ge_executor.h b/inc/framework/executor/ge_executor.h index ce7c82ac..c5df77df 100644 --- a/inc/framework/executor/ge_executor.h +++ b/inc/framework/executor/ge_executor.h @@ -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 #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" diff --git a/inc/framework/generator/ge_generator.h b/inc/framework/generator/ge_generator.h index 5da5a593..b746dbac 100644 --- a/inc/framework/generator/ge_generator.h +++ b/inc/framework/generator/ge_generator.h @@ -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 #include #include -#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 &>; 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 &inputs = std::vector()); - Status GenerateOnlineModel(const Graph &graph, const vector &inputs, ge::ModelBufferData &model); + Status GenerateOnlineModel(const Graph &graph, const std::vector &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 &inputs, const vector &outputs, - OpEngineType engine_type, ModelBufferData &model_buff); - Status BuildSingleOpModel(OpDescPtr &op_desc, const vector &inputs, const vector &outputs, - OpEngineType engine_type, int32_t compile_flag, ModelBufferData &model_buff); + Status BuildSingleOpModel(OpDescPtr &op_desc, const std::vector &inputs, + const std::vector &outputs, OpEngineType engine_type, + ModelBufferData &model_buff); + Status BuildSingleOpModel(OpDescPtr &op_desc, const std::vector &inputs, + const std::vector &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 &inputs, const vector &outputs, - std::string graph_name, Graph &graph); + Status BuildSingleOpGraph(OpDescPtr &op_desc, const InOutTensorRef &inputs_outputs, std::string graph_name, + Graph &graph, std::vector> &inputs_name_type); private: - Status GenerateModel(const Graph &graph, const string &file_name_prefix, const vector &inputs, + Status GenerateModel(const Graph &graph, const std::string &file_name_prefix, const std::vector &inputs, ge::ModelBufferData &model, bool is_offline = true); - Status BuildSingleOp(OpDescPtr &op_desc, const vector &inputs, const vector &outputs, - const string &model_file_name, OpEngineType engine_type, ModelBufferData &model_buff, + Status BuildSingleOp(OpDescPtr &op_desc, const std::vector &inputs, const std::vector &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 &inputs, vector &outputs); - Status CheckForSingleOp(OpDescPtr &op_desc, const vector &inputs, const vector &outputs); + void RemoveConst(const std::vector &inputs, std::vector &outputs); + Status CheckForSingleOp(OpDescPtr &op_desc, const std::vector &inputs, + const std::vector &outputs); Status InferFormatForSingleOp(OpDescPtr &op_desc, Graph &graph); using GeRootModelPtr = std::shared_ptr; Status SetModelNameForDump(const GeRootModelPtr &ge_root_model); + Status CreateGeneralizedBuildAttrs(const GeRootModelPtr &ge_root_model, const std::vector &inputs, + const std::vector &outputs, + const std::vector> &inputs_name_type, + std::vector &generalized_build_attrs); class Impl; diff --git a/inc/framework/generator/generator_api.h b/inc/framework/generator/generator_api.h deleted file mode 100644 index 56b83a20..00000000 --- a/inc/framework/generator/generator_api.h +++ /dev/null @@ -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 - -#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_ diff --git a/inc/framework/memory/memory_api.h b/inc/framework/memory/memory_api.h index da36cdd6..a04a1ebe 100644 --- a/inc/framework/memory/memory_api.h +++ b/inc/framework/memory/memory_api.h @@ -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 #include -#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 { diff --git a/inc/framework/memory/memory_assigner.h b/inc/framework/memory/memory_assigner.h index 173cc64e..1ccbd785 100644 --- a/inc/framework/memory/memory_assigner.h +++ b/inc/framework/memory/memory_assigner.h @@ -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 -#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 &mem_offset, size_t &zero_copy_mem_size); + Status AssignMemory(bool is_loop_graph, std::map &mem_offset, size_t &zero_copy_mem_size); private: ge::ComputeGraphPtr compute_graph_; diff --git a/inc/framework/omg/ge_init.h b/inc/framework/omg/ge_init.h index 67ef1082..a2fe6fc9 100644 --- a/inc/framework/omg/ge_init.h +++ b/inc/framework/omg/ge_init.h @@ -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 #include -#include "common/ge_inner_error_codes.h" +#include "framework/common/ge_inner_error_codes.h" namespace ge { class GE_FUNC_VISIBILITY GEInit { diff --git a/inc/framework/omg/model_tool.h b/inc/framework/omg/model_tool.h index 8c425823..24554e65 100644 --- a/inc/framework/omg/model_tool.h +++ b/inc/framework/omg/model_tool.h @@ -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. diff --git a/inc/framework/omg/omg.h b/inc/framework/omg/omg.h index a5360bb3..029b7a24 100644 --- a/inc/framework/omg/omg.h +++ b/inc/framework/omg/omg.h @@ -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 &atc_params, +GE_FUNC_VISIBILITY Status ParseGraph(ge::Graph &graph, const std::map &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 &fileList, string &caffe_parser_path); +GE_FUNC_VISIBILITY void FindParserSo(const std::string &path, std::vector &fileList, + std::string &caffe_parser_path); GE_FUNC_VISIBILITY Status DumpInfershapeJson(const ge::Graph &graph, const char *json_file); diff --git a/inc/framework/omg/omg_inner_types.h b/inc/framework/omg/omg_inner_types.h index a3621d8b..3f7b5db1 100644 --- a/inc/framework/omg/omg_inner_types.h +++ b/inc/framework/omg/omg_inner_types.h @@ -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> user_real_input_dims; - std::vector cur_dynamic_dims; bool need_multi_batch = false; std::vector data_nodes; std::vector 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 diff --git a/inc/framework/omg/omg_types.h b/inc/framework/omg/omg_types.h index 771a53a4..8ec2a49b 100644 --- a/inc/framework/omg/omg_types.h +++ b/inc/framework/omg/omg_types.h @@ -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. diff --git a/inc/framework/omg/parser/model_parser.h b/inc/framework/omg/parser/model_parser.h index d311706d..b6ebd8a8 100644 --- a/inc/framework/omg/parser/model_parser.h +++ b/inc/framework/omg/parser/model_parser.h @@ -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. diff --git a/inc/framework/omg/parser/op_parser.h b/inc/framework/omg/parser/op_parser.h index 7d02b257..760b41f5 100644 --- a/inc/framework/omg/parser/op_parser.h +++ b/inc/framework/omg/parser/op_parser.h @@ -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 #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" diff --git a/inc/framework/omg/parser/parser_api.h b/inc/framework/omg/parser/parser_api.h index a493e29f..26c9e051 100644 --- a/inc/framework/omg/parser/parser_api.h +++ b/inc/framework/omg/parser/parser_api.h @@ -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 #include #include -#include "ge/ge_api_error_codes.h" +#include "external/ge/ge_api_error_codes.h" namespace ge { // Initialize parser diff --git a/inc/framework/omg/parser/parser_factory.h b/inc/framework/omg/parser/parser_factory.h index 06aaecb7..5b505d52 100644 --- a/inc/framework/omg/parser/parser_factory.h +++ b/inc/framework/omg/parser/parser_factory.h @@ -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. diff --git a/inc/framework/omg/parser/parser_inner_ctx.h b/inc/framework/omg/parser/parser_inner_ctx.h index 5de54704..fd559468 100644 --- a/inc/framework/omg/parser/parser_inner_ctx.h +++ b/inc/framework/omg/parser/parser_inner_ctx.h @@ -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. diff --git a/inc/framework/omg/parser/parser_types.h b/inc/framework/omg/parser/parser_types.h index f3b7f00a..a2452c65 100644 --- a/inc/framework/omg/parser/parser_types.h +++ b/inc/framework/omg/parser/parser_types.h @@ -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 +#include #include #include "register/register_types.h" diff --git a/inc/framework/omg/parser/weights_parser.h b/inc/framework/omg/parser/weights_parser.h index a568f927..c231fd41 100644 --- a/inc/framework/omg/parser/weights_parser.h +++ b/inc/framework/omg/parser/weights_parser.h @@ -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. diff --git a/inc/framework/omg/version.h b/inc/framework/omg/version.h index 4facba0d..156fbc5c 100644 --- a/inc/framework/omg/version.h +++ b/inc/framework/omg/version.h @@ -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 #include -#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 version_splits = StringUtils::Split(ver, '.'); + const std::vector 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());