@@ -66,7 +66,7 @@ elseif(DEFINED ENV{D_LINK_PATH}) | |||||
endif() | endif() | ||||
set(GE_LIB_PATH ${GE_LIB_PATH}/${GE_SYS_ARCH}) | set(GE_LIB_PATH ${GE_LIB_PATH}/${GE_SYS_ARCH}) | ||||
find_library(slog libslog.so ${GE_LIB_PATH}) | find_library(slog libslog.so ${GE_LIB_PATH}) | ||||
find_library(mmpa libmmpa.so ${GE_LIB_PATH}) | |||||
find_library(mmpa libmmpa.a ${GE_LIB_PATH}) | |||||
find_library(runtime libruntime.so ${GE_LIB_PATH}) | find_library(runtime libruntime.so ${GE_LIB_PATH}) | ||||
find_library(msprof libmsprofiler.a ${GE_LIB_PATH}) | find_library(msprof libmsprofiler.a ${GE_LIB_PATH}) | ||||
find_library(register libregister.so ${GE_LIB_PATH}) | find_library(register libregister.so ${GE_LIB_PATH}) | ||||
@@ -84,7 +84,7 @@ else() | |||||
set(ASCEND_DRIVER_DIR ${ASCEND_DIR}/driver/lib64/common ${ASCEND_DIR}/driver/lib64) | set(ASCEND_DRIVER_DIR ${ASCEND_DIR}/driver/lib64/common ${ASCEND_DIR}/driver/lib64) | ||||
set(ASCEND_RUNTIME_DIR ${ASCEND_DIR}/fwkacllib/lib64 ${ASCEND_DIR}/acllib/lib64 ${ASCEND_DIR}/atc/lib64) | set(ASCEND_RUNTIME_DIR ${ASCEND_DIR}/fwkacllib/lib64 ${ASCEND_DIR}/acllib/lib64 ${ASCEND_DIR}/atc/lib64) | ||||
find_library(slog libslog.so ${ASCEND_DRIVER_DIR}) | find_library(slog libslog.so ${ASCEND_DRIVER_DIR}) | ||||
find_library(mmpa libmmpa.so ${ASCEND_DRIVER_DIR}) | |||||
find_library(mmpa libmmpa.a ${ASCEND_RUNTIME_DIR}) | |||||
find_library(msprof libmsprofiler.a ${ASCEND_RUNTIME_DIR}) | find_library(msprof libmsprofiler.a ${ASCEND_RUNTIME_DIR}) | ||||
find_library(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) | find_library(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) | ||||
@@ -67,6 +67,28 @@ class ErrorManager { | |||||
void ATCReportErrMessage(std::string error_code, const std::vector<std::string> &key = {}, | void ATCReportErrMessage(std::string error_code, const std::vector<std::string> &key = {}, | ||||
const std::vector<std::string> &value = {}); | const std::vector<std::string> &value = {}); | ||||
/// | |||||
/// @brief report graph compile failed message such as error code and op_name in mstune case | |||||
/// @param [in] msg: failed message map, key is error code, value is op_name | |||||
/// @return int 0(success) -1(fail) | |||||
/// | |||||
int ReportMstuneCompileFailedMsg(const std::map<std::string, std::string> &msg); | |||||
/// | |||||
/// @brief save graph compile failed message from thread local map to global map | |||||
/// @param [in] graph_name: graph name | |||||
/// | |||||
void SaveMstuneCompileFailedMsg(const std::string &graph_name); | |||||
/// | |||||
/// @brief get graph compile failed message in mstune case | |||||
/// @param [in] graph_name: graph name | |||||
/// @param [out] msg_map: failed message map, key is error code, value is op_name list | |||||
/// @return int 0(success) -1(fail) | |||||
/// | |||||
int GetMstuneCompileFailedMsg(const std::string &graph_name, | |||||
std::map<std::string, std::vector<std::string>> &msg_map); | |||||
private: | private: | ||||
struct ErrorInfo { | struct ErrorInfo { | ||||
std::string error_id; | std::string error_id; | ||||
@@ -91,6 +113,7 @@ class ErrorManager { | |||||
std::map<std::string, ErrorInfo> error_map_; | std::map<std::string, ErrorInfo> error_map_; | ||||
std::vector<std::string> error_messages_; | std::vector<std::string> error_messages_; | ||||
std::vector<std::string> warning_messages_; | std::vector<std::string> warning_messages_; | ||||
std::map<std::string, std::map<std::string, std::vector<std::string>>> compile_failed_msg_map_; | |||||
}; | }; | ||||
#endif // ERROR_MANAGER_H_ | #endif // ERROR_MANAGER_H_ |
@@ -29,16 +29,26 @@ | |||||
namespace ge { | namespace ge { | ||||
typedef uint32_t (*pCallBackFunc)(uint32_t graph_id, const std::map<std::string, ge::Tensor> ¶ms_list); | typedef uint32_t (*pCallBackFunc)(uint32_t graph_id, const std::map<std::string, ge::Tensor> ¶ms_list); | ||||
namespace session { | |||||
typedef uint32_t (*pCallBackFunc)(uint32_t graph_id, const std::map<AscendString, ge::Tensor> ¶ms_list); | |||||
} | |||||
// Initialize GE | // Initialize GE | ||||
ATTRIBUTED_DEPRECATED(Status GEInitialize(const std::map<AscendString, AscendString> &)) | |||||
Status GEInitialize(const std::map<std::string, std::string> &options); | Status GEInitialize(const std::map<std::string, std::string> &options); | ||||
Status GEInitialize(const std::map<AscendString, AscendString> &options); | |||||
// Finalize GE, release all resources | // Finalize GE, release all resources | ||||
Status GEFinalize(); | Status GEFinalize(); | ||||
class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Session { | class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Session { | ||||
public: | public: | ||||
ATTRIBUTED_DEPRECATED(Session(const std::map<AscendString, AscendString> &)) | |||||
explicit Session(const std::map<std::string, std::string> &options); | explicit Session(const std::map<std::string, std::string> &options); | ||||
explicit Session(const std::map<AscendString, AscendString> &options); | |||||
~Session(); | ~Session(); | ||||
/// | /// | ||||
@@ -57,10 +67,21 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Session { | |||||
/// @param [in] options graph options | /// @param [in] options graph options | ||||
/// @return Status result of function | /// @return Status result of function | ||||
/// | /// | ||||
ATTRIBUTED_DEPRECATED(Status AddGraph(uint32_t, const Graph &, const std::map<AscendString, AscendString> &)) | |||||
Status AddGraph(uint32_t graphId, const Graph &graph, const std::map<std::string, std::string> &options); | Status AddGraph(uint32_t graphId, const Graph &graph, const std::map<std::string, std::string> &options); | ||||
/// | /// | ||||
/// @ingroup client | /// @ingroup client | ||||
/// @brief add a graph with a specific graphId and graphOptions | |||||
/// @param [in] graphId graph id | |||||
/// @param [in] graph the graph | |||||
/// @param [in] options graph options | |||||
/// @return Status result of function | |||||
/// | |||||
Status AddGraph(uint32_t graphId, const Graph &graph, const std::map<AscendString, AscendString> &options); | |||||
/// | |||||
/// @ingroup client | |||||
/// @brief add a copy graph with a specific graphId | /// @brief add a copy graph with a specific graphId | ||||
/// @param [in] graphId graph id | /// @param [in] graphId graph id | ||||
/// @param [in] graph the graph | /// @param [in] graph the graph | ||||
@@ -124,10 +145,20 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Session { | |||||
/// @param [out] var_values: variable values | /// @param [out] var_values: variable values | ||||
/// @return Status result of function | /// @return Status result of function | ||||
/// | /// | ||||
ATTRIBUTED_DEPRECATED(Status GetVariables(const std::vector<std::string> &, std::vector<Tensor> &)) | |||||
Status GetVariables(const std::vector<std::string> &var_names, std::vector<Tensor> &var_values); | Status GetVariables(const std::vector<std::string> &var_names, std::vector<Tensor> &var_values); | ||||
/// | /// | ||||
/// @ingroup ge_graph | /// @ingroup ge_graph | ||||
/// @brief get variables in the session with specific session id | |||||
/// @param [in] var_names: variable names | |||||
/// @param [out] var_values: variable values | |||||
/// @return Status result of function | |||||
/// | |||||
Status GetVariables(const std::vector<AscendString> &var_names, std::vector<Tensor> &var_values); | |||||
/// | |||||
/// @ingroup ge_graph | |||||
/// @brief register callback func with specific summary or checkpoint by users | /// @brief register callback func with specific summary or checkpoint by users | ||||
/// @param [in] key: func key | /// @param [in] key: func key | ||||
/// @param [in] callback: callback specific summary or checkpoint. | /// @param [in] callback: callback specific summary or checkpoint. | ||||
@@ -135,8 +166,11 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Session { | |||||
/// Please ensure that the implementation of the function is trusted. | /// Please ensure that the implementation of the function is trusted. | ||||
/// @return Status result of function | /// @return Status result of function | ||||
/// | /// | ||||
ATTRIBUTED_DEPRECATED(Status RegisterCallBackFunc(const char *, const session::pCallBackFunc &)) | |||||
Status RegisterCallBackFunc(const std::string &key, const pCallBackFunc &callback); | Status RegisterCallBackFunc(const std::string &key, const pCallBackFunc &callback); | ||||
Status RegisterCallBackFunc(const char *key, const session::pCallBackFunc &callback); | |||||
bool IsGraphNeedRebuild(uint32_t graphId); | bool IsGraphNeedRebuild(uint32_t graphId); | ||||
private: | private: | ||||
@@ -19,8 +19,15 @@ | |||||
#include <map> | #include <map> | ||||
#include <string> | #include <string> | ||||
#include "ge_error_codes.h" | |||||
namespace ge { | namespace ge { | ||||
#ifdef __GNUC__ | |||||
#define ATTRIBUTED_DEPRECATED(replacement) __attribute__((deprecated("Please use " #replacement " instead."))) | |||||
#else | |||||
#define ATTRIBUTED_DEPRECATED(replacement) __declspec(deprecated("Please use " #replacement " instead.")) | |||||
#endif | |||||
class StatusFactory { | class StatusFactory { | ||||
public: | public: | ||||
static StatusFactory *Instance() { | static StatusFactory *Instance() { | ||||
@@ -36,6 +43,17 @@ class StatusFactory { | |||||
err_desc_[err] = desc; | err_desc_[err] = desc; | ||||
} | } | ||||
void RegisterErrorNo(uint32_t err, const char *desc) { | |||||
if (desc == nullptr) { | |||||
return; | |||||
} | |||||
std::string error_desc = desc; | |||||
if (err_desc_.find(err) != err_desc_.end()) { | |||||
return; | |||||
} | |||||
err_desc_[err] = error_desc; | |||||
} | |||||
std::string GetErrDesc(uint32_t err) { | std::string GetErrDesc(uint32_t err) { | ||||
auto iter_find = err_desc_.find(err); | auto iter_find = err_desc_.find(err); | ||||
if (iter_find == err_desc_.end()) { | if (iter_find == err_desc_.end()) { | ||||
@@ -55,6 +73,7 @@ class StatusFactory { | |||||
class ErrorNoRegisterar { | class ErrorNoRegisterar { | ||||
public: | public: | ||||
ErrorNoRegisterar(uint32_t err, const std::string &desc) { StatusFactory::Instance()->RegisterErrorNo(err, desc); } | ErrorNoRegisterar(uint32_t err, const std::string &desc) { StatusFactory::Instance()->RegisterErrorNo(err, desc); } | ||||
ErrorNoRegisterar(uint32_t err, const char *desc) { StatusFactory::Instance()->RegisterErrorNo(err, desc); } | |||||
~ErrorNoRegisterar() {} | ~ErrorNoRegisterar() {} | ||||
}; | }; | ||||
@@ -66,11 +85,47 @@ class ErrorNoRegisterar { | |||||
((0xFF & (static_cast<uint8_t>(modid))) << 12) | (0x0FFF & (static_cast<uint16_t>(value))); \ | ((0xFF & (static_cast<uint8_t>(modid))) << 12) | (0x0FFF & (static_cast<uint16_t>(value))); \ | ||||
const ErrorNoRegisterar g_##name##_errorno(name, desc); | const ErrorNoRegisterar g_##name##_errorno(name, desc); | ||||
#define GE_ERRORNO_EXTERNAL(name, desc) const ErrorNoRegisterar g_##name##_errorno(name, desc); | |||||
using Status = uint32_t; | using Status = uint32_t; | ||||
// General error code | // General error code | ||||
GE_ERRORNO(0, 0, 0, 0, 0, SUCCESS, 0, "success"); | GE_ERRORNO(0, 0, 0, 0, 0, SUCCESS, 0, "success"); | ||||
GE_ERRORNO(0b11, 0b11, 0b111, 0xFF, 0b11111, FAILED, 0xFFF, "failed"); | GE_ERRORNO(0b11, 0b11, 0b111, 0xFF, 0b11111, FAILED, 0xFFF, "failed"); | ||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_PARAM_INVALID, "Parameter invalid."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_NOT_INIT, "GE executor not initialized yet."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "Model file path invalid."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_ID_INVALID, "Model id invalid."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_KEY_PATH_INVALID, "Model key path invalid."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_NOT_SUPPORT_ENCRYPTION, "Model does not support encryption."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID, "Data size of model invalid."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_ADDR_INVALID, "Model addr invalid."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_QUEUE_ID_INVALID, "Queue id of model invalid."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_LOAD_MODEL_REPEATED, "The model loaded repeatedly."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_PARTITION_NUM_INVALID, "Model partition num invalid."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_DYNAMIC_INPUT_ADDR_INVALID, "Dynamic input addr invalid."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_DYNAMIC_INPUT_LENGTH_INVALID, "Dynamic input size invalid."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_DYNAMIC_BATCH_SIZE_INVALID, "Dynamic batch size invalid."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_AIPP_BATCH_EMPTY, "AIPP batch parameter empty."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_AIPP_NOT_EXIST, "AIPP parameter not exist."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_AIPP_MODE_INVALID, "AIPP mode invalid."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_OP_TASK_TYPE_INVALID, "Task type invalid."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_OP_KERNEL_TYPE_INVALID, "Kernel type invalid."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_MEMORY_ALLOCATION, "Memory allocation error."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_INTERNAL_ERROR, "Internal error."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_LOAD_MODEL, "Load model error."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_LOAD_MODEL_PARTITION_FAILED, "Failed to load model partition."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_LOAD_WEIGHT_PARTITION_FAILED, "Failed to load weight partition."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_LOAD_TASK_PARTITION_FAILED, "Failed to load task partition."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_LOAD_KERNEL_PARTITION_FAILED, "Failed to load op kernel partition."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_RELEASE_MODEL_DATA, "Failed to release the model data."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_COMMAND_HANDLE, "Command handle error."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_GET_TENSOR_INFO, "Get tensor info error."); | |||||
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_UNLOAD_MODEL, "Load model error."); | |||||
} // namespace ge | } // namespace ge | ||||
#endif // INC_EXTERNAL_GE_GE_API_ERROR_CODES_H_ | #endif // INC_EXTERNAL_GE_GE_API_ERROR_CODES_H_ |
@@ -65,7 +65,47 @@ const char *const OPTION_EXEC_ENABLE_TAILING_OPTIMIZATION = "ge.exec.isTailingOp | |||||
// Option key: memory init | // Option key: memory init | ||||
const char *const GRAPH_MEMORY_MAX_SIZE = "ge.graphMemoryMaxSize"; | const char *const GRAPH_MEMORY_MAX_SIZE = "ge.graphMemoryMaxSize"; | ||||
const char *const VARIABLE_MEMORY_MAX_SIZE = "ge.variableMemoryMaxSize"; | const char *const VARIABLE_MEMORY_MAX_SIZE = "ge.variableMemoryMaxSize"; | ||||
namespace configure_option { | |||||
const char *const STREAM_NUM = "ge.streamNum"; | |||||
const char *const HEAD_STREAM = "ge.headStream"; | |||||
const char *const PERF_LEVEL = "ge.perfLevel"; | |||||
const char *const ENCRYPT_MODE = "ge.encryptMode"; | |||||
const char *const EK_FILE = "ge.ekFile"; | |||||
const char *const CERT_FILE = "ge.certFile"; | |||||
const char *const HW_KEY_FILE = "ge.hwKeyFile"; | |||||
const char *const PRIVATE_KEY_FILE = "ge.privateKeyFile"; | |||||
const char *const FRAMEWORK_TYPE = "ge.frameworkType"; | |||||
const char *const CALIBRATION_CONF_FILE = "ge.calibrationConfFile"; | |||||
const char *const INSERT_OP_FILE = "ge.insertOpFile"; | |||||
const char *const OUTPUT_NODE_NAME = "ge.outputNodeName"; | |||||
const char *const COMPRESS_FLAG = "ge.compressFlag"; | |||||
const char *const PRECISION_MODE = "ge.exec.precision_mode"; | |||||
const char *const SINGLE_OP_FLAG = "ge.exec.single_op"; | |||||
const char *const TRAIN_FLAG = "ge.trainFlag"; | |||||
const char *const RUN_FLAG = "ge.runFlag"; | |||||
const char *const LOCAL_FMKOP_FLAG = "ge.enabledLocalFmkop"; | |||||
const char *const TBE_PLUGIN_PATH_FLAG = "ge.TBE_plugin_path"; | |||||
const char *const DDK_VERSION_FLAG = "ge.DDK_version"; | |||||
const char *const GE_FE_FLAG = "ge.feFlag"; | |||||
const char *const STREAM_MAX_PARALLEL_NUM = "ge.streamMaxParallelNum"; | |||||
const char *const OUTPUT_DATATYPE = "ge.outputDatatype"; | |||||
const char *const OP_SELECT_IMPL_MODE = "ge.opSelectImplmode"; | |||||
const char *const OPTYPELIST_FOR_IMPLMODE = "ge.optypelistForImplmode"; | |||||
const char *const HCOM_PARALLEL = "ge.hcomParallel"; | |||||
const char *const AUTO_TUNE_MODE = "ge.autoTuneMode"; | |||||
const char *const SOC_VERSION = "ge.socVersion"; | |||||
const char *const CORE_TYPE = "ge.engineType"; | |||||
const char *const AICORE_NUM = "ge.aicoreNum"; | |||||
const char *const L1_FUSION = "ge.l1Fusion"; | |||||
const char *const BUFFER_OPTIMIZE = "ge.bufferOptimize"; | |||||
const char *const ENABLE_SMALL_CHANNEL = "ge.enableSmallChannel"; | |||||
const char *const ENABLE_COMPRESS_WEIGHT = "ge.enableCompressWeight"; | |||||
const char *const FUSION_SWITCH_FILE = "ge.fusionSwitchFile"; | |||||
const char *const SAVE_ORIGINAL_MODEL = "ge.saveOriginalModel"; | |||||
const char *const ORIGINAL_MODEL_FILE = "ge.originalModelFile"; | |||||
const char *const INPUT_FP16_NODES = "ge.INPUT_NODES_SET_FP16"; | |||||
const char *const OP_DEBUG_LEVEL = "ge.opDebugLevel"; | |||||
} // namespace configure_option | |||||
// Configure stream num by Session constructor options param, | // Configure stream num by Session constructor options param, | ||||
// its value should be int32_t type, default value is "1" | // its value should be int32_t type, default value is "1" | ||||
const std::string STREAM_NUM = "ge.streamNum"; | const std::string STREAM_NUM = "ge.streamNum"; | ||||
@@ -174,6 +214,9 @@ const std::string HCOM_PARALLEL = "ge.hcomParallel"; | |||||
// configure whether to use dynamic batch size | // configure whether to use dynamic batch size | ||||
const char *const kDynamicBatchSize = "ge.dynamicBatchSize"; | const char *const kDynamicBatchSize = "ge.dynamicBatchSize"; | ||||
const std::string INPUT_SHAPE = "ge.inputShape"; | |||||
const std::string DYNAMIC_NODE_TYPE = "ge.dynamicNodeType"; | |||||
// configure whether to use dynamic image size | // configure whether to use dynamic image size | ||||
const char *const kDynamicImageSize = "ge.dynamicImageSize"; | const char *const kDynamicImageSize = "ge.dynamicImageSize"; | ||||
@@ -323,6 +366,7 @@ static const char *const OP_COMPILER_CACHE_DIR = ge::OP_COMPILER_CACHE_DIR; | |||||
static const char *const OP_COMPILER_CACHE_MODE = ge::OP_COMPILER_CACHE_MODE; | static const char *const OP_COMPILER_CACHE_MODE = ge::OP_COMPILER_CACHE_MODE; | ||||
static const char *const MDL_BANK_PATH_FLAG = ge::MDL_BANK_PATH_FLAG.c_str(); | static const char *const MDL_BANK_PATH_FLAG = ge::MDL_BANK_PATH_FLAG.c_str(); | ||||
static const char *const OP_BANK_PATH_FLAG = ge::OP_BANK_PATH_FLAG.c_str(); | static const char *const OP_BANK_PATH_FLAG = ge::OP_BANK_PATH_FLAG.c_str(); | ||||
static const char *const OP_DEBUG_LEVEL = ge::OP_DEBUG_LEVEL.c_str(); | |||||
// for interface: aclgrphBuildModel | // for interface: aclgrphBuildModel | ||||
const std::set<std::string> ir_builder_suppported_options = {INPUT_FORMAT, | const std::set<std::string> ir_builder_suppported_options = {INPUT_FORMAT, | ||||
@@ -342,7 +386,9 @@ const std::set<std::string> ir_builder_suppported_options = {INPUT_FORMAT, | |||||
OP_DEBUG_LEVEL, | OP_DEBUG_LEVEL, | ||||
DEBUG_DIR, | DEBUG_DIR, | ||||
OP_COMPILER_CACHE_DIR, | OP_COMPILER_CACHE_DIR, | ||||
OP_COMPILER_CACHE_MODE}; | |||||
OP_COMPILER_CACHE_MODE, | |||||
MDL_BANK_PATH_FLAG, | |||||
OP_BANK_PATH_FLAG}; | |||||
// for interface: aclgrphParse | // for interface: aclgrphParse | ||||
const std::set<std::string> ir_parser_suppported_options = {INPUT_FORMAT, | const std::set<std::string> ir_parser_suppported_options = {INPUT_FORMAT, | ||||
@@ -357,9 +403,7 @@ const std::set<std::string> ir_parser_suppported_options = {INPUT_FORMAT, | |||||
OUT_NODES, | OUT_NODES, | ||||
COMPRESS_WEIGHT_CONF, | COMPRESS_WEIGHT_CONF, | ||||
ENABLE_SCOPE_FUSION_PASSES, | ENABLE_SCOPE_FUSION_PASSES, | ||||
LOG_LEVEL, | |||||
MDL_BANK_PATH_FLAG, | |||||
OP_BANK_PATH_FLAG}; | |||||
LOG_LEVEL}; | |||||
// for interface: aclgrphBuildInitialize | // for interface: aclgrphBuildInitialize | ||||
const std::set<std::string> global_options = {CORE_TYPE, | const std::set<std::string> global_options = {CORE_TYPE, | ||||
@@ -0,0 +1,58 @@ | |||||
/** | |||||
* 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_EXTERNAL_GE_GE_ERROR_CODES_H_ | |||||
#define INC_EXTERNAL_GE_GE_ERROR_CODES_H_ | |||||
#include <stddef.h> | |||||
#ifdef __cplusplus | |||||
extern "C" { | |||||
#endif | |||||
static const uint32_t ACL_ERROR_GE_PARAM_INVALID = 145000; | |||||
static const uint32_t ACL_ERROR_GE_EXEC_NOT_INIT = 145001; | |||||
static const uint32_t ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID = 145002; | |||||
static const uint32_t ACL_ERROR_GE_EXEC_MODEL_ID_INVALID = 145003; | |||||
static const uint32_t ACL_ERROR_GE_EXEC_MODEL_KEY_PATH_INVALID = 145004; | |||||
static const uint32_t ACL_ERROR_GE_EXEC_MODEL_NOT_SUPPORT_ENCRYPTION = 145005; | |||||
static const uint32_t ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID = 145006; | |||||
static const uint32_t ACL_ERROR_GE_EXEC_MODEL_ADDR_INVALID = 145007; | |||||
static const uint32_t ACL_ERROR_GE_EXEC_MODEL_QUEUE_ID_INVALID = 145008; | |||||
static const uint32_t ACL_ERROR_GE_EXEC_LOAD_MODEL_REPEATED = 145009; | |||||
static const uint32_t ACL_ERROR_GE_EXEC_MODEL_PARTITION_NUM_INVALID = 145010; | |||||
static const uint32_t ACL_ERROR_GE_DYNAMIC_INPUT_ADDR_INVALID = 145011; | |||||
static const uint32_t ACL_ERROR_GE_DYNAMIC_INPUT_LENGTH_INVALID = 145012; | |||||
static const uint32_t ACL_ERROR_GE_DYNAMIC_BATCH_SIZE_INVALID = 145013; | |||||
static const uint32_t ACL_ERROR_GE_AIPP_BATCH_EMPTY = 145014; | |||||
static const uint32_t ACL_ERROR_GE_AIPP_NOT_EXIST = 145015; | |||||
static const uint32_t ACL_ERROR_GE_AIPP_MODE_INVALID = 145016; | |||||
static const uint32_t ACL_ERROR_GE_OP_TASK_TYPE_INVALID = 145017; | |||||
static const uint32_t ACL_ERROR_GE_OP_KERNEL_TYPE_INVALID = 145018; | |||||
static const uint32_t ACL_ERROR_GE_MEMORY_ALLOCATION = 245000; | |||||
static const uint32_t ACL_ERROR_GE_INTERNAL_ERROR = 545000; | |||||
static const uint32_t ACL_ERROR_GE_LOAD_MODEL = 545001; | |||||
static const uint32_t ACL_ERROR_GE_EXEC_LOAD_MODEL_PARTITION_FAILED = 545002; | |||||
static const uint32_t ACL_ERROR_GE_EXEC_LOAD_WEIGHT_PARTITION_FAILED = 545003; | |||||
static const uint32_t ACL_ERROR_GE_EXEC_LOAD_TASK_PARTITION_FAILED = 545004; | |||||
static const uint32_t ACL_ERROR_GE_EXEC_LOAD_KERNEL_PARTITION_FAILED = 545005; | |||||
static const uint32_t ACL_ERROR_GE_EXEC_RELEASE_MODEL_DATA = 545006; | |||||
static const uint32_t ACL_ERROR_GE_COMMAND_HANDLE = 545007; | |||||
static const uint32_t ACL_ERROR_GE_GET_TENSOR_INFO = 545008; | |||||
static const uint32_t ACL_ERROR_GE_UNLOAD_MODEL = 545009; | |||||
#ifdef __cplusplus | |||||
} // namespace ge | |||||
#endif | |||||
#endif // INC_EXTERNAL_GE_GE_ERROR_CODES_H_ |
@@ -44,8 +44,11 @@ struct ModelBufferData { | |||||
* @retval GRAPH_SUCCESS The function is successfully executed. | * @retval GRAPH_SUCCESS The function is successfully executed. | ||||
* @retval OtherValues Failure | * @retval OtherValues Failure | ||||
*/ | */ | ||||
ATTRIBUTED_DEPRECATED(graphStatus aclgrphBuildInitialize(std::map<AscendString, AscendString> &)) | |||||
graphStatus aclgrphBuildInitialize(std::map<std::string, std::string> global_options); | graphStatus aclgrphBuildInitialize(std::map<std::string, std::string> global_options); | ||||
graphStatus aclgrphBuildInitialize(std::map<AscendString, AscendString> &global_options); | |||||
/** | /** | ||||
* @ingroup AscendCL | * @ingroup AscendCL | ||||
* @brief build model.Notice the model is stored in buffer | * @brief build model.Notice the model is stored in buffer | ||||
@@ -63,9 +66,14 @@ void aclgrphBuildFinalize(); | |||||
* @retval GRAPH_SUCCESS The function is successfully executed. | * @retval GRAPH_SUCCESS The function is successfully executed. | ||||
* @retval OtherValues Failure | * @retval OtherValues Failure | ||||
*/ | */ | ||||
ATTRIBUTED_DEPRECATED(graphStatus aclgrphBuildModel(const ge::Graph &, const std::map<AscendString, AscendString> &, | |||||
ModelBufferData &)) | |||||
graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map<std::string, std::string> &build_options, | graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map<std::string, std::string> &build_options, | ||||
ModelBufferData &model); | ModelBufferData &model); | ||||
graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map<AscendString, AscendString> &build_options, | |||||
ModelBufferData &model); | |||||
/** | /** | ||||
* @ingroup AscendCL | * @ingroup AscendCL | ||||
* @brief save model buffer to file | * @brief save model buffer to file | ||||
@@ -75,8 +83,11 @@ graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map<std::string | |||||
* @retval GRAPH_SUCCESS The function is successfully executed. | * @retval GRAPH_SUCCESS The function is successfully executed. | ||||
* @retval OtherValues Failure | * @retval OtherValues Failure | ||||
*/ | */ | ||||
ATTRIBUTED_DEPRECATED(graphStatus aclgrphSaveModel(const char *, const ModelBufferData &)) | |||||
graphStatus aclgrphSaveModel(const string &output_file, const ModelBufferData &model); | graphStatus aclgrphSaveModel(const string &output_file, const ModelBufferData &model); | ||||
graphStatus aclgrphSaveModel(const char *output_file, const ModelBufferData &model); | |||||
/** | /** | ||||
* @ingroup AscendCL | * @ingroup AscendCL | ||||
* @brief query IR interface version | * @brief query IR interface version | ||||
@@ -110,5 +121,5 @@ graphStatus aclgrphInferShapeAndType(ge::Graph &graph); | |||||
* @retval OtherValues Failure | * @retval OtherValues Failure | ||||
*/ | */ | ||||
graphStatus aclgrphDumpGraph(const ge::Graph &graph, const char *file, const size_t len); | graphStatus aclgrphDumpGraph(const ge::Graph &graph, const char *file, const size_t len); | ||||
}; // namespace ge | |||||
#endif | |||||
}; // namespace ge | |||||
#endif // INC_EXTERNAL_GE_IR_BUILD_H_ |
@@ -19,6 +19,7 @@ | |||||
#include <string> | #include <string> | ||||
#include <memory> | #include <memory> | ||||
#include <functional> | |||||
namespace ge { | namespace ge { | ||||
class AscendString { | class AscendString { | ||||
@@ -27,7 +28,7 @@ class AscendString { | |||||
~AscendString() = default; | ~AscendString() = default; | ||||
explicit AscendString(const char* name); | |||||
AscendString(const char* name); | |||||
const char* GetString() const; | const char* GetString() const; | ||||
@@ -47,4 +48,17 @@ class AscendString { | |||||
std::shared_ptr<std::string> name_; | std::shared_ptr<std::string> name_; | ||||
}; | }; | ||||
} // namespace ge | } // namespace ge | ||||
namespace std { | |||||
template <> | |||||
struct hash<ge::AscendString> { | |||||
size_t operator()(const ge::AscendString& name) const { | |||||
std::string str_name; | |||||
if (name.GetString() != nullptr) { | |||||
str_name = name.GetString(); | |||||
} | |||||
return hash<string>()(str_name); | |||||
} | |||||
}; | |||||
} // namespace std | |||||
#endif // INC_EXTERNAL_GRAPH_ASCEND_STRING_H_ | #endif // INC_EXTERNAL_GRAPH_ASCEND_STRING_H_ |
@@ -23,6 +23,7 @@ | |||||
#include <vector> | #include <vector> | ||||
#include "./ge_error_codes.h" | #include "./ge_error_codes.h" | ||||
#include "ascend_string.h" | |||||
using std::make_shared; | using std::make_shared; | ||||
using std::map; | using std::map; | ||||
@@ -60,6 +61,8 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY AttrValue { | |||||
return val; | return val; | ||||
} | } | ||||
graphStatus GetValue(AscendString &val); | |||||
std::shared_ptr<AttrValueImpl> impl; | std::shared_ptr<AttrValueImpl> impl; | ||||
private: | private: | ||||
@@ -28,10 +28,16 @@ namespace ge { | |||||
#else | #else | ||||
#define GE_FUNC_DEV_VISIBILITY | #define GE_FUNC_DEV_VISIBILITY | ||||
#endif | #endif | ||||
#ifdef __GNUC__ | |||||
#define ATTRIBUTED_DEPRECATED(replacement) __attribute__((deprecated("Please use " #replacement " instead."))) | |||||
#else | |||||
#define ATTRIBUTED_DEPRECATED(replacement) __declspec(deprecated("Please use " #replacement " instead.")) | |||||
#endif | |||||
using graphStatus = uint32_t; | using graphStatus = uint32_t; | ||||
const graphStatus GRAPH_FAILED = 0xFFFFFFFF; | const graphStatus GRAPH_FAILED = 0xFFFFFFFF; | ||||
const graphStatus GRAPH_SUCCESS = 0; | const graphStatus GRAPH_SUCCESS = 0; | ||||
const graphStatus GRAPH_NOT_CHANGED = 1343242304; | |||||
const graphStatus GRAPH_PARAM_INVALID = 50331649; | const graphStatus GRAPH_PARAM_INVALID = 50331649; | ||||
const graphStatus GRAPH_NODE_WITHOUT_CONST_INPUT = 50331648; | const graphStatus GRAPH_NODE_WITHOUT_CONST_INPUT = 50331648; | ||||
} // namespace ge | } // namespace ge | ||||
@@ -44,9 +44,9 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GNode { | |||||
~GNode() = default; | ~GNode() = default; | ||||
graphStatus GetType(ge::AscendString &type) const; | |||||
graphStatus GetType(AscendString &type) const; | |||||
graphStatus GetName(ge::AscendString &name) const; | |||||
graphStatus GetName(AscendString &name) const; | |||||
std::pair<GNodePtr, int32_t> GetInDataNodesAndPortIndexs(const int32_t index) const; | std::pair<GNodePtr, int32_t> GetInDataNodesAndPortIndexs(const int32_t index) const; | ||||
@@ -58,9 +58,9 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GNode { | |||||
graphStatus GetInputConstData(const int32_t index, Tensor &data) const; | graphStatus GetInputConstData(const int32_t index, Tensor &data) const; | ||||
graphStatus GetInputIndexByName(const ge::AscendString &name, int32_t &index); | |||||
graphStatus GetInputIndexByName(const AscendString &name, int32_t &index); | |||||
graphStatus GetOutputIndexByName(const ge::AscendString &name, int32_t &index); | |||||
graphStatus GetOutputIndexByName(const AscendString &name, int32_t &index); | |||||
size_t GetInputsSize() const; | size_t GetInputsSize() const; | ||||
@@ -74,47 +74,47 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GNode { | |||||
graphStatus UpdateOutputDesc(const int32_t index, const TensorDesc &tensor_desc); | graphStatus UpdateOutputDesc(const int32_t index, const TensorDesc &tensor_desc); | ||||
graphStatus GetAttr(const ge::AscendString &name, int64_t &attr_value) const; | |||||
graphStatus GetAttr(const ge::AscendString &name, int32_t &attr_value) const; | |||||
graphStatus GetAttr(const ge::AscendString &name, uint32_t &attr_value) const; | |||||
graphStatus GetAttr(const ge::AscendString &name, float &attr_value) const; | |||||
graphStatus GetAttr(const ge::AscendString &name, ge::AscendString &attr_value) const; | |||||
graphStatus GetAttr(const ge::AscendString &name, bool &attr_value) const; | |||||
graphStatus GetAttr(const ge::AscendString &name, Tensor &attr_value) const; | |||||
graphStatus GetAttr(const ge::AscendString &name, std::vector<int64_t> &attr_value) const; | |||||
graphStatus GetAttr(const ge::AscendString &name, std::vector<int32_t> &attr_value) const; | |||||
graphStatus GetAttr(const ge::AscendString &name, std::vector<uint32_t> &attr_value) const; | |||||
graphStatus GetAttr(const ge::AscendString &name, std::vector<float> &attr_value) const; | |||||
graphStatus GetAttr(const ge::AscendString &name, std::vector<ge::AscendString> &attr_values) const; | |||||
graphStatus GetAttr(const ge::AscendString &name, std::vector<bool> &attr_value) const; | |||||
graphStatus GetAttr(const ge::AscendString &name, std::vector<Tensor> &attr_value) const; | |||||
graphStatus GetAttr(const ge::AscendString &name, OpBytes &attr_value) const; | |||||
graphStatus GetAttr(const ge::AscendString &name, std::vector<std::vector<int64_t>> &attr_value) const; | |||||
graphStatus GetAttr(const ge::AscendString &name, std::vector<ge::DataType> &attr_value) const; | |||||
graphStatus GetAttr(const ge::AscendString &name, ge::DataType &attr_value) const; | |||||
graphStatus GetAttr(const ge::AscendString &name, AttrValue &attr_value) const; | |||||
graphStatus SetAttr(const ge::AscendString &name, int64_t &attr_value) const; | |||||
graphStatus SetAttr(const ge::AscendString &name, int32_t &attr_value) const; | |||||
graphStatus SetAttr(const ge::AscendString &name, uint32_t &attr_value) const; | |||||
graphStatus SetAttr(const ge::AscendString &name, float &attr_value) const; | |||||
graphStatus SetAttr(const ge::AscendString &name, ge::AscendString &attr_value) const; | |||||
graphStatus SetAttr(const ge::AscendString &name, bool &attr_value) const; | |||||
graphStatus SetAttr(const ge::AscendString &name, Tensor &attr_value) const; | |||||
graphStatus SetAttr(const ge::AscendString &name, std::vector<int64_t> &attr_value) const; | |||||
graphStatus SetAttr(const ge::AscendString &name, std::vector<int32_t> &attr_value) const; | |||||
graphStatus SetAttr(const ge::AscendString &name, std::vector<uint32_t> &attr_value) const; | |||||
graphStatus SetAttr(const ge::AscendString &name, std::vector<float> &attr_value) const; | |||||
graphStatus SetAttr(const ge::AscendString &name, std::vector<ge::AscendString> &attr_values) const; | |||||
graphStatus SetAttr(const ge::AscendString &name, std::vector<bool> &attr_value) const; | |||||
graphStatus SetAttr(const ge::AscendString &name, std::vector<Tensor> &attr_value) const; | |||||
graphStatus SetAttr(const ge::AscendString &name, OpBytes &attr_value) const; | |||||
graphStatus SetAttr(const ge::AscendString &name, std::vector<std::vector<int64_t>> &attr_value) const; | |||||
graphStatus SetAttr(const ge::AscendString &name, std::vector<ge::DataType> &attr_value) const; | |||||
graphStatus SetAttr(const ge::AscendString &name, ge::DataType &attr_value) const; | |||||
graphStatus SetAttr(const ge::AscendString &name, AttrValue &attr_value) const; | |||||
bool HasAttr(const ge::AscendString &name); | |||||
graphStatus GetAttr(const AscendString &name, int64_t &attr_value) const; | |||||
graphStatus GetAttr(const AscendString &name, int32_t &attr_value) const; | |||||
graphStatus GetAttr(const AscendString &name, uint32_t &attr_value) const; | |||||
graphStatus GetAttr(const AscendString &name, float &attr_value) const; | |||||
graphStatus GetAttr(const AscendString &name, AscendString &attr_value) const; | |||||
graphStatus GetAttr(const AscendString &name, bool &attr_value) const; | |||||
graphStatus GetAttr(const AscendString &name, Tensor &attr_value) const; | |||||
graphStatus GetAttr(const AscendString &name, std::vector<int64_t> &attr_value) const; | |||||
graphStatus GetAttr(const AscendString &name, std::vector<int32_t> &attr_value) const; | |||||
graphStatus GetAttr(const AscendString &name, std::vector<uint32_t> &attr_value) const; | |||||
graphStatus GetAttr(const AscendString &name, std::vector<float> &attr_value) const; | |||||
graphStatus GetAttr(const AscendString &name, std::vector<AscendString> &attr_values) const; | |||||
graphStatus GetAttr(const AscendString &name, std::vector<bool> &attr_value) const; | |||||
graphStatus GetAttr(const AscendString &name, std::vector<Tensor> &attr_value) const; | |||||
graphStatus GetAttr(const AscendString &name, OpBytes &attr_value) const; | |||||
graphStatus GetAttr(const AscendString &name, std::vector<std::vector<int64_t>> &attr_value) const; | |||||
graphStatus GetAttr(const AscendString &name, std::vector<ge::DataType> &attr_value) const; | |||||
graphStatus GetAttr(const AscendString &name, ge::DataType &attr_value) const; | |||||
graphStatus GetAttr(const AscendString &name, AttrValue &attr_value) const; | |||||
graphStatus SetAttr(const AscendString &name, int64_t &attr_value) const; | |||||
graphStatus SetAttr(const AscendString &name, int32_t &attr_value) const; | |||||
graphStatus SetAttr(const AscendString &name, uint32_t &attr_value) const; | |||||
graphStatus SetAttr(const AscendString &name, float &attr_value) const; | |||||
graphStatus SetAttr(const AscendString &name, AscendString &attr_value) const; | |||||
graphStatus SetAttr(const AscendString &name, bool &attr_value) const; | |||||
graphStatus SetAttr(const AscendString &name, Tensor &attr_value) const; | |||||
graphStatus SetAttr(const AscendString &name, std::vector<int64_t> &attr_value) const; | |||||
graphStatus SetAttr(const AscendString &name, std::vector<int32_t> &attr_value) const; | |||||
graphStatus SetAttr(const AscendString &name, std::vector<uint32_t> &attr_value) const; | |||||
graphStatus SetAttr(const AscendString &name, std::vector<float> &attr_value) const; | |||||
graphStatus SetAttr(const AscendString &name, std::vector<AscendString> &attr_values) const; | |||||
graphStatus SetAttr(const AscendString &name, std::vector<bool> &attr_value) const; | |||||
graphStatus SetAttr(const AscendString &name, std::vector<Tensor> &attr_value) const; | |||||
graphStatus SetAttr(const AscendString &name, OpBytes &attr_value) const; | |||||
graphStatus SetAttr(const AscendString &name, std::vector<std::vector<int64_t>> &attr_value) const; | |||||
graphStatus SetAttr(const AscendString &name, std::vector<ge::DataType> &attr_value) const; | |||||
graphStatus SetAttr(const AscendString &name, ge::DataType &attr_value) const; | |||||
graphStatus SetAttr(const AscendString &name, AttrValue &attr_value) const; | |||||
bool HasAttr(const AscendString &name); | |||||
graphStatus GetSubgraph(uint32_t index, GraphPtr &graph) const; | graphStatus GetSubgraph(uint32_t index, GraphPtr &graph) const; | ||||
@@ -36,8 +36,11 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Graph { | |||||
friend class GraphUtils; | friend class GraphUtils; | ||||
public: | public: | ||||
ATTRIBUTED_DEPRECATED(Graph(const char *)) | |||||
explicit Graph(const std::string &name); | explicit Graph(const std::string &name); | ||||
explicit Graph(const char *name); | |||||
Graph() = default; | Graph() = default; | ||||
~Graph() = default; | ~Graph() = default; | ||||
@@ -48,26 +51,47 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Graph { | |||||
Graph &SetOutputs(const std::vector<std::pair<Operator, std::vector<size_t>>> &output_indexs); | Graph &SetOutputs(const std::vector<std::pair<Operator, std::vector<size_t>>> &output_indexs); | ||||
ATTRIBUTED_DEPRECATED(Graph &SetOutputs(const std::vector < std::pair < ge::Operator, AscendString) &) | |||||
Graph &SetOutputs(const std::vector<std::pair<ge::Operator, std::string>> &outputs); | Graph &SetOutputs(const std::vector<std::pair<ge::Operator, std::string>> &outputs); | ||||
Graph &SetOutputs(const std::vector<std::pair<ge::Operator, AscendString>> &outputs); | |||||
Graph &SetTargets(const std::vector<Operator> &targets); | Graph &SetTargets(const std::vector<Operator> &targets); | ||||
bool IsValid() const; | bool IsValid() const; | ||||
graphStatus AddOp(const ge::Operator &op); | graphStatus AddOp(const ge::Operator &op); | ||||
ATTRIBUTED_DEPRECATED(graphStatus FindOpByName(const char *, ge::Operator &)) | |||||
graphStatus FindOpByName(const std::string &name, ge::Operator &op) const; | graphStatus FindOpByName(const std::string &name, ge::Operator &op) const; | ||||
graphStatus FindOpByName(const char *name, ge::Operator &op) const; | |||||
ATTRIBUTED_DEPRECATED(graphStatus FindOpByType(const char *, std::vector<ge::Operator> &)) | |||||
graphStatus FindOpByType(const std::string &type, std::vector<ge::Operator> &ops) const; | graphStatus FindOpByType(const std::string &type, std::vector<ge::Operator> &ops) const; | ||||
graphStatus FindOpByType(const char *type, std::vector<ge::Operator> &ops) const; | |||||
ATTRIBUTED_DEPRECATED(graphStatus GetAllOpName(std::vector<AscendString> &) const) | |||||
graphStatus GetAllOpName(std::vector<std::string> &op_name) const; | graphStatus GetAllOpName(std::vector<std::string> &op_name) const; | ||||
graphStatus GetAllOpName(std::vector<AscendString> &names) const; | |||||
ATTRIBUTED_DEPRECATED(graphStatus SaveToFile(const char *file_name) const) | |||||
graphStatus SaveToFile(const std::string &file_name) const; | graphStatus SaveToFile(const std::string &file_name) const; | ||||
graphStatus SaveToFile(const char *file_name) const; | |||||
ATTRIBUTED_DEPRECATED(graphStatus LoadFromFile(const char *)) | |||||
graphStatus LoadFromFile(const std::string &file_name); | graphStatus LoadFromFile(const std::string &file_name); | ||||
graphStatus LoadFromFile(const char *file_name); | |||||
ATTRIBUTED_DEPRECATED(graphStatus GetName(AscendString &) const) | |||||
const std::string &GetName() const; | const std::string &GetName() const; | ||||
graphStatus GetName(AscendString &name) const; | |||||
/// | /// | ||||
/// Set is need train iteration. | /// Set is need train iteration. | ||||
/// If set true, it means this graph need to be run iteration some | /// If set true, it means this graph need to be run iteration some | ||||
@@ -90,7 +114,7 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Graph { | |||||
graphStatus AddControlEdge(GNode &src_node, GNode &dst_node); | graphStatus AddControlEdge(GNode &src_node, GNode &dst_node); | ||||
static GraphPtr ConstructFromInputs(const std::vector<Operator> &inputs, const ge::AscendString &name); | |||||
static GraphPtr ConstructFromInputs(const std::vector<Operator> &inputs, const AscendString &name); | |||||
private: | private: | ||||
GraphImplPtr impl_{nullptr}; | GraphImplPtr impl_{nullptr}; | ||||
@@ -23,6 +23,7 @@ | |||||
#include "./tensor.h" | #include "./tensor.h" | ||||
#include "./types.h" | #include "./types.h" | ||||
#include "ascend_string.h" | |||||
namespace ge { | namespace ge { | ||||
class InferenceContext; | class InferenceContext; | ||||
@@ -63,8 +64,13 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY InferenceContext { | |||||
void SetOutputHandleShapesAndTypes(const std::vector<std::vector<ShapeAndType>> &shapes_and_types); | void SetOutputHandleShapesAndTypes(const std::vector<std::vector<ShapeAndType>> &shapes_and_types); | ||||
void SetOutputHandleShapesAndTypes(std::vector<std::vector<ShapeAndType>> &&shapes_and_types); | void SetOutputHandleShapesAndTypes(std::vector<std::vector<ShapeAndType>> &&shapes_and_types); | ||||
ATTRIBUTED_DEPRECATED(void SetMarks(const std::vector<AscendString> &)) | |||||
void SetMarks(const std::vector<std::string> &marks); | void SetMarks(const std::vector<std::string> &marks); | ||||
void SetMarks(const std::vector<AscendString> &marks); | |||||
ATTRIBUTED_DEPRECATED(void GetMarks(std::vector<AscendString> &) const) | |||||
const std::vector<std::string> &GetMarks() const; | const std::vector<std::string> &GetMarks() const; | ||||
void GetMarks(std::vector<AscendString> &marks) const; | |||||
static std::unique_ptr<InferenceContext> Create(); | static std::unique_ptr<InferenceContext> Create(); | ||||
@@ -72,6 +72,7 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator { | |||||
using OpInt = int64_t; | using OpInt = int64_t; | ||||
using OpFloat = float; | using OpFloat = float; | ||||
using OpString = string; | using OpString = string; | ||||
using OpAscendString = AscendString; | |||||
using OpBool = bool; | using OpBool = bool; | ||||
using OpTensor = Tensor; | using OpTensor = Tensor; | ||||
using OpType = ge::DataType; | using OpType = ge::DataType; | ||||
@@ -79,6 +80,7 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator { | |||||
using OpListInt = std::vector<int64_t>; | using OpListInt = std::vector<int64_t>; | ||||
using OpListFloat = std::vector<float>; | using OpListFloat = std::vector<float>; | ||||
using OpListString = std::vector<string>; | using OpListString = std::vector<string>; | ||||
using OpListAcendString = std::vector<AscendString>; | |||||
using OpListBool = std::vector<bool>; | using OpListBool = std::vector<bool>; | ||||
using OpListTensor = std::vector<Tensor>; | using OpListTensor = std::vector<Tensor>; | ||||
using OpBytes = std::vector<uint8_t>; | using OpBytes = std::vector<uint8_t>; | ||||
@@ -87,56 +89,114 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator { | |||||
using OpListNamedAttrs = std::vector<ge::NamedAttrs>; | using OpListNamedAttrs = std::vector<ge::NamedAttrs>; | ||||
Operator() {} | Operator() {} | ||||
ATTRIBUTED_DEPRECATED(Operator(const char *)) | |||||
explicit Operator(const string &type); | explicit Operator(const string &type); | ||||
explicit Operator(const char *type); | |||||
ATTRIBUTED_DEPRECATED(Operator(const AscendString &, const AscendString &)) | |||||
Operator(const string &name, const string &type); | Operator(const string &name, const string &type); | ||||
Operator(const AscendString &name, const AscendString &type); | |||||
Operator(const char *name, const char *type); | |||||
virtual ~Operator() = default; | virtual ~Operator() = default; | ||||
bool IsEmpty() const; | bool IsEmpty() const; | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetName(AscendString &) const) | |||||
string GetName() const; | string GetName() const; | ||||
graphStatus GetName(AscendString &name) const; | |||||
ATTRIBUTED_DEPRECATED(graphStatus GetOpType(AscendString &) const) | |||||
string GetOpType() const; | string GetOpType() const; | ||||
graphStatus GetOpType(AscendString &type) const; | |||||
// Only has one output index = 0 | // Only has one output index = 0 | ||||
ATTRIBUTED_DEPRECATED(Operator &SetInput(const char *, const Operator &)) | |||||
Operator &SetInput(const string &dst_name, const Operator &src_oprt); | Operator &SetInput(const string &dst_name, const Operator &src_oprt); | ||||
Operator &SetInput(const char *dst_name, const Operator &src_oprt); | |||||
ATTRIBUTED_DEPRECATED(Operator &SetInput(const char *, const Operator &, const char *)) | |||||
Operator &SetInput(const string &dst_name, const Operator &src_oprt, const string &name); | Operator &SetInput(const string &dst_name, const Operator &src_oprt, const string &name); | ||||
Operator &SetInput(const char *dst_name, const Operator &src_oprt, const char *name); | |||||
ATTRIBUTED_DEPRECATED(Operator &SetInput(const char *, const Operator &, uint32_t)) | |||||
Operator &SetInput(const string &dst_name, const Operator &src_oprt, uint32_t index); | Operator &SetInput(const string &dst_name, const Operator &src_oprt, uint32_t index); | ||||
Operator &SetInput(const char *dst_name, const Operator &src_oprt, uint32_t index); | |||||
Operator &AddControlInput(const Operator &src_oprt); | Operator &AddControlInput(const Operator &src_oprt); | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetInputConstData(const char *, Tensor &) const) | |||||
graphStatus GetInputConstData(const string &dst_name, Tensor &data) const; | graphStatus GetInputConstData(const string &dst_name, Tensor &data) const; | ||||
graphStatus GetInputConstData(const char *dst_name, Tensor &data) const; | |||||
ATTRIBUTED_DEPRECATED(TensorDesc GetInputDesc(const char *, uint32_t len) const) | |||||
TensorDesc GetInputDesc(const string &name) const; | TensorDesc GetInputDesc(const string &name) const; | ||||
TensorDesc GetInputDesc(const char *name, uint32_t len) const; | |||||
TensorDesc GetInputDesc(uint32_t index) const; | TensorDesc GetInputDesc(uint32_t index) const; | ||||
ATTRIBUTED_DEPRECATED(int GetDynamicOutputNum(const char *) const) | |||||
int GetDynamicOutputNum(const string &name) const; | int GetDynamicOutputNum(const string &name) const; | ||||
int GetDynamicOutputNum(const char *name) const; | |||||
ATTRIBUTED_DEPRECATED(int GetDynamicInputNum(const char *)) | |||||
int GetDynamicInputNum(const string &name) const; | int GetDynamicInputNum(const string &name) const; | ||||
int GetDynamicInputNum(const char *name) const; | |||||
ATTRIBUTED_DEPRECATED(graphStatus TryGetInputDesc(const char *, TensorDesc &) const) | |||||
graphStatus TryGetInputDesc(const string &name, TensorDesc &tensor_desc) const; | graphStatus TryGetInputDesc(const string &name, TensorDesc &tensor_desc) const; | ||||
graphStatus TryGetInputDesc(const char *name, TensorDesc &tensor_desc) const; | |||||
ATTRIBUTED_DEPRECATED(graphStatus UpdateInputDesc(const char *, const TensorDesc &)) | |||||
graphStatus UpdateInputDesc(const string &name, const TensorDesc &tensor_desc); | graphStatus UpdateInputDesc(const string &name, const TensorDesc &tensor_desc); | ||||
graphStatus UpdateInputDesc(const char *name, const TensorDesc &tensor_desc); | |||||
ATTRIBUTED_DEPRECATED(TensorDesc GetOutputDesc(const char *, uint32_t len) const) | |||||
TensorDesc GetOutputDesc(const string &name) const; | TensorDesc GetOutputDesc(const string &name) const; | ||||
TensorDesc GetOutputDesc(const char *name, uint32_t len) const; | |||||
TensorDesc GetOutputDesc(uint32_t index) const; | TensorDesc GetOutputDesc(uint32_t index) const; | ||||
ATTRIBUTED_DEPRECATED(graphStatus UpdateOutputDesc(const char *, const TensorDesc &tensor_desc)) | |||||
graphStatus UpdateOutputDesc(const string &name, const TensorDesc &tensor_desc); | graphStatus UpdateOutputDesc(const string &name, const TensorDesc &tensor_desc); | ||||
graphStatus UpdateOutputDesc(const char *name, const TensorDesc &tensor_desc); | |||||
ATTRIBUTED_DEPRECATED(TensorDesc GetDynamicInputDesc(const char *, uint32_t) const) | |||||
TensorDesc GetDynamicInputDesc(const string &name, uint32_t index) const; | TensorDesc GetDynamicInputDesc(const string &name, uint32_t index) const; | ||||
TensorDesc GetDynamicInputDesc(const char *name, uint32_t index) const; | |||||
ATTRIBUTED_DEPRECATED(graphStatus UpdateDynamicInputDesc(const char *, uint32_t, const TensorDesc &)) | |||||
graphStatus UpdateDynamicInputDesc(const string &name, uint32_t index, const TensorDesc &tensor_desc); | graphStatus UpdateDynamicInputDesc(const string &name, uint32_t index, const TensorDesc &tensor_desc); | ||||
graphStatus UpdateDynamicInputDesc(const char *name, uint32_t index, const TensorDesc &tensor_desc); | |||||
ATTRIBUTED_DEPRECATED(TensorDesc GetDynamicOutputDesc(const char *, uint32_t) const) | |||||
TensorDesc GetDynamicOutputDesc(const string &name, uint32_t index) const; | TensorDesc GetDynamicOutputDesc(const string &name, uint32_t index) const; | ||||
TensorDesc GetDynamicOutputDesc(const char *name, uint32_t index) const; | |||||
ATTRIBUTED_DEPRECATED(graphStatus UpdateDynamicOutputDesc(const char *, uint32_t, const TensorDesc &)) | |||||
graphStatus UpdateDynamicOutputDesc(const string &name, uint32_t index, const TensorDesc &tensor_desc); | graphStatus UpdateDynamicOutputDesc(const string &name, uint32_t index, const TensorDesc &tensor_desc); | ||||
graphStatus UpdateDynamicOutputDesc(const char *name, uint32_t index, const TensorDesc &tensor_desc); | |||||
graphStatus InferShapeAndType(); | graphStatus InferShapeAndType(); | ||||
void SetInferenceContext(const InferenceContextPtr &inference_context); | void SetInferenceContext(const InferenceContextPtr &inference_context); | ||||
@@ -148,72 +208,178 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator { | |||||
size_t GetOutputsSize() const; | size_t GetOutputsSize() const; | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetAllAttrNamesAndTypes(std::map<AscendString, AscendString> &) const) | |||||
const std::map<std::string, std::string> GetAllAttrNamesAndTypes() const; | const std::map<std::string, std::string> GetAllAttrNamesAndTypes() const; | ||||
graphStatus GetAllAttrNamesAndTypes(std::map<AscendString, AscendString> &attr_name_types) const; | |||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, int64_t)) | |||||
Operator &SetAttr(const string &name, int64_t attr_value); | Operator &SetAttr(const string &name, int64_t attr_value); | ||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, int32_t)) | |||||
Operator &SetAttr(const string &name, int32_t attr_value); | Operator &SetAttr(const string &name, int32_t attr_value); | ||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, uint32_t)) | |||||
Operator &SetAttr(const string &name, uint32_t attr_value); | Operator &SetAttr(const string &name, uint32_t attr_value); | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, int64_t &) const) | |||||
graphStatus GetAttr(const string &name, int64_t &attr_value) const; | graphStatus GetAttr(const string &name, int64_t &attr_value) const; | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, int32_t &) const) | |||||
graphStatus GetAttr(const string &name, int32_t &attr_value) const; | graphStatus GetAttr(const string &name, int32_t &attr_value) const; | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, uint32_t &) const) | |||||
graphStatus GetAttr(const string &name, uint32_t &attr_value) const; | graphStatus GetAttr(const string &name, uint32_t &attr_value) const; | ||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector<int64_t> &)) | |||||
Operator &SetAttr(const string &name, const std::vector<int64_t> &attr_value); | Operator &SetAttr(const string &name, const std::vector<int64_t> &attr_value); | ||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector<int32_t> &)) | |||||
Operator &SetAttr(const string &name, const std::vector<int32_t> &attr_value); | Operator &SetAttr(const string &name, const std::vector<int32_t> &attr_value); | ||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector<uint32_t> &)) | |||||
Operator &SetAttr(const string &name, const std::vector<uint32_t> &attr_value); | Operator &SetAttr(const string &name, const std::vector<uint32_t> &attr_value); | ||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, std::initializer_list<int64_t> &&)) | |||||
Operator &SetAttr(const string &name, std::initializer_list<int64_t> &&attr_value); | Operator &SetAttr(const string &name, std::initializer_list<int64_t> &&attr_value); | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *name, std::vector<int64_t> &) const) | |||||
graphStatus GetAttr(const string &name, std::vector<int64_t> &attr_value) const; | graphStatus GetAttr(const string &name, std::vector<int64_t> &attr_value) const; | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *name, std::vector<int32_t> &) const) | |||||
graphStatus GetAttr(const string &name, std::vector<int32_t> &attr_value) const; | graphStatus GetAttr(const string &name, std::vector<int32_t> &attr_value) const; | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const string &, std::vector<uint32_t> &) const) | |||||
graphStatus GetAttr(const string &name, std::vector<uint32_t> &attr_value) const; | graphStatus GetAttr(const string &name, std::vector<uint32_t> &attr_value) const; | ||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, float attr_value)) | |||||
Operator &SetAttr(const string &name, float attr_value); | Operator &SetAttr(const string &name, float attr_value); | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, float &) const) | |||||
graphStatus GetAttr(const string &name, float &attr_value) const; | graphStatus GetAttr(const string &name, float &attr_value) const; | ||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector<float> &)) | |||||
Operator &SetAttr(const string &name, const std::vector<float> &attr_value); | Operator &SetAttr(const string &name, const std::vector<float> &attr_value); | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, std::vector<float> &) const) | |||||
graphStatus GetAttr(const string &name, std::vector<float> &attr_value) const; | graphStatus GetAttr(const string &name, std::vector<float> &attr_value) const; | ||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, AttrValue &&)) | |||||
Operator &SetAttr(const string &name, AttrValue &&attr_value); | Operator &SetAttr(const string &name, AttrValue &&attr_value); | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, AttrValue &) const) | |||||
graphStatus GetAttr(const string &name, AttrValue &attr_value) const; | graphStatus GetAttr(const string &name, AttrValue &attr_value) const; | ||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const AscendString &)) | |||||
Operator &SetAttr(const string &name, const string &attr_value); | Operator &SetAttr(const string &name, const string &attr_value); | ||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const string &)) | |||||
graphStatus GetAttr(const string &name, string &attr_value) const; | graphStatus GetAttr(const string &name, string &attr_value) const; | ||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector<AscendString> &)) | |||||
Operator &SetAttr(const string &name, const std::vector<string> &attr_value); | Operator &SetAttr(const string &name, const std::vector<string> &attr_value); | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const string &, std::vector<AscendString> &) const) | |||||
graphStatus GetAttr(const string &name, std::vector<string> &attr_value) const; | graphStatus GetAttr(const string &name, std::vector<string> &attr_value) const; | ||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, bool)) | |||||
Operator &SetAttr(const string &name, bool attr_value); | Operator &SetAttr(const string &name, bool attr_value); | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, bool &) const) | |||||
graphStatus GetAttr(const string &name, bool &attr_value) const; | graphStatus GetAttr(const string &name, bool &attr_value) const; | ||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector<bool> &)) | |||||
Operator &SetAttr(const string &name, const std::vector<bool> &attr_value); | Operator &SetAttr(const string &name, const std::vector<bool> &attr_value); | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, std::vector<bool> &) const) | |||||
graphStatus GetAttr(const string &name, std::vector<bool> &attr_value) const; | graphStatus GetAttr(const string &name, std::vector<bool> &attr_value) const; | ||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const Tensor &)) | |||||
Operator &SetAttr(const string &name, const Tensor &attr_value); | Operator &SetAttr(const string &name, const Tensor &attr_value); | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, Tensor &) const) | |||||
graphStatus GetAttr(const string &name, Tensor &attr_value) const; | graphStatus GetAttr(const string &name, Tensor &attr_value) const; | ||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector<Tensor> &)) | |||||
Operator &SetAttr(const string &name, const std::vector<Tensor> &attr_value); | Operator &SetAttr(const string &name, const std::vector<Tensor> &attr_value); | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, std::vector<Tensor> &) const) | |||||
graphStatus GetAttr(const string &name, std::vector<Tensor> &attr_value) const; | graphStatus GetAttr(const string &name, std::vector<Tensor> &attr_value) const; | ||||
// Bytes type | // Bytes type | ||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const OpBytes &)) | |||||
Operator &SetAttr(const string &name, const OpBytes &attr_value); | Operator &SetAttr(const string &name, const OpBytes &attr_value); | ||||
// Bytes type | // Bytes type | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, OpBytes &) const) | |||||
graphStatus GetAttr(const string &name, OpBytes &attr_value) const; | graphStatus GetAttr(const string &name, OpBytes &attr_value) const; | ||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector<std::vector<int64_t>> &)) | |||||
Operator &SetAttr(const string &name, const std::vector<std::vector<int64_t>> &attr_value); | Operator &SetAttr(const string &name, const std::vector<std::vector<int64_t>> &attr_value); | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, std::vector<std::vector<int64_t>> &) const) | |||||
graphStatus GetAttr(const string &name, std::vector<std::vector<int64_t>> &attr_value) const; | graphStatus GetAttr(const string &name, std::vector<std::vector<int64_t>> &attr_value) const; | ||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector<ge::DataType> &)) | |||||
Operator &SetAttr(const string &name, const std::vector<ge::DataType> &attr_value); | Operator &SetAttr(const string &name, const std::vector<ge::DataType> &attr_value); | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, std::vector<ge::DataType> &) const) | |||||
graphStatus GetAttr(const string &name, std::vector<ge::DataType> &attr_value) const; | graphStatus GetAttr(const string &name, std::vector<ge::DataType> &attr_value) const; | ||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const ge::DataType &)) | |||||
Operator &SetAttr(const string &name, const ge::DataType &attr_value); | Operator &SetAttr(const string &name, const ge::DataType &attr_value); | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, ge::DataType &) const) | |||||
graphStatus GetAttr(const string &name, ge::DataType &attr_value) const; | graphStatus GetAttr(const string &name, ge::DataType &attr_value) const; | ||||
// func type | // func type | ||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const ge::NamedAttrs &)) | |||||
Operator &SetAttr(const string &name, const ge::NamedAttrs &attr_value); | Operator &SetAttr(const string &name, const ge::NamedAttrs &attr_value); | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, ge::NamedAttrs &) const) | |||||
graphStatus GetAttr(const string &name, ge::NamedAttrs &attr_value) const; | graphStatus GetAttr(const string &name, ge::NamedAttrs &attr_value) const; | ||||
ATTRIBUTED_DEPRECATED(Operator &SetAttr(const char *, const std::vector<ge::NamedAttrs> &)) | |||||
Operator &SetAttr(const string &name, const std::vector<ge::NamedAttrs> &attr_value); | Operator &SetAttr(const string &name, const std::vector<ge::NamedAttrs> &attr_value); | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetAttr(const char *, std::vector<ge::NamedAttrs> &) const) | |||||
graphStatus GetAttr(const string &name, std::vector<ge::NamedAttrs> &attr_value) const; | graphStatus GetAttr(const string &name, std::vector<ge::NamedAttrs> &attr_value) const; | ||||
Operator &SetAttr(const char *name, int64_t attr_value); | |||||
Operator &SetAttr(const char *name, int32_t attr_value); | |||||
Operator &SetAttr(const char *name, uint32_t attr_value); | |||||
graphStatus GetAttr(const char *name, int64_t &attr_value) const; | |||||
graphStatus GetAttr(const char *name, int32_t &attr_value) const; | |||||
graphStatus GetAttr(const char *name, uint32_t &attr_value) const; | |||||
Operator &SetAttr(const char *name, const std::vector<int64_t> &attr_value); | |||||
Operator &SetAttr(const char *name, const std::vector<int32_t> &attr_value); | |||||
Operator &SetAttr(const char *name, const std::vector<uint32_t> &attr_value); | |||||
Operator &SetAttr(const char *name, std::initializer_list<int64_t> &&attr_value); | |||||
graphStatus GetAttr(const char *name, std::vector<int64_t> &attr_value) const; | |||||
graphStatus GetAttr(const char *name, std::vector<int32_t> &attr_value) const; | |||||
graphStatus GetAttr(const char *name, std::vector<uint32_t> &attr_value) const; | |||||
Operator &SetAttr(const char *name, float attr_value); | |||||
graphStatus GetAttr(const char *name, float &attr_value) const; | |||||
Operator &SetAttr(const char *name, const std::vector<float> &attr_value); | |||||
graphStatus GetAttr(const char *name, std::vector<float> &attr_value) const; | |||||
Operator &SetAttr(const char *name, AttrValue &&attr_value); | |||||
graphStatus GetAttr(const char *name, AttrValue &attr_value) const; | |||||
Operator &SetAttr(const char *name, const char *attr_value); | |||||
Operator &SetAttr(const char *name, const AscendString &attr_value); | |||||
graphStatus GetAttr(const char *name, AscendString &attr_value) const; | |||||
Operator &SetAttr(const char *name, const std::vector<AscendString> &attr_values); | |||||
graphStatus GetAttr(const char *name, std::vector<AscendString> &attr_values) const; | |||||
Operator &SetAttr(const char *name, bool attr_value); | |||||
graphStatus GetAttr(const char *name, bool &attr_value) const; | |||||
Operator &SetAttr(const char *name, const std::vector<bool> &attr_value); | |||||
graphStatus GetAttr(const char *name, std::vector<bool> &attr_value) const; | |||||
Operator &SetAttr(const char *name, const Tensor &attr_value); | |||||
graphStatus GetAttr(const char *name, Tensor &attr_value) const; | |||||
Operator &SetAttr(const char *name, const std::vector<Tensor> &attr_value); | |||||
graphStatus GetAttr(const char *name, std::vector<Tensor> &attr_value) const; | |||||
// Bytes type | |||||
Operator &SetAttr(const char *name, const OpBytes &attr_value); | |||||
// Bytes type | |||||
graphStatus GetAttr(const char *name, OpBytes &attr_value) const; | |||||
Operator &SetAttr(const char *name, const std::vector<std::vector<int64_t>> &attr_value); | |||||
graphStatus GetAttr(const char *name, std::vector<std::vector<int64_t>> &attr_value) const; | |||||
Operator &SetAttr(const char *name, const std::vector<ge::DataType> &attr_value); | |||||
graphStatus GetAttr(const char *name, std::vector<ge::DataType> &attr_value) const; | |||||
Operator &SetAttr(const char *name, const ge::DataType &attr_value); | |||||
graphStatus GetAttr(const char *name, ge::DataType &attr_value) const; | |||||
// func type | |||||
Operator &SetAttr(const char *name, const ge::NamedAttrs &attr_value); | |||||
graphStatus GetAttr(const char *name, ge::NamedAttrs &attr_value) const; | |||||
Operator &SetAttr(const char *name, const std::vector<ge::NamedAttrs> &attr_value); | |||||
graphStatus GetAttr(const char *name, std::vector<ge::NamedAttrs> &attr_value) const; | |||||
void BreakConnect() const; | void BreakConnect() const; | ||||
size_t GetSubgraphNamesCount() const; | size_t GetSubgraphNamesCount() const; | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetSubgraphNames(std::vector<AscendString> &) const) | |||||
std::vector<std::string> GetSubgraphNames() const; | std::vector<std::string> GetSubgraphNames() const; | ||||
graphStatus GetSubgraphNames(std::vector<AscendString> &names) const; | |||||
ATTRIBUTED_DEPRECATED(SubgraphBuilder GetSubgraphBuilder(const char *) const) | |||||
SubgraphBuilder GetSubgraphBuilder(const string &name) const; | SubgraphBuilder GetSubgraphBuilder(const string &name) const; | ||||
SubgraphBuilder GetSubgraphBuilder(const char *name) const; | |||||
ATTRIBUTED_DEPRECATED(Graph GetSubgraph(const char *) const) | |||||
Graph GetSubgraph(const string &name) const; | Graph GetSubgraph(const string &name) const; | ||||
Graph GetSubgraph(const char *name) const; | |||||
ATTRIBUTED_DEPRECATED(SubgraphBuilder GetDynamicSubgraphBuilder(const char *, uint32_t) const) | |||||
SubgraphBuilder GetDynamicSubgraphBuilder(const string &name, uint32_t index) const; | SubgraphBuilder GetDynamicSubgraphBuilder(const string &name, uint32_t index) const; | ||||
SubgraphBuilder GetDynamicSubgraphBuilder(const char *name, uint32_t index) const; | |||||
ATTRIBUTED_DEPRECATED(Graph GetDynamicSubgraph(const char *, uint32_t) const) | |||||
Graph GetDynamicSubgraph(const string &name, uint32_t index) const; | Graph GetDynamicSubgraph(const string &name, uint32_t index) const; | ||||
Graph GetDynamicSubgraph(const char *name, uint32_t index) const; | |||||
protected: | protected: | ||||
void AttrRegister(const string &name, float attr_value); | void AttrRegister(const string &name, float attr_value); | ||||
@@ -265,6 +431,7 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator { | |||||
void SubgraphRegister(const string &ir_name, bool dynamic); | void SubgraphRegister(const string &ir_name, bool dynamic); | ||||
void SubgraphCountRegister(const string &ir_name, uint32_t count); | void SubgraphCountRegister(const string &ir_name, uint32_t count); | ||||
void SetSubgraphBuilder(const string &ir_name, uint32_t index, const SubgraphBuilder &builder); | void SetSubgraphBuilder(const string &ir_name, uint32_t index, const SubgraphBuilder &builder); | ||||
Graph GetSubgraphImpl(const string &name) const; | |||||
private: | private: | ||||
Operator &SetInput(const string &dst_name, const OutHandler &out_handler); | Operator &SetInput(const string &dst_name, const OutHandler &out_handler); | ||||
@@ -27,40 +27,58 @@ | |||||
namespace ge { | namespace ge { | ||||
using OpCreator = std::function<Operator(const std::string &)>; | using OpCreator = std::function<Operator(const std::string &)>; | ||||
using OpCreatorV2 = std::function<Operator(const AscendString &)>; | |||||
using InferShapeFunc = std::function<graphStatus(Operator &)>; | using InferShapeFunc = std::function<graphStatus(Operator &)>; | ||||
using InferFormatFunc = std::function<graphStatus(Operator &)>; | using InferFormatFunc = std::function<graphStatus(Operator &)>; | ||||
using VerifyFunc = std::function<graphStatus(Operator &)>; | using VerifyFunc = std::function<graphStatus(Operator &)>; | ||||
class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OperatorFactory { | class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OperatorFactory { | ||||
public: | public: | ||||
ATTRIBUTED_DEPRECATED(static Operator CreateOperator(const char *, const char *)) | |||||
static Operator CreateOperator(const std::string &operator_name, const std::string &operator_type); | static Operator CreateOperator(const std::string &operator_name, const std::string &operator_type); | ||||
static Operator CreateOperator(const char *operator_name, const char *operator_type); | |||||
ATTRIBUTED_DEPRECATED(graphStatus GetOpsTypeList(std::vector<AscendString> &)) | |||||
static graphStatus GetOpsTypeList(std::vector<std::string> &all_ops); | static graphStatus GetOpsTypeList(std::vector<std::string> &all_ops); | ||||
static graphStatus GetOpsTypeList(std::vector<AscendString> &all_ops); | |||||
ATTRIBUTED_DEPRECATED(bool IsExistOp(const char *)) | |||||
static bool IsExistOp(const string &operator_type); | static bool IsExistOp(const string &operator_type); | ||||
static bool IsExistOp(const char *operator_type); | |||||
}; | }; | ||||
class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OperatorCreatorRegister { | class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OperatorCreatorRegister { | ||||
public: | public: | ||||
ATTRIBUTED_DEPRECATED(OperatorCreatorRegister(const char *, OpCreatorV2 const &)) | |||||
OperatorCreatorRegister(const string &operator_type, OpCreator const &op_creator); | OperatorCreatorRegister(const string &operator_type, OpCreator const &op_creator); | ||||
OperatorCreatorRegister(const char *operator_type, OpCreatorV2 const &op_creator); | |||||
~OperatorCreatorRegister() = default; | ~OperatorCreatorRegister() = default; | ||||
}; | }; | ||||
class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY InferShapeFuncRegister { | class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY InferShapeFuncRegister { | ||||
public: | public: | ||||
ATTRIBUTED_DEPRECATED(InferShapeFuncRegister(const char *, const InferShapeFunc &)) | |||||
InferShapeFuncRegister(const std::string &operator_type, const InferShapeFunc &infer_shape_func); | InferShapeFuncRegister(const std::string &operator_type, const InferShapeFunc &infer_shape_func); | ||||
InferShapeFuncRegister(const char *operator_type, const InferShapeFunc &infer_shape_func); | |||||
~InferShapeFuncRegister() = default; | ~InferShapeFuncRegister() = default; | ||||
}; | }; | ||||
class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY InferFormatFuncRegister { | class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY InferFormatFuncRegister { | ||||
public: | public: | ||||
ATTRIBUTED_DEPRECATED(InferFormatFuncRegister(const char *, const InferFormatFunc &)) | |||||
InferFormatFuncRegister(const std::string &operator_type, const InferFormatFunc &infer_format_func); | InferFormatFuncRegister(const std::string &operator_type, const InferFormatFunc &infer_format_func); | ||||
InferFormatFuncRegister(const char *operator_type, const InferFormatFunc &infer_format_func); | |||||
~InferFormatFuncRegister() = default; | ~InferFormatFuncRegister() = default; | ||||
}; | }; | ||||
class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY VerifyFuncRegister { | class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY VerifyFuncRegister { | ||||
public: | public: | ||||
ATTRIBUTED_DEPRECATED(VerifyFuncRegister(const char *, const VerifyFunc &)) | |||||
VerifyFuncRegister(const std::string &operator_type, const VerifyFunc &verify_func); | VerifyFuncRegister(const std::string &operator_type, const VerifyFunc &verify_func); | ||||
VerifyFuncRegister(const char *operator_type, const VerifyFunc &verify_func); | |||||
~VerifyFuncRegister() = default; | ~VerifyFuncRegister() = default; | ||||
}; | }; | ||||
} // namespace ge | } // namespace ge | ||||
@@ -54,144 +54,167 @@ class OpReg { | |||||
OpReg &INFER_SHAPE_AND_TYPE() { return *this; } | OpReg &INFER_SHAPE_AND_TYPE() { return *this; } | ||||
}; | }; | ||||
#define REG_OP(x) \ | |||||
namespace op { \ | |||||
class x : public Operator { \ | |||||
typedef x _THIS_TYPE; \ | |||||
\ | |||||
public: \ | |||||
explicit x(const string &name) : Operator(name, #x) { __##x(); } \ | |||||
x() : Operator(#x) { __##x(); } \ | |||||
\ | |||||
private: \ | |||||
void __##x() { \ | |||||
#define REG_OP(x) \ | |||||
namespace op { \ | |||||
class x : public Operator { \ | |||||
typedef x _THIS_TYPE; \ | |||||
\ | |||||
public: \ | |||||
ATTRIBUTED_DEPRECATED(x(const AscendString &)) \ | |||||
explicit x(const string &name) : Operator(name, #x) { __##x(); } \ | |||||
explicit x(const char *name) : Operator(name, #x) { __##x(); } \ | |||||
explicit x(const AscendString &name) : Operator(name, #x) { __##x(); } \ | |||||
x() : Operator(#x) { __##x(); } \ | |||||
\ | |||||
private: \ | |||||
void __##x() { \ | |||||
OpReg() | OpReg() | ||||
#define ATTR(x, Type, ...) \ | |||||
N(); \ | |||||
__attr_##x(); \ | |||||
} \ | |||||
\ | |||||
public: \ | |||||
static const string name_attr_##x() { return #x; } \ | |||||
Op##Type get_attr_##x() const { \ | |||||
Op##Type ret = __VA_ARGS__; \ | |||||
if (Operator::GetAttr(#x, ret) == GRAPH_FAILED) { \ | |||||
return ret; \ | |||||
} \ | |||||
return ret; \ | |||||
} \ | |||||
_THIS_TYPE &set_attr_##x(const Op##Type &v) { \ | |||||
Operator::SetAttr(#x, v); \ | |||||
return *this; \ | |||||
} \ | |||||
_THIS_TYPE &set_attr_##x(const function<Op##Type()> &v) { return *this; } \ | |||||
\ | |||||
private: \ | |||||
void __attr_##x() { \ | |||||
Operator::AttrRegister(#x, Op##Type(__VA_ARGS__)); \ | |||||
string attr_name(#x); \ | |||||
#define ATTR(x, Type, ...) \ | |||||
N(); \ | |||||
__attr_##x(); \ | |||||
} \ | |||||
\ | |||||
public: \ | |||||
ATTRIBUTED_DEPRECATED(static const void name_attr_##x(AscendString &)) \ | |||||
static const string name_attr_##x() { return #x; } \ | |||||
static const void name_attr_##x(AscendString &attr) { attr = AscendString(#x); } \ | |||||
Op##Type get_attr_##x() const { \ | |||||
Op##Type ret = __VA_ARGS__; \ | |||||
if (Operator::GetAttr(#x, ret) == GRAPH_FAILED) { \ | |||||
return ret; \ | |||||
} \ | |||||
return ret; \ | |||||
} \ | |||||
_THIS_TYPE &set_attr_##x(const Op##Type &v) { \ | |||||
Operator::SetAttr(#x, v); \ | |||||
return *this; \ | |||||
} \ | |||||
_THIS_TYPE &set_attr_##x(const function<Op##Type()> &v) { return *this; } \ | |||||
\ | |||||
private: \ | |||||
void __attr_##x() { \ | |||||
Operator::AttrRegister(#x, Op##Type(__VA_ARGS__)); \ | |||||
string attr_name(#x); \ | |||||
(void)OpReg() | (void)OpReg() | ||||
#define REQUIRED_ATTR(x, Type) \ | |||||
N(); \ | |||||
__required_attr_##x(); \ | |||||
} \ | |||||
\ | |||||
public: \ | |||||
static const string name_attr_##x() { return #x; } \ | |||||
Op##Type get_attr_##x() const { \ | |||||
Op##Type ret; \ | |||||
if (Operator::GetAttr(#x, ret) == GRAPH_FAILED) { \ | |||||
return ret; \ | |||||
} \ | |||||
return ret; \ | |||||
} \ | |||||
_THIS_TYPE &set_attr_##x(const Op##Type &v) { \ | |||||
Operator::SetAttr(#x, v); \ | |||||
return *this; \ | |||||
} \ | |||||
_THIS_TYPE &set_attr_##x(const function<Op##Type()> &v) { return *this; } \ | |||||
\ | |||||
private: \ | |||||
void __required_attr_##x() { \ | |||||
Operator::RequiredAttrRegister(#x); \ | |||||
string attr_name(#x); \ | |||||
#define REQUIRED_ATTR(x, Type) \ | |||||
N(); \ | |||||
__required_attr_##x(); \ | |||||
} \ | |||||
\ | |||||
public: \ | |||||
ATTRIBUTED_DEPRECATED(static const void name_attr_##x(AscendString &)) \ | |||||
static const string name_attr_##x() { return #x; } \ | |||||
static const void name_attr_##x(AscendString &attr_name) { attr_name = AscendString(#x); } \ | |||||
Op##Type get_attr_##x() const { \ | |||||
Op##Type ret; \ | |||||
if (Operator::GetAttr(#x, ret) == GRAPH_FAILED) { \ | |||||
return ret; \ | |||||
} \ | |||||
return ret; \ | |||||
} \ | |||||
_THIS_TYPE &set_attr_##x(const Op##Type &v) { \ | |||||
Operator::SetAttr(#x, v); \ | |||||
return *this; \ | |||||
} \ | |||||
_THIS_TYPE &set_attr_##x(const function<Op##Type()> &v) { return *this; } \ | |||||
\ | |||||
private: \ | |||||
void __required_attr_##x() { \ | |||||
Operator::RequiredAttrRegister(#x); \ | |||||
string attr_name(#x); \ | |||||
(void)OpReg() | (void)OpReg() | ||||
#define INPUT(x, t) \ | |||||
N(); \ | |||||
__input_##x(); \ | |||||
} \ | |||||
\ | |||||
public: \ | |||||
static const string name_in_##x() { return #x; } \ | |||||
_THIS_TYPE &set_input_##x(Operator &v, const string &srcName) { \ | |||||
Operator::SetInput(#x, v, srcName); \ | |||||
return *this; \ | |||||
} \ | |||||
_THIS_TYPE &set_input_##x(Operator &v, uint32_t index) { \ | |||||
Operator::SetInput(#x, v, index); \ | |||||
return *this; \ | |||||
} \ | |||||
_THIS_TYPE &set_input_##x(Operator &v) { \ | |||||
Operator::SetInput(#x, v); \ | |||||
return *this; \ | |||||
} \ | |||||
TensorDesc get_input_desc_##x() const { return Operator::GetInputDesc(#x); } \ | |||||
graphStatus update_input_desc_##x(const TensorDesc &tensorDesc) { \ | |||||
return Operator::UpdateInputDesc(#x, tensorDesc); \ | |||||
} \ | |||||
\ | |||||
private: \ | |||||
void __input_##x() { \ | |||||
Operator::InputRegister(#x); \ | |||||
#define INPUT(x, t) \ | |||||
N(); \ | |||||
__input_##x(); \ | |||||
} \ | |||||
\ | |||||
public: \ | |||||
ATTRIBUTED_DEPRECATED(static const void name_in_##x(AscendString &)) \ | |||||
static const string name_in_##x() { return #x; } \ | |||||
static const void name_in_##x(AscendString &name) { name = AscendString(#x); } \ | |||||
ATTRIBUTED_DEPRECATED(_THIS_TYPE &set_input_##x(Operator &, const char *)) \ | |||||
_THIS_TYPE &set_input_##x(Operator &v, const string &srcName) { \ | |||||
Operator::SetInput(#x, v, srcName); \ | |||||
return *this; \ | |||||
} \ | |||||
_THIS_TYPE &set_input_##x(Operator &v, const char *srcName) { \ | |||||
Operator::SetInput(#x, v, srcName); \ | |||||
return *this; \ | |||||
} \ | |||||
_THIS_TYPE &set_input_##x(Operator &v, uint32_t index) { \ | |||||
Operator::SetInput(#x, v, index); \ | |||||
return *this; \ | |||||
} \ | |||||
_THIS_TYPE &set_input_##x(Operator &v) { \ | |||||
Operator::SetInput(#x, v); \ | |||||
return *this; \ | |||||
} \ | |||||
TensorDesc get_input_desc_##x() const { return Operator::GetInputDesc(#x, 0); } \ | |||||
graphStatus update_input_desc_##x(const TensorDesc &tensorDesc) { \ | |||||
return Operator::UpdateInputDesc(#x, tensorDesc); \ | |||||
} \ | |||||
\ | |||||
private: \ | |||||
void __input_##x() { \ | |||||
Operator::InputRegister(#x); \ | |||||
(void)OpReg() | (void)OpReg() | ||||
#define OPTIONAL_INPUT(x, t) \ | |||||
N(); \ | |||||
__optional_input_##x(); \ | |||||
} \ | |||||
\ | |||||
public: \ | |||||
static const string name_in_##x() { return #x; } \ | |||||
_THIS_TYPE &set_input_##x(Operator &v) { \ | |||||
Operator::SetInput(#x, v); \ | |||||
return *this; \ | |||||
} \ | |||||
_THIS_TYPE &set_input_##x(Operator &v, const string &srcName) { \ | |||||
Operator::SetInput(#x, v, srcName); \ | |||||
return *this; \ | |||||
} \ | |||||
_THIS_TYPE &set_input_##x(Operator &v, uint32_t index) { \ | |||||
Operator::SetInput(#x, v, index); \ | |||||
return *this; \ | |||||
} \ | |||||
TensorDesc get_input_desc_##x() const { return Operator::GetInputDesc(#x); } \ | |||||
graphStatus update_input_desc_##x(const TensorDesc &tensorDesc) { \ | |||||
return Operator::UpdateInputDesc(#x, tensorDesc); \ | |||||
} \ | |||||
\ | |||||
private: \ | |||||
void __optional_input_##x() { \ | |||||
Operator::OptionalInputRegister(#x); \ | |||||
#define OPTIONAL_INPUT(x, t) \ | |||||
N(); \ | |||||
__optional_input_##x(); \ | |||||
} \ | |||||
\ | |||||
public: \ | |||||
ATTRIBUTED_DEPRECATED(static const void name_in_##x(AscendString &)) \ | |||||
static const string name_in_##x() { return #x; } \ | |||||
static const void name_in_##x(AscendString &name) { name = AscendString(#x); } \ | |||||
_THIS_TYPE &set_input_##x(Operator &v) { \ | |||||
Operator::SetInput(#x, v); \ | |||||
return *this; \ | |||||
} \ | |||||
ATTRIBUTED_DEPRECATED(_THIS_TYPE &set_input_##x(Operator &, const char *)) \ | |||||
_THIS_TYPE &set_input_##x(Operator &v, const string &srcName) { \ | |||||
Operator::SetInput(#x, v, srcName); \ | |||||
return *this; \ | |||||
} \ | |||||
_THIS_TYPE &set_input_##x(Operator &v, const char *srcName) { \ | |||||
Operator::SetInput(#x, v, srcName); \ | |||||
return *this; \ | |||||
} \ | |||||
_THIS_TYPE &set_input_##x(Operator &v, uint32_t index) { \ | |||||
Operator::SetInput(#x, v, index); \ | |||||
return *this; \ | |||||
} \ | |||||
TensorDesc get_input_desc_##x() const { return Operator::GetInputDesc(#x, 0); } \ | |||||
graphStatus update_input_desc_##x(const TensorDesc &tensorDesc) { \ | |||||
return Operator::UpdateInputDesc(#x, tensorDesc); \ | |||||
} \ | |||||
\ | |||||
private: \ | |||||
void __optional_input_##x() { \ | |||||
Operator::OptionalInputRegister(#x); \ | |||||
(void)OpReg() | (void)OpReg() | ||||
#define OUTPUT(x, t) \ | |||||
N(); \ | |||||
__out_##x(); \ | |||||
} \ | |||||
\ | |||||
public: \ | |||||
static const string name_out_##x() { return #x; } \ | |||||
TensorDesc get_output_desc_##x() const { return Operator::GetOutputDesc(#x); } \ | |||||
graphStatus update_output_desc_##x(const TensorDesc &tensorDesc) { \ | |||||
return Operator::UpdateOutputDesc(#x, tensorDesc); \ | |||||
} \ | |||||
\ | |||||
private: \ | |||||
void __out_##x() { \ | |||||
Operator::OutputRegister(#x); \ | |||||
#define OUTPUT(x, t) \ | |||||
N(); \ | |||||
__out_##x(); \ | |||||
} \ | |||||
\ | |||||
public: \ | |||||
ATTRIBUTED_DEPRECATED(static const void name_out_##x(AscendString &)) \ | |||||
static const string name_out_##x() { return #x; } \ | |||||
static const void name_out_##x(AscendString &name) { name = AscendString(#x); } \ | |||||
TensorDesc get_output_desc_##x() const { return Operator::GetOutputDesc(#x, 0); } \ | |||||
graphStatus update_output_desc_##x(const TensorDesc &tensorDesc) { \ | |||||
return Operator::UpdateOutputDesc(#x, tensorDesc); \ | |||||
} \ | |||||
\ | |||||
private: \ | |||||
void __out_##x() { \ | |||||
Operator::OutputRegister(#x); \ | |||||
(void)OpReg() | (void)OpReg() | ||||
#define DYNAMIC_INPUT(x, t) \ | #define DYNAMIC_INPUT(x, t) \ | ||||
@@ -216,10 +239,15 @@ class OpReg { | |||||
Operator::SetInput(#x, dstIndex, v); \ | Operator::SetInput(#x, dstIndex, v); \ | ||||
return *this; \ | return *this; \ | ||||
} \ | } \ | ||||
ATTRIBUTED_DEPRECATED(_THIS_TYPE &set_dynamic_input_##x(uint32_t, Operator &, const char *)) \ | |||||
_THIS_TYPE &set_dynamic_input_##x(uint32_t dstIndex, Operator &v, const string &srcName) { \ | _THIS_TYPE &set_dynamic_input_##x(uint32_t dstIndex, Operator &v, const string &srcName) { \ | ||||
Operator::SetInput(#x, dstIndex, v, srcName); \ | Operator::SetInput(#x, dstIndex, v, srcName); \ | ||||
return *this; \ | return *this; \ | ||||
} \ | } \ | ||||
_THIS_TYPE &set_dynamic_input_##x(uint32_t dstIndex, Operator &v, const char *srcName) { \ | |||||
Operator::SetInput(#x, dstIndex, v, srcName); \ | |||||
return *this; \ | |||||
} \ | |||||
\ | \ | ||||
private: \ | private: \ | ||||
void __dy_input_##x() { \ | void __dy_input_##x() { \ | ||||
@@ -252,7 +280,9 @@ class OpReg { | |||||
} \ | } \ | ||||
\ | \ | ||||
public: \ | public: \ | ||||
ATTRIBUTED_DEPRECATED(static const void name_graph_##x(AscendString &)) \ | |||||
static const string name_graph_##x() { return #x; } \ | static const string name_graph_##x() { return #x; } \ | ||||
static const void name_graph_##x(AscendString &name) { name = AscendString(#x); } \ | |||||
SubgraphBuilder get_subgraph_builder_##x() const { return Operator::GetSubgraphBuilder(#x); } \ | SubgraphBuilder get_subgraph_builder_##x() const { return Operator::GetSubgraphBuilder(#x); } \ | ||||
_THIS_TYPE &set_subgraph_builder_##x(const SubgraphBuilder &v) { \ | _THIS_TYPE &set_subgraph_builder_##x(const SubgraphBuilder &v) { \ | ||||
Operator::SetSubgraphBuilder(#x, 0, v); \ | Operator::SetSubgraphBuilder(#x, 0, v); \ | ||||
@@ -272,7 +302,9 @@ class OpReg { | |||||
} \ | } \ | ||||
\ | \ | ||||
public: \ | public: \ | ||||
ATTRIBUTED_DEPRECATED(static const void name_graph_##x(AscendString &)) \ | |||||
static const string name_graph_##x() { return #x; } \ | static const string name_graph_##x() { return #x; } \ | ||||
static const void name_graph_##x(AscendString &name) { name = AscendString(#x); } \ | |||||
_THIS_TYPE &create_dynamic_subgraph_##x(uint32_t num) { \ | _THIS_TYPE &create_dynamic_subgraph_##x(uint32_t num) { \ | ||||
Operator::SubgraphCountRegister(#x, num); \ | Operator::SubgraphCountRegister(#x, num); \ | ||||
return *this; \ | return *this; \ | ||||
@@ -292,15 +324,15 @@ class OpReg { | |||||
(void)OpReg() | (void)OpReg() | ||||
#define PASTE(g_register, y) g_register##y | #define PASTE(g_register, y) g_register##y | ||||
#define __OP_END_IMPL__(x, y) \ | |||||
N(); \ | |||||
} \ | |||||
static_assert( \ | |||||
std::is_same<x, _THIS_TYPE>::value, \ | |||||
"The class name entered into the OP_END_FACTORY_REG needs to be the same as the operator name you define."); \ | |||||
} \ | |||||
; \ | |||||
static const OperatorCreatorRegister PASTE(g_register, y)(#x, [](const std::string &name) { return x(name); }); \ | |||||
#define __OP_END_IMPL__(x, y) \ | |||||
N(); \ | |||||
} \ | |||||
static_assert( \ | |||||
std::is_same<x, _THIS_TYPE>::value, \ | |||||
"The class name entered into the OP_END_FACTORY_REG needs to be the same as the operator name you define."); \ | |||||
} \ | |||||
; \ | |||||
static const OperatorCreatorRegister PASTE(g_register, y)(#x, [](const AscendString &name) { return x(name); }); \ | |||||
} | } | ||||
#define OP_END_FACTORY_REG(x) __OP_END_IMPL__(x, __COUNTER__) | #define OP_END_FACTORY_REG(x) __OP_END_IMPL__(x, __COUNTER__) | ||||
@@ -347,30 +379,30 @@ class OpReg { | |||||
// Common shape inferencer | // Common shape inferencer | ||||
#define ELMTWISE_INFER_SHAPEANDTYPE(in_name, out_name) \ | |||||
[](Operator op) -> graphStatus { \ | |||||
auto x_shape = op.GetInputDesc(in_name).GetShape().GetDims(); \ | |||||
auto x_type = op.GetInputDesc(in_name).GetDataType(); \ | |||||
TensorDesc op_output_desc = op.GetOutputDesc(out_name); \ | |||||
op_output_desc.SetShape(ge::Shape(x_shape)); \ | |||||
op_output_desc.SetOriginShape(ge::Shape(x_shape)); \ | |||||
op_output_desc.SetDataType(x_type); \ | |||||
return op.UpdateOutputDesc(out_name, op_output_desc); \ | |||||
#define ELMTWISE_INFER_SHAPEANDTYPE(in_name, out_name) \ | |||||
[](Operator op) -> graphStatus { \ | |||||
auto x_shape = op.GetInputDesc(in_name, 0).GetShape().GetDims(); \ | |||||
auto x_type = op.GetInputDesc(in_name, 0).GetDataType(); \ | |||||
TensorDesc op_output_desc = op.GetOutputDesc(out_name, 0); \ | |||||
op_output_desc.SetShape(ge::Shape(x_shape)); \ | |||||
op_output_desc.SetOriginShape(ge::Shape(x_shape)); \ | |||||
op_output_desc.SetDataType(x_type); \ | |||||
return op.UpdateOutputDesc(out_name, op_output_desc); \ | |||||
} | } | ||||
graphStatus BroadCastInfer(const function<vector<int64_t>()> &get_in1_shape, | graphStatus BroadCastInfer(const function<vector<int64_t>()> &get_in1_shape, | ||||
const function<vector<int64_t>()> &get_in2_shape, | const function<vector<int64_t>()> &get_in2_shape, | ||||
const function<void(const vector<int64_t> &y_shape)> &set_out_shape); | const function<void(const vector<int64_t> &y_shape)> &set_out_shape); | ||||
#define BROADCAST_INFER(in1_name, in2_name, out_name) \ | |||||
[](Operator op) -> graphStatus { \ | |||||
return BroadCastInfer([&]() { return op.GetInputDesc(in1_name).GetShape().GetDims(); }, \ | |||||
[&]() { return op.GetInputDesc(in2_name).GetShape().GetDims(); }, \ | |||||
[&](const vector<int64_t> &y_shape) { \ | |||||
TensorDesc op_output_desc = op.GetOutputDesc(out_name); \ | |||||
op_output_desc.SetShape(ge::Shape(y_shape)); \ | |||||
(void)op.UpdateOutputDesc(out_name, op_output_desc); \ | |||||
}); \ | |||||
#define BROADCAST_INFER(in1_name, in2_name, out_name) \ | |||||
[](Operator op) -> graphStatus { \ | |||||
return BroadCastInfer([&]() { return op.GetInputDesc(in1_name, 0).GetShape().GetDims(); }, \ | |||||
[&]() { return op.GetInputDesc(in2_name, 0).GetShape().GetDims(); }, \ | |||||
[&](const vector<int64_t> &y_shape) { \ | |||||
TensorDesc op_output_desc = op.GetOutputDesc(out_name, 0); \ | |||||
op_output_desc.SetShape(ge::Shape(y_shape)); \ | |||||
(void)op.UpdateOutputDesc(out_name, op_output_desc); \ | |||||
}); \ | |||||
} | } | ||||
} // namespace ge | } // namespace ge | ||||
#endif // INC_EXTERNAL_GRAPH_OPERATOR_REG_H_ | #endif // INC_EXTERNAL_GRAPH_OPERATOR_REG_H_ |
@@ -25,6 +25,7 @@ | |||||
#include "./ge_error_codes.h" | #include "./ge_error_codes.h" | ||||
#include "./types.h" | #include "./types.h" | ||||
#include "ascend_string.h" | |||||
namespace ge { | namespace ge { | ||||
class ShapeImpl; | class ShapeImpl; | ||||
@@ -81,8 +82,13 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY TensorDesc { | |||||
DataType GetDataType() const; | DataType GetDataType() const; | ||||
void SetDataType(DataType dt); | void SetDataType(DataType dt); | ||||
ATTRIBUTED_DEPRECATED(graphStatus GetName(AscendString &)) | |||||
std::string GetName() const; | std::string GetName() const; | ||||
graphStatus GetName(AscendString &name); | |||||
ATTRIBUTED_DEPRECATED(void SetName(const char *)) | |||||
void SetName(const std::string &name); | void SetName(const std::string &name); | ||||
void SetName(const char *name); | |||||
// Attr acess | // Attr acess | ||||
void SetSize(int64_t size); | void SetSize(int64_t size); | ||||
@@ -115,8 +121,12 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Tensor { | |||||
graphStatus SetData(std::vector<uint8_t> &&data); | graphStatus SetData(std::vector<uint8_t> &&data); | ||||
graphStatus SetData(const std::vector<uint8_t> &data); | graphStatus SetData(const std::vector<uint8_t> &data); | ||||
graphStatus SetData(const uint8_t *data, size_t size); | graphStatus SetData(const uint8_t *data, size_t size); | ||||
ATTRIBUTED_DEPRECATED(graphStatus SetData(const char *data)) | |||||
graphStatus SetData(const std::string &data); | graphStatus SetData(const std::string &data); | ||||
graphStatus SetData(const char *data); | |||||
ATTRIBUTED_DEPRECATED(graphStatus SetData(const std::vector<AscendString> &)) | |||||
graphStatus SetData(const std::vector<std::string> &data); | graphStatus SetData(const std::vector<std::string> &data); | ||||
graphStatus SetData(const std::vector<AscendString> &datas); | |||||
graphStatus IsValid(); | graphStatus IsValid(); | ||||
Tensor Clone() const; | Tensor Clone() const; | ||||
@@ -76,7 +76,10 @@ struct DynamicInputOutputInfo { | |||||
Status AutoMappingByOpFn(const ge::Operator &op_src, ge::Operator &op); | Status AutoMappingByOpFn(const ge::Operator &op_src, ge::Operator &op); | ||||
Status AutoMappingByOpFnDynamic(const ge::Operator &op_src, ge::Operator &op, | Status AutoMappingByOpFnDynamic(const ge::Operator &op_src, ge::Operator &op, | ||||
const vector<DynamicInputOutputInfo> &dynamic_name_attr_value); | const vector<DynamicInputOutputInfo> &dynamic_name_attr_value); | ||||
ATTRIBUTED_DEPRECATED(Status AutoMappingByOpFn(const ge::Operator &, ge::Operator &)) | |||||
Status AutoMappingFn(const google::protobuf::Message *op_src, ge::Operator &op); | Status AutoMappingFn(const google::protobuf::Message *op_src, ge::Operator &op); | ||||
ATTRIBUTED_DEPRECATED(Status AutoMappingByOpFnDynamic(const ge::Operator &, ge::Operator &, | |||||
const vector<DynamicInputOutputInfo> &)) | |||||
Status AutoMappingFnDynamic(const google::protobuf::Message *op_src, ge::Operator &op, | Status AutoMappingFnDynamic(const google::protobuf::Message *op_src, ge::Operator &op, | ||||
std::map<std::string, std::pair<std::string, std::string>> dynamic_name_attr_value, | std::map<std::string, std::pair<std::string, std::string>> dynamic_name_attr_value, | ||||
int in_pos = -1, int out_pos = -1); | int in_pos = -1, int out_pos = -1); | ||||
@@ -95,19 +98,29 @@ using FusionParseParamFunc = | |||||
using FusionParseParamByOpFunc = std::function<domi::Status(const std::vector<ge::Operator> &, ge::Operator &)>; | using FusionParseParamByOpFunc = std::function<domi::Status(const std::vector<ge::Operator> &, ge::Operator &)>; | ||||
using ParseSubgraphFunc = std::function<Status(const std::string &subgraph_name, const ge::Graph &graph)>; | using ParseSubgraphFunc = std::function<Status(const std::string &subgraph_name, const ge::Graph &graph)>; | ||||
using ParseOpToGraphFunc = std::function<Status(const ge::Operator &, ge::Graph &)>; | using ParseOpToGraphFunc = std::function<Status(const ge::Operator &, ge::Graph &)>; | ||||
using ParseSubgraphFuncV2 = std::function<Status(const ge::AscendString &subgraph_name, const ge::Graph &graph)>; | |||||
class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpRegistrationData { | class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpRegistrationData { | ||||
public: | public: | ||||
ATTRIBUTED_DEPRECATED(OpRegistrationData(const char *)) | |||||
OpRegistrationData(const std::string &om_optype); | OpRegistrationData(const std::string &om_optype); | ||||
OpRegistrationData(const char *om_optype); | |||||
~OpRegistrationData(); | ~OpRegistrationData(); | ||||
OpRegistrationData &FrameworkType(const domi::FrameworkType &fmk_type); | OpRegistrationData &FrameworkType(const domi::FrameworkType &fmk_type); | ||||
ATTRIBUTED_DEPRECATED(OpRegistrationData &OriginOpType(const std::vector<ge::AscendString> &)) | |||||
OpRegistrationData &OriginOpType(const std::initializer_list<std::string> &ori_optype_list); | OpRegistrationData &OriginOpType(const std::initializer_list<std::string> &ori_optype_list); | ||||
OpRegistrationData &OriginOpType(const std::vector<ge::AscendString> &ori_op_type_list); | |||||
ATTRIBUTED_DEPRECATED(OpRegistrationData &OriginOpType(const char *)) | |||||
OpRegistrationData &OriginOpType(const std::string &ori_optype); | OpRegistrationData &OriginOpType(const std::string &ori_optype); | ||||
OpRegistrationData &OriginOpType(const char *ori_op_type); | |||||
OpRegistrationData &ParseParamsFn(const ParseParamFunc &parseParamFn); | OpRegistrationData &ParseParamsFn(const ParseParamFunc &parseParamFn); | ||||
OpRegistrationData &ParseParamsByOperatorFn(const ParseParamByOpFunc &parse_param_by_op_fn); | OpRegistrationData &ParseParamsByOperatorFn(const ParseParamByOpFunc &parse_param_by_op_fn); | ||||
@@ -116,21 +129,34 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpRegistrationData { | |||||
OpRegistrationData &FusionParseParamsFn(const FusionParseParamByOpFunc &fusion_parse_param_fn); | OpRegistrationData &FusionParseParamsFn(const FusionParseParamByOpFunc &fusion_parse_param_fn); | ||||
ATTRIBUTED_DEPRECATED(OpRegistrationData &ParseSubgraphPostFn(const ParseSubgraphFuncV2 &)) | |||||
OpRegistrationData &ParseSubgraphPostFn(const ParseSubgraphFunc &subgraph_post_fn); | OpRegistrationData &ParseSubgraphPostFn(const ParseSubgraphFunc &subgraph_post_fn); | ||||
OpRegistrationData &ParseSubgraphPostFn(const ParseSubgraphFuncV2 &subgraph_post_fn); | |||||
OpRegistrationData &ImplyType(const domi::ImplyType &imply_type); | OpRegistrationData &ImplyType(const domi::ImplyType &imply_type); | ||||
ATTRIBUTED_DEPRECATED(OpRegistrationData &DelInputWithCond(int, const char *, bool)) | |||||
OpRegistrationData &DelInputWithCond(int inputIdx, const std::string &attrName, bool attrValue); | OpRegistrationData &DelInputWithCond(int inputIdx, const std::string &attrName, bool attrValue); | ||||
OpRegistrationData &DelInputWithCond(int input_idx, const char *attr_name, bool attr_value); | |||||
ATTRIBUTED_DEPRECATED(OpRegistrationData &DelInputWithOriginalType(int, const char *)) | |||||
OpRegistrationData &DelInputWithOriginalType(int input_idx, const std::string &ori_type); | OpRegistrationData &DelInputWithOriginalType(int input_idx, const std::string &ori_type); | ||||
OpRegistrationData &DelInputWithOriginalType(int input_idx, const char *ori_type); | |||||
OpRegistrationData &InputReorderVector(const vector<int> &input_order); | OpRegistrationData &InputReorderVector(const vector<int> &input_order); | ||||
OpRegistrationData &ParseOpToGraphFn(const ParseOpToGraphFunc &parse_op_to_graph_fn); | OpRegistrationData &ParseOpToGraphFn(const ParseOpToGraphFunc &parse_op_to_graph_fn); | ||||
domi::ImplyType GetImplyType() const; | domi::ImplyType GetImplyType() const; | ||||
ATTRIBUTED_DEPRECATED(Status GetOmOptype(ge::AscendString &) const) | |||||
std::string GetOmOptype() const; | std::string GetOmOptype() const; | ||||
Status GetOmOptype(ge::AscendString &om_op_type) const; | |||||
ATTRIBUTED_DEPRECATED(GetOriginOpTypeSet(std::set<ge::AscendString> &) const) | |||||
std::set<std::string> GetOriginOpTypeSet() const; | std::set<std::string> GetOriginOpTypeSet() const; | ||||
Status GetOriginOpTypeSet(std::set<ge::AscendString> &ori_op_type) const; | |||||
domi::FrameworkType GetFrameworkType() const; | domi::FrameworkType GetFrameworkType() const; | ||||
ParseParamFunc GetParseParamFn() const; | ParseParamFunc GetParseParamFn() const; | ||||
ParseParamByOpFunc GetParseParamByOperatorFn() const; | ParseParamByOpFunc GetParseParamByOperatorFn() const; | ||||
@@ -138,6 +164,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpRegistrationData { | |||||
FusionParseParamByOpFunc GetFusionParseParamByOpFn() const; | FusionParseParamByOpFunc GetFusionParseParamByOpFn() const; | ||||
ParseSubgraphFunc GetParseSubgraphPostFn() const; | ParseSubgraphFunc GetParseSubgraphPostFn() const; | ||||
ParseOpToGraphFunc GetParseOpToGraphFn() const; | ParseOpToGraphFunc GetParseOpToGraphFn() const; | ||||
Status GetParseSubgraphPostFn(ParseSubgraphFuncV2 &func) const; | |||||
private: | private: | ||||
std::shared_ptr<OpRegistrationDataImpl> impl_; | std::shared_ptr<OpRegistrationDataImpl> impl_; | ||||
@@ -28,7 +28,11 @@ namespace domi { | |||||
#else | #else | ||||
#define FMK_FUNC_DEV_VISIBILITY | #define FMK_FUNC_DEV_VISIBILITY | ||||
#endif | #endif | ||||
#ifdef __GNUC__ | |||||
#define ATTRIBUTED_DEPRECATED(replacement) __attribute__((deprecated("Please use " #replacement " instead."))) | |||||
#else | |||||
#define ATTRIBUTED_DEPRECATED(replacement) __declspec(deprecated("Please use " #replacement " instead.")) | |||||
#endif | |||||
/// CCE defined constant | /// CCE defined constant | ||||
/// | /// | ||||
@@ -54,14 +54,25 @@ class ScopePassManager; | |||||
class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY Scope { | class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY Scope { | ||||
public: | public: | ||||
Scope(); | Scope(); | ||||
ATTRIBUTED_DEPRECATED(Status Init(const char *, const char *, Scope *)) | |||||
Status Init(const std::string &name, const std::string &sub_type = "", Scope *father_scope = nullptr); | Status Init(const std::string &name, const std::string &sub_type = "", Scope *father_scope = nullptr); | ||||
Status Init(const char *name, const char *sub_type, Scope *father_scope = nullptr); | |||||
~Scope(); | ~Scope(); | ||||
ATTRIBUTED_DEPRECATED(Status Name(AscendString &) const) | |||||
const std::string &Name() const; | const std::string &Name() const; | ||||
Status Name(AscendString &name) const; | |||||
ATTRIBUTED_DEPRECATED(Status SubType(AscendString &) const) | |||||
const std::string &SubType() const; | const std::string &SubType() const; | ||||
Status SubType(AscendString &sub_type) const; | |||||
ATTRIBUTED_DEPRECATED(Status AllNodesMap(std::unordered_map<AscendString, ge::OperatorPtr> &) const) | |||||
const std::unordered_map<std::string, ge::OperatorPtr> &AllNodesMap() const; | const std::unordered_map<std::string, ge::OperatorPtr> &AllNodesMap() const; | ||||
Status AllNodesMap(std::unordered_map<AscendString, ge::OperatorPtr> &node_map) const; | |||||
ATTRIBUTED_DEPRECATED(Scope *GetSubScope(const char *scope_name) const) | |||||
Scope *GetSubScope(const std::string &scope_name) const; | Scope *GetSubScope(const std::string &scope_name) const; | ||||
Scope *GetSubScope(const char *scope_name) const; | |||||
ATTRIBUTED_DEPRECATED(Status LastName(AscendString &) const) | |||||
const std::string LastName() const; | const std::string LastName() const; | ||||
Status LastName(AscendString &name) const; | |||||
const std::vector<Scope *> &GetAllSubScopes() const; | const std::vector<Scope *> &GetAllSubScopes() const; | ||||
const Scope *GetFatherScope() const; | const Scope *GetFatherScope() const; | ||||
@@ -80,45 +91,85 @@ class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY FusionScopesResult { | |||||
FusionScopesResult(); | FusionScopesResult(); | ||||
Status Init(); | Status Init(); | ||||
~FusionScopesResult(); | ~FusionScopesResult(); | ||||
ATTRIBUTED_DEPRECATED(void SetName(const char *)) | |||||
void SetName(const std::string &name); | void SetName(const std::string &name); | ||||
void SetName(const char *name); | |||||
ATTRIBUTED_DEPRECATED(void SetType(const char *)) | |||||
void SetType(const std::string &type); | void SetType(const std::string &type); | ||||
void SetType(const char *type); | |||||
ATTRIBUTED_DEPRECATED(void SetDescription(const char *)) | |||||
void SetDescription(const std::string &description); | void SetDescription(const std::string &description); | ||||
void SetDescription(const char *description); | |||||
ATTRIBUTED_DEPRECATED(const Status Name(AscendString &) const) | |||||
const std::string &Name() const; | const std::string &Name() const; | ||||
const Status Name(AscendString &name) const; | |||||
const std::vector<ge::OperatorPtr> &Nodes() const; | const std::vector<ge::OperatorPtr> &Nodes() const; | ||||
ATTRIBUTED_DEPRECATED(void InsertInputs(const char *, const std::vector<int32_t> &)) | |||||
void InsertInputs(const std::string &inner_op_name, const std::vector<int32_t> &index_map); | void InsertInputs(const std::string &inner_op_name, const std::vector<int32_t> &index_map); | ||||
void InsertInputs(const char *inner_op_name, const std::vector<int32_t> &index_map); | |||||
ATTRIBUTED_DEPRECATED(void InsertOutputs(const char *, const std::vector<int32_t> &)) | |||||
void InsertOutputs(const std::string &inner_op_name, const std::vector<int32_t> &index_map); | void InsertOutputs(const std::string &inner_op_name, const std::vector<int32_t> &index_map); | ||||
void InsertOutputs(const char *inner_op_name, const std::vector<int32_t> &index_map); | |||||
class InnerNodeInfo { | class InnerNodeInfo { | ||||
public: | public: | ||||
ATTRIBUTED_DEPRECATED(InnerNodeInfo(const char *)) | |||||
explicit InnerNodeInfo(const std::string &fusion_node_name); | explicit InnerNodeInfo(const std::string &fusion_node_name); | ||||
explicit InnerNodeInfo(const char *fusion_node_name); | |||||
ATTRIBUTED_DEPRECATED(InnerNodeInfo(const char *, const char *, const char *)) | |||||
InnerNodeInfo(const std::string &fusion_node_name, const std::string &name, const std::string &type); | InnerNodeInfo(const std::string &fusion_node_name, const std::string &name, const std::string &type); | ||||
InnerNodeInfo(const char *fusion_node_name, const char *name, const char *type); | |||||
InnerNodeInfo(InnerNodeInfo &&other) noexcept; | InnerNodeInfo(InnerNodeInfo &&other) noexcept; | ||||
InnerNodeInfo &operator=(InnerNodeInfo &&other) noexcept; | InnerNodeInfo &operator=(InnerNodeInfo &&other) noexcept; | ||||
InnerNodeInfo(const InnerNodeInfo &) = delete; | InnerNodeInfo(const InnerNodeInfo &) = delete; | ||||
InnerNodeInfo &operator=(const InnerNodeInfo &) = delete; | InnerNodeInfo &operator=(const InnerNodeInfo &) = delete; | ||||
~InnerNodeInfo(); | ~InnerNodeInfo(); | ||||
ATTRIBUTED_DEPRECATED(InnerNodeInfo &SetName(const char *)) | |||||
InnerNodeInfo &SetName(const std::string &name); | InnerNodeInfo &SetName(const std::string &name); | ||||
InnerNodeInfo &SetName(const char *name); | |||||
ATTRIBUTED_DEPRECATED(InnerNodeInfo &SetType(const char *)) | |||||
InnerNodeInfo &SetType(const std::string &type); | InnerNodeInfo &SetType(const std::string &type); | ||||
InnerNodeInfo &SetType(const char *type); | |||||
ATTRIBUTED_DEPRECATED(InnerNodeInfo &InsertInput(const char *, int32_t)) | |||||
InnerNodeInfo &InsertInput(const std::string &input_node, int32_t peer_out_idx); | InnerNodeInfo &InsertInput(const std::string &input_node, int32_t peer_out_idx); | ||||
InnerNodeInfo &InsertInput(const char *input_node, int32_t peer_out_idx); | |||||
ATTRIBUTED_DEPRECATED(InnerNodeInfo &InsertOutput(const char *, int32_t)) | |||||
InnerNodeInfo &InsertOutput(const std::string &output_node, int32_t peer_in_idx); | InnerNodeInfo &InsertOutput(const std::string &output_node, int32_t peer_in_idx); | ||||
InnerNodeInfo &InsertOutput(const char *output_node, int32_t peer_in_idx); | |||||
ge::graphStatus BuildInnerNode(); | ge::graphStatus BuildInnerNode(); | ||||
ATTRIBUTED_DEPRECATED(ge::graphStatus SetInputFormat(const char *, const char *)) | |||||
ge::graphStatus SetInputFormat(const std::string &input_name, const std::string &format); | ge::graphStatus SetInputFormat(const std::string &input_name, const std::string &format); | ||||
ge::graphStatus SetInputFormat(const char *input_name, const char *format); | |||||
ATTRIBUTED_DEPRECATED(ge::graphStatus SetOutputFormat(const char *, const char *)) | |||||
ge::graphStatus SetOutputFormat(const std::string &output_name, const std::string &format); | ge::graphStatus SetOutputFormat(const std::string &output_name, const std::string &format); | ||||
ge::graphStatus SetOutputFormat(const char *output_name, const char *format); | |||||
ATTRIBUTED_DEPRECATED(ge::graphStatus SetDynamicInputFormat(const char *, uint32_t index, const char *)) | |||||
ge::graphStatus SetDynamicInputFormat(const std::string &input_name, uint32_t index, const std::string &format); | ge::graphStatus SetDynamicInputFormat(const std::string &input_name, uint32_t index, const std::string &format); | ||||
ge::graphStatus SetDynamicInputFormat(const char *input_name, uint32_t index, const char *format); | |||||
ATTRIBUTED_DEPRECATED(ge::graphStatus SetDynamicOutputFormat(const char *, uint32_t, const char *)) | |||||
ge::graphStatus SetDynamicOutputFormat(const std::string &output_name, uint32_t index, const std::string &format); | ge::graphStatus SetDynamicOutputFormat(const std::string &output_name, uint32_t index, const std::string &format); | ||||
ge::graphStatus SetDynamicOutputFormat(const char *output_name, uint32_t index, const char *format); | |||||
ge::Operator *MutableOperator(); | ge::Operator *MutableOperator(); | ||||
ATTRIBUTED_DEPRECATED(ge::graphStatus GetName(AscendString &) const) | |||||
std::string GetName() const; | std::string GetName() const; | ||||
ge::graphStatus GetName(AscendString &name) const; | |||||
ATTRIBUTED_DEPRECATED(ge::graphStatus GetType(AscendString &) const) | |||||
std::string GetType() const; | std::string GetType() const; | ||||
ge::graphStatus GetType(AscendString &type) const; | |||||
ATTRIBUTED_DEPRECATED(ge::graphStatus GetInputs(std::vector<std::pair<AscendString, int32_t>> &) const) | |||||
std::vector<std::pair<std::string, int32_t>> GetInputs() const; | std::vector<std::pair<std::string, int32_t>> GetInputs() const; | ||||
ge::graphStatus GetInputs(std::vector<std::pair<AscendString, int32_t>> &inputs) const; | |||||
ATTRIBUTED_DEPRECATED(ge::graphStatus GetOutputs(std::vector<std::pair<AscendString, int32_t>> &) const) | |||||
std::vector<std::pair<std::string, int32_t>> GetOutputs() const; | std::vector<std::pair<std::string, int32_t>> GetOutputs() const; | ||||
ge::graphStatus GetOutputs(std::vector<std::pair<AscendString, int32_t>> &outputs) const; | |||||
private: | private: | ||||
class InnerNodeInfoImpl; | class InnerNodeInfoImpl; | ||||
std::unique_ptr<InnerNodeInfoImpl> impl_; | std::unique_ptr<InnerNodeInfoImpl> impl_; | ||||
}; | }; | ||||
ATTRIBUTED_DEPRECATED(InnerNodeInfo *AddInnerNode(const char *, const char *)) | |||||
InnerNodeInfo *AddInnerNode(const std::string &name, const std::string &type); | InnerNodeInfo *AddInnerNode(const std::string &name, const std::string &type); | ||||
InnerNodeInfo *AddInnerNode(const char *name, const char *type); | |||||
InnerNodeInfo *MutableRecentInnerNode(); | InnerNodeInfo *MutableRecentInnerNode(); | ||||
InnerNodeInfo *MutableInnerNode(uint32_t index); | InnerNodeInfo *MutableInnerNode(uint32_t index); | ||||
ge::graphStatus CheckInnerNodesInfo(); | ge::graphStatus CheckInnerNodesInfo(); | ||||
@@ -157,7 +208,9 @@ class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeGraph { | |||||
~ScopeGraph(); | ~ScopeGraph(); | ||||
const ScopeTree *GetScopeTree() const; | const ScopeTree *GetScopeTree() const; | ||||
ATTRIBUTED_DEPRECATED(Status GetNodesMap(std::unordered_map<AscendString, ge::OperatorPtr> &) const) | |||||
const std::unordered_map<std::string, ge::OperatorPtr> &GetNodesMap() const; | const std::unordered_map<std::string, ge::OperatorPtr> &GetNodesMap() const; | ||||
Status GetNodesMap(std::unordered_map<AscendString, ge::OperatorPtr> &nodes_map) const; | |||||
private: | private: | ||||
class ScopeGraphImpl; | class ScopeGraphImpl; | ||||
@@ -176,7 +229,9 @@ class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeAttrValue { | |||||
void SetIntValue(int64_t value); | void SetIntValue(int64_t value); | ||||
void SetFloatValue(float value); | void SetFloatValue(float value); | ||||
ATTRIBUTED_DEPRECATED(void SetStringValue(const char *)) | |||||
void SetStringValue(std::string value); | void SetStringValue(std::string value); | ||||
void SetStringValue(const char *value); | |||||
void SetBoolValue(bool value); | void SetBoolValue(bool value); | ||||
private: | private: | ||||
@@ -193,7 +248,9 @@ class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeBaseFeature { | |||||
class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY NodeOpTypeFeature : ScopeBaseFeature { | class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY NodeOpTypeFeature : ScopeBaseFeature { | ||||
public: | public: | ||||
ATTRIBUTED_DEPRECATED(NodeOpTypeFeature(const char *, int, int)) | |||||
NodeOpTypeFeature(std::string nodeType, int num, int step = 0); | NodeOpTypeFeature(std::string nodeType, int num, int step = 0); | ||||
NodeOpTypeFeature(const char *node_type, int num, int step = 0); | |||||
NodeOpTypeFeature(NodeOpTypeFeature const &feature); | NodeOpTypeFeature(NodeOpTypeFeature const &feature); | ||||
NodeOpTypeFeature &operator=(NodeOpTypeFeature const &feature); | NodeOpTypeFeature &operator=(NodeOpTypeFeature const &feature); | ||||
~NodeOpTypeFeature(); | ~NodeOpTypeFeature(); | ||||
@@ -206,7 +263,9 @@ class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY NodeOpTypeFeature : ScopeBa | |||||
class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY NodeAttrFeature : ScopeBaseFeature { | class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY NodeAttrFeature : ScopeBaseFeature { | ||||
public: | public: | ||||
ATTRIBUTED_DEPRECATED(NodeAttrFeature(const char *, const char *, ge::DataType, ScopeAttrValue &)) | |||||
NodeAttrFeature(std::string nodeType, std::string attr_name, ge::DataType datatype, ScopeAttrValue &attr_value); | NodeAttrFeature(std::string nodeType, std::string attr_name, ge::DataType datatype, ScopeAttrValue &attr_value); | ||||
NodeAttrFeature(const char *node_type, const char *attr_name, ge::DataType datatype, ScopeAttrValue &attr_value); | |||||
NodeAttrFeature(NodeAttrFeature const &feature); | NodeAttrFeature(NodeAttrFeature const &feature); | ||||
NodeAttrFeature &operator=(NodeAttrFeature const &feature); | NodeAttrFeature &operator=(NodeAttrFeature const &feature); | ||||
~NodeAttrFeature(); | ~NodeAttrFeature(); | ||||
@@ -219,8 +278,10 @@ class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY NodeAttrFeature : ScopeBase | |||||
class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeFeature : ScopeBaseFeature { | class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeFeature : ScopeBaseFeature { | ||||
public: | public: | ||||
ATTRIBUTED_DEPRECATED(ScopeFeature(const char *, int32_t, const char *, const char *, int)) | |||||
ScopeFeature(std::string sub_type, int32_t num, std::string suffix = "", std::string sub_scope_mask = "", | ScopeFeature(std::string sub_type, int32_t num, std::string suffix = "", std::string sub_scope_mask = "", | ||||
int step = 0); | int step = 0); | ||||
ScopeFeature(const char *sub_type, int32_t num, const char *suffix, const char *sub_scope_mask, int step = 0); | |||||
ScopeFeature(ScopeFeature const &feature); | ScopeFeature(ScopeFeature const &feature); | ||||
ScopeFeature &operator=(ScopeFeature const &feature); | ScopeFeature &operator=(ScopeFeature const &feature); | ||||
~ScopeFeature(); | ~ScopeFeature(); | ||||
@@ -235,8 +296,9 @@ class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopePattern { | |||||
public: | public: | ||||
ScopePattern(); | ScopePattern(); | ||||
~ScopePattern(); | ~ScopePattern(); | ||||
ATTRIBUTED_DEPRECATED(ScopePattern &SetSubType(const char *)) | |||||
ScopePattern &SetSubType(const std::string &sub_type); | ScopePattern &SetSubType(const std::string &sub_type); | ||||
ScopePattern &SetSubType(const char *sub_type); | |||||
ScopePattern &AddNodeOpTypeFeature(NodeOpTypeFeature feature); | ScopePattern &AddNodeOpTypeFeature(NodeOpTypeFeature feature); | ||||
ScopePattern &AddNodeAttrFeature(NodeAttrFeature feature); | ScopePattern &AddNodeAttrFeature(NodeAttrFeature feature); | ||||
ScopePattern &AddScopeFeature(ScopeFeature feature); | ScopePattern &AddScopeFeature(ScopeFeature feature); | ||||
@@ -296,8 +358,11 @@ class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeFusionPassRegistry { | |||||
return instance; | return instance; | ||||
} | } | ||||
ATTRIBUTED_DEPRECATED(void RegisterScopeFusionPass(const char *, CreateFn, bool)) | |||||
void RegisterScopeFusionPass(const std::string &pass_name, CreateFn create_fn, bool is_general); | void RegisterScopeFusionPass(const std::string &pass_name, CreateFn create_fn, bool is_general); | ||||
void RegisterScopeFusionPass(const char *pass_name, CreateFn create_fn, bool is_general); | |||||
private: | private: | ||||
ScopeFusionPassRegistry(); | ScopeFusionPassRegistry(); | ||||
class ScopeFusionPassRegistryImpl; | class ScopeFusionPassRegistryImpl; | ||||
@@ -307,7 +372,9 @@ class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeFusionPassRegistry { | |||||
class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeUtil { | class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeUtil { | ||||
public: | public: | ||||
ATTRIBUTED_DEPRECATED(static AscendString StringReplaceAll(const char *, const char *, const char *)) | |||||
static std::string StringReplaceAll(std::string str, const std::string &old_value, const std::string &new_value); | static std::string StringReplaceAll(std::string str, const std::string &old_value, const std::string &new_value); | ||||
static AscendString StringReplaceAll(const char *str, const char *old_value, const char *new_value); | |||||
static void FreeScopePatterns(ScopeFusionPatterns &patterns); | static void FreeScopePatterns(ScopeFusionPatterns &patterns); | ||||
static void FreeOneBatchPattern(std::vector<ScopePattern *> &one_batch_pattern); | static void FreeOneBatchPattern(std::vector<ScopePattern *> &one_batch_pattern); | ||||
}; | }; | ||||
@@ -18,24 +18,39 @@ | |||||
#define INC_FRAMEWORK_COMMON_DEBUG_GE_LOG_H_ | #define INC_FRAMEWORK_COMMON_DEBUG_GE_LOG_H_ | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <unistd.h> | |||||
#include <sys/syscall.h> | |||||
#include "framework/common/ge_inner_error_codes.h" | #include "framework/common/ge_inner_error_codes.h" | ||||
#include "toolchain/slog.h" | #include "toolchain/slog.h" | ||||
#ifdef __GNUC__ | |||||
#include <unistd.h> | |||||
#include <sys/syscall.h> | |||||
#else | |||||
#include "mmpa/mmpa_api.h" | |||||
#endif | |||||
#ifdef __cplusplus | |||||
extern "C" { | |||||
#endif | |||||
#define GE_MODULE_NAME static_cast<int>(GE) | #define GE_MODULE_NAME static_cast<int>(GE) | ||||
// trace status of log | // trace status of log | ||||
enum TraceStatus { TRACE_INIT = 0, TRACE_RUNNING, TRACE_WAITING, TRACE_STOP }; | enum TraceStatus { TRACE_INIT = 0, TRACE_RUNNING, TRACE_WAITING, TRACE_STOP }; | ||||
#define GELOGE(ERROR_CODE, ...) GE_LOG_ERROR(GE_MODULE_NAME, ERROR_CODE, __VA_ARGS__) | |||||
#define GELOGW(...) GE_LOG_WARN(GE_MODULE_NAME, __VA_ARGS__) | |||||
#define GELOGI(...) GE_LOG_INFO(GE_MODULE_NAME, __VA_ARGS__) | |||||
#define GELOGD(...) GE_LOG_DEBUG(GE_MODULE_NAME, __VA_ARGS__) | |||||
#define GEEVENT(...) GE_LOG_EVENT(GE_MODULE_NAME, __VA_ARGS__) | |||||
#define GELOGO(...) GE_LOG_OPLOG(GE_MODULE_NAME, __VA_ARGS__) | |||||
#define GELOGT(VALUE, ...) GE_LOG_TRACE(GE_MODULE_NAME, VALUE, __VA_ARGS__) | |||||
class GeLog { | |||||
public: | |||||
#ifdef __GNUC__ | |||||
static pid_t GetTid() { | |||||
thread_local static pid_t tid = syscall(__NR_gettid); | |||||
return tid; | |||||
} | |||||
#else | |||||
static int GetTid() { | |||||
thread_local static int tid = static_cast<int>(GetCurrentThreadId()); | |||||
return tid; | |||||
} | |||||
#endif | |||||
}; | |||||
inline bool IsLogEnable(int module_name, int log_level) { | inline bool IsLogEnable(int module_name, int log_level) { | ||||
int32_t enable = CheckLogLevel(module_name, log_level); | int32_t enable = CheckLogLevel(module_name, log_level); | ||||
@@ -46,33 +61,57 @@ inline bool IsLogEnable(int module_name, int log_level) { | |||||
return false; | return false; | ||||
} | } | ||||
inline pid_t GetTid() { | |||||
thread_local static pid_t tid = syscall(__NR_gettid); | |||||
return tid; | |||||
} | |||||
#define GELOGE(ERROR_CODE, fmt, ...) \ | |||||
dlog_error(GE_MODULE_NAME, "%lu %s: ErrorNo: %d(%s) " fmt, GeLog::GetTid(), __FUNCTION__, ERROR_CODE, \ | |||||
((GE_GET_ERRORNO_STR(ERROR_CODE)).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 GELOGO(fmt, ...) Dlog(GE_MODULE_NAME, DLOG_OPLOG, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||||
#define GELOGT(VALUE, fmt, ...) \ | |||||
do { \ | |||||
TraceStatus stat = VALUE; \ | |||||
const char *const TraceStatStr[] = {"INIT", "RUNNING", "WAITING", "STOP"}; \ | |||||
int idx = static_cast<int>(stat); \ | |||||
char *k = const_cast<char *>("status"); \ | |||||
char *v = const_cast<char *>(TraceStatStr[idx]); \ | |||||
KeyValue kv = {k, v}; \ | |||||
DlogWithKV(static_cast<int>(GE_MODULE_NAME), DLOG_TRACE, &kv, 1, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, \ | |||||
##__VA_ARGS__); \ | |||||
} while (0) | |||||
#define GE_LOG_ERROR(MOD_NAME, ERROR_CODE, fmt, ...) \ | |||||
dlog_error(MOD_NAME, "%lu %s: ErrorNo: %d(%s) " fmt, GetTid(), __FUNCTION__, ERROR_CODE, \ | |||||
#define GE_LOG_ERROR(MOD_NAME, ERROR_CODE, fmt, ...) \ | |||||
dlog_error(MOD_NAME, "%lu %s: ErrorNo: %d(%s) " fmt, GeLog::GetTid(), __FUNCTION__, ERROR_CODE, \ | |||||
((GE_GET_ERRORNO_STR(ERROR_CODE)).c_str()), ##__VA_ARGS__) | ((GE_GET_ERRORNO_STR(ERROR_CODE)).c_str()), ##__VA_ARGS__) | ||||
#define GE_LOG_WARN(MOD_NAME, fmt, ...) \ | #define GE_LOG_WARN(MOD_NAME, fmt, ...) \ | ||||
if (IsLogEnable(MOD_NAME, DLOG_WARN)) dlog_warn(MOD_NAME, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||||
if (IsLogEnable(MOD_NAME, DLOG_WARN)) dlog_warn(MOD_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||||
#define GE_LOG_INFO(MOD_NAME, fmt, ...) \ | #define GE_LOG_INFO(MOD_NAME, fmt, ...) \ | ||||
if (IsLogEnable(MOD_NAME, DLOG_INFO)) dlog_info(MOD_NAME, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||||
if (IsLogEnable(MOD_NAME, DLOG_INFO)) dlog_info(MOD_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||||
#define GE_LOG_DEBUG(MOD_NAME, fmt, ...) \ | #define GE_LOG_DEBUG(MOD_NAME, fmt, ...) \ | ||||
if (IsLogEnable(MOD_NAME, DLOG_DEBUG)) dlog_debug(MOD_NAME, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||||
#define GE_LOG_EVENT(MOD_NAME, fmt, ...) dlog_event(MOD_NAME, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||||
if (IsLogEnable(MOD_NAME, DLOG_DEBUG)) \ | |||||
dlog_debug(MOD_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||||
#define GE_LOG_EVENT(MOD_NAME, fmt, ...) \ | |||||
dlog_event(MOD_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||||
#define GE_LOG_OPLOG(MOD_NAME, fmt, ...) \ | #define GE_LOG_OPLOG(MOD_NAME, fmt, ...) \ | ||||
Dlog(MOD_NAME, DLOG_OPLOG, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||||
Dlog(MOD_NAME, DLOG_OPLOG, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||||
#define GE_LOG_TRACE(MOD_NAME, value, fmt, ...) \ | |||||
do { \ | |||||
TraceStatus stat = value; \ | |||||
const char *const TraceStatStr[] = {"INIT", "RUNNING", "WAITING", "STOP"}; \ | |||||
int idx = static_cast<int>(stat); \ | |||||
char *k = const_cast<char *>("status"); \ | |||||
char *v = const_cast<char *>(TraceStatStr[idx]); \ | |||||
KeyValue kv = {k, v}; \ | |||||
DlogWithKV(static_cast<int>(MOD_NAME), DLOG_TRACE, &kv, 1, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__); \ | |||||
#define GE_LOG_TRACE(MOD_NAME, value, fmt, ...) \ | |||||
do { \ | |||||
TraceStatus stat = value; \ | |||||
const char *const TraceStatStr[] = {"INIT", "RUNNING", "WAITING", "STOP"}; \ | |||||
int idx = static_cast<int>(stat); \ | |||||
char *k = const_cast<char *>("status"); \ | |||||
char *v = const_cast<char *>(TraceStatStr[idx]); \ | |||||
KeyValue kv = {k, v}; \ | |||||
DlogWithKV(static_cast<int>(MOD_NAME), DLOG_TRACE, &kv, 1, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, \ | |||||
##__VA_ARGS__); \ | |||||
} while (0) | } while (0) | ||||
// print memory when it is greater than 1KB. | // print memory when it is greater than 1KB. | ||||
@@ -82,4 +121,7 @@ inline pid_t GetTid() { | |||||
GELOGI("MallocMemory, func=%s, size=%zu, purpose=%s", (#FUNC), static_cast<size_t>(SIZE), (PURPOSE)); \ | GELOGI("MallocMemory, func=%s, size=%zu, purpose=%s", (#FUNC), static_cast<size_t>(SIZE), (PURPOSE)); \ | ||||
} \ | } \ | ||||
} while (0); | } while (0); | ||||
#ifdef __cplusplus | |||||
} | |||||
#endif | |||||
#endif // INC_FRAMEWORK_COMMON_DEBUG_GE_LOG_H_ | #endif // INC_FRAMEWORK_COMMON_DEBUG_GE_LOG_H_ |
@@ -0,0 +1,32 @@ | |||||
/** | |||||
* 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_COMMON_GE_COMPILER_OPTIONS_H_ | |||||
#define INC_FRAMEWORK_COMMON_GE_COMPILER_OPTIONS_H_ | |||||
namespace ge { | |||||
#ifdef __GNUC__ | |||||
#define GE_ATTRIBUTE_UNUSED __attribute__((unused)) | |||||
#define GE_FUNCTION_IDENTIFIER __PRETTY_FUNCTION__ | |||||
#define GE_BUILTIN_PREFETCH(args_addr) __builtin_prefetch(args_addr) | |||||
#else | |||||
#define GE_ATTRIBUTE_UNUSED | |||||
#define GE_FUNCTION_IDENTIFIER __FUNCSIG__ | |||||
#define GE_BUILTIN_PREFETCH(args_addr) | |||||
#endif | |||||
} // namespace ge | |||||
#endif // INC_FRAMEWORK_COMMON_GE_COMPILER_OPTIONS_H_ |
@@ -105,6 +105,7 @@ struct ShapeDescription { | |||||
int64_t height = 0; | int64_t height = 0; | ||||
int64_t width = 0; | int64_t width = 0; | ||||
std::vector<int64_t> dims; | std::vector<int64_t> dims; | ||||
std::vector<std::pair<int64_t, int64_t>> shape_ranges; | |||||
}; | }; | ||||
// Definition of input and output description information | // Definition of input and output description information | ||||
@@ -17,6 +17,7 @@ | |||||
#ifndef INC_FRAMEWORK_COMMON_STRING_UTIL_H_ | #ifndef INC_FRAMEWORK_COMMON_STRING_UTIL_H_ | ||||
#define INC_FRAMEWORK_COMMON_STRING_UTIL_H_ | #define INC_FRAMEWORK_COMMON_STRING_UTIL_H_ | ||||
#include <cctype> | |||||
#include <securec.h> | #include <securec.h> | ||||
#include <algorithm> | #include <algorithm> | ||||
@@ -18,7 +18,6 @@ | |||||
#define INC_FRAMEWORK_COMMON_TYPES_H_ | #define INC_FRAMEWORK_COMMON_TYPES_H_ | ||||
#include <limits.h> | #include <limits.h> | ||||
#include <linux/limits.h> | |||||
#include <stdint.h> | #include <stdint.h> | ||||
#include <algorithm> | #include <algorithm> | ||||
#include <map> | #include <map> | ||||
@@ -526,7 +525,10 @@ REGISTER_OPTYPE_DECLARE(HVDCALLBACKALLGATHER, "HorovodAllgather"); | |||||
REGISTER_OPTYPE_DECLARE(HVDCALLBACKBROADCAST, "HorovodBroadcast"); | REGISTER_OPTYPE_DECLARE(HVDCALLBACKBROADCAST, "HorovodBroadcast"); | ||||
REGISTER_OPTYPE_DECLARE(HVDWAIT, "HorovodWait"); | REGISTER_OPTYPE_DECLARE(HVDWAIT, "HorovodWait"); | ||||
enum InputMode { INPUT = 0, CONST }; | |||||
// aicpu op for online_infer dynamic_dims | |||||
REGISTER_OPTYPE_DECLARE(GETDYNAMICDIMS, "GetDynamicDims"); | |||||
enum InputMode { INPUT = 0, CONST_INPUT }; | |||||
// Definition of the processing status enum of the process module | // Definition of the processing status enum of the process module | ||||
enum ModelProcessState { | enum ModelProcessState { | ||||
@@ -115,6 +115,10 @@ struct OmgContext { | |||||
std::string dynamic_batch_size; | std::string dynamic_batch_size; | ||||
std::string dynamic_image_size; | std::string dynamic_image_size; | ||||
std::string dynamic_dims; | std::string dynamic_dims; | ||||
std::string dynamic_node_type; | |||||
std::vector<std::vector<int64_t>> user_real_input_dims; | |||||
std::vector<int64_t> cur_dynamic_dims; | |||||
bool need_multi_batch = false; | |||||
}; | }; | ||||
} // namespace ge | } // namespace ge | ||||
@@ -17,6 +17,8 @@ | |||||
#ifndef INC_GRAPH_ANCHOR_H_ | #ifndef INC_GRAPH_ANCHOR_H_ | ||||
#define INC_GRAPH_ANCHOR_H_ | #define INC_GRAPH_ANCHOR_H_ | ||||
#include "graph/compiler_options.h" | |||||
#include <memory> | #include <memory> | ||||
#include <string> | #include <string> | ||||
#include <vector> | #include <vector> | ||||
@@ -128,7 +130,7 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Anchor : public std::enable | |||||
template <class T> | template <class T> | ||||
static Anchor::TYPE TypeOf() { | static Anchor::TYPE TypeOf() { | ||||
static_assert(std::is_base_of<Anchor, T>::value, "T must be a Anchor!"); | static_assert(std::is_base_of<Anchor, T>::value, "T must be a Anchor!"); | ||||
return __PRETTY_FUNCTION__; | |||||
return METADEF_FUNCTION_IDENTIFIER; | |||||
} | } | ||||
public: | public: | ||||
@@ -20,6 +20,7 @@ | |||||
#include <string> | #include <string> | ||||
#include <vector> | #include <vector> | ||||
#include "graph/ge_attr_value.h" | #include "graph/ge_attr_value.h" | ||||
#include "graph/compiler_options.h" | |||||
namespace ge { | namespace ge { | ||||
@@ -92,7 +93,7 @@ class _GeSerializable { | |||||
SaveItem(namedAttrs, args...); | SaveItem(namedAttrs, args...); | ||||
} | } | ||||
static void SaveItem(GeAttrValue::NAMED_ATTRS &namedAttrs __attribute__((__unused__))) {} | |||||
static void SaveItem(GeAttrValue::NAMED_ATTRS &namedAttrs METADEF_ATTRIBUTE_UNUSED) {} | |||||
template <class T, class... Args> | template <class T, class... Args> | ||||
static graphStatus LoadItem(GeAttrValue::NAMED_ATTRS &namedAttrs, string itemName, T &item, Args &... args) { | static graphStatus LoadItem(GeAttrValue::NAMED_ATTRS &namedAttrs, string itemName, T &item, Args &... args) { | ||||
@@ -104,9 +105,7 @@ class _GeSerializable { | |||||
return LoadItem(namedAttrs, args...); | return LoadItem(namedAttrs, args...); | ||||
} | } | ||||
static graphStatus LoadItem(GeAttrValue::NAMED_ATTRS &namedAttrs __attribute__((__unused__))) { | |||||
return GRAPH_SUCCESS; | |||||
} | |||||
static graphStatus LoadItem(GeAttrValue::NAMED_ATTRS &namedAttrs METADEF_ATTRIBUTE_UNUSED) { return GRAPH_SUCCESS; } | |||||
}; | }; | ||||
#define _GE_FI(a) #a, a | #define _GE_FI(a) #a, a | ||||
@@ -0,0 +1,32 @@ | |||||
/** | |||||
* 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_GRAPH_COMPILER_OPTIONS_H_ | |||||
#define INC_GRAPH_COMPILER_OPTIONS_H_ | |||||
namespace ge { | |||||
#ifdef __GNUC__ | |||||
#define METADEF_ATTRIBUTE_UNUSED __attribute__((unused)) | |||||
#define METADEF_FUNCTION_IDENTIFIER __PRETTY_FUNCTION__ | |||||
#define METADEF_BUILTIN_PREFETCH(args_addr) __builtin_prefetch(args_addr) | |||||
#else | |||||
#define METADEF_ATTRIBUTE_UNUSED | |||||
#define METADEF_FUNCTION_IDENTIFIER __FUNCSIG__ | |||||
#define METADEF_BUILTIN_PREFETCH(args_addr) | |||||
#endif | |||||
} // namespace ge | |||||
#endif // INC_GRAPH_COMPILER_OPTIONS_H_ |
@@ -1139,6 +1139,13 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_ZER | |||||
// The processing mode of INF and NAN during floating-point number calculation. | // The processing mode of INF and NAN during floating-point number calculation. | ||||
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_FP_CEILING_MODE; | GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_FP_CEILING_MODE; | ||||
// count of data from getnext_sink | |||||
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_GETNEXT_SINK_DATA_COUNT; | |||||
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_GETNEXT_SINK_SHAPE_INFO; | |||||
// getnext_sink marked on NetOutput | |||||
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_GETNEXT_SINK_DYNMAIC; | |||||
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_ALL_GEARS_INFO; | |||||
} // namespace ge | } // namespace ge | ||||
#endif // INC_GRAPH_DEBUG_GE_ATTR_DEFINE_H_ | #endif // INC_GRAPH_DEBUG_GE_ATTR_DEFINE_H_ |
@@ -22,6 +22,8 @@ | |||||
#include <string> | #include <string> | ||||
#include <utility> | #include <utility> | ||||
#include "graph/compiler_options.h" | |||||
namespace ge { | namespace ge { | ||||
using std::shared_ptr; | using std::shared_ptr; | ||||
using std::string; | using std::string; | ||||
@@ -30,7 +32,7 @@ class TypeID { | |||||
public: | public: | ||||
template <class T> | template <class T> | ||||
static TypeID Of() { | static TypeID Of() { | ||||
return TypeID(__PRETTY_FUNCTION__); | |||||
return TypeID(METADEF_FUNCTION_IDENTIFIER); | |||||
} | } | ||||
~TypeID() = default; | ~TypeID() = default; | ||||
@@ -164,6 +164,10 @@ class OpDesc : public std::enable_shared_from_this<OpDesc>, public AttrHolder { | |||||
std::map<string, uint32_t> GetAllOutputName(); | std::map<string, uint32_t> GetAllOutputName(); | ||||
std::map<string, uint32_t> &MutableAllInputName(); | |||||
std::map<string, uint32_t> &MutableAllOutputName(); | |||||
bool UpdateInputName(std::map<string, uint32_t> inputNameIdx); | bool UpdateInputName(std::map<string, uint32_t> inputNameIdx); | ||||
bool UpdateOutputName(std::map<string, uint32_t> outputNameIdx); | bool UpdateOutputName(std::map<string, uint32_t> outputNameIdx); | ||||
@@ -43,6 +43,8 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OperatorFactoryImpl { | |||||
static graphStatus RegisterOperatorCreator(const std::string &operator_type, OpCreator const &op_creator); | static graphStatus RegisterOperatorCreator(const std::string &operator_type, OpCreator const &op_creator); | ||||
static graphStatus RegisterOperatorCreator(const std::string &operator_type, OpCreatorV2 const &op_creator); | |||||
static graphStatus RegisterInferShapeFunc(const std::string &operator_type, InferShapeFunc const infer_shape_func); | static graphStatus RegisterInferShapeFunc(const std::string &operator_type, InferShapeFunc const infer_shape_func); | ||||
static graphStatus RegisterInferFormatFunc(const std::string &operator_type, InferFormatFunc const infer_format_func); | static graphStatus RegisterInferFormatFunc(const std::string &operator_type, InferFormatFunc const infer_format_func); | ||||
@@ -53,6 +55,7 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OperatorFactoryImpl { | |||||
InferDataSliceFunc const infer_data_slice_func); | InferDataSliceFunc const infer_data_slice_func); | ||||
static shared_ptr<std::map<string, OpCreator>> operator_creators_; | static shared_ptr<std::map<string, OpCreator>> operator_creators_; | ||||
static shared_ptr<std::map<string, OpCreatorV2>> operator_creators_v2_; | |||||
static shared_ptr<std::map<string, InferShapeFunc>> operator_infershape_funcs_; | static shared_ptr<std::map<string, InferShapeFunc>> operator_infershape_funcs_; | ||||
static shared_ptr<std::map<string, InferFormatFunc>> operator_inferformat_funcs_; | static shared_ptr<std::map<string, InferFormatFunc>> operator_inferformat_funcs_; | ||||
static shared_ptr<std::map<string, VerifyFunc>> operator_verify_funcs_; | static shared_ptr<std::map<string, VerifyFunc>> operator_verify_funcs_; | ||||
@@ -17,8 +17,6 @@ | |||||
#ifndef INC_GRAPH_OPSPROTO_MANAGER_H_ | #ifndef INC_GRAPH_OPSPROTO_MANAGER_H_ | ||||
#define INC_GRAPH_OPSPROTO_MANAGER_H_ | #define INC_GRAPH_OPSPROTO_MANAGER_H_ | ||||
#include <dirent.h> | |||||
#include <dlfcn.h> | |||||
#include <string.h> | #include <string.h> | ||||
#include <map> | #include <map> | ||||
#include <string> | #include <string> | ||||
@@ -55,7 +55,7 @@ struct RefCell { | |||||
struct RefCellHash { | struct RefCellHash { | ||||
size_t operator()(const RefCell &c) const { | size_t operator()(const RefCell &c) const { | ||||
unsigned long number = reinterpret_cast<unsigned long>(reinterpret_cast<uintptr_t>(c.node.get())); | |||||
unsigned long number = static_cast<unsigned long>(reinterpret_cast<uintptr_t>(c.node.get())); | |||||
string tmp = c.node_name + std::to_string(c.in_out) + std::to_string(c.in_out_idx) + std::to_string(number); | string tmp = c.node_name + std::to_string(c.in_out) + std::to_string(c.in_out_idx) + std::to_string(number); | ||||
return std::hash<string>()(tmp); | return std::hash<string>()(tmp); | ||||
} | } | ||||
@@ -31,6 +31,8 @@ class ShapeRefiner { | |||||
static graphStatus InferShapeAndType(const NodePtr &node, bool before_subgraph); | static graphStatus InferShapeAndType(const NodePtr &node, bool before_subgraph); | ||||
static graphStatus InferShapeAndType(const NodePtr &node); | static graphStatus InferShapeAndType(const NodePtr &node); | ||||
static graphStatus InferShapeAndType(const ConstNodePtr &node, Operator &op); | static graphStatus InferShapeAndType(const ConstNodePtr &node, Operator &op); | ||||
static graphStatus InferShapeAndTypeForRunning(const ConstNodePtr &node, Operator &op, bool before_subgraph); | |||||
static graphStatus InferShapeAndTypeForRunning(const NodePtr &node, bool before_subgraph); | |||||
static void ClearContextMap(); | static void ClearContextMap(); | ||||
private: | private: | ||||
@@ -71,7 +71,7 @@ const std::set<std::string> build_step_options = {BUILD_STEP_BEFORE_UB_MATCH, BU | |||||
using SubgraphCreateOutNode = std::unordered_map<ComputeGraphPtr, NodePtr>; | using SubgraphCreateOutNode = std::unordered_map<ComputeGraphPtr, NodePtr>; | ||||
using NodetoNodeMap = std::unordered_map<NodePtr, NodePtr>; | using NodetoNodeMap = std::unordered_map<NodePtr, NodePtr>; | ||||
using NodeSet = std::set<NodePtr>; | |||||
using NodeVec = std::vector<NodePtr>; | |||||
using NodeNametoNodeNameMap = std::unordered_map<std::string, std::string>; | using NodeNametoNodeNameMap = std::unordered_map<std::string, std::string>; | ||||
using NodetoNodeNameMap = std::unordered_map<NodePtr, std::string>; | using NodetoNodeNameMap = std::unordered_map<NodePtr, std::string>; | ||||
class TuningUtils { | class TuningUtils { | ||||
@@ -119,8 +119,8 @@ class TuningUtils { | |||||
static NodeNametoNodeNameMap data_2_netoutput_; | static NodeNametoNodeNameMap data_2_netoutput_; | ||||
static NodetoNodeNameMap data_node_2_netoutput_; | static NodetoNodeNameMap data_node_2_netoutput_; | ||||
static NodetoNodeMap data_node_2_netoutput_node_; | static NodetoNodeMap data_node_2_netoutput_node_; | ||||
static NodeSet netoutput_nodes_; | |||||
static NodeSet merged_graph_nodes_; | |||||
static NodeVec netoutput_nodes_; | |||||
static NodeVec merged_graph_nodes_; | |||||
static std::mutex mutex_; | static std::mutex mutex_; | ||||
// for debug | // for debug | ||||
static std::string PrintCheckLog(); | static std::string PrintCheckLog(); | ||||
@@ -67,12 +67,15 @@ include_directories(${GE_SOURCE_DIR}/build) | |||||
######### libgraph.so ############# | ######### libgraph.so ############# | ||||
add_library(graph SHARED ${SRC_LIST} ${PROTO_SRCS} ${PROTO_ONNX_SRCS}) | add_library(graph SHARED ${SRC_LIST} ${PROTO_SRCS} ${PROTO_ONNX_SRCS}) | ||||
target_compile_definitions(graph PRIVATE | target_compile_definitions(graph PRIVATE | ||||
DAVINCI_CLOUD | |||||
Werror) | |||||
DAVINCI_CLOUD) | |||||
target_compile_options(graph PRIVATE | |||||
-Werror | |||||
-Wno-deprecated-declarations) | |||||
target_link_libraries(graph PRIVATE | target_link_libraries(graph PRIVATE | ||||
${PROTOBUF_LIBRARY} | ${PROTOBUF_LIBRARY} | ||||
${c_sec} | ${c_sec} | ||||
${slog} | ${slog} | ||||
${error_manager} | ${error_manager} | ||||
${mmpa} | |||||
rt | rt | ||||
dl) | dl) |
@@ -15,11 +15,15 @@ | |||||
*/ | */ | ||||
#include "external/graph/ascend_string.h" | #include "external/graph/ascend_string.h" | ||||
#include "debug/ge_log.h" | |||||
namespace ge { | namespace ge { | ||||
AscendString::AscendString(const char* name) { | AscendString::AscendString(const char* name) { | ||||
if (name != nullptr) { | if (name != nullptr) { | ||||
name_ = std::shared_ptr<std::string>(new (std::nothrow) std::string(name)); | name_ = std::shared_ptr<std::string>(new (std::nothrow) std::string(name)); | ||||
if (name_ == nullptr) { | |||||
GELOGE(FAILED, "AscendString[%s] make shared failed.", name); | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -35,4 +35,14 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY AttrValue::AttrValue() { impl = C | |||||
ATTR_VALUE_SET_GET_IMP(AttrValue::STR) | ATTR_VALUE_SET_GET_IMP(AttrValue::STR) | ||||
ATTR_VALUE_SET_GET_IMP(AttrValue::INT) | ATTR_VALUE_SET_GET_IMP(AttrValue::INT) | ||||
ATTR_VALUE_SET_GET_IMP(AttrValue::FLOAT) | ATTR_VALUE_SET_GET_IMP(AttrValue::FLOAT) | ||||
graphStatus AttrValue::GetValue(AscendString &val) { | |||||
std::string val_get; | |||||
auto status = GetValue(val_get); | |||||
if (status != GRAPH_SUCCESS) { | |||||
return status; | |||||
} | |||||
val = AscendString(val_get.c_str()); | |||||
return GRAPH_SUCCESS; | |||||
} | |||||
} // namespace ge | } // namespace ge |
@@ -729,7 +729,7 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus ComputeGraph::InsertE | |||||
graphStatus ComputeGraph::DFSTopologicalSorting(std::vector<NodePtr> &node_vec, | graphStatus ComputeGraph::DFSTopologicalSorting(std::vector<NodePtr> &node_vec, | ||||
std::map<NodePtr, uint32_t> &map_in_edge_num, | std::map<NodePtr, uint32_t> &map_in_edge_num, | ||||
std::vector<NodePtr> &stack, bool reverse) { | std::vector<NodePtr> &stack, bool reverse) { | ||||
GELOGI("Runing_Dfs_Sort: %s", name_.c_str()); | |||||
GELOGD("Runing_Dfs_Sort: %s", name_.c_str()); | |||||
// Record the number of non data nodes but no input nodes | // Record the number of non data nodes but no input nodes | ||||
GE_CHK_BOOL_EXEC(SortNodes(stack, map_in_edge_num) == GRAPH_SUCCESS, return GRAPH_FAILED, "sort nodes failed"); | GE_CHK_BOOL_EXEC(SortNodes(stack, map_in_edge_num) == GRAPH_SUCCESS, return GRAPH_FAILED, "sort nodes failed"); | ||||
std::vector<NodePtr> out_nodes; | std::vector<NodePtr> out_nodes; | ||||
@@ -1031,7 +1031,7 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool ComputeGraph::IsValid() cons | |||||
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void ComputeGraph::Dump() const { | GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void ComputeGraph::Dump() const { | ||||
GELOGI("graph name = %s.", GetName().c_str()); | GELOGI("graph name = %s.", GetName().c_str()); | ||||
for (const auto &node : GetAllNodes()) { | for (const auto &node : GetAllNodes()) { | ||||
GELOGI("node name = %s.", node->GetName().c_str()); | |||||
GELOGD("node name = %s.", node->GetName().c_str()); | |||||
for (const auto &anchor : node->GetAllOutDataAnchors()) { | for (const auto &anchor : node->GetAllOutDataAnchors()) { | ||||
for (const auto &peer_in_anchor : anchor->GetPeerInDataAnchors()) { | for (const auto &peer_in_anchor : anchor->GetPeerInDataAnchors()) { | ||||
GE_IF_BOOL_EXEC(peer_in_anchor != nullptr && peer_in_anchor->GetOwnerNode() != nullptr, | GE_IF_BOOL_EXEC(peer_in_anchor != nullptr && peer_in_anchor->GetOwnerNode() != nullptr, | ||||
@@ -17,8 +17,10 @@ | |||||
#ifndef COMMON_GRAPH_DEBUG_GE_OP_TYPES_H_ | #ifndef COMMON_GRAPH_DEBUG_GE_OP_TYPES_H_ | ||||
#define COMMON_GRAPH_DEBUG_GE_OP_TYPES_H_ | #define COMMON_GRAPH_DEBUG_GE_OP_TYPES_H_ | ||||
#include "graph/compiler_options.h" | |||||
namespace ge { | namespace ge { | ||||
#define GE_REGISTER_OPTYPE(var_name, str_name) static const char *var_name __attribute__((unused)) = str_name | |||||
#define GE_REGISTER_OPTYPE(var_name, str_name) static const char *var_name METADEF_ATTRIBUTE_UNUSED = str_name | |||||
GE_REGISTER_OPTYPE(DATA, "Data"); | GE_REGISTER_OPTYPE(DATA, "Data"); | ||||
GE_REGISTER_OPTYPE(AIPPDATA, "AippData"); | GE_REGISTER_OPTYPE(AIPPDATA, "AippData"); | ||||
@@ -1102,4 +1102,11 @@ const std::string ATTR_ZERO_COPY_RELATIVE_OFFSET = "_zero_copy_relative_offset"; | |||||
// The processing mode of INF and NAN during floating-point number calculation. | // The processing mode of INF and NAN during floating-point number calculation. | ||||
const std::string ATTR_FP_CEILING_MODE = "_fp_ceiling_mode"; | const std::string ATTR_FP_CEILING_MODE = "_fp_ceiling_mode"; | ||||
// count of data from getnext_sink | |||||
const std::string ATTR_GETNEXT_SINK_DATA_COUNT = "N"; | |||||
const std::string ATTR_GETNEXT_SINK_SHAPE_INFO = "shape_info"; | |||||
// getnext_sink marked on NetOutput | |||||
const std::string ATTR_GETNEXT_SINK_DYNMAIC = "getnext_sink_dynamic"; | |||||
const std::string ATTR_ALL_GEARS_INFO = "all_gears_info"; | |||||
} // namespace ge | } // namespace ge |
@@ -89,7 +89,7 @@ GNodePtr NodeAdapter::Node2GNodePtr(const ge::NodePtr &node) { | |||||
GNode::GNode() { impl_ = ComGraphMakeShared<NodeImpl>(); } | GNode::GNode() { impl_ = ComGraphMakeShared<NodeImpl>(); } | ||||
graphStatus GNode::GetType(ge::AscendString &type) const { | |||||
graphStatus GNode::GetType(AscendString &type) const { | |||||
if (impl_ == nullptr) { | if (impl_ == nullptr) { | ||||
GELOGE(GRAPH_FAILED, "GetType: node impl is nullptr."); | GELOGE(GRAPH_FAILED, "GetType: node impl is nullptr."); | ||||
return GRAPH_FAILED; | return GRAPH_FAILED; | ||||
@@ -107,7 +107,7 @@ graphStatus GNode::GetType(ge::AscendString &type) const { | |||||
return GRAPH_SUCCESS; | return GRAPH_SUCCESS; | ||||
} | } | ||||
graphStatus GNode::GetName(ge::AscendString &name) const { | |||||
graphStatus GNode::GetName(AscendString &name) const { | |||||
if (impl_ == nullptr) { | if (impl_ == nullptr) { | ||||
GELOGE(GRAPH_FAILED, "GetName: node impl is nullptr."); | GELOGE(GRAPH_FAILED, "GetName: node impl is nullptr."); | ||||
return GRAPH_FAILED; | return GRAPH_FAILED; | ||||
@@ -295,7 +295,7 @@ graphStatus GNode::GetInputConstData(const int32_t index, Tensor &data) const { | |||||
return GRAPH_NODE_WITHOUT_CONST_INPUT; | return GRAPH_NODE_WITHOUT_CONST_INPUT; | ||||
} | } | ||||
graphStatus GNode::GetInputIndexByName(const ge::AscendString &name, int32_t &index) { | |||||
graphStatus GNode::GetInputIndexByName(const AscendString &name, int32_t &index) { | |||||
const char *ascend_name = name.GetString(); | const char *ascend_name = name.GetString(); | ||||
if (ascend_name == nullptr) { | if (ascend_name == nullptr) { | ||||
GELOGE(GRAPH_PARAM_INVALID, "GetInputIndexByName: ascend string error."); | GELOGE(GRAPH_PARAM_INVALID, "GetInputIndexByName: ascend string error."); | ||||
@@ -325,7 +325,7 @@ graphStatus GNode::GetInputIndexByName(const ge::AscendString &name, int32_t &in | |||||
return GRAPH_SUCCESS; | return GRAPH_SUCCESS; | ||||
} | } | ||||
graphStatus GNode::GetOutputIndexByName(const ge::AscendString &name, int32_t &index) { | |||||
graphStatus GNode::GetOutputIndexByName(const AscendString &name, int32_t &index) { | |||||
const char *ascend_name = name.GetString(); | const char *ascend_name = name.GetString(); | ||||
if (ascend_name == nullptr) { | if (ascend_name == nullptr) { | ||||
GELOGE(GRAPH_PARAM_INVALID, "GetOutputIndexByName: ascend string error."); | GELOGE(GRAPH_PARAM_INVALID, "GetOutputIndexByName: ascend string error."); | ||||
@@ -528,7 +528,7 @@ graphStatus GNode::UpdateOutputDesc(const int32_t index, const TensorDesc &tenso | |||||
} | } | ||||
#define NODE_ATTR_GET_IMP(ArgType) \ | #define NODE_ATTR_GET_IMP(ArgType) \ | ||||
graphStatus GNode::GetAttr(const ge::AscendString &name, ArgType &attr_value) const { \ | |||||
graphStatus GNode::GetAttr(const AscendString &name, ArgType &attr_value) const { \ | |||||
const char *ascend_name = name.GetString(); \ | const char *ascend_name = name.GetString(); \ | ||||
if (ascend_name == nullptr) { \ | if (ascend_name == nullptr) { \ | ||||
GELOGE(GRAPH_PARAM_INVALID, "GetAttr: ascend string error."); \ | GELOGE(GRAPH_PARAM_INVALID, "GetAttr: ascend string error."); \ | ||||
@@ -556,29 +556,29 @@ graphStatus GNode::UpdateOutputDesc(const int32_t index, const TensorDesc &tenso | |||||
return GRAPH_SUCCESS; \ | return GRAPH_SUCCESS; \ | ||||
} | } | ||||
#define NODE_ATTR_SET_IMP(ArgType) \ | |||||
graphStatus GNode::SetAttr(const ge::AscendString &name, ArgType &attr_value) const { \ | |||||
const char *ascend_name = name.GetString(); \ | |||||
if (ascend_name == nullptr) { \ | |||||
GELOGE(GRAPH_PARAM_INVALID, "SetAttr: ascend string error."); \ | |||||
return GRAPH_PARAM_INVALID; \ | |||||
} \ | |||||
\ | |||||
if (impl_ == nullptr) { \ | |||||
GELOGE(GRAPH_FAILED, "SetAttr: node impl is nullptr."); \ | |||||
return GRAPH_FAILED; \ | |||||
} \ | |||||
\ | |||||
std::shared_ptr<Node> node_ptr = impl_->node_ptr_.lock(); \ | |||||
if (node_ptr == nullptr) { \ | |||||
GELOGE(GRAPH_FAILED, "SetAttr: the shared ptr is not valid."); \ | |||||
return GRAPH_FAILED; \ | |||||
} \ | |||||
\ | |||||
std::string node_name = ascend_name; \ | |||||
Operator op = OpDescUtils::CreateOperatorFromNode(node_ptr); \ | |||||
(void)op.SetAttr(node_name, attr_value); \ | |||||
return GRAPH_SUCCESS; \ | |||||
#define NODE_ATTR_SET_IMP(ArgType) \ | |||||
graphStatus GNode::SetAttr(const AscendString &name, ArgType &attr_value) const { \ | |||||
const char *ascend_name = name.GetString(); \ | |||||
if (ascend_name == nullptr) { \ | |||||
GELOGE(GRAPH_PARAM_INVALID, "SetAttr: ascend string error."); \ | |||||
return GRAPH_PARAM_INVALID; \ | |||||
} \ | |||||
\ | |||||
if (impl_ == nullptr) { \ | |||||
GELOGE(GRAPH_FAILED, "SetAttr: node impl is nullptr."); \ | |||||
return GRAPH_FAILED; \ | |||||
} \ | |||||
\ | |||||
std::shared_ptr<Node> node_ptr = impl_->node_ptr_.lock(); \ | |||||
if (node_ptr == nullptr) { \ | |||||
GELOGE(GRAPH_FAILED, "SetAttr: the shared ptr is not valid."); \ | |||||
return GRAPH_FAILED; \ | |||||
} \ | |||||
\ | |||||
std::string node_name = ascend_name; \ | |||||
Operator op = OpDescUtils::CreateOperatorFromNode(node_ptr); \ | |||||
(void)op.SetAttr(node_name, attr_value); \ | |||||
return GRAPH_SUCCESS; \ | |||||
} | } | ||||
NODE_ATTR_GET_IMP(int64_t) | NODE_ATTR_GET_IMP(int64_t) | ||||
@@ -616,7 +616,7 @@ NODE_ATTR_SET_IMP(std::vector<std::vector<int64_t>>) | |||||
NODE_ATTR_SET_IMP(std::vector<ge::DataType>) | NODE_ATTR_SET_IMP(std::vector<ge::DataType>) | ||||
NODE_ATTR_SET_IMP(ge::DataType) | NODE_ATTR_SET_IMP(ge::DataType) | ||||
graphStatus GNode::SetAttr(const ge::AscendString &name, AttrValue &attr_value) const { | |||||
graphStatus GNode::SetAttr(const AscendString &name, AttrValue &attr_value) const { | |||||
const char *ascend_name = name.GetString(); | const char *ascend_name = name.GetString(); | ||||
if (ascend_name == nullptr) { | if (ascend_name == nullptr) { | ||||
GELOGE(GRAPH_PARAM_INVALID, "SetAttr: ascend string error."); | GELOGE(GRAPH_PARAM_INVALID, "SetAttr: ascend string error."); | ||||
@@ -640,7 +640,7 @@ graphStatus GNode::SetAttr(const ge::AscendString &name, AttrValue &attr_value) | |||||
return GRAPH_SUCCESS; | return GRAPH_SUCCESS; | ||||
} | } | ||||
graphStatus GNode::SetAttr(const ge::AscendString &name, ge::AscendString &attr_value) const { | |||||
graphStatus GNode::SetAttr(const AscendString &name, AscendString &attr_value) const { | |||||
const char *ascend_name = name.GetString(); | const char *ascend_name = name.GetString(); | ||||
if (ascend_name == nullptr) { | if (ascend_name == nullptr) { | ||||
GELOGE(GRAPH_PARAM_INVALID, "SetAttr: name ascend string error."); | GELOGE(GRAPH_PARAM_INVALID, "SetAttr: name ascend string error."); | ||||
@@ -671,7 +671,7 @@ graphStatus GNode::SetAttr(const ge::AscendString &name, ge::AscendString &attr_ | |||||
return GRAPH_SUCCESS; | return GRAPH_SUCCESS; | ||||
} | } | ||||
graphStatus GNode::SetAttr(const ge::AscendString &name, std::vector<ge::AscendString> &attr_values) const { | |||||
graphStatus GNode::SetAttr(const AscendString &name, std::vector<AscendString> &attr_values) const { | |||||
const char *ascend_name = name.GetString(); | const char *ascend_name = name.GetString(); | ||||
if (ascend_name == nullptr) { | if (ascend_name == nullptr) { | ||||
GELOGE(GRAPH_PARAM_INVALID, "SetAttr: name ascend string error."); | GELOGE(GRAPH_PARAM_INVALID, "SetAttr: name ascend string error."); | ||||
@@ -710,7 +710,7 @@ graphStatus GNode::SetAttr(const ge::AscendString &name, std::vector<ge::AscendS | |||||
return GRAPH_SUCCESS; | return GRAPH_SUCCESS; | ||||
} | } | ||||
graphStatus GNode::GetAttr(const ge::AscendString &name, ge::AscendString &attr_value) const { | |||||
graphStatus GNode::GetAttr(const AscendString &name, AscendString &attr_value) const { | |||||
const char *ascend_name = name.GetString(); | const char *ascend_name = name.GetString(); | ||||
if (ascend_name == nullptr) { | if (ascend_name == nullptr) { | ||||
GELOGE(GRAPH_PARAM_INVALID, "GetAttr: name ascend string error."); | GELOGE(GRAPH_PARAM_INVALID, "GetAttr: name ascend string error."); | ||||
@@ -736,13 +736,13 @@ graphStatus GNode::GetAttr(const ge::AscendString &name, ge::AscendString &attr_ | |||||
return GRAPH_FAILED; | return GRAPH_FAILED; | ||||
} | } | ||||
ge::AscendString attr_value_get(op_name.c_str()); | |||||
AscendString attr_value_get(op_name.c_str()); | |||||
attr_value = attr_value_get; | attr_value = attr_value_get; | ||||
return GRAPH_SUCCESS; | return GRAPH_SUCCESS; | ||||
} | } | ||||
graphStatus GNode::GetAttr(const ge::AscendString &name, std::vector<ge::AscendString> &attr_values) const { | |||||
graphStatus GNode::GetAttr(const AscendString &name, std::vector<AscendString> &attr_values) const { | |||||
const char *ascend_name = name.GetString(); | const char *ascend_name = name.GetString(); | ||||
if (ascend_name == nullptr) { | if (ascend_name == nullptr) { | ||||
GELOGE(GRAPH_PARAM_INVALID, "GetAttr: name ascend string error."); | GELOGE(GRAPH_PARAM_INVALID, "GetAttr: name ascend string error."); | ||||
@@ -776,7 +776,7 @@ graphStatus GNode::GetAttr(const ge::AscendString &name, std::vector<ge::AscendS | |||||
return GRAPH_SUCCESS; | return GRAPH_SUCCESS; | ||||
} | } | ||||
bool GNode::HasAttr(const ge::AscendString &name) { | |||||
bool GNode::HasAttr(const AscendString &name) { | |||||
const char *ascend_name = name.GetString(); | const char *ascend_name = name.GetString(); | ||||
if (ascend_name == nullptr) { | if (ascend_name == nullptr) { | ||||
GELOGE(GRAPH_PARAM_INVALID, "HasAttr: ascend string error."); | GELOGE(GRAPH_PARAM_INVALID, "HasAttr: ascend string error."); | ||||
@@ -308,6 +308,18 @@ Graph::Graph(const std::string &name) { | |||||
} | } | ||||
} | } | ||||
Graph::Graph(const char *name) { | |||||
if (name != nullptr) { | |||||
std::string graph_name = name; | |||||
impl_ = ComGraphMakeShared<GraphImpl>(graph_name); | |||||
if (impl_ == nullptr) { | |||||
GELOGW("GraphImpl make shared failed, impl_ is nullptr."); | |||||
} | |||||
} else { | |||||
GELOGW("Graph name is nullptr."); | |||||
} | |||||
} | |||||
graphStatus Graph::AddOp(const ge::Operator &op) { | graphStatus Graph::AddOp(const ge::Operator &op) { | ||||
GE_CHK_BOOL_EXEC(impl_ != nullptr, return GRAPH_FAILED, "AddOp failed: graph can not be used, impl is nullptr."); | GE_CHK_BOOL_EXEC(impl_ != nullptr, return GRAPH_FAILED, "AddOp failed: graph can not be used, impl is nullptr."); | ||||
return impl_->AddOp(op); | return impl_->AddOp(op); | ||||
@@ -319,6 +331,22 @@ graphStatus Graph::GetAllOpName(std::vector<std::string> &op_name) const { | |||||
return impl_->GetAllOpName(op_name); | return impl_->GetAllOpName(op_name); | ||||
} | } | ||||
graphStatus Graph::GetAllOpName(std::vector<AscendString> &names) const { | |||||
GE_CHK_BOOL_EXEC(impl_ != nullptr, return GRAPH_FAILED, | |||||
"GetAllOpName failed: graph can not be used, impl is nullptr."); | |||||
std::vector<std::string> op_names; | |||||
if (impl_->GetAllOpName(op_names) != GRAPH_SUCCESS) { | |||||
GELOGE(GRAPH_FAILED, "Get all op name failed."); | |||||
return GRAPH_FAILED; | |||||
} | |||||
for (auto &op_name : op_names) { | |||||
names.emplace_back(op_name.c_str()); | |||||
} | |||||
return GRAPH_SUCCESS; | |||||
} | |||||
graphStatus Graph::FindOpByName(const std::string &name, Operator &op) const { | graphStatus Graph::FindOpByName(const std::string &name, Operator &op) const { | ||||
Operator op_find_op_def("NULL"); | Operator op_find_op_def("NULL"); | ||||
op = op_find_op_def; | op = op_find_op_def; | ||||
@@ -327,11 +355,34 @@ graphStatus Graph::FindOpByName(const std::string &name, Operator &op) const { | |||||
return impl_->FindOpByName(name, op); | return impl_->FindOpByName(name, op); | ||||
} | } | ||||
graphStatus Graph::FindOpByName(const char *name, Operator &op) const { | |||||
if (name == nullptr) { | |||||
GELOGE(GRAPH_FAILED, "FindOpByName: name is nullptr."); | |||||
return GRAPH_FAILED; | |||||
} | |||||
Operator op_find_op_def("NULL"); | |||||
op = op_find_op_def; | |||||
GE_CHK_BOOL_EXEC(impl_ != nullptr, return GRAPH_FAILED, | |||||
"FindOpByName failed: graph can not be used, impl is nullptr."); | |||||
std::string op_name = name; | |||||
return impl_->FindOpByName(op_name, op); | |||||
} | |||||
graphStatus Graph::FindOpByType(const string &type, std::vector<ge::Operator> &ops) const { | graphStatus Graph::FindOpByType(const string &type, std::vector<ge::Operator> &ops) const { | ||||
GE_CHECK_NOTNULL(impl_); | GE_CHECK_NOTNULL(impl_); | ||||
return impl_->FindOpByType(type, ops); | return impl_->FindOpByType(type, ops); | ||||
} | } | ||||
graphStatus Graph::FindOpByType(const char *type, std::vector<ge::Operator> &ops) const { | |||||
if (type == nullptr) { | |||||
GELOGE(GRAPH_FAILED, "FindOpByType: name is nullptr."); | |||||
return GRAPH_FAILED; | |||||
} | |||||
GE_CHECK_NOTNULL(impl_); | |||||
std::string op_type = type; | |||||
return impl_->FindOpByType(op_type, ops); | |||||
} | |||||
Graph &Graph::SetInputs(const vector<ge::Operator> &inputs) { | Graph &Graph::SetInputs(const vector<ge::Operator> &inputs) { | ||||
GE_CHK_BOOL_EXEC(impl_ != nullptr, return *this, "SetInputs failed: graph can not be used, impl is nullptr.") | GE_CHK_BOOL_EXEC(impl_ != nullptr, return *this, "SetInputs failed: graph can not be used, impl is nullptr.") | ||||
GE_CHK_BOOL_EXEC(inputs.size() > 0, return *this, "SetInputs failed: input operator size can not be 0."); | GE_CHK_BOOL_EXEC(inputs.size() > 0, return *this, "SetInputs failed: input operator size can not be 0."); | ||||
@@ -363,6 +414,23 @@ Graph &Graph::SetOutputs(const std::vector<pair<Operator, string>> &outputs) { | |||||
return *this; | return *this; | ||||
} | } | ||||
Graph &Graph::SetOutputs(const std::vector<std::pair<ge::Operator, AscendString>> &outputs) { | |||||
GE_CHK_BOOL_EXEC(impl_ != nullptr, return *this, "SetOutputs failed: graph can not be used, impl is nullptr.") | |||||
vector<std::pair<ge::Operator, std::string>> graph_outputs; | |||||
for (auto &item : outputs) { | |||||
const char *name = item.second.GetString(); | |||||
if (name != nullptr) { | |||||
string output_name = name; | |||||
graph_outputs.emplace_back((std::pair<ge::Operator, std::string>(item.first, name))); | |||||
} else { | |||||
GELOGW("Output name is nullptr."); | |||||
} | |||||
} | |||||
(void)impl_->SetOutputs(graph_outputs); | |||||
return *this; | |||||
} | |||||
Graph &Graph::SetTargets(const vector<ge::Operator> &targets) { | Graph &Graph::SetTargets(const vector<ge::Operator> &targets) { | ||||
if (impl_ == nullptr) { | if (impl_ == nullptr) { | ||||
GELOGE(GRAPH_FAILED, "SetTargets failed: graph can not be used, impl is nullptr."); | GELOGE(GRAPH_FAILED, "SetTargets failed: graph can not be used, impl is nullptr."); | ||||
@@ -604,7 +672,7 @@ graphStatus Graph::AddControlEdge(GNode &src_node, GNode &dst_node) { | |||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
GraphPtr Graph::ConstructFromInputs(const std::vector<Operator> &inputs, const ge::AscendString &name) { | |||||
GraphPtr Graph::ConstructFromInputs(const std::vector<Operator> &inputs, const AscendString &name) { | |||||
const char *ascend_name = name.GetString(); | const char *ascend_name = name.GetString(); | ||||
if (ascend_name == nullptr) { | if (ascend_name == nullptr) { | ||||
GELOGE(GRAPH_PARAM_INVALID, "ConstructFromInputs: ascend string error."); | GELOGE(GRAPH_PARAM_INVALID, "ConstructFromInputs: ascend string error."); | ||||
@@ -644,6 +712,18 @@ graphStatus Graph::SaveToFile(const string &file_name) const { | |||||
return model.SaveToFile(file_name); | return model.SaveToFile(file_name); | ||||
} | } | ||||
graphStatus Graph::SaveToFile(const char *file_name) const { | |||||
if (file_name == nullptr) { | |||||
GELOGE(GRAPH_FAILED, "SaveToFile: file name is nullptr."); | |||||
return GRAPH_FAILED; | |||||
} | |||||
Model model = Model(); | |||||
model.SetGraph(*this); | |||||
std::string file = file_name; | |||||
return model.SaveToFile(file); | |||||
} | |||||
graphStatus Graph::LoadFromFile(const string &file_name) { | graphStatus Graph::LoadFromFile(const string &file_name) { | ||||
Model model = Model(); | Model model = Model(); | ||||
graphStatus ret = model.LoadFromFile(file_name); | graphStatus ret = model.LoadFromFile(file_name); | ||||
@@ -654,8 +734,34 @@ graphStatus Graph::LoadFromFile(const string &file_name) { | |||||
return GRAPH_SUCCESS; | return GRAPH_SUCCESS; | ||||
} | } | ||||
graphStatus Graph::LoadFromFile(const char *file_name) { | |||||
if (file_name == nullptr) { | |||||
GELOGE(GRAPH_FAILED, "SaveToFile: file name is nullptr."); | |||||
return GRAPH_FAILED; | |||||
} | |||||
Model model = Model(); | |||||
std::string file = file_name; | |||||
graphStatus ret = model.LoadFromFile(file); | |||||
if (ret != GRAPH_SUCCESS) { | |||||
return ret; | |||||
} | |||||
*this = model.GetGraph(); | |||||
return GRAPH_SUCCESS; | |||||
} | |||||
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY const std::string &Graph::GetName() const { return impl_->GetName(); } | GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY const std::string &Graph::GetName() const { return impl_->GetName(); } | ||||
graphStatus Graph::GetName(AscendString &name) const { | |||||
if (impl_ == nullptr) { | |||||
GELOGE(GRAPH_FAILED, "GetName: impl is nullptr."); | |||||
return GRAPH_FAILED; | |||||
} | |||||
std::string graph_name = impl_->GetName(); | |||||
name = AscendString(graph_name.c_str()); | |||||
return GRAPH_SUCCESS; | |||||
} | |||||
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Graph | GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Graph | ||||
GraphUtils::CreateGraphFromComputeGraph(const ge::ComputeGraphPtr compute_graph) { | GraphUtils::CreateGraphFromComputeGraph(const ge::ComputeGraphPtr compute_graph) { | ||||
GE_CHK_BOOL_EXEC_NOLOG(compute_graph != nullptr, return Graph("")); | GE_CHK_BOOL_EXEC_NOLOG(compute_graph != nullptr, return Graph("")); | ||||
@@ -83,7 +83,7 @@ COMMON_LOCAL_C_INCLUDES := \ | |||||
include $(CLEAR_VARS) | include $(CLEAR_VARS) | ||||
LOCAL_MODULE := libgraph | LOCAL_MODULE := libgraph | ||||
LOCAL_CFLAGS += -DFMK_SUPPORT_DUMP -O2 -Dgoogle=ascend_private | |||||
LOCAL_CFLAGS += -DFMK_SUPPORT_DUMP -O2 -Dgoogle=ascend_private -Wno-deprecated-declarations | |||||
LOCAL_CPPFLAGS += -fexceptions | LOCAL_CPPFLAGS += -fexceptions | ||||
LOCAL_C_INCLUDES := $(COMMON_LOCAL_C_INCLUDES) | LOCAL_C_INCLUDES := $(COMMON_LOCAL_C_INCLUDES) | ||||
@@ -95,6 +95,9 @@ LOCAL_SHARED_LIBRARIES := \ | |||||
libslog \ | libslog \ | ||||
liberror_manager \ | liberror_manager \ | ||||
LOCAL_STATIC_LIBRARIES := \ | |||||
libmmpa \ | |||||
LOCAL_LDFLAGS := -lrt -ldl | LOCAL_LDFLAGS := -lrt -ldl | ||||
LOCAL_MULTILIB := 64 | LOCAL_MULTILIB := 64 | ||||
@@ -106,7 +109,7 @@ include $(BUILD_HOST_SHARED_LIBRARY) | |||||
include $(CLEAR_VARS) | include $(CLEAR_VARS) | ||||
LOCAL_MODULE := stub/libgraph | LOCAL_MODULE := stub/libgraph | ||||
LOCAL_CFLAGS += -DFMK_SUPPORT_DUMP -O2 | |||||
LOCAL_CFLAGS += -DFMK_SUPPORT_DUMP -O2 -Wno-deprecated-declarations | |||||
LOCAL_CPPFLAGS += -fexceptions | LOCAL_CPPFLAGS += -fexceptions | ||||
LOCAL_C_INCLUDES := $(COMMON_LOCAL_C_INCLUDES) | LOCAL_C_INCLUDES := $(COMMON_LOCAL_C_INCLUDES) | ||||
@@ -132,7 +135,7 @@ include $(BUILD_HOST_SHARED_LIBRARY) | |||||
include $(CLEAR_VARS) | include $(CLEAR_VARS) | ||||
LOCAL_MODULE := fwk_stub/libgraph | LOCAL_MODULE := fwk_stub/libgraph | ||||
LOCAL_CFLAGS += -DFMK_SUPPORT_DUMP -O2 | |||||
LOCAL_CFLAGS += -DFMK_SUPPORT_DUMP -O2 -Wno-deprecated-declarations | |||||
LOCAL_CPPFLAGS += -fexceptions | LOCAL_CPPFLAGS += -fexceptions | ||||
LOCAL_C_INCLUDES := $(COMMON_LOCAL_C_INCLUDES) | LOCAL_C_INCLUDES := $(COMMON_LOCAL_C_INCLUDES) | ||||
@@ -159,7 +162,7 @@ include $(BUILD_HOST_SHARED_LIBRARY) | |||||
include $(CLEAR_VARS) | include $(CLEAR_VARS) | ||||
LOCAL_MODULE := libgraph | LOCAL_MODULE := libgraph | ||||
LOCAL_CFLAGS += -O2 -Dgoogle=ascend_private | |||||
LOCAL_CFLAGS += -O2 -Dgoogle=ascend_private -Wno-deprecated-declarations | |||||
LOCAL_C_INCLUDES := $(COMMON_LOCAL_C_INCLUDES) | LOCAL_C_INCLUDES := $(COMMON_LOCAL_C_INCLUDES) | ||||
LOCAL_SRC_FILES := $(COMMON_LOCAL_SRC_FILES) | LOCAL_SRC_FILES := $(COMMON_LOCAL_SRC_FILES) | ||||
@@ -170,6 +173,9 @@ LOCAL_SHARED_LIBRARIES := \ | |||||
libslog \ | libslog \ | ||||
liberror_manager \ | liberror_manager \ | ||||
LOCAL_STATIC_LIBRARIES := \ | |||||
libmmpa \ | |||||
LOCAL_LDFLAGS := -lrt -ldl | LOCAL_LDFLAGS := -lrt -ldl | ||||
ifeq ($(device_os),android) | ifeq ($(device_os),android) | ||||
@@ -256,6 +262,9 @@ LOCAL_SHARED_LIBRARIES := \ | |||||
libslog \ | libslog \ | ||||
liberror_manager \ | liberror_manager \ | ||||
LOCAL_STATIC_LIBRARIES := \ | |||||
libmmpa \ | |||||
LOCAL_LDFLAGS := -lrt -ldl | LOCAL_LDFLAGS := -lrt -ldl | ||||
LOCAL_MULTILIB := 64 | LOCAL_MULTILIB := 64 | ||||
@@ -108,5 +108,22 @@ void InferenceContext::SetOutputHandleShapesAndTypes(std::vector<std::vector<Sha | |||||
void InferenceContext::SetMarks(const std::vector<std::string> &marks) { inference_context_impl_->marks_ = marks; } | void InferenceContext::SetMarks(const std::vector<std::string> &marks) { inference_context_impl_->marks_ = marks; } | ||||
void InferenceContext::SetMarks(const std::vector<AscendString> &marks) { | |||||
std::vector<std::string> impl_marks; | |||||
for (const auto &mark : marks) { | |||||
if (mark.GetString() != nullptr) { | |||||
impl_marks.emplace_back(mark.GetString()); | |||||
} | |||||
} | |||||
inference_context_impl_->marks_ = impl_marks; | |||||
} | |||||
const std::vector<std::string> &InferenceContext::GetMarks() const { return inference_context_impl_->marks_; } | const std::vector<std::string> &InferenceContext::GetMarks() const { return inference_context_impl_->marks_; } | ||||
void InferenceContext::GetMarks(std::vector<AscendString> &marks) const { | |||||
std::vector<std::string> str_marks = inference_context_impl_->marks_; | |||||
for (auto &str_mark : str_marks) { | |||||
marks.emplace_back(str_mark.c_str()); | |||||
} | |||||
} | |||||
} // namespace ge | } // namespace ge |
@@ -15,14 +15,12 @@ | |||||
*/ | */ | ||||
#include "graph/model.h" | #include "graph/model.h" | ||||
#include <fcntl.h> | |||||
#include <google/protobuf/io/coded_stream.h> | #include <google/protobuf/io/coded_stream.h> | ||||
#include <google/protobuf/io/zero_copy_stream.h> | #include <google/protobuf/io/zero_copy_stream.h> | ||||
#include <google/protobuf/io/zero_copy_stream_impl.h> | #include <google/protobuf/io/zero_copy_stream_impl.h> | ||||
#include <google/protobuf/text_format.h> | #include <google/protobuf/text_format.h> | ||||
#include <sys/stat.h> | #include <sys/stat.h> | ||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#include <unistd.h> | |||||
#include <algorithm> | #include <algorithm> | ||||
#include <cstring> | #include <cstring> | ||||
#include <fstream> | #include <fstream> | ||||
@@ -31,9 +29,10 @@ | |||||
#include "debug/ge_util.h" | #include "debug/ge_util.h" | ||||
#include "framework/common/debug/ge_log.h" | #include "framework/common/debug/ge_log.h" | ||||
#include "graph/model_serialize.h" | #include "graph/model_serialize.h" | ||||
#include "proto/ge_ir.pb.h" | |||||
#include "mmpa/mmpa_api.h" | |||||
#include "utils/attr_utils.h" | #include "utils/attr_utils.h" | ||||
#include "utils/ge_ir_utils.h" | #include "utils/ge_ir_utils.h" | ||||
#include "proto/ge_ir.pb.h" | |||||
using google::protobuf::io::FileInputStream; | using google::protobuf::io::FileInputStream; | ||||
using google::protobuf::io::FileOutputStream; | using google::protobuf::io::FileOutputStream; | ||||
@@ -106,14 +105,15 @@ graphStatus Model::SaveToFile(const string &file_name) const { | |||||
if (!ge_proto.ParseFromString(str)) { | if (!ge_proto.ParseFromString(str)) { | ||||
return GRAPH_FAILED; | return GRAPH_FAILED; | ||||
} | } | ||||
char real_path[PATH_MAX] = {0x00}; | |||||
if (strlen(file_name.c_str()) >= PATH_MAX) { | |||||
char real_path[MMPA_MAX_PATH] = {0x00}; | |||||
if (strlen(file_name.c_str()) >= MMPA_MAX_PATH) { | |||||
return GRAPH_FAILED; | return GRAPH_FAILED; | ||||
} | } | ||||
if (realpath(file_name.c_str(), real_path) == nullptr) { | |||||
INT32 result = mmRealPath(file_name.c_str(), real_path, MMPA_MAX_PATH); | |||||
if (result != EN_OK) { | |||||
GELOGI("file %s does not exit, it will be created.", file_name.c_str()); | GELOGI("file %s does not exit, it will be created.", file_name.c_str()); | ||||
} | } | ||||
int fd = open(real_path, O_WRONLY | O_CREAT | O_TRUNC, ACCESS_PERMISSION_BITS); | |||||
int fd = mmOpen2(real_path, M_WRONLY | M_CREAT | O_TRUNC, ACCESS_PERMISSION_BITS); | |||||
if (fd < 0) { | if (fd < 0) { | ||||
GELOGE(GRAPH_FAILED, "open file failed, file path [%s], %s ", real_path, strerror(errno)); | GELOGE(GRAPH_FAILED, "open file failed, file path [%s], %s ", real_path, strerror(errno)); | ||||
return GRAPH_FAILED; | return GRAPH_FAILED; | ||||
@@ -148,15 +148,16 @@ graphStatus Model::Load(ge::proto::ModelDef &model_def) { | |||||
bool Model::IsValid() const { return graph_.IsValid(); } | bool Model::IsValid() const { return graph_.IsValid(); } | ||||
graphStatus Model::LoadFromFile(const string &file_name) { | graphStatus Model::LoadFromFile(const string &file_name) { | ||||
char real_path[PATH_MAX] = {0x00}; | |||||
if (strlen(file_name.c_str()) >= PATH_MAX) { | |||||
char real_path[MMPA_MAX_PATH] = {0x00}; | |||||
if (strlen(file_name.c_str()) >= MMPA_MAX_PATH) { | |||||
return GRAPH_FAILED; | return GRAPH_FAILED; | ||||
} | } | ||||
if (realpath(file_name.c_str(), real_path) == nullptr) { | |||||
INT32 result = mmRealPath(file_name.c_str(), real_path, MMPA_MAX_PATH); | |||||
if (result != EN_OK) { | |||||
GELOGE(GRAPH_FAILED, "file %s does not exit, can not load.", file_name.c_str()); | GELOGE(GRAPH_FAILED, "file %s does not exit, can not load.", file_name.c_str()); | ||||
return GRAPH_FAILED; | return GRAPH_FAILED; | ||||
} | } | ||||
int fd = open(real_path, O_RDONLY); | |||||
int fd = mmOpen(real_path, M_RDONLY); | |||||
if (fd < 0) { | if (fd < 0) { | ||||
GELOGE(GRAPH_FAILED, "open file failed, %s", strerror(errno)); | GELOGE(GRAPH_FAILED, "open file failed, %s", strerror(errno)); | ||||
return GRAPH_FAILED; | return GRAPH_FAILED; | ||||
@@ -166,13 +167,13 @@ graphStatus Model::LoadFromFile(const string &file_name) { | |||||
bool ret = model_def.ParseFromFileDescriptor(fd); | bool ret = model_def.ParseFromFileDescriptor(fd); | ||||
if (!ret) { | if (!ret) { | ||||
GELOGE(GRAPH_FAILED, "ParseFromFileDescriptor failed"); | GELOGE(GRAPH_FAILED, "ParseFromFileDescriptor failed"); | ||||
if (close(fd) != 0) { | |||||
if (mmClose(fd) != 0) { | |||||
GELOGE(GRAPH_FAILED, "close file descriptor fail."); | GELOGE(GRAPH_FAILED, "close file descriptor fail."); | ||||
return GRAPH_FAILED; | return GRAPH_FAILED; | ||||
} | } | ||||
return GRAPH_FAILED; | return GRAPH_FAILED; | ||||
} | } | ||||
if (close(fd) != 0) { | |||||
if (mmClose(fd) != 0) { | |||||
GELOGE(GRAPH_FAILED, "close file descriptor fail."); | GELOGE(GRAPH_FAILED, "close file descriptor fail."); | ||||
return GRAPH_FAILED; | return GRAPH_FAILED; | ||||
} | } | ||||
@@ -66,6 +66,8 @@ const std::string ATTR_NAME_IS_INPUT_CONST = "is_input_const"; | |||||
const std::string ATTR_NAME_OP_INFER_DEPENDS = "_op_infer_depends"; | const std::string ATTR_NAME_OP_INFER_DEPENDS = "_op_infer_depends"; | ||||
const std::string ATTR_NAME_OP_KERNEL_LIB_NAME = "_ge_attr_op_kernel_lib_name"; | |||||
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDesc::OpDesc() { | GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDesc::OpDesc() { | ||||
op_def_.InitDefault(); | op_def_.InitDefault(); | ||||
if (op_def_.GetProtoMsg() != nullptr) { | if (op_def_.GetProtoMsg() != nullptr) { | ||||
@@ -522,10 +524,19 @@ GE_FUNC_HOST_VISIBILITY OpDesc::Vistor<string> OpDesc::GetAllInputNames() const | |||||
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::SetOpKernelLibName(const std::string &name) { | GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::SetOpKernelLibName(const std::string &name) { | ||||
op_kernel_lib_name_ = name; | op_kernel_lib_name_ = name; | ||||
auto ret = AttrUtils::SetStr(this, ATTR_NAME_OP_KERNEL_LIB_NAME, name); | |||||
if (ret != true) { | |||||
GELOGE(GRAPH_FAILED, "set op kernel lib name failed."); | |||||
} | |||||
} | } | ||||
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY std::string OpDesc::GetOpKernelLibName() const { | GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY std::string OpDesc::GetOpKernelLibName() const { | ||||
return op_kernel_lib_name_; | |||||
if (!op_kernel_lib_name_.empty()) { | |||||
return op_kernel_lib_name_; | |||||
} | |||||
string op_kernel_lib_name; | |||||
(void)AttrUtils::GetStr(this, ATTR_NAME_OP_KERNEL_LIB_NAME, op_kernel_lib_name); | |||||
return op_kernel_lib_name; | |||||
} | } | ||||
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::SetOpEngineName(const std::string &name) { | GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::SetOpEngineName(const std::string &name) { | ||||
@@ -765,6 +776,10 @@ std::map<string, uint32_t> OpDesc::GetAllInputName() const { return input_name_i | |||||
std::map<string, uint32_t> OpDesc::GetAllOutputName() { return output_name_idx_; } | std::map<string, uint32_t> OpDesc::GetAllOutputName() { return output_name_idx_; } | ||||
std::map<string, uint32_t> &OpDesc::MutableAllInputName() { return input_name_idx_; } | |||||
std::map<string, uint32_t> &OpDesc::MutableAllOutputName() { return output_name_idx_; } | |||||
bool OpDesc::UpdateInputName(std::map<string, uint32_t> input_name_idx) { | bool OpDesc::UpdateInputName(std::map<string, uint32_t> input_name_idx) { | ||||
bool ret = true; | bool ret = true; | ||||
// Use inputDesc_.size() to contain the InValid OptionInput.GetInputsSize() will remove default OptionInput name. | // Use inputDesc_.size() to contain the InValid OptionInput.GetInputsSize() will remove default OptionInput name. | ||||
@@ -16,6 +16,7 @@ | |||||
#include <stdint.h> | #include <stdint.h> | ||||
#include <functional> | #include <functional> | ||||
#include <algorithm> | |||||
#include <vector> | #include <vector> | ||||
#include "debug/ge_log.h" | #include "debug/ge_log.h" | ||||
#include "debug/ge_util.h" | #include "debug/ge_util.h" | ||||
@@ -22,27 +22,90 @@ Operator OperatorFactory::CreateOperator(const std::string &operator_name, const | |||||
return OperatorFactoryImpl::CreateOperator(operator_name, operator_type); | return OperatorFactoryImpl::CreateOperator(operator_name, operator_type); | ||||
} | } | ||||
Operator OperatorFactory::CreateOperator(const char *operator_name, const char *operator_type) { | |||||
if (operator_name == nullptr || operator_type == nullptr) { | |||||
GELOGE(GRAPH_FAILED, "Create Operator input parameter is nullptr."); | |||||
return Operator(); | |||||
} | |||||
std::string op_name = operator_name; | |||||
std::string op_type = operator_type; | |||||
return OperatorFactoryImpl::CreateOperator(op_name, op_type); | |||||
} | |||||
graphStatus OperatorFactory::GetOpsTypeList(std::vector<std::string> &all_ops) { | graphStatus OperatorFactory::GetOpsTypeList(std::vector<std::string> &all_ops) { | ||||
return OperatorFactoryImpl::GetOpsTypeList(all_ops); | return OperatorFactoryImpl::GetOpsTypeList(all_ops); | ||||
} | } | ||||
graphStatus OperatorFactory::GetOpsTypeList(std::vector<AscendString> &all_ops) { | |||||
std::vector<std::string> all_op_types; | |||||
if (OperatorFactoryImpl::GetOpsTypeList(all_op_types) != GRAPH_SUCCESS) { | |||||
GELOGE(GRAPH_FAILED, "Get ops type list failed."); | |||||
return GRAPH_FAILED; | |||||
} | |||||
for (auto &op_type : all_op_types) { | |||||
all_ops.emplace_back(op_type.c_str()); | |||||
} | |||||
return GRAPH_SUCCESS; | |||||
} | |||||
bool OperatorFactory::IsExistOp(const string &operator_type) { return OperatorFactoryImpl::IsExistOp(operator_type); } | bool OperatorFactory::IsExistOp(const string &operator_type) { return OperatorFactoryImpl::IsExistOp(operator_type); } | ||||
bool OperatorFactory::IsExistOp(const char *operator_type) { | |||||
if (operator_type == nullptr) { | |||||
GELOGE(GRAPH_FAILED, "Operator type is nullptr."); | |||||
return false; | |||||
} | |||||
std::string op_type = operator_type; | |||||
return OperatorFactoryImpl::IsExistOp(op_type); | |||||
} | |||||
OperatorCreatorRegister::OperatorCreatorRegister(const string &operator_type, OpCreator const &op_creator) { | OperatorCreatorRegister::OperatorCreatorRegister(const string &operator_type, OpCreator const &op_creator) { | ||||
(void)OperatorFactoryImpl::RegisterOperatorCreator(operator_type, op_creator); | (void)OperatorFactoryImpl::RegisterOperatorCreator(operator_type, op_creator); | ||||
} | } | ||||
OperatorCreatorRegister::OperatorCreatorRegister(const char *operator_type, OpCreatorV2 const &op_creator) { | |||||
std::string op_type; | |||||
if (operator_type != nullptr) { | |||||
op_type = operator_type; | |||||
} | |||||
(void)OperatorFactoryImpl::RegisterOperatorCreator(op_type, op_creator); | |||||
} | |||||
InferShapeFuncRegister::InferShapeFuncRegister(const std::string &operator_type, | InferShapeFuncRegister::InferShapeFuncRegister(const std::string &operator_type, | ||||
const InferShapeFunc &infer_shape_func) { | const InferShapeFunc &infer_shape_func) { | ||||
(void)OperatorFactoryImpl::RegisterInferShapeFunc(operator_type, infer_shape_func); | (void)OperatorFactoryImpl::RegisterInferShapeFunc(operator_type, infer_shape_func); | ||||
} | } | ||||
InferShapeFuncRegister::InferShapeFuncRegister(const char *operator_type, const InferShapeFunc &infer_shape_func) { | |||||
std::string op_type; | |||||
if (operator_type != nullptr) { | |||||
op_type = operator_type; | |||||
} | |||||
(void)OperatorFactoryImpl::RegisterInferShapeFunc(op_type, infer_shape_func); | |||||
} | |||||
InferFormatFuncRegister::InferFormatFuncRegister(const std::string &operator_type, | InferFormatFuncRegister::InferFormatFuncRegister(const std::string &operator_type, | ||||
const InferFormatFunc &infer_format_func) { | const InferFormatFunc &infer_format_func) { | ||||
(void)OperatorFactoryImpl::RegisterInferFormatFunc(operator_type, infer_format_func); | (void)OperatorFactoryImpl::RegisterInferFormatFunc(operator_type, infer_format_func); | ||||
} | } | ||||
InferFormatFuncRegister::InferFormatFuncRegister(const char *operator_type, const InferFormatFunc &infer_format_func) { | |||||
std::string op_type; | |||||
if (operator_type != nullptr) { | |||||
op_type = operator_type; | |||||
} | |||||
(void)OperatorFactoryImpl::RegisterInferFormatFunc(op_type, infer_format_func); | |||||
} | |||||
VerifyFuncRegister::VerifyFuncRegister(const std::string &operator_type, const VerifyFunc &verify_func) { | VerifyFuncRegister::VerifyFuncRegister(const std::string &operator_type, const VerifyFunc &verify_func) { | ||||
(void)OperatorFactoryImpl::RegisterVerifyFunc(operator_type, verify_func); | (void)OperatorFactoryImpl::RegisterVerifyFunc(operator_type, verify_func); | ||||
} | } | ||||
VerifyFuncRegister::VerifyFuncRegister(const char *operator_type, const VerifyFunc &verify_func) { | |||||
std::string op_type; | |||||
if (operator_type != nullptr) { | |||||
op_type = operator_type; | |||||
} | |||||
(void)OperatorFactoryImpl::RegisterVerifyFunc(op_type, verify_func); | |||||
} | |||||
} // namespace ge | } // namespace ge |
@@ -20,18 +20,27 @@ | |||||
namespace ge { | namespace ge { | ||||
shared_ptr<std::map<string, OpCreator>> OperatorFactoryImpl::operator_creators_; | shared_ptr<std::map<string, OpCreator>> OperatorFactoryImpl::operator_creators_; | ||||
shared_ptr<std::map<string, OpCreatorV2>> OperatorFactoryImpl::operator_creators_v2_; | |||||
shared_ptr<std::map<string, InferShapeFunc>> OperatorFactoryImpl::operator_infershape_funcs_; | shared_ptr<std::map<string, InferShapeFunc>> OperatorFactoryImpl::operator_infershape_funcs_; | ||||
shared_ptr<std::map<string, InferFormatFunc>> OperatorFactoryImpl::operator_inferformat_funcs_; | shared_ptr<std::map<string, InferFormatFunc>> OperatorFactoryImpl::operator_inferformat_funcs_; | ||||
shared_ptr<std::map<string, VerifyFunc>> OperatorFactoryImpl::operator_verify_funcs_; | shared_ptr<std::map<string, VerifyFunc>> OperatorFactoryImpl::operator_verify_funcs_; | ||||
shared_ptr<std::map<string, InferDataSliceFunc>> OperatorFactoryImpl::operator_infer_data_slice_funcs_; | shared_ptr<std::map<string, InferDataSliceFunc>> OperatorFactoryImpl::operator_infer_data_slice_funcs_; | ||||
Operator OperatorFactoryImpl::CreateOperator(const std::string &operator_name, const std::string &operator_type) { | Operator OperatorFactoryImpl::CreateOperator(const std::string &operator_name, const std::string &operator_type) { | ||||
if (operator_creators_v2_ != nullptr) { | |||||
auto it_v2 = operator_creators_v2_->find(operator_type); | |||||
if (it_v2 != operator_creators_v2_->end()) { | |||||
return it_v2->second(operator_name.c_str()); | |||||
} else { | |||||
GELOGW("No OpProto of [%s] registered by AscendString.", operator_type.c_str()); | |||||
} | |||||
} | |||||
if (operator_creators_ == nullptr) { | if (operator_creators_ == nullptr) { | ||||
return Operator(); | return Operator(); | ||||
} | } | ||||
auto it = operator_creators_->find(operator_type); | auto it = operator_creators_->find(operator_type); | ||||
if (it == operator_creators_->end()) { | if (it == operator_creators_->end()) { | ||||
GELOGW("no OpProto of [%s] registered", operator_type.c_str()); | |||||
GELOGW("no OpProto of [%s] registered by string.", operator_type.c_str()); | |||||
return Operator(); | return Operator(); | ||||
} | } | ||||
return it->second(operator_name); | return it->second(operator_name); | ||||
@@ -39,6 +48,15 @@ Operator OperatorFactoryImpl::CreateOperator(const std::string &operator_name, c | |||||
graphStatus OperatorFactoryImpl::GetOpsTypeList(std::vector<std::string> &all_ops) { | graphStatus OperatorFactoryImpl::GetOpsTypeList(std::vector<std::string> &all_ops) { | ||||
all_ops.clear(); | all_ops.clear(); | ||||
if (operator_creators_v2_ != nullptr) { | |||||
for (auto it_v2 = operator_creators_v2_->begin(); it_v2 != operator_creators_v2_->end(); ++it_v2) { | |||||
all_ops.emplace_back(it_v2->first); | |||||
} | |||||
return GRAPH_SUCCESS; | |||||
} else { | |||||
GELOGW("Ops not registered by AscendString."); | |||||
} | |||||
if (operator_creators_ != nullptr) { | if (operator_creators_ != nullptr) { | ||||
for (auto it = operator_creators_->begin(); it != operator_creators_->end(); ++it) { | for (auto it = operator_creators_->begin(); it != operator_creators_->end(); ++it) { | ||||
all_ops.emplace_back(it->first); | all_ops.emplace_back(it->first); | ||||
@@ -51,6 +69,13 @@ graphStatus OperatorFactoryImpl::GetOpsTypeList(std::vector<std::string> &all_op | |||||
} | } | ||||
bool OperatorFactoryImpl::IsExistOp(const string &operator_type) { | bool OperatorFactoryImpl::IsExistOp(const string &operator_type) { | ||||
if (operator_creators_v2_ != nullptr) { | |||||
auto it_v2 = operator_creators_v2_->find(operator_type); | |||||
if (it_v2 != operator_creators_v2_->end()) { | |||||
return true; | |||||
} | |||||
} | |||||
if (operator_creators_ == nullptr) { | if (operator_creators_ == nullptr) { | ||||
return false; | return false; | ||||
} | } | ||||
@@ -118,6 +143,18 @@ graphStatus OperatorFactoryImpl::RegisterOperatorCreator(const string &operator_ | |||||
return GRAPH_SUCCESS; | return GRAPH_SUCCESS; | ||||
} | } | ||||
graphStatus OperatorFactoryImpl::RegisterOperatorCreator(const string &operator_type, OpCreatorV2 const &op_creator) { | |||||
if (operator_creators_v2_ == nullptr) { | |||||
operator_creators_v2_.reset(new (std::nothrow) std::map<string, OpCreatorV2>()); | |||||
} | |||||
auto it = operator_creators_v2_->find(operator_type); | |||||
if (it != operator_creators_v2_->end()) { | |||||
return GRAPH_FAILED; | |||||
} | |||||
(void)operator_creators_v2_->emplace(operator_type, op_creator); | |||||
return GRAPH_SUCCESS; | |||||
} | |||||
graphStatus OperatorFactoryImpl::RegisterInferShapeFunc(const std::string &operator_type, | graphStatus OperatorFactoryImpl::RegisterInferShapeFunc(const std::string &operator_type, | ||||
InferShapeFunc const infer_shape_func) { | InferShapeFunc const infer_shape_func) { | ||||
if (operator_infershape_funcs_ == nullptr) { | if (operator_infershape_funcs_ == nullptr) { | ||||
@@ -23,6 +23,7 @@ | |||||
#include "debug/ge_util.h" | #include "debug/ge_util.h" | ||||
#include "framework/common/debug/ge_log.h" | #include "framework/common/debug/ge_log.h" | ||||
#include "graph/debug/ge_log.h" | #include "graph/debug/ge_log.h" | ||||
#include "mmpa/mmpa_api.h" | |||||
namespace ge { | namespace ge { | ||||
OpsProtoManager *OpsProtoManager::Instance() { | OpsProtoManager *OpsProtoManager::Instance() { | ||||
@@ -62,8 +63,10 @@ void OpsProtoManager::Finalize() { | |||||
for (auto handle : handles_) { | for (auto handle : handles_) { | ||||
if (handle != nullptr) { | if (handle != nullptr) { | ||||
if (dlclose(handle) != 0) { | |||||
GELOGW("failed to close handle, message: %s", dlerror()); | |||||
if (mmDlclose(handle) != 0) { | |||||
const char *error = mmDlerror(); | |||||
error = (error == nullptr) ? "" : error; | |||||
GELOGW("failed to close handle, message: %s", error); | |||||
continue; | continue; | ||||
} | } | ||||
GELOGI("close opsprotomanager handler success"); | GELOGI("close opsprotomanager handler success"); | ||||
@@ -103,42 +106,48 @@ static void FindParserSo(const std::string &path, std::vector<std::string> &file | |||||
GELOGI("realPath is empty"); | GELOGI("realPath is empty"); | ||||
return; | return; | ||||
} | } | ||||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(path.size() >= PATH_MAX, return, "path is invalid"); | |||||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(path.size() >= MMPA_MAX_PATH, return, "path is invalid"); | |||||
char resolved_path[PATH_MAX] = {0}; | |||||
char resolved_path[MMPA_MAX_PATH] = {0}; | |||||
// Nullptr is returned when the path does not exist or there is no permission | // Nullptr is returned when the path does not exist or there is no permission | ||||
// Return absolute path when path is accessible | // Return absolute path when path is accessible | ||||
if (realpath(path.c_str(), resolved_path) == nullptr) { | |||||
INT32 result = mmRealPath(path.c_str(), resolved_path, MMPA_MAX_PATH); | |||||
if (result != EN_OK) { | |||||
GELOGW("the path [%s] not exsit.", path.c_str()); | GELOGW("the path [%s] not exsit.", path.c_str()); | ||||
return; | return; | ||||
} | } | ||||
struct dirent *dent = nullptr; | |||||
DIR *dir = opendir(resolved_path); | |||||
INT32 is_dir = mmIsDir(resolved_path); | |||||
// Lib plugin path not exist | // Lib plugin path not exist | ||||
if (dir == nullptr) { | |||||
if (is_dir != EN_OK) { | |||||
GELOGW("Open directory %s failed,maybe it is not exit or not a dir", resolved_path); | GELOGW("Open directory %s failed,maybe it is not exit or not a dir", resolved_path); | ||||
return; | return; | ||||
} | } | ||||
while ((dent = readdir(dir)) != nullptr) { | |||||
if (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0) { | |||||
mmDirent **entries = nullptr; | |||||
auto ret = mmScandir(resolved_path, &entries, nullptr, nullptr); | |||||
if (ret < EN_OK) { | |||||
GELOGW("scan dir failed. path = %s, ret = %d", resolved_path, ret); | |||||
return; | |||||
} | |||||
for (int i = 0; i < ret; ++i) { | |||||
mmDirent *dir_ent = entries[i]; | |||||
std::string name = std::string(dir_ent->d_name); | |||||
if (strcmp(name.c_str(), ".") == 0 || strcmp(name.c_str(), "..") == 0) { | |||||
continue; | continue; | ||||
} | } | ||||
std::string name = dent->d_name; | |||||
std::string full_name = path + "/" + name; | std::string full_name = path + "/" + name; | ||||
const std::string so_suff = ".so"; | const std::string so_suff = ".so"; | ||||
if (dent->d_type != DT_DIR && name.size() >= so_suff.size() && | |||||
if (dir_ent->d_type != DT_DIR && name.size() >= so_suff.size() && | |||||
name.compare(name.size() - so_suff.size(), so_suff.size(), so_suff) == 0) { | name.compare(name.size() - so_suff.size(), so_suff.size(), so_suff) == 0) { | ||||
file_list.push_back(full_name); | file_list.push_back(full_name); | ||||
GELOGI("OpsProtoManager Parse full name = %s \n", full_name.c_str()); | GELOGI("OpsProtoManager Parse full name = %s \n", full_name.c_str()); | ||||
} | } | ||||
} | } | ||||
if (closedir(dir) != 0) { | |||||
GELOGW("close dir fail."); | |||||
} | |||||
mmScandirFree(entries, ret); | |||||
GELOGI("Found %d libs.", ret); | |||||
} | } | ||||
static void GetPluginSoFileList(const std::string &path, std::vector<std::string> &file_list) { | static void GetPluginSoFileList(const std::string &path, std::vector<std::string> &file_list) { | ||||
@@ -171,9 +180,11 @@ void OpsProtoManager::LoadOpsProtoPluginSo(std::string &path) { | |||||
// Load .so file | // Load .so file | ||||
for (auto elem : file_list) { | for (auto elem : file_list) { | ||||
void *handle = dlopen(elem.c_str(), RTLD_NOW | RTLD_GLOBAL); | |||||
void *handle = mmDlopen(elem.c_str(), MMPA_RTLD_NOW | MMPA_RTLD_GLOBAL); | |||||
if (handle == nullptr) { | if (handle == nullptr) { | ||||
GELOGW("OpsProtoManager dlopen failed, plugin name:%s. Message(%s).", elem.c_str(), dlerror()); | |||||
const char *error = mmDlerror(); | |||||
error = (error == nullptr) ? "" : error; | |||||
GELOGW("OpsProtoManager dlopen failed, plugin name:%s. Message(%s).", elem.c_str(), error); | |||||
continue; | continue; | ||||
} else { | } else { | ||||
// Close dl when the program exist, not close here | // Close dl when the program exist, not close here | ||||
@@ -31,6 +31,7 @@ | |||||
#include "external/graph/operator_factory.h" | #include "external/graph/operator_factory.h" | ||||
#include "framework/common/debug/ge_log.h" | #include "framework/common/debug/ge_log.h" | ||||
#include "graph/compute_graph.h" | #include "graph/compute_graph.h" | ||||
#include "graph/operator_factory_impl.h" | |||||
#include "utils/node_utils.h" | #include "utils/node_utils.h" | ||||
#include "utils/op_desc_utils.h" | #include "utils/op_desc_utils.h" | ||||
#include "utils/tensor_utils.h" | #include "utils/tensor_utils.h" | ||||
@@ -76,7 +77,6 @@ graphStatus UpdataOutputForMultiBatcch(const ConstNodePtr &node, | |||||
int64_t max_size = 0; | int64_t max_size = 0; | ||||
size_t max_shape_index = 0; | size_t max_shape_index = 0; | ||||
auto &ref_out_tensor = ref_out_tensors[i].at(0); | auto &ref_out_tensor = ref_out_tensors[i].at(0); | ||||
const auto &ref_out_tensor_shape = ref_out_tensor.MutableShape(); | |||||
for (size_t j = 0; j < ref_out_tensors[i].size(); ++j) { | for (size_t j = 0; j < ref_out_tensors[i].size(); ++j) { | ||||
auto &tensor = ref_out_tensors[i].at(j); | auto &tensor = ref_out_tensors[i].at(j); | ||||
if (ref_out_tensor.GetDataType() != tensor.GetDataType()) { | if (ref_out_tensor.GetDataType() != tensor.GetDataType()) { | ||||
@@ -85,12 +85,6 @@ graphStatus UpdataOutputForMultiBatcch(const ConstNodePtr &node, | |||||
} | } | ||||
auto shape = tensor.MutableShape(); | auto shape = tensor.MutableShape(); | ||||
if (shape.GetDims().size() != ref_out_tensor_shape.GetDims().size()) { | |||||
GELOGE(GRAPH_FAILED, "node is %s, i : %d, shape size: %lu, ref_out_tensor_shape size: %lu", | |||||
node->GetName().c_str(), i, shape.GetShapeSize(), ref_out_tensor_shape.GetShapeSize()); | |||||
return GRAPH_FAILED; | |||||
} | |||||
int64_t size = 1; | int64_t size = 1; | ||||
for (auto dim : shape.GetDims()) { | for (auto dim : shape.GetDims()) { | ||||
if (INT64_MAX / dim < size) { | if (INT64_MAX / dim < size) { | ||||
@@ -510,63 +504,6 @@ void ShapeRefiner::PrintInOutTensorShape(const ge::NodePtr &node, const std::str | |||||
GELOGD("Shape dump [%s], Node name: [%s]. %s", phase.c_str(), node->GetName().c_str(), str.c_str()); | GELOGD("Shape dump [%s], Node name: [%s]. %s", phase.c_str(), node->GetName().c_str(), str.c_str()); | ||||
} | } | ||||
graphStatus ShapeRefiner::InferShapeAndType(const ConstNodePtr &node, Operator &op) { | |||||
return InferShapeAndType(node, op, true); | |||||
} | |||||
graphStatus ShapeRefiner::InferShapeAndType(const ConstNodePtr &node, Operator &op, bool before_subgraph) { | |||||
auto op_desc = node->GetOpDesc(); | |||||
const auto &op_type = op_desc->GetType(); | |||||
graphStatus ret; | |||||
if (before_subgraph) { | |||||
ret = UpdateSubGraphDataNodes(node); | |||||
if (ret != GRAPH_SUCCESS) { | |||||
return ret; | |||||
} | |||||
} | |||||
// Get infer func and execute | |||||
ret = op_desc->CallInferFunc(op); | |||||
if (ret == GRAPH_PARAM_INVALID) { | |||||
// Op ir no infer func, try to get infer func from operator factory | |||||
auto node_op = ge::OperatorFactory::CreateOperator("node_op", op_desc->GetType()); | |||||
if (node_op.IsEmpty()) { | |||||
GELOGW("get op from OperatorFactory fail. opType: %s", op_type.c_str()); | |||||
return ret; | |||||
} | |||||
GELOGD("get op from OperatorFactory success. opType: %s", op_type.c_str()); | |||||
auto temp_op_desc = ge::OpDescUtils::GetOpDescFromOperator(node_op); | |||||
node_op.BreakConnect(); | |||||
if (temp_op_desc == nullptr) { | |||||
GELOGE(GRAPH_FAILED, "temp op desc is null"); | |||||
return GRAPH_FAILED; | |||||
} | |||||
if (!op_desc->UpdateInputName(temp_op_desc->GetAllInputName())) { | |||||
GELOGW("InferShapeAndType UpdateInputName failed"); | |||||
for (const auto &out_desc : op_desc->GetAllOutputsDescPtr()) { | |||||
if (out_desc != nullptr && out_desc->GetShape().GetDims().empty()) { | |||||
break; | |||||
} | |||||
return GRAPH_SUCCESS; | |||||
} | |||||
} | |||||
if (!op_desc->UpdateOutputName(temp_op_desc->GetAllOutputName())) { | |||||
GELOGW("InferShapeAndType UpdateOutputName failed"); | |||||
} | |||||
op_desc->AddInferFunc(temp_op_desc->GetInferFunc()); | |||||
ret = op_desc->CallInferFunc(op); | |||||
GELOGI("op CallInferFunc second. ret: %u", ret); | |||||
} | |||||
if (ret != GRAPH_SUCCESS) { | |||||
return ret; | |||||
} | |||||
if (!before_subgraph) { | |||||
return UpdateParentNodeOutTensor(node); | |||||
} | |||||
return GRAPH_SUCCESS; | |||||
} | |||||
InferenceContextPtr CreateInferenceContext(const std::unordered_map<NodePtr, InferenceContextPtr> &context_map, | InferenceContextPtr CreateInferenceContext(const std::unordered_map<NodePtr, InferenceContextPtr> &context_map, | ||||
const NodePtr &node) { | const NodePtr &node) { | ||||
if (node == nullptr) { | if (node == nullptr) { | ||||
@@ -633,9 +570,122 @@ thread_local std::unordered_map<NodePtr, InferenceContextPtr> context_map; | |||||
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void ShapeRefiner::ClearContextMap() { context_map.clear(); } | GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void ShapeRefiner::ClearContextMap() { context_map.clear(); } | ||||
graphStatus ShapeRefiner::InferShapeAndType(const ConstNodePtr &node, Operator &op) { | |||||
return InferShapeAndType(node, op, true); | |||||
} | |||||
graphStatus ShapeRefiner::InferShapeAndType(const ConstNodePtr &node, Operator &op, bool before_subgraph) { | |||||
auto op_desc = node->GetOpDesc(); | |||||
const auto &op_type = op_desc->GetType(); | |||||
graphStatus ret; | |||||
if (before_subgraph) { | |||||
ret = UpdateSubGraphDataNodes(node); | |||||
if (ret != GRAPH_SUCCESS) { | |||||
return ret; | |||||
} | |||||
} | |||||
// Get infer func and execute | |||||
ret = op_desc->CallInferFunc(op); | |||||
if (ret == GRAPH_PARAM_INVALID) { | |||||
// Op ir no infer func, try to get infer func from operator factory | |||||
auto node_op = ge::OperatorFactory::CreateOperator("node_op", op_desc->GetType()); | |||||
if (node_op.IsEmpty()) { | |||||
GELOGW("get op from OperatorFactory fail. opType: %s", op_type.c_str()); | |||||
return ret; | |||||
} | |||||
GELOGD("get op from OperatorFactory success. opType: %s", op_type.c_str()); | |||||
auto temp_op_desc = ge::OpDescUtils::GetOpDescFromOperator(node_op); | |||||
node_op.BreakConnect(); | |||||
if (temp_op_desc == nullptr) { | |||||
GELOGE(GRAPH_FAILED, "temp op desc is null"); | |||||
return GRAPH_FAILED; | |||||
} | |||||
if (!op_desc->UpdateInputName(temp_op_desc->GetAllInputName())) { | |||||
GELOGW("InferShapeAndType UpdateInputName failed"); | |||||
for (const auto &out_desc : op_desc->GetAllOutputsDescPtr()) { | |||||
if (out_desc != nullptr && out_desc->GetShape().GetDims().empty()) { | |||||
break; | |||||
} | |||||
return GRAPH_SUCCESS; | |||||
} | |||||
} | |||||
if (!op_desc->UpdateOutputName(temp_op_desc->GetAllOutputName())) { | |||||
GELOGW("InferShapeAndType UpdateOutputName failed"); | |||||
} | |||||
op_desc->AddInferFunc(temp_op_desc->GetInferFunc()); | |||||
ret = op_desc->CallInferFunc(op); | |||||
GELOGI("op CallInferFunc second. ret: %u", ret); | |||||
} | |||||
if (ret != GRAPH_SUCCESS) { | |||||
return ret; | |||||
} | |||||
if (!before_subgraph) { | |||||
return UpdateParentNodeOutTensor(node); | |||||
} | |||||
return GRAPH_SUCCESS; | |||||
} | |||||
graphStatus ShapeRefiner::InferShapeAndTypeForRunning(const ConstNodePtr &node, Operator &op, bool before_subgraph) { | |||||
auto op_desc = node->GetOpDesc(); | |||||
const auto &op_type = op_desc->GetType(); | |||||
graphStatus ret; | |||||
if (before_subgraph) { | |||||
ret = UpdateSubGraphDataNodes(node); | |||||
if (ret != GRAPH_SUCCESS) { | |||||
return ret; | |||||
} | |||||
} | |||||
// Get infer func and execute | |||||
ret = op_desc->CallInferFunc(op); | |||||
if (ret == GRAPH_PARAM_INVALID) { | |||||
GELOGD("NodeUtils::GetNodeType return value is: [%s]", NodeUtils::GetNodeType(*node).c_str()); | |||||
auto origin_type = NodeUtils::GetNodeType(*node); | |||||
auto infer_func = ge::OperatorFactoryImpl::GetInferShapeFunc(origin_type); | |||||
if (infer_func == nullptr) { | |||||
GELOGE(GRAPH_FAILED, "Failed to Get InferFunc.type is %s", origin_type.c_str()); | |||||
return GRAPH_FAILED; | |||||
} | |||||
op_desc->AddInferFunc(infer_func); | |||||
ret = op_desc->CallInferFunc(op); | |||||
GELOGI("op CallInferFunc second. ret: %u", ret); | |||||
} | |||||
if (ret != GRAPH_SUCCESS) { | |||||
return ret; | |||||
} | |||||
if (!before_subgraph) { | |||||
return UpdateParentNodeOutTensor(node); | |||||
} | |||||
return GRAPH_SUCCESS; | |||||
} | |||||
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus ShapeRefiner::InferShapeAndType(const NodePtr &node) { | GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus ShapeRefiner::InferShapeAndType(const NodePtr &node) { | ||||
return InferShapeAndType(node, true); | return InferShapeAndType(node, true); | ||||
} | } | ||||
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus | |||||
ShapeRefiner::InferShapeAndTypeForRunning(const NodePtr &node, bool before_subgraph) { | |||||
GE_IF_BOOL_EXEC(node == nullptr, GELOGE(GRAPH_FAILED, "node is null."); return GRAPH_FAILED); | |||||
auto opdesc = node->GetOpDesc(); | |||||
GE_IF_BOOL_EXEC(opdesc == nullptr, GELOGE(GRAPH_FAILED, "op_desc is null."); return GRAPH_FAILED); | |||||
PrintInOutTensorShape(node, "before_infershape when running"); | |||||
Operator op = OpDescUtils::CreateOperatorFromNode(node); | |||||
graphStatus status = InferShapeAndTypeForRunning(node, op, before_subgraph); | |||||
if (status == GRAPH_PARAM_INVALID || status == GRAPH_SUCCESS) { | |||||
PrintInOutTensorShape(node, "after_infershape when running"); | |||||
return GRAPH_SUCCESS; | |||||
} else { | |||||
GELOGE(GRAPH_FAILED, "%s call infer function failed.", node->GetName().c_str()); | |||||
return GRAPH_FAILED; | |||||
} | |||||
} | |||||
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus ShapeRefiner::InferShapeAndType(const NodePtr &node, | GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus ShapeRefiner::InferShapeAndType(const NodePtr &node, | ||||
bool before_subgraph) { | bool before_subgraph) { | ||||
GE_IF_BOOL_EXEC(node == nullptr, GELOGE(GRAPH_FAILED, "node is null."); return GRAPH_FAILED); | GE_IF_BOOL_EXEC(node == nullptr, GELOGE(GRAPH_FAILED, "node is null."); return GRAPH_FAILED); | ||||
@@ -89,6 +89,65 @@ class TensorImpl { | |||||
TensorImpl(TensorDesc &&tensor_desc, std::vector<uint8_t> &&data) | TensorImpl(TensorDesc &&tensor_desc, std::vector<uint8_t> &&data) | ||||
: ge_tensor(TensorAdapter::TensorDesc2GeTensorDesc(tensor_desc), std::move(data)) {} | : ge_tensor(TensorAdapter::TensorDesc2GeTensorDesc(tensor_desc), std::move(data)) {} | ||||
graphStatus SetData(const std::string &data) { | |||||
if (!data.empty()) { | |||||
/// Extra 8 bytes store pointer of string | |||||
/// Extra 1 byte store '\0' | |||||
size_t total_size = data.size() + EXTRA_STORE_POINTER_FOR_STRING_AND_END_SYMBOL; | |||||
std::unique_ptr<char[]> buff(new (std::nothrow) char[total_size]()); | |||||
if (buff == nullptr) { | |||||
GELOGE(GRAPH_FAILED, "allocate string raw data buff failed"); | |||||
return GRAPH_FAILED; | |||||
} | |||||
uint64_t *p = reinterpret_cast<uint64_t *>(buff.get()); | |||||
// Front 8 bytes store pointer of string | |||||
char *raw_data = buff.get() + EXTRA_STORE_POINTER_FOR_STRING; | |||||
p[0] = reinterpret_cast<uintptr_t>(raw_data); | |||||
int32_t memcpy_ret = | |||||
memcpy_s(raw_data, total_size - EXTRA_STORE_POINTER_FOR_STRING, data.c_str(), data.size() + 1); | |||||
GE_CHK_BOOL_RET_STATUS(memcpy_ret == EOK, GRAPH_FAILED, "copy data failed"); | |||||
(void)ge_tensor.SetData(reinterpret_cast<const uint8_t *>(buff.get()), total_size); | |||||
return GRAPH_SUCCESS; | |||||
} | |||||
return GRAPH_FAILED; | |||||
} | |||||
graphStatus SetData(const std::vector<std::string> &data) { | |||||
if (data.empty()) { | |||||
GELOGE(GRAPH_FAILED, "there is no data, please check the input variable"); | |||||
return GRAPH_FAILED; | |||||
} | |||||
size_t total_size = 0; | |||||
for (auto str : data) { | |||||
/// Extra 8 bytes store pointer of each string | |||||
/// Extra 1 byte store '\0' | |||||
total_size += (str.size() + EXTRA_STORE_POINTER_FOR_STRING_AND_END_SYMBOL); | |||||
} | |||||
std::unique_ptr<char[]> buff(new (std::nothrow) char[total_size]); | |||||
if (buff == nullptr) { | |||||
GELOGE(GRAPH_FAILED, "allocate string raw data buff failed"); | |||||
return GRAPH_FAILED; | |||||
} | |||||
uint64_t *p = reinterpret_cast<uint64_t *>(buff.get()); | |||||
// Front some bytes store pointer of each string | |||||
char *raw_data = buff.get() + data.size() * sizeof(uint64_t); | |||||
uint64_t ptr_size = data.size() * sizeof(uint64_t); | |||||
for (size_t i = 0; i < data.size(); ++i) { | |||||
p[i] = reinterpret_cast<uintptr_t>(raw_data); | |||||
if (total_size < ptr_size) { | |||||
GELOGE(GRAPH_FAILED, "Subtraction invalid, total_size: %zu, ptr_size: %lu", total_size, ptr_size); | |||||
return GRAPH_FAILED; | |||||
} | |||||
int32_t memcpy_ret = memcpy_s(raw_data, total_size - ptr_size, data[i].c_str(), data[i].size() + 1); | |||||
GE_CHK_BOOL_RET_STATUS(memcpy_ret == EOK, GRAPH_FAILED, "copy data failed"); | |||||
raw_data += (data[i].size() + 1); | |||||
ptr_size += (data[i].size() + 1); | |||||
} | |||||
(void)ge_tensor.SetData(reinterpret_cast<const uint8_t *>(buff.get()), total_size); | |||||
return GRAPH_SUCCESS; | |||||
} | |||||
GeTensor ge_tensor; | GeTensor ge_tensor; | ||||
}; | }; | ||||
@@ -356,6 +415,20 @@ void TensorDesc::SetName(const std::string &name) { | |||||
} | } | ||||
} | } | ||||
graphStatus TensorDesc::GetName(AscendString &name) { | |||||
if (impl != nullptr) { | |||||
name = AscendString(impl->name_.c_str()); | |||||
return GRAPH_SUCCESS; | |||||
} | |||||
return GRAPH_FAILED; | |||||
} | |||||
void TensorDesc::SetName(const char *name) { | |||||
if (impl != nullptr && name != nullptr) { | |||||
impl->name_ = name; | |||||
} | |||||
} | |||||
Tensor::Tensor() { impl = ComGraphMakeShared<TensorImpl>(); } | Tensor::Tensor() { impl = ComGraphMakeShared<TensorImpl>(); } | ||||
Tensor::Tensor(const TensorDesc &tensor_desc) { impl = ComGraphMakeShared<TensorImpl>(tensor_desc); } | Tensor::Tensor(const TensorDesc &tensor_desc) { impl = ComGraphMakeShared<TensorImpl>(tensor_desc); } | ||||
@@ -489,60 +562,53 @@ graphStatus Tensor::SetData(const uint8_t *data, size_t size) { | |||||
} | } | ||||
graphStatus Tensor::SetData(const std::string &data) { | graphStatus Tensor::SetData(const std::string &data) { | ||||
if (impl != nullptr && (!data.empty())) { | |||||
/// Extra 8 bytes store pointer of string | |||||
/// Extra 1 byte store '\0' | |||||
size_t total_size = data.size() + EXTRA_STORE_POINTER_FOR_STRING_AND_END_SYMBOL; | |||||
std::unique_ptr<char[]> buff(new (std::nothrow) char[total_size]()); | |||||
if (buff == nullptr) { | |||||
GELOGE(GRAPH_FAILED, "allocate string raw data buff failed"); | |||||
if (impl != nullptr) { | |||||
if (impl->SetData(data) != GRAPH_SUCCESS) { | |||||
GELOGE(GRAPH_FAILED, "Tensor set data failed."); | |||||
return GRAPH_FAILED; | return GRAPH_FAILED; | ||||
} | } | ||||
uint64_t *p = reinterpret_cast<uint64_t *>(buff.get()); | |||||
// Front 8 bytes store pointer of string | |||||
char *raw_data = buff.get() + EXTRA_STORE_POINTER_FOR_STRING; | |||||
p[0] = reinterpret_cast<uintptr_t>(raw_data); | |||||
int32_t memcpy_ret = memcpy_s(raw_data, total_size - EXTRA_STORE_POINTER_FOR_STRING, data.c_str(), data.size() + 1); | |||||
GE_CHK_BOOL_RET_STATUS(memcpy_ret == EOK, GRAPH_FAILED, "copy data failed"); | |||||
(void)impl->ge_tensor.SetData(reinterpret_cast<const uint8_t *>(buff.get()), total_size); | |||||
return GRAPH_SUCCESS; | return GRAPH_SUCCESS; | ||||
} | } | ||||
return GRAPH_FAILED; | return GRAPH_FAILED; | ||||
} | } | ||||
graphStatus Tensor::SetData(const std::vector<std::string> &data) { | graphStatus Tensor::SetData(const std::vector<std::string> &data) { | ||||
if (impl != nullptr) { | if (impl != nullptr) { | ||||
if (data.empty()) { | |||||
GELOGE(GRAPH_FAILED, "there is no data, please check the input variable"); | |||||
if (impl->SetData(data) != GRAPH_SUCCESS) { | |||||
GELOGE(GRAPH_FAILED, "Tensor set vector data failed."); | |||||
return GRAPH_FAILED; | return GRAPH_FAILED; | ||||
} | } | ||||
size_t total_size = 0; | |||||
for (auto str : data) { | |||||
/// Extra 8 bytes store pointer of each string | |||||
/// Extra 1 byte store '\0' | |||||
total_size += (str.size() + EXTRA_STORE_POINTER_FOR_STRING_AND_END_SYMBOL); | |||||
} | |||||
std::unique_ptr<char[]> buff(new (std::nothrow) char[total_size]); | |||||
if (buff == nullptr) { | |||||
GELOGE(GRAPH_FAILED, "allocate string raw data buff failed"); | |||||
return GRAPH_SUCCESS; | |||||
} | |||||
return GRAPH_FAILED; | |||||
} | |||||
graphStatus Tensor::SetData(const char *data) { | |||||
if (impl != nullptr && data != nullptr) { | |||||
std::string tensor_data = data; | |||||
if (impl->SetData(tensor_data) != GRAPH_SUCCESS) { | |||||
GELOGE(GRAPH_FAILED, "Tensor set data failed."); | |||||
return GRAPH_FAILED; | return GRAPH_FAILED; | ||||
} | } | ||||
uint64_t *p = reinterpret_cast<uint64_t *>(buff.get()); | |||||
// Front some bytes store pointer of each string | |||||
char *raw_data = buff.get() + data.size() * sizeof(uint64_t); | |||||
uint64_t ptr_size = data.size() * sizeof(uint64_t); | |||||
for (size_t i = 0; i < data.size(); ++i) { | |||||
p[i] = reinterpret_cast<uintptr_t>(raw_data); | |||||
if (total_size < ptr_size) { | |||||
GELOGE(GRAPH_FAILED, "Subtraction invalid, total_size: %zu, ptr_size: %lu", total_size, ptr_size); | |||||
return GRAPH_SUCCESS; | |||||
} | |||||
return GRAPH_FAILED; | |||||
} | |||||
graphStatus Tensor::SetData(const std::vector<AscendString> &datas) { | |||||
if (impl != nullptr) { | |||||
std::vector<std::string> tensor_data; | |||||
for (auto &data : datas) { | |||||
if (data.GetString() == nullptr) { | |||||
GELOGE(GRAPH_FAILED, "Data is nullptr."); | |||||
return GRAPH_FAILED; | return GRAPH_FAILED; | ||||
} | } | ||||
int32_t memcpy_ret = memcpy_s(raw_data, total_size - ptr_size, data[i].c_str(), data[i].size() + 1); | |||||
GE_CHK_BOOL_RET_STATUS(memcpy_ret == EOK, GRAPH_FAILED, "copy data failed"); | |||||
raw_data += (data[i].size() + 1); | |||||
ptr_size += (data[i].size() + 1); | |||||
tensor_data.emplace_back(data.GetString()); | |||||
} | |||||
if (impl->SetData(tensor_data) != GRAPH_SUCCESS) { | |||||
GELOGE(GRAPH_FAILED, "Tensor set vector data failed."); | |||||
return GRAPH_FAILED; | |||||
} | } | ||||
(void)impl->ge_tensor.SetData(reinterpret_cast<const uint8_t *>(buff.get()), total_size); | |||||
return GRAPH_SUCCESS; | return GRAPH_SUCCESS; | ||||
} | } | ||||
return GRAPH_FAILED; | return GRAPH_FAILED; | ||||
@@ -63,6 +63,30 @@ const int32_t AXIS_C1HWNCoC0_DIM_N = 3; | |||||
const int32_t AXIS_C1HWNCoC0_DIM_Co = 4; | const int32_t AXIS_C1HWNCoC0_DIM_Co = 4; | ||||
const int32_t AXIS_C1HWNCoC0_DIM_C0 = 5; | const int32_t AXIS_C1HWNCoC0_DIM_C0 = 5; | ||||
const int32_t NDHWC_DIM_N = 0; | |||||
const int32_t NDHWC_DIM_D = 1; | |||||
const int32_t NDHWC_DIM_H = 2; | |||||
const int32_t NDHWC_DIM_W = 3; | |||||
const int32_t NDHWC_DIM_C = 4; | |||||
const int32_t NCDHW_DIM_N = 0; | |||||
const int32_t NCDHW_DIM_C = 1; | |||||
const int32_t NCDHW_DIM_D = 2; | |||||
const int32_t NCDHW_DIM_H = 3; | |||||
const int32_t NCDHW_DIM_W = 4; | |||||
const int32_t DHWCN_DIM_D = 0; | |||||
const int32_t DHWCN_DIM_H = 1; | |||||
const int32_t DHWCN_DIM_W = 2; | |||||
const int32_t DHWCN_DIM_C = 3; | |||||
const int32_t DHWCN_DIM_N = 4; | |||||
const int32_t DHWNC_DIM_D = 0; | |||||
const int32_t DHWNC_DIM_H = 1; | |||||
const int32_t DHWNC_DIM_W = 2; | |||||
const int32_t DHWNC_DIM_N = 3; | |||||
const int32_t DHWNC_DIM_C = 4; | |||||
#define CHECK_NOTNULL(val) \ | #define CHECK_NOTNULL(val) \ | ||||
do { \ | do { \ | ||||
if ((val) == nullptr) { \ | if ((val) == nullptr) { \ | ||||
@@ -134,6 +158,17 @@ class AxisUtil { | |||||
static bool GetAxisValueByC1HWNCoC0(const std::vector<int64_t>& originalDimVec, const uint32_t& c0, | static bool GetAxisValueByC1HWNCoC0(const std::vector<int64_t>& originalDimVec, const uint32_t& c0, | ||||
std::vector<int64_t>& axisValue, std::vector<int64_t>& ndValue); | std::vector<int64_t>& axisValue, std::vector<int64_t>& ndValue); | ||||
static bool GetAxisValueByNDHWC(const std::vector<int64_t>& original_dim_vec, const uint32_t& c0, | |||||
std::vector<int64_t>& axis_value, std::vector<int64_t>& nd_value); | |||||
static bool GetAxisValueByNCDHW(const std::vector<int64_t>& original_dim_vec, const uint32_t& c0, | |||||
std::vector<int64_t>& axis_value, std::vector<int64_t>& nd_value); | |||||
static bool GetAxisValueByDHWCN(const std::vector<int64_t>& original_dim_vec, const uint32_t& c0, | |||||
std::vector<int64_t>& axis_value, std::vector<int64_t>& nd_value); | |||||
static bool GetAxisValueByDHWNC(const std::vector<int64_t>& original_dim_vec, const uint32_t& c0, | |||||
std::vector<int64_t>& axis_value, std::vector<int64_t>& nd_value); | |||||
/* map of GetAxisValueInfoByFormat, get axis value by different original | /* map of GetAxisValueInfoByFormat, get axis value by different original | ||||
* formats. */ | * formats. */ | ||||
std::map<ge::Format, GetAxisValueInfoByFormatPtr> getAxisValueFuncMap; | std::map<ge::Format, GetAxisValueInfoByFormatPtr> getAxisValueFuncMap; | ||||
@@ -89,6 +89,9 @@ class ShapeTransferAccordingToFormat { | |||||
bool GetShapeAccordingToFormat(ShapeAndFormat &inputAndOutputInfo, int64_t *c = nullptr); | bool GetShapeAccordingToFormat(ShapeAndFormat &inputAndOutputInfo, int64_t *c = nullptr); | ||||
/* ----------Below is the function of getting new shape---------------------- */ | /* ----------Below is the function of getting new shape---------------------- */ | ||||
static bool GetNDC1HWC0ShapeByAxisValue(vector<int64_t> &new_shape, const int64_t &impl_type, | |||||
const std::vector<int64_t> &axis_value, const vector<int64_t> &nd_value); | |||||
static bool GetNCHWShapeByAxisValue(vector<int64_t> &newShape, const int64_t &implType, | static bool GetNCHWShapeByAxisValue(vector<int64_t> &newShape, const int64_t &implType, | ||||
const vector<int64_t> &axisValue, const vector<int64_t> &ndValue); | const vector<int64_t> &axisValue, const vector<int64_t> &ndValue); | ||||
@@ -32,7 +32,11 @@ AxisUtil::AxisUtil() { | |||||
{FORMAT_NC1HWC0, std::make_shared<GetAxisValueInfoByFormat>(GetAxisValueByNC1HWC0)}, | {FORMAT_NC1HWC0, std::make_shared<GetAxisValueInfoByFormat>(GetAxisValueByNC1HWC0)}, | ||||
{FORMAT_HWCN, std::make_shared<GetAxisValueInfoByFormat>(GetAxisValueByHWCN)}, | {FORMAT_HWCN, std::make_shared<GetAxisValueInfoByFormat>(GetAxisValueByHWCN)}, | ||||
{FORMAT_ND, std::make_shared<GetAxisValueInfoByFormat>(GetAxisValueByND)}, | {FORMAT_ND, std::make_shared<GetAxisValueInfoByFormat>(GetAxisValueByND)}, | ||||
{FORMAT_C1HWNCoC0, std::make_shared<GetAxisValueInfoByFormat>(GetAxisValueByC1HWNCoC0)}}; | |||||
{FORMAT_C1HWNCoC0, std::make_shared<GetAxisValueInfoByFormat>(GetAxisValueByC1HWNCoC0)}, | |||||
{FORMAT_NDHWC, std::make_shared<GetAxisValueInfoByFormat>(GetAxisValueByNDHWC)}, | |||||
{FORMAT_NCDHW, std::make_shared<GetAxisValueInfoByFormat>(GetAxisValueByNCDHW)}, | |||||
{FORMAT_DHWCN, std::make_shared<GetAxisValueInfoByFormat>(GetAxisValueByDHWCN)}, | |||||
{FORMAT_DHWNC, std::make_shared<GetAxisValueInfoByFormat>(GetAxisValueByDHWNC)}}; | |||||
} | } | ||||
int64_t DivisionCeiling(int64_t dividend, int64_t divisor) { | int64_t DivisionCeiling(int64_t dividend, int64_t divisor) { | ||||
@@ -105,8 +109,9 @@ bool AxisUtil::GetAxisValueByNCHW(const vector<int64_t> &originalDimVec, const u | |||||
CHECK(originalDimVec.empty(), GELOGI("Original dim vector is empty!"), return true); | CHECK(originalDimVec.empty(), GELOGI("Original dim vector is empty!"), return true); | ||||
/* C0 Must be set for case ND or 2D-NCHW to NZ */ | /* C0 Must be set for case ND or 2D-NCHW to NZ */ | ||||
axisValue[AXIS_C0] = c0; | axisValue[AXIS_C0] = c0; | ||||
CHECK(CheckParams(originalDimVec, c0, axisValue, ndValue) != true, | |||||
GELOGE(GRAPH_FAILED, "[ERROR]Parameter is invalid!"), return false); | |||||
// TODO: temporarily modified to warning level.If modified normally, it needs complementary dimension for origin shape | |||||
CHECK(CheckParams(originalDimVec, c0, axisValue, ndValue) != true, GELOGW("[WARNING]Parameter is invalid!"), | |||||
return false); | |||||
axisValue[AXIS_N] = originalDimVec[AXIS_NCHW_DIM_N]; | axisValue[AXIS_N] = originalDimVec[AXIS_NCHW_DIM_N]; | ||||
axisValue[AXIS_C] = originalDimVec[AXIS_NCHW_DIM_C]; | axisValue[AXIS_C] = originalDimVec[AXIS_NCHW_DIM_C]; | ||||
@@ -123,8 +128,9 @@ bool AxisUtil::GetAxisValueByNHWC(const vector<int64_t> &originalDimVec, const u | |||||
CHECK(originalDimVec.empty(), GELOGI("Original dim vector is empty!"), return true); | CHECK(originalDimVec.empty(), GELOGI("Original dim vector is empty!"), return true); | ||||
/* C0 Must be set for case ND or 2D-NHWC to NZ */ | /* C0 Must be set for case ND or 2D-NHWC to NZ */ | ||||
axisValue[AXIS_C0] = c0; | axisValue[AXIS_C0] = c0; | ||||
CHECK(CheckParams(originalDimVec, c0, axisValue, ndValue) != true, | |||||
GELOGE(GRAPH_FAILED, "[ERROR]Parameter is invalid!"), return false); | |||||
// TODO: temporarily modified to warning level.If modified normally, it needs complementary dimension for origin shape | |||||
CHECK(CheckParams(originalDimVec, c0, axisValue, ndValue) != true, GELOGW("[WARNING]Parameter is invalid!"), | |||||
return false); | |||||
axisValue[AXIS_N] = originalDimVec[AXIS_NHWC_DIM_N]; | axisValue[AXIS_N] = originalDimVec[AXIS_NHWC_DIM_N]; | ||||
axisValue[AXIS_C] = originalDimVec[AXIS_NHWC_DIM_C]; | axisValue[AXIS_C] = originalDimVec[AXIS_NHWC_DIM_C]; | ||||
@@ -165,8 +171,10 @@ bool AxisUtil::GetAxisValueByHWCN(const vector<int64_t> &originalDimVec, const u | |||||
CHECK(originalDimVec.empty(), GELOGI("Original dim vector is empty!"), return true); | CHECK(originalDimVec.empty(), GELOGI("Original dim vector is empty!"), return true); | ||||
/* C0 Must be set for case ND or 2D-NHWC to NZ */ | /* C0 Must be set for case ND or 2D-NHWC to NZ */ | ||||
axisValue[AXIS_C0] = c0; | axisValue[AXIS_C0] = c0; | ||||
CHECK(CheckParams(originalDimVec, c0, axisValue, ndValue) != true, | |||||
GELOGE(GRAPH_FAILED, "[ERROR]Parameter is invalid!"), return false); | |||||
// TODO: temporarily modified to warning level. If modified normally, it needs complementary dimension for origin | |||||
// shape | |||||
CHECK(CheckParams(originalDimVec, c0, axisValue, ndValue) != true, GELOGW("[WARNING]Parameter is invalid!"), | |||||
return false); | |||||
axisValue[AXIS_N] = originalDimVec[AXIS_HWCN_DIM_N]; | axisValue[AXIS_N] = originalDimVec[AXIS_HWCN_DIM_N]; | ||||
axisValue[AXIS_C] = originalDimVec[AXIS_HWCN_DIM_C]; | axisValue[AXIS_C] = originalDimVec[AXIS_HWCN_DIM_C]; | ||||
@@ -194,5 +202,89 @@ bool AxisUtil::GetAxisValueByC1HWNCoC0(const vector<int64_t> &originalDimVec, co | |||||
axisValue[AXIS_Co] = originalDimVec[AXIS_C1HWNCoC0_DIM_Co]; | axisValue[AXIS_Co] = originalDimVec[AXIS_C1HWNCoC0_DIM_Co]; | ||||
return true; | return true; | ||||
} | } | ||||
bool AxisUtil::GetAxisValueByNDHWC(const std::vector<int64_t> &original_dim_vec, const uint32_t &c0, | |||||
std::vector<int64_t> &axis_value, std::vector<int64_t> &nd_value) { | |||||
CHECK(axis_value.empty(), GELOGI("AxisValue is empty!"), return true); | |||||
CHECK(original_dim_vec.empty(), GELOGI("Original dim vector is empty!"), return true); | |||||
axis_value[AXIS_C0] = c0; | |||||
nd_value = original_dim_vec; | |||||
axis_value[AXIS_N] = original_dim_vec[NDHWC_DIM_N]; | |||||
int64_t axis_c_val = original_dim_vec[NDHWC_DIM_C]; | |||||
axis_value[AXIS_C] = axis_c_val; | |||||
axis_value[AXIS_H] = original_dim_vec[NDHWC_DIM_H]; | |||||
axis_value[AXIS_W] = original_dim_vec[NDHWC_DIM_W]; | |||||
axis_value[AXIS_C1] = DivisionCeiling(axis_c_val, c0); | |||||
axis_value[AXIS_C0] = c0; | |||||
axis_value[AXIS_Co] = c0; | |||||
axis_value[AXIS_D] = original_dim_vec[NDHWC_DIM_D]; | |||||
return true; | |||||
} | |||||
bool AxisUtil::GetAxisValueByNCDHW(const std::vector<int64_t> &original_dim_vec, const uint32_t &c0, | |||||
std::vector<int64_t> &axis_value, std::vector<int64_t> &nd_value) { | |||||
CHECK(axis_value.empty(), GELOGI("AxisValue is empty!"), return true); | |||||
CHECK(original_dim_vec.empty(), GELOGI("Original dim vector is empty!"), return true); | |||||
axis_value[AXIS_C0] = c0; | |||||
nd_value = original_dim_vec; | |||||
axis_value[AXIS_N] = original_dim_vec[NCDHW_DIM_N]; | |||||
int64_t axis_c_val = original_dim_vec[NCDHW_DIM_C]; | |||||
axis_value[AXIS_C] = axis_c_val; | |||||
axis_value[AXIS_H] = original_dim_vec[NCDHW_DIM_H]; | |||||
axis_value[AXIS_W] = original_dim_vec[NCDHW_DIM_W]; | |||||
axis_value[AXIS_C1] = DivisionCeiling(axis_c_val, c0); | |||||
axis_value[AXIS_C0] = c0; | |||||
axis_value[AXIS_Co] = c0; | |||||
axis_value[AXIS_D] = original_dim_vec[NCDHW_DIM_D]; | |||||
return true; | |||||
} | |||||
bool AxisUtil::GetAxisValueByDHWCN(const std::vector<int64_t> &original_dim_vec, const uint32_t &c0, | |||||
std::vector<int64_t> &axis_value, std::vector<int64_t> &nd_value) { | |||||
CHECK(axis_value.empty(), GELOGI("AxisValue is empty!"), return true); | |||||
CHECK(original_dim_vec.empty(), GELOGI("Original dim vector is empty!"), return true); | |||||
axis_value[AXIS_C0] = c0; | |||||
nd_value = original_dim_vec; | |||||
axis_value[AXIS_N] = original_dim_vec[DHWCN_DIM_N]; | |||||
int64_t axis_c_val = original_dim_vec[DHWCN_DIM_C]; | |||||
axis_value[AXIS_C] = axis_c_val; | |||||
axis_value[AXIS_H] = original_dim_vec[DHWCN_DIM_H]; | |||||
axis_value[AXIS_W] = original_dim_vec[DHWCN_DIM_W]; | |||||
axis_value[AXIS_C1] = DivisionCeiling(axis_c_val, c0); | |||||
axis_value[AXIS_C0] = c0; | |||||
axis_value[AXIS_Co] = c0; | |||||
axis_value[AXIS_D] = original_dim_vec[DHWCN_DIM_D]; | |||||
return true; | |||||
} | |||||
bool AxisUtil::GetAxisValueByDHWNC(const std::vector<int64_t> &original_dim_vec, const uint32_t &c0, | |||||
std::vector<int64_t> &axis_value, std::vector<int64_t> &nd_value) { | |||||
CHECK(axis_value.empty(), GELOGI("AxisValue is empty!"), return true); | |||||
CHECK(original_dim_vec.empty(), GELOGI("Original dim vector is empty!"), return true); | |||||
axis_value[AXIS_C0] = c0; | |||||
nd_value = original_dim_vec; | |||||
axis_value[AXIS_N] = original_dim_vec[DHWNC_DIM_N]; | |||||
int64_t axis_c_val = original_dim_vec[DHWNC_DIM_C]; | |||||
axis_value[AXIS_C] = axis_c_val; | |||||
axis_value[AXIS_H] = original_dim_vec[DHWNC_DIM_H]; | |||||
axis_value[AXIS_W] = original_dim_vec[DHWNC_DIM_W]; | |||||
axis_value[AXIS_C1] = DivisionCeiling(axis_c_val, c0); | |||||
axis_value[AXIS_C0] = c0; | |||||
axis_value[AXIS_Co] = c0; | |||||
axis_value[AXIS_D] = original_dim_vec[DHWNC_DIM_D]; | |||||
return true; | |||||
} | |||||
} // namespace transformer | } // namespace transformer | ||||
} // namespace common | } // namespace common |
@@ -30,6 +30,7 @@ ShapeTransferAccordingToFormat::ShapeTransferAccordingToFormat(void) { | |||||
{ge::FORMAT_NCHW, std::make_shared<GetNewShapeByAxisValueAndFormat>(GetNCHWShapeByAxisValue)}, | {ge::FORMAT_NCHW, std::make_shared<GetNewShapeByAxisValueAndFormat>(GetNCHWShapeByAxisValue)}, | ||||
{ge::FORMAT_NHWC, std::make_shared<GetNewShapeByAxisValueAndFormat>(GetNHWCShapeByAxisValue)}, | {ge::FORMAT_NHWC, std::make_shared<GetNewShapeByAxisValueAndFormat>(GetNHWCShapeByAxisValue)}, | ||||
{ge::FORMAT_NC1HWC0, std::make_shared<GetNewShapeByAxisValueAndFormat>(GetNC1HWC0ShapeByAxisValue)}, | {ge::FORMAT_NC1HWC0, std::make_shared<GetNewShapeByAxisValueAndFormat>(GetNC1HWC0ShapeByAxisValue)}, | ||||
{ge::FORMAT_NDC1HWC0, std::make_shared<GetNewShapeByAxisValueAndFormat>(GetNDC1HWC0ShapeByAxisValue)}, | |||||
{ge::FORMAT_FRACTAL_Z, std::make_shared<GetNewShapeByAxisValueAndFormat>(GetFzShapeByAxisValue)}, | {ge::FORMAT_FRACTAL_Z, std::make_shared<GetNewShapeByAxisValueAndFormat>(GetFzShapeByAxisValue)}, | ||||
{ge::FORMAT_HWCN, std::make_shared<GetNewShapeByAxisValueAndFormat>(GetHWCNShapeByAxisValue)}, | {ge::FORMAT_HWCN, std::make_shared<GetNewShapeByAxisValueAndFormat>(GetHWCNShapeByAxisValue)}, | ||||
{ge::FORMAT_C1HWNCoC0, std::make_shared<GetNewShapeByAxisValueAndFormat>(GetC1HWNCoC0ShapeByAxisValue)}, | {ge::FORMAT_C1HWNCoC0, std::make_shared<GetNewShapeByAxisValueAndFormat>(GetC1HWNCoC0ShapeByAxisValue)}, | ||||
@@ -42,6 +43,19 @@ ShapeTransferAccordingToFormat::ShapeTransferAccordingToFormat(void) { | |||||
{ge::DT_UINT64, SHAPE_NUMBER_16}, {ge::DT_BOOL, SHAPE_NUMBER_16}}; | {ge::DT_UINT64, SHAPE_NUMBER_16}, {ge::DT_BOOL, SHAPE_NUMBER_16}}; | ||||
} | } | ||||
bool ShapeTransferAccordingToFormat::GetNDC1HWC0ShapeByAxisValue(vector<int64_t>& new_shape, const int64_t& impl_type, | |||||
const std::vector<int64_t>& axis_value, | |||||
const vector<int64_t>& nd_value) { | |||||
CHECK(axis_value.empty(), GELOGD("AxisValue is empty!"), return true); | |||||
new_shape.push_back(axis_value[AXIS_N]); | |||||
new_shape.push_back(axis_value[AXIS_D]); | |||||
new_shape.push_back(axis_value[AXIS_C1]); | |||||
new_shape.push_back(axis_value[AXIS_H]); | |||||
new_shape.push_back(axis_value[AXIS_W]); | |||||
new_shape.push_back(axis_value[AXIS_C0]); | |||||
return true; | |||||
} | |||||
bool ShapeTransferAccordingToFormat::GetNCHWShapeByAxisValue(vector<int64_t>& newShape, const int64_t& implType, | bool ShapeTransferAccordingToFormat::GetNCHWShapeByAxisValue(vector<int64_t>& newShape, const int64_t& implType, | ||||
const vector<int64_t>& axisValue, | const vector<int64_t>& axisValue, | ||||
const vector<int64_t>& ndValue) { | const vector<int64_t>& ndValue) { | ||||
@@ -17,6 +17,7 @@ | |||||
#include "graph/utils/ge_ir_utils.h" | #include "graph/utils/ge_ir_utils.h" | ||||
#include <utility> | #include <utility> | ||||
#include "framework/common/debug/ge_log.h" | #include "framework/common/debug/ge_log.h" | ||||
#include "mmpa/mmpa_api.h" | |||||
namespace { | namespace { | ||||
const char *const kControlAnchorIndex = ":-1"; | const char *const kControlAnchorIndex = ":-1"; | ||||
@@ -25,8 +26,10 @@ const char *const kPrefixForInputDesc = "input_desc_attr_"; | |||||
const char *const kPrefixForOutputDesc = "output_desc_attr_"; | const char *const kPrefixForOutputDesc = "output_desc_attr_"; | ||||
const char *const kDumpGEGraph = "DUMP_GE_GRAPH"; | const char *const kDumpGEGraph = "DUMP_GE_GRAPH"; | ||||
const int8_t kMaxRecursionDepth = 10; | const int8_t kMaxRecursionDepth = 10; | ||||
const char *const kDumpGeGraph = std::getenv(kDumpGEGraph); | |||||
const int64_t kDumpLevel = (kDumpGeGraph != nullptr) ? std::strtol(kDumpGeGraph, nullptr, 10) : ge::OnnxUtils::NO_DUMP; | |||||
char kDumpGeGraph[MMPA_MAX_PATH] = {0x00}; | |||||
const int64_t kDumpLevel = (mmGetEnv(kDumpGEGraph, kDumpGeGraph, MMPA_MAX_PATH) == EN_OK) | |||||
? std::strtol(kDumpGeGraph, nullptr, 10) | |||||
: ge::OnnxUtils::NO_DUMP; | |||||
const int64_t kInputPrefixLength = 5; | const int64_t kInputPrefixLength = 5; | ||||
const int64_t kOutputPrefixLength = 6; | const int64_t kOutputPrefixLength = 6; | ||||
using AttrDefPair = ::google::protobuf::MapPair<std::string, ge::proto::AttrDef>; | using AttrDefPair = ::google::protobuf::MapPair<std::string, ge::proto::AttrDef>; | ||||
@@ -43,6 +46,12 @@ static const std::map<ge::DataType, onnx::TensorProto_DataType> kGeDataTypeToOnn | |||||
{DT_DOUBLE, onnx::TensorProto_DataType_DOUBLE}, {DT_BOOL, onnx::TensorProto_DataType_BOOL}, | {DT_DOUBLE, onnx::TensorProto_DataType_DOUBLE}, {DT_BOOL, onnx::TensorProto_DataType_BOOL}, | ||||
}; | }; | ||||
struct AttrNameComp { | |||||
inline bool operator()(const onnx::AttributeProto &lsh, const onnx::AttributeProto &rsh) { | |||||
return lsh.name() < rsh.name(); | |||||
} | |||||
}; | |||||
onnx::TensorProto_DataType OnnxUtils::EncodeDataType(DataType data_type) { | onnx::TensorProto_DataType OnnxUtils::EncodeDataType(DataType data_type) { | ||||
auto it = kGeDataTypeToOnnxMap.find(data_type); | auto it = kGeDataTypeToOnnxMap.find(data_type); | ||||
if (it != kGeDataTypeToOnnxMap.end()) { | if (it != kGeDataTypeToOnnxMap.end()) { | ||||
@@ -547,6 +556,9 @@ bool OnnxUtils::EncodeNodeDesc(const NodePtr &node, onnx::NodeProto *node_proto) | |||||
} | } | ||||
// 3.Encode ge::Node members to AttributeProto | // 3.Encode ge::Node members to AttributeProto | ||||
AddAttrProtoFromNodeMembers(node, node_proto); | AddAttrProtoFromNodeMembers(node, node_proto); | ||||
// 4. Sort node attributes by name. | |||||
std::sort(node_proto->mutable_attribute()->begin(), node_proto->mutable_attribute()->end(), AttrNameComp()); | |||||
return true; | return true; | ||||
} | } | ||||
@@ -20,10 +20,8 @@ | |||||
#include <google/protobuf/io/zero_copy_stream_impl.h> | #include <google/protobuf/io/zero_copy_stream_impl.h> | ||||
#include <google/protobuf/text_format.h> | #include <google/protobuf/text_format.h> | ||||
#include <fcntl.h> | |||||
#include <sys/stat.h> | #include <sys/stat.h> | ||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#include <unistd.h> | |||||
#include <algorithm> | #include <algorithm> | ||||
#include <cstring> | #include <cstring> | ||||
#include <fstream> | #include <fstream> | ||||
@@ -43,6 +41,7 @@ | |||||
#include "graph/debug/ge_attr_define.h" | #include "graph/debug/ge_attr_define.h" | ||||
#include "graph/utils/op_desc_utils.h" | #include "graph/utils/op_desc_utils.h" | ||||
#include "graph/utils/tensor_utils.h" | #include "graph/utils/tensor_utils.h" | ||||
#include "mmpa/mmpa_api.h" | |||||
using google::protobuf::io::FileOutputStream; | using google::protobuf::io::FileOutputStream; | ||||
@@ -68,6 +67,7 @@ const char *const kDumpStrPartition = "partition"; | |||||
const char *const kDumpStrOptimizeSubgraph = "OptimizeSubGraph"; | const char *const kDumpStrOptimizeSubgraph = "OptimizeSubGraph"; | ||||
const char *const kDumpStrSubgraphFunc = "sub_graph"; | const char *const kDumpStrSubgraphFunc = "sub_graph"; | ||||
const char *const kDumpStrAicpu = "Aicpu"; | const char *const kDumpStrAicpu = "Aicpu"; | ||||
const int32_t kNameMax = 255; | |||||
}; // namespace | }; // namespace | ||||
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::AddEdge(const OutDataAnchorPtr &src, | GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::AddEdge(const OutDataAnchorPtr &src, | ||||
@@ -538,9 +538,9 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void GraphUtils::RecordOriginalNa | |||||
} | } | ||||
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool GraphUtils::MatchDumpStr(const std::string &suffix) { | GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool GraphUtils::MatchDumpStr(const std::string &suffix) { | ||||
char *dump_level = std::getenv(kDumpGraphLevel); | |||||
int64_t dump_graph_level = | |||||
(dump_level != nullptr) ? std::strtol(dump_level, nullptr, kBaseOfIntegerValue) : kDumpLevel2; | |||||
char dump_level[MMPA_MAX_PATH] = {0x00}; | |||||
INT32 res = mmGetEnv(kDumpGraphLevel, dump_level, MMPA_MAX_PATH); | |||||
int64_t dump_graph_level = (res == EN_OK) ? std::strtol(dump_level, nullptr, kBaseOfIntegerValue) : kDumpLevel2; | |||||
if (dump_graph_level == kDumpLevel1) { | if (dump_graph_level == kDumpLevel1) { | ||||
return false; | return false; | ||||
@@ -565,8 +565,9 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void GraphUtils::DumpGEGraph(cons | |||||
bool is_always_dump, | bool is_always_dump, | ||||
const std::string &user_graph_name) { | const std::string &user_graph_name) { | ||||
#ifdef FMK_SUPPORT_DUMP | #ifdef FMK_SUPPORT_DUMP | ||||
char *dump_ge_graph = std::getenv(kDumpGeGraph); | |||||
GE_IF_BOOL_EXEC(dump_ge_graph == nullptr && !is_always_dump, return;); | |||||
char dump_ge_graph[MMPA_MAX_PATH] = {0x00}; | |||||
INT32 res = mmGetEnv(kDumpGeGraph, dump_ge_graph, MMPA_MAX_PATH); | |||||
GE_IF_BOOL_EXEC(res != EN_OK && !is_always_dump, return;); | |||||
// dump the graph according to different graph level | // dump the graph according to different graph level | ||||
if (GraphUtils::MatchDumpStr(suffix)) { | if (GraphUtils::MatchDumpStr(suffix)) { | ||||
@@ -615,9 +616,9 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void GraphUtils::DumpGEGraph(cons | |||||
GELOGE(GRAPH_FAILED, "parse from string failed."); | GELOGE(GRAPH_FAILED, "parse from string failed."); | ||||
return; | return; | ||||
} | } | ||||
char real_path[PATH_MAX] = {0x00}; | |||||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(proto_file.c_str()) >= PATH_MAX, return, "file path is too longer!"); | |||||
GE_IF_BOOL_EXEC(realpath(proto_file.c_str(), real_path) == nullptr, | |||||
char real_path[MMPA_MAX_PATH] = {0x00}; | |||||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(proto_file.c_str()) >= MMPA_MAX_PATH, return, "file path is too longer!"); | |||||
GE_IF_BOOL_EXEC(mmRealPath(proto_file.c_str(), real_path, MMPA_MAX_PATH) != EN_OK, | |||||
GELOGI("file %s does not exist, it will be created.", proto_file.c_str())); | GELOGI("file %s does not exist, it will be created.", proto_file.c_str())); | ||||
GraphUtils::WriteProtoToTextFile(ge_proto, real_path); | GraphUtils::WriteProtoToTextFile(ge_proto, real_path); | ||||
@@ -730,7 +731,7 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void GraphUtils::WriteProtoToText | |||||
const google::protobuf::Message &proto, const char *real_path) { | const google::protobuf::Message &proto, const char *real_path) { | ||||
#ifdef FMK_SUPPORT_DUMP | #ifdef FMK_SUPPORT_DUMP | ||||
const int FILE_AUTHORITY = 0600; | const int FILE_AUTHORITY = 0600; | ||||
int fd = open(real_path, O_WRONLY | O_CREAT | O_TRUNC, FILE_AUTHORITY); | |||||
int fd = mmOpen2(real_path, M_WRONLY | M_CREAT | O_TRUNC, FILE_AUTHORITY); | |||||
if (fd < 0) { | if (fd < 0) { | ||||
GELOGE(GRAPH_FAILED, "fail to open the file: %s, %s", real_path, strerror(errno)); | GELOGE(GRAPH_FAILED, "fail to open the file: %s, %s", real_path, strerror(errno)); | ||||
return; | return; | ||||
@@ -738,7 +739,7 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void GraphUtils::WriteProtoToText | |||||
google::protobuf::io::FileOutputStream *output = new (std::nothrow) FileOutputStream(fd); | google::protobuf::io::FileOutputStream *output = new (std::nothrow) FileOutputStream(fd); | ||||
if (output == nullptr) { | if (output == nullptr) { | ||||
GELOGE(GRAPH_FAILED, "Output is nullptr"); | GELOGE(GRAPH_FAILED, "Output is nullptr"); | ||||
if (close(fd) != 0) { | |||||
if (mmClose(fd) != 0) { | |||||
GELOGE(GRAPH_FAILED, "Close fileoutputstream failed"); | GELOGE(GRAPH_FAILED, "Close fileoutputstream failed"); | ||||
} | } | ||||
return; | return; | ||||
@@ -748,12 +749,12 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void GraphUtils::WriteProtoToText | |||||
GELOGE(GRAPH_FAILED, "Fail to write the file: %s", real_path); | GELOGE(GRAPH_FAILED, "Fail to write the file: %s", real_path); | ||||
delete output; | delete output; | ||||
output = nullptr; | output = nullptr; | ||||
GE_CHK_BOOL_EXEC(close(fd) == 0, return, "Close fileoutputstream failed"); | |||||
GE_CHK_BOOL_EXEC(mmClose(fd) == 0, return, "Close fileoutputstream failed"); | |||||
return; | return; | ||||
} | } | ||||
delete output; | delete output; | ||||
output = nullptr; | output = nullptr; | ||||
GE_CHK_BOOL_EXEC(close(fd) == 0, return, "Close fileoutputstream failed"); | |||||
GE_CHK_BOOL_EXEC(mmClose(fd) == 0, return, "Close fileoutputstream failed"); | |||||
FILE *file = fopen(real_path, "rb"); | FILE *file = fopen(real_path, "rb"); | ||||
if (file == nullptr) { | if (file == nullptr) { | ||||
@@ -770,7 +771,7 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void GraphUtils::WriteProtoToText | |||||
} | } | ||||
if (max_dump_file_size != 0 && fileSize != -1 && fileSize > max_dump_file_size) { | if (max_dump_file_size != 0 && fileSize != -1 && fileSize > max_dump_file_size) { | ||||
GELOGW("dump graph file size > maxDumpFileSize, maxDumpFileSize=%ld.", max_dump_file_size); | GELOGW("dump graph file size > maxDumpFileSize, maxDumpFileSize=%ld.", max_dump_file_size); | ||||
GE_IF_BOOL_EXEC(std::remove(real_path) != 0, GELOGW("remove %s failed", real_path)); | |||||
GE_IF_BOOL_EXEC(remove(real_path) != 0, GELOGW("remove %s failed", real_path)); | |||||
GE_CHK_BOOL_EXEC(fclose(file) == 0, return, "Fclose %s failed", real_path); | GE_CHK_BOOL_EXEC(fclose(file) == 0, return, "Fclose %s failed", real_path); | ||||
return; | return; | ||||
} | } | ||||
@@ -804,9 +805,10 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool GraphUtils::ReadProtoFromTex | |||||
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void GraphUtils::DumpGEGraphToOnnx(const ge::ComputeGraph &compute_graph, | GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void GraphUtils::DumpGEGraphToOnnx(const ge::ComputeGraph &compute_graph, | ||||
const std::string &suffix) { | const std::string &suffix) { | ||||
#ifdef FMK_SUPPORT_DUMP | #ifdef FMK_SUPPORT_DUMP | ||||
char *dump_ge_graph = std::getenv(kDumpGeGraph); | |||||
char dump_ge_graph[MMPA_MAX_PATH] = {0x00}; | |||||
INT32 res = mmGetEnv(kDumpGeGraph, dump_ge_graph, MMPA_MAX_PATH); | |||||
int64_t dump_ge_graph_level = | int64_t dump_ge_graph_level = | ||||
(dump_ge_graph != nullptr) ? std::strtol(dump_ge_graph, nullptr, kBaseOfIntegerValue) : OnnxUtils::NO_DUMP; | |||||
(res == EN_OK) ? std::strtol(dump_ge_graph, nullptr, kBaseOfIntegerValue) : OnnxUtils::NO_DUMP; | |||||
if ((dump_ge_graph_level == OnnxUtils::NO_DUMP) || (dump_ge_graph_level >= OnnxUtils::DUMP_LEVEL_END)) { | if ((dump_ge_graph_level == OnnxUtils::NO_DUMP) || (dump_ge_graph_level >= OnnxUtils::DUMP_LEVEL_END)) { | ||||
GELOGD("Skip DumpGEGraphToOnnx with dump_ge_graph_level %ld.", dump_ge_graph_level); | GELOGD("Skip DumpGEGraphToOnnx with dump_ge_graph_level %ld.", dump_ge_graph_level); | ||||
return; | return; | ||||
@@ -853,24 +855,26 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void GraphUtils::DumpGEGraphToOnn | |||||
stream_file_name << "_graph_" << compute_graph.GetGraphID(); | stream_file_name << "_graph_" << compute_graph.GetGraphID(); | ||||
stream_file_name << "_" << suffix << ".pbtxt"; | stream_file_name << "_" << suffix << ".pbtxt"; | ||||
std::string proto_file = stream_file_name.str(); | std::string proto_file = stream_file_name.str(); | ||||
if ((proto_file.length()) >= NAME_MAX) { | |||||
if ((proto_file.length()) >= kNameMax) { | |||||
GELOGE(GRAPH_FAILED, "File name is too longer!"); | GELOGE(GRAPH_FAILED, "File name is too longer!"); | ||||
return; | return; | ||||
} | } | ||||
std::unique_ptr<char[]> real_path(new (std::nothrow) char[PATH_MAX]{0}); | |||||
std::unique_ptr<char[]> real_path(new (std::nothrow) char[MMPA_MAX_PATH]{0}); | |||||
if (real_path == nullptr) { | if (real_path == nullptr) { | ||||
GELOGE(GRAPH_FAILED, "New real_path failed."); | GELOGE(GRAPH_FAILED, "New real_path failed."); | ||||
return; | return; | ||||
} | } | ||||
/// Returning nullptr means 3 case as follows: | /// Returning nullptr means 3 case as follows: | ||||
/// a.path is PATH_MAX chars or more | |||||
/// a.path is MMPA_MAX_PATH chars or more | |||||
/// b.the file does not exist | /// b.the file does not exist | ||||
/// c.the path has no permissions | /// c.the path has no permissions | ||||
/// Distinguish between last the two cases in the function WriteProtoToTextFile call open() | /// Distinguish between last the two cases in the function WriteProtoToTextFile call open() | ||||
if (realpath(proto_file.c_str(), real_path.get()) == nullptr) { | |||||
if (mmRealPath(proto_file.c_str(), real_path.get(), MMPA_MAX_PATH) != EN_OK) { | |||||
// For case a | // For case a | ||||
if (errno == ENAMETOOLONG) { | |||||
GELOGE(GRAPH_FAILED, "Call realpath failed: path is PATH_MAX chars or more."); | |||||
int err_num = errno; | |||||
// linux: ENAMETOOLONG windows: ERANGE | |||||
if (err_num == ENAMETOOLONG || err_num == ERANGE) { | |||||
GELOGE(GRAPH_FAILED, "Call realpath failed: path is MMPA_MAX_PATH chars or more."); | |||||
return; | return; | ||||
} | } | ||||
} | } | ||||
@@ -619,7 +619,7 @@ OpDescPtr OpDescUtils::CreateConstOp(const GeTensorPtr &tensor_ptr) { | |||||
const_opdesc->SetType(CONSTANT); | const_opdesc->SetType(CONSTANT); | ||||
thread_local int64_t const_count = 0; | thread_local int64_t const_count = 0; | ||||
const_opdesc->SetName("dynamic_const_" + std::to_string(GetTid()) + "_" + std::to_string(const_count)); | |||||
const_opdesc->SetName("dynamic_const_" + std::to_string(GeLog::GetTid()) + "_" + std::to_string(const_count)); | |||||
GELOGI("add const op: %s", const_opdesc->GetName().c_str()); | GELOGI("add const op: %s", const_opdesc->GetName().c_str()); | ||||
++const_count; | ++const_count; | ||||
@@ -18,6 +18,7 @@ | |||||
#define COMMON_GRAPH_UTILS_STRING_UTILS_H_ | #define COMMON_GRAPH_UTILS_STRING_UTILS_H_ | ||||
#include <algorithm> | #include <algorithm> | ||||
#include <cctype> | |||||
#include <functional> | #include <functional> | ||||
#include <sstream> | #include <sstream> | ||||
#include <string> | #include <string> | ||||
@@ -23,6 +23,7 @@ | |||||
#include "graph/ge_tensor.h" | #include "graph/ge_tensor.h" | ||||
#include "graph/types.h" | #include "graph/types.h" | ||||
#include "graph/utils/type_utils.h" | #include "graph/utils/type_utils.h" | ||||
#include "mmpa/mmpa_api.h" | |||||
namespace ge { | namespace ge { | ||||
namespace { | namespace { | ||||
@@ -181,8 +182,9 @@ static graphStatus CalcElementCntOfNc1hwc0(const std::vector<int64_t> &dims, Dat | |||||
/// | /// | ||||
static graphStatus CalcElementCntOfFractalZ(const std::vector<int64_t> &dims, DataType data_type, | static graphStatus CalcElementCntOfFractalZ(const std::vector<int64_t> &dims, DataType data_type, | ||||
int64_t &element_cnt) { | int64_t &element_cnt) { | ||||
static char *parser_priority = std::getenv("PARSER_PRIORITY"); | |||||
if (parser_priority != nullptr && string(parser_priority) == "cce") { | |||||
static char parser_priority[MMPA_MAX_PATH] = {0x00}; | |||||
INT32 res = mmGetEnv("PARSER_PRIORITY", parser_priority, MMPA_MAX_PATH); | |||||
if (res == EN_OK && string(parser_priority) == "cce") { | |||||
if (dims.size() != kDimSize4d) { | if (dims.size() != kDimSize4d) { | ||||
GELOGE(GRAPH_FAILED, "CalcElementCntOfFractalZ failed as dims.size=%zu is not %u.", dims.size(), kDimSize4d); | GELOGE(GRAPH_FAILED, "CalcElementCntOfFractalZ failed as dims.size=%zu is not %u.", dims.size(), kDimSize4d); | ||||
return GRAPH_FAILED; | return GRAPH_FAILED; | ||||
@@ -22,10 +22,10 @@ | |||||
namespace ge { | namespace ge { | ||||
bool NodeShapeTransUtils::CatchFormatAndShape() { | bool NodeShapeTransUtils::CatchFormatAndShape() { | ||||
inputs_ = op_desc_->GetAllInputName(); | |||||
outputs_ = op_desc_->GetAllOutputName(); | |||||
auto inputs = op_desc_->MutableAllInputName(); | |||||
auto outputs = op_desc_->MutableAllOutputName(); | |||||
for (auto &ele : inputs_) { | |||||
for (auto &ele : inputs) { | |||||
auto tensor_desc_input = op_desc_->MutableInputDesc(ele.first); | auto tensor_desc_input = op_desc_->MutableInputDesc(ele.first); | ||||
if (tensor_desc_input == nullptr) { | if (tensor_desc_input == nullptr) { | ||||
continue; | continue; | ||||
@@ -45,7 +45,7 @@ bool NodeShapeTransUtils::CatchFormatAndShape() { | |||||
tensor_desc_input->SetShape(tensor_desc_input->GetOriginShape()); | tensor_desc_input->SetShape(tensor_desc_input->GetOriginShape()); | ||||
} | } | ||||
for (auto &ele : outputs_) { | |||||
for (auto &ele : outputs) { | |||||
auto tensor_desc_output = op_desc_->MutableOutputDesc(ele.first); | auto tensor_desc_output = op_desc_->MutableOutputDesc(ele.first); | ||||
if (tensor_desc_output == nullptr) { | if (tensor_desc_output == nullptr) { | ||||
continue; | continue; | ||||
@@ -72,7 +72,10 @@ bool NodeShapeTransUtils::CatchFormatAndShape() { | |||||
} | } | ||||
bool NodeShapeTransUtils::UpdateFormatAndShape() { | bool NodeShapeTransUtils::UpdateFormatAndShape() { | ||||
for (auto &ele : inputs_) { | |||||
auto inputs = op_desc_->MutableAllInputName(); | |||||
auto outputs = op_desc_->MutableAllOutputName(); | |||||
for (auto &ele : inputs) { | |||||
auto tensor_desc_input = op_desc_->MutableInputDesc(ele.first); | auto tensor_desc_input = op_desc_->MutableInputDesc(ele.first); | ||||
if (tensor_desc_input == nullptr) { | if (tensor_desc_input == nullptr) { | ||||
continue; | continue; | ||||
@@ -107,7 +110,7 @@ bool NodeShapeTransUtils::UpdateFormatAndShape() { | |||||
tensor_desc_input->SetShape(GeShape(out_dims)); | tensor_desc_input->SetShape(GeShape(out_dims)); | ||||
} | } | ||||
for (auto &ele : outputs_) { | |||||
for (auto &ele : outputs) { | |||||
auto tensor_desc_output = op_desc_->MutableOutputDesc(ele.first); | auto tensor_desc_output = op_desc_->MutableOutputDesc(ele.first); | ||||
if (tensor_desc_output == nullptr) { | if (tensor_desc_output == nullptr) { | ||||
continue; | continue; | ||||
@@ -41,8 +41,6 @@ class NodeShapeTransUtils { | |||||
std::map<std::string, Format> map_format_out_; | std::map<std::string, Format> map_format_out_; | ||||
std::map<std::string, Format> map_ori_format_out_; | std::map<std::string, Format> map_ori_format_out_; | ||||
std::map<std::string, DataType> map_dtype_out_; | std::map<std::string, DataType> map_dtype_out_; | ||||
std::map<std::string, uint32_t> inputs_; | |||||
std::map<std::string, uint32_t> outputs_; | |||||
OpDescPtr op_desc_; | OpDescPtr op_desc_; | ||||
}; | }; | ||||
@@ -34,8 +34,8 @@ const std::set<std::string> kExeTypes = {DATA, NETOUTPUT}; | |||||
NodeNametoNodeNameMap TuningUtils::data_2_netoutput_; | NodeNametoNodeNameMap TuningUtils::data_2_netoutput_; | ||||
NodetoNodeNameMap TuningUtils::data_node_2_netoutput_; | NodetoNodeNameMap TuningUtils::data_node_2_netoutput_; | ||||
NodetoNodeMap TuningUtils::data_node_2_netoutput_node_; | NodetoNodeMap TuningUtils::data_node_2_netoutput_node_; | ||||
NodeSet TuningUtils::netoutput_nodes_; | |||||
NodeSet TuningUtils::merged_graph_nodes_; | |||||
NodeVec TuningUtils::netoutput_nodes_; | |||||
NodeVec TuningUtils::merged_graph_nodes_; | |||||
SubgraphCreateOutNode TuningUtils::create_output_; | SubgraphCreateOutNode TuningUtils::create_output_; | ||||
std::mutex TuningUtils::mutex_; | std::mutex TuningUtils::mutex_; | ||||
@@ -592,12 +592,12 @@ graphStatus TuningUtils::MergeSubGraph(ComputeGraphPtr &subgraph) { | |||||
(AttrUtils::GetListStr(op_desc, alias_name_attr, out_alias_name)) && (!out_alias_name.empty()); | (AttrUtils::GetListStr(op_desc, alias_name_attr, out_alias_name)) && (!out_alias_name.empty()); | ||||
if (has_valid_str) { | if (has_valid_str) { | ||||
std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
netoutput_nodes_.insert(node); | |||||
netoutput_nodes_.emplace_back(node); | |||||
} | } | ||||
} | } | ||||
{ | { | ||||
std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
merged_graph_nodes_.emplace(node); | |||||
merged_graph_nodes_.emplace_back(node); | |||||
} | } | ||||
GELOGD("TUU:subgraph %s add node %s success", subgraph->GetName().c_str(), node->GetName().c_str()); | GELOGD("TUU:subgraph %s add node %s success", subgraph->GetName().c_str(), node->GetName().c_str()); | ||||
} | } | ||||
@@ -627,13 +627,7 @@ graphStatus TuningUtils::RemoveDataNetoutputEdge(ComputeGraphPtr &graph) { | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
// 3. relink | // 3. relink | ||||
if (GraphUtils::RemoveEdge(src_out_anchor, net_output_in_anchor) != GRAPH_SUCCESS) { | |||||
GELOGE(FAILED, "TUU:remove edge from %s(%d) to %s(%d) failed. node_name:(data:%s;netoutput:%s), graph_name:%s", | |||||
GetNodeNameByAnchor(src_out_anchor.get()).c_str(), src_out_anchor->GetIdx(), | |||||
GetNodeNameByAnchor(net_output_in_anchor.get()).c_str(), net_output_in_anchor->GetIdx(), | |||||
data_node->GetName().c_str(), netoutput_node->GetName().c_str(), graph->GetName().c_str()); | |||||
return FAILED; | |||||
} | |||||
// unlink netoutput_node with it's input in stage 4 | |||||
GE_CHECK_NOTNULL(data_out_anchor); | GE_CHECK_NOTNULL(data_out_anchor); | ||||
for (const auto &peer_in_anchor : data_out_anchor->GetPeerAnchors()) { | for (const auto &peer_in_anchor : data_out_anchor->GetPeerAnchors()) { | ||||
if (GraphUtils::RemoveEdge(data_out_anchor, peer_in_anchor) != GRAPH_SUCCESS) { | if (GraphUtils::RemoveEdge(data_out_anchor, peer_in_anchor) != GRAPH_SUCCESS) { | ||||
@@ -704,4 +698,4 @@ graphStatus TuningUtils::GetInAndOutAnchorPair(NodePtr &data_node, NodePtr &out_ | |||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
} // namespace ge | |||||
} // namespace ge |
@@ -220,6 +220,11 @@ if (NOT ENABLE_ACL) | |||||
DAVINCI_SUPPORT_PROFILING | DAVINCI_SUPPORT_PROFILING | ||||
REUSE_MEMORY=1 | REUSE_MEMORY=1 | ||||
DAVINCI_CLOUD) | DAVINCI_CLOUD) | ||||
target_compile_options(ge_runner PRIVATE | |||||
-Werror | |||||
-Wno-deprecated-declarations | |||||
-Wno-unused-function | |||||
-Wno-maybe-uninitialized) | |||||
target_link_libraries(ge_runner | target_link_libraries(ge_runner | ||||
graph | graph | ||||
ge_common | ge_common | ||||
@@ -374,6 +379,11 @@ target_compile_definitions(ge_compiler PRIVATE | |||||
FMK_SUPPORT_DUMP | FMK_SUPPORT_DUMP | ||||
COMPILE_OMG_PACKAGE | COMPILE_OMG_PACKAGE | ||||
REUSE_MEMORY=1) | REUSE_MEMORY=1) | ||||
target_compile_options(ge_compiler PRIVATE | |||||
-Werror | |||||
-Wno-deprecated-declarations | |||||
-Wno-unused-function | |||||
-Wno-maybe-uninitialized) | |||||
target_link_libraries(ge_compiler | target_link_libraries(ge_compiler | ||||
graph | graph | ||||
ge_common | ge_common | ||||
@@ -76,7 +76,7 @@ Status CheckOptionsValid(const std::map<string, string> &options) { | |||||
} | } | ||||
// Initialize GE, prepare for execution, call GELib::Initialize | // Initialize GE, prepare for execution, call GELib::Initialize | ||||
Status GEInitialize(const std::map<string, string> &options) { | |||||
Status GEInitializeImpl(const std::map<string, string> &options) { | |||||
GELOGT(TRACE_INIT, "GEInitialize start"); | GELOGT(TRACE_INIT, "GEInitialize start"); | ||||
// 0.check init status | // 0.check init status | ||||
if (g_ge_initialized) { | if (g_ge_initialized) { | ||||
@@ -127,6 +127,23 @@ Status GEInitialize(const std::map<string, string> &options) { | |||||
return ret; | return ret; | ||||
} | } | ||||
// Initialize GE, prepare for execution, call GELib::Initialize | |||||
Status GEInitialize(const std::map<string, string> &options) { return GEInitializeImpl(options); } | |||||
Status GEInitialize(const std::map<AscendString, AscendString> &options) { | |||||
std::map<std::string, std::string> str_options; | |||||
for (auto &option : options) { | |||||
if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { | |||||
GELOGE(FAILED, "GEInitialize options is nullptr."); | |||||
return FAILED; | |||||
} | |||||
std::string key = option.first.GetString(); | |||||
std::string val = option.second.GetString(); | |||||
str_options[key] = val; | |||||
} | |||||
return GEInitializeImpl(str_options); | |||||
} | |||||
// GE finalize, releasing all resources | // GE finalize, releasing all resources | ||||
Status GEFinalize() { | Status GEFinalize() { | ||||
GELOGT(TRACE_INIT, "GEFinalize start"); | GELOGT(TRACE_INIT, "GEFinalize start"); | ||||
@@ -177,7 +194,7 @@ Session::Session(const std::map<string, string> &options) { | |||||
// check init status | // check init status | ||||
sessionId_ = 0; | sessionId_ = 0; | ||||
if (!g_ge_initialized) { | if (!g_ge_initialized) { | ||||
GELOGE(GE_CLI_GE_NOT_INITIALIZED); | |||||
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized."); | |||||
return; | return; | ||||
} | } | ||||
// call Initialize | // call Initialize | ||||
@@ -202,6 +219,46 @@ Session::Session(const std::map<string, string> &options) { | |||||
GELOGT(TRACE_STOP, "Session Constructor finished"); | GELOGT(TRACE_STOP, "Session Constructor finished"); | ||||
} | } | ||||
Session::Session(const std::map<AscendString, AscendString> &options) { | |||||
GELOGT(TRACE_INIT, "Session Constructor start"); | |||||
// check init status | |||||
sessionId_ = 0; | |||||
if (!g_ge_initialized) { | |||||
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized."); | |||||
return; | |||||
} | |||||
// call Initialize | |||||
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | |||||
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | |||||
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Session Constructor failed"); | |||||
return; | |||||
} | |||||
GELOGT(TRACE_RUNNING, "Creating session"); | |||||
std::map<std::string, std::string> str_options; | |||||
for (auto &option : options) { | |||||
if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { | |||||
GELOGE(FAILED, "Session options is nullptr."); | |||||
return; | |||||
} | |||||
std::string key = option.first.GetString(); | |||||
std::string val = option.second.GetString(); | |||||
str_options[key] = val; | |||||
} | |||||
uint64_t session_id = 0; | |||||
Status ret = instance_ptr->SessionManagerObj().CreateSession(str_options, session_id); | |||||
GELOGT(TRACE_RUNNING, "Session id is %lu", session_id); | |||||
// check return status, return, update session id if success | |||||
if (ret == SUCCESS) { | |||||
sessionId_ = session_id; | |||||
} else { | |||||
GELOGE(ret, "Session constructor failed, session Id not initialized"); | |||||
return; | |||||
} | |||||
GELOGT(TRACE_STOP, "Session Constructor finished"); | |||||
} | |||||
// session destructor | // session destructor | ||||
Session::~Session() { | Session::~Session() { | ||||
GELOGT(TRACE_INIT, "Session Destructor start"); | GELOGT(TRACE_INIT, "Session Destructor start"); | ||||
@@ -260,6 +317,33 @@ Status Session::AddGraph(uint32_t graph_id, const Graph &graph, const std::map<s | |||||
return ret; | return ret; | ||||
} | } | ||||
Status Session::AddGraph(uint32_t graph_id, const Graph &graph, const std::map<AscendString, AscendString> &options) { | |||||
GELOGT(TRACE_INIT, "Start to add graph in Session. graph_id: %u, session_id: %lu.", graph_id, sessionId_); | |||||
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | |||||
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | |||||
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "AddGraph failed in Session."); | |||||
return FAILED; | |||||
} | |||||
GELOGD("Adding graph to session"); | |||||
std::map<std::string, std::string> str_options; | |||||
for (auto &option : options) { | |||||
if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { | |||||
GELOGE(FAILED, "AddGraph options is nullptr."); | |||||
return FAILED; | |||||
} | |||||
std::string key = option.first.GetString(); | |||||
std::string val = option.second.GetString(); | |||||
str_options[key] = val; | |||||
} | |||||
Status ret = instance_ptr->SessionManagerObj().AddGraph(sessionId_, graph_id, graph, str_options); | |||||
if (ret != SUCCESS) { | |||||
GELOGE(ret, "AddGraph failed in Session."); | |||||
return FAILED; | |||||
} | |||||
GELOGD("AddGraph finished in Session."); | |||||
return ret; | |||||
} | |||||
Status Session::AddGraphWithCopy(uint32_t graph_id, const Graph &graph) { | Status Session::AddGraphWithCopy(uint32_t graph_id, const Graph &graph) { | ||||
std::map<AscendString, AscendString> options; | std::map<AscendString, AscendString> options; | ||||
return AddGraphWithCopy(graph_id, graph, options); | return AddGraphWithCopy(graph_id, graph, options); | ||||
@@ -387,6 +471,14 @@ Status Session::RegisterCallBackFunc(const std::string &key, const pCallBackFunc | |||||
return ge::GELib::GetInstance()->SessionManagerObj().RegisterCallBackFunc(sessionId_, key, callback); | return ge::GELib::GetInstance()->SessionManagerObj().RegisterCallBackFunc(sessionId_, key, callback); | ||||
} | } | ||||
Status Session::RegisterCallBackFunc(const char *key, const session::pCallBackFunc &callback) { | |||||
std::string str_key; | |||||
if (key != nullptr) { | |||||
str_key = key; | |||||
} | |||||
return ge::GELib::GetInstance()->SessionManagerObj().RegisterCallBackFunc(sessionId_, str_key, callback); | |||||
} | |||||
Status Session::BuildGraph(uint32_t graph_id, const std::vector<InputTensorInfo> &inputs) { | Status Session::BuildGraph(uint32_t graph_id, const std::vector<InputTensorInfo> &inputs) { | ||||
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | ||||
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | ||||
@@ -436,6 +528,29 @@ Status Session::GetVariables(const std::vector<std::string> &var_names, std::vec | |||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
Status Session::GetVariables(const std::vector<AscendString> &var_names, std::vector<Tensor> &var_values) { | |||||
auto instance_ptr = ge::GELib::GetInstance(); | |||||
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | |||||
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "SessionConstructor failed"); | |||||
return FAILED; | |||||
} | |||||
GELOGT(TRACE_RUNNING, "Get Variables"); | |||||
std::vector<ge::string> str_var_names; | |||||
for (auto &var_name : var_names) { | |||||
if (var_name.GetString() == nullptr) { | |||||
GELOGE(FAILED, "GetVariables name is nullptr."); | |||||
return FAILED; | |||||
} | |||||
str_var_names.emplace_back(var_name.GetString()); | |||||
} | |||||
Status ret = ge::GELib::GetInstance()->SessionManagerObj().GetVariables(sessionId_, str_var_names, var_values); | |||||
if (ret != SUCCESS) { | |||||
GELOGE(ret, "SessionManager RunGraphAsync failed"); | |||||
return FAILED; | |||||
} | |||||
return SUCCESS; | |||||
} | |||||
bool Session::IsGraphNeedRebuild(uint32_t graph_id) { | bool Session::IsGraphNeedRebuild(uint32_t graph_id) { | ||||
return ge::GELib::GetInstance()->SessionManagerObj().IsGraphNeedRebuild(sessionId_, graph_id); | return ge::GELib::GetInstance()->SessionManagerObj().IsGraphNeedRebuild(sessionId_, graph_id); | ||||
} | } | ||||
@@ -90,6 +90,9 @@ target_compile_definitions(ge_common PUBLIC | |||||
PROTOBUF_INLINE_NOT_IN_HEADERS=0 | PROTOBUF_INLINE_NOT_IN_HEADERS=0 | ||||
HOST_VISIBILITY | HOST_VISIBILITY | ||||
OS_CENTOS) | OS_CENTOS) | ||||
target_compile_options(ge_common PRIVATE | |||||
-Werror | |||||
-Wno-deprecated-declarations) | |||||
target_link_libraries(ge_common | target_link_libraries(ge_common | ||||
graph | graph | ||||
${PROTOBUF_LIBRARY} | ${PROTOBUF_LIBRARY} | ||||
@@ -16,9 +16,7 @@ | |||||
#include "common/auth/file_saver.h" | #include "common/auth/file_saver.h" | ||||
#include <fcntl.h> | |||||
#include <securec.h> | #include <securec.h> | ||||
#include <unistd.h> | |||||
#include <cstdlib> | #include <cstdlib> | ||||
#include <fstream> | #include <fstream> | ||||
#include <vector> | #include <vector> | ||||
@@ -39,12 +37,12 @@ Status FileSaver::OpenFile(int32_t &fd, const std::string &file_path) { | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
char real_path[PATH_MAX] = {0}; | |||||
GE_IF_BOOL_EXEC(realpath(file_path.c_str(), real_path) == nullptr, | |||||
char real_path[MMPA_MAX_PATH] = {0}; | |||||
GE_IF_BOOL_EXEC(mmRealPath(file_path.c_str(), real_path, MMPA_MAX_PATH) != EN_OK, | |||||
GELOGI("File %s is not exist, it will be created.", file_path.c_str())); | GELOGI("File %s is not exist, it will be created.", file_path.c_str())); | ||||
// Open file | // Open file | ||||
mode_t mode = S_IRUSR | S_IWUSR; | |||||
fd = mmOpen2(real_path, O_RDWR | O_CREAT | O_TRUNC, mode); | |||||
mmMode_t mode = M_IRUSR | M_IWUSR; | |||||
fd = mmOpen2(real_path, M_RDWR | M_CREAT | O_TRUNC, mode); | |||||
if (fd == EN_INVALID_PARAM || fd == EN_ERROR) { | if (fd == EN_INVALID_PARAM || fd == EN_ERROR) { | ||||
// -1: Failed to open file; - 2: Illegal parameter | // -1: Failed to open file; - 2: Illegal parameter | ||||
GELOGE(FAILED, "Open file failed. mmpa_errno = %d, %s", fd, strerror(errno)); | GELOGE(FAILED, "Open file failed. mmpa_errno = %d, %s", fd, strerror(errno)); | ||||
@@ -193,7 +191,7 @@ Status FileSaver::SaveToBuffWithFileHeader(const ModelFileHeader &file_header, | |||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::CheckPath(const std::string &file_path) { | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::CheckPath(const std::string &file_path) { | ||||
// Determine file path length | // Determine file path length | ||||
if (file_path.size() >= PATH_MAX) { | |||||
if (file_path.size() >= MMPA_MAX_PATH) { | |||||
GELOGE(FAILED, "Path is too long:%zu", file_path.size()); | GELOGE(FAILED, "Path is too long:%zu", file_path.size()); | ||||
return FAILED; | return FAILED; | ||||
} | } | ||||
@@ -23,7 +23,7 @@ CustAICPUKernelStore::CustAICPUKernelStore() {} | |||||
void CustAICPUKernelStore::AddCustAICPUKernel(const CustAICPUKernelPtr &kernel) { AddKernel(kernel); } | void CustAICPUKernelStore::AddCustAICPUKernel(const CustAICPUKernelPtr &kernel) { AddKernel(kernel); } | ||||
void CustAICPUKernelStore::LoadCustAICPUKernelBinToOpDesc(const std::shared_ptr<ge::OpDesc> &op_desc) const { | void CustAICPUKernelStore::LoadCustAICPUKernelBinToOpDesc(const std::shared_ptr<ge::OpDesc> &op_desc) const { | ||||
GELOGI("LoadCustAICPUKernelBinToOpDesc in"); | |||||
GELOGD("LoadCustAICPUKernelBinToOpDesc in"); | |||||
if (op_desc != nullptr) { | if (op_desc != nullptr) { | ||||
auto kernel_bin = FindKernel(op_desc->GetName()); | auto kernel_bin = FindKernel(op_desc->GetName()); | ||||
if (kernel_bin != nullptr) { | if (kernel_bin != nullptr) { | ||||
@@ -32,6 +32,6 @@ void CustAICPUKernelStore::LoadCustAICPUKernelBinToOpDesc(const std::shared_ptr< | |||||
GELOGI("Load cust aicpu kernel:%s, %zu", kernel_bin->GetName().c_str(), kernel_bin->GetBinDataSize()); | GELOGI("Load cust aicpu kernel:%s, %zu", kernel_bin->GetName().c_str(), kernel_bin->GetBinDataSize()); | ||||
} | } | ||||
} | } | ||||
GELOGI("LoadCustAICPUKernelBinToOpDesc success"); | |||||
GELOGD("LoadCustAICPUKernelBinToOpDesc success"); | |||||
} | } | ||||
} // namespace ge | } // namespace ge |
@@ -16,9 +16,6 @@ | |||||
#include "common/debug/memory_dumper.h" | #include "common/debug/memory_dumper.h" | ||||
#include <fcntl.h> | |||||
#include <unistd.h> | |||||
#include <string> | #include <string> | ||||
#include "framework/common/debug/log.h" | #include "framework/common/debug/log.h" | ||||
@@ -138,26 +135,26 @@ int MemoryDumper::OpenFile(const char *filename) { | |||||
} | } | ||||
// Get the absolute path | // Get the absolute path | ||||
string real_path; | string real_path; | ||||
char tmp_path[PATH_MAX] = {0}; | |||||
GE_IF_BOOL_EXEC( | |||||
-1 != path_split_pos, string prefix_path = std::string(filename).substr(0, path_split_pos); | |||||
string last_path = std::string(filename).substr(path_split_pos, strlen(filename) - 1); | |||||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(prefix_path.length() >= PATH_MAX, return kInvalidFd, "Prefix path is too long!"); | |||||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(realpath(prefix_path.c_str(), tmp_path) == nullptr, return kInvalidFd, | |||||
"Dir %s does not exit.", prefix_path.c_str()); | |||||
real_path = std::string(tmp_path) + last_path;) | |||||
char tmp_path[MMPA_MAX_PATH] = {0}; | |||||
GE_IF_BOOL_EXEC(-1 != path_split_pos, string prefix_path = std::string(filename).substr(0, path_split_pos); | |||||
string last_path = std::string(filename).substr(path_split_pos, strlen(filename) - 1); | |||||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(prefix_path.length() >= MMPA_MAX_PATH, return kInvalidFd, | |||||
"Prefix path is too long!"); | |||||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(mmRealPath(prefix_path.c_str(), tmp_path, MMPA_MAX_PATH) != EN_OK, | |||||
return kInvalidFd, "Dir %s does not exit.", prefix_path.c_str()); | |||||
real_path = std::string(tmp_path) + last_path;) | |||||
GE_IF_BOOL_EXEC( | GE_IF_BOOL_EXEC( | ||||
path_split_pos == -1 || path_split_pos == 0, | path_split_pos == -1 || path_split_pos == 0, | ||||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(filename) >= PATH_MAX, return kInvalidFd, "Prefix path is too long!"); | |||||
GE_IF_BOOL_EXEC(realpath(filename, tmp_path) == nullptr, | |||||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(filename) >= MMPA_MAX_PATH, return kInvalidFd, "Prefix path is too long!"); | |||||
GE_IF_BOOL_EXEC(mmRealPath(filename, tmp_path, MMPA_MAX_PATH) != EN_OK, | |||||
GELOGI("File %s does not exit, it will be created.", filename)); | GELOGI("File %s does not exit, it will be created.", filename)); | ||||
real_path = std::string(tmp_path);) | real_path = std::string(tmp_path);) | ||||
// Open file, only the current user can read and write, to avoid malicious application access | // Open file, only the current user can read and write, to avoid malicious application access | ||||
// Using the O_EXCL, if the file already exists,return failed to avoid privilege escalation vulnerability. | // Using the O_EXCL, if the file already exists,return failed to avoid privilege escalation vulnerability. | ||||
mode_t mode = S_IRUSR | S_IWUSR; | |||||
mmMode_t mode = M_IRUSR | M_IWUSR; | |||||
int32_t fd = mmOpen2(real_path.c_str(), O_RDWR | O_CREAT | O_APPEND, mode); | |||||
int32_t fd = mmOpen2(real_path.c_str(), M_RDWR | M_CREAT | O_TRUNC, mode); | |||||
if (fd == EN_ERROR || fd == EN_INVALID_PARAM) { | if (fd == EN_ERROR || fd == EN_INVALID_PARAM) { | ||||
GELOGE(kInvalidFd, "open file failed. errno = %d, %s", fd, strerror(errno)); | GELOGE(kInvalidFd, "open file failed. errno = %d, %s", fd, strerror(errno)); | ||||
return kInvalidFd; | return kInvalidFd; | ||||
@@ -118,19 +118,19 @@ Status TransFormatFromNchwToFzC04(const TransArgs &args, TransResult &result) { | |||||
// data overflow check totally | // data overflow check totally | ||||
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(h_o, w_o), | GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(h_o, w_o), | ||||
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%lld], B[%lld]", h_o, w_o); | |||||
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", h_o, w_o); | |||||
return INTERNAL_ERROR); | return INTERNAL_ERROR); | ||||
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(n_o, c_o), | GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(n_o, c_o), | ||||
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%lld], B[%lld]", n_o, c_o); | |||||
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", n_o, c_o); | |||||
return INTERNAL_ERROR); | return INTERNAL_ERROR); | ||||
auto t1 = h_o * w_o; | auto t1 = h_o * w_o; | ||||
auto t2 = n_o * c_o; | auto t2 = n_o * c_o; | ||||
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(t1, t2), GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%lld], B[%lld]", t1, t2); | |||||
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(t1, t2), GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", t1, t2); | |||||
return INTERNAL_ERROR); | return INTERNAL_ERROR); | ||||
int64_t total_ele_cnt = n_o * c_o * h_o * w_o; | int64_t total_ele_cnt = n_o * c_o * h_o * w_o; | ||||
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(total_ele_cnt, size), | GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(total_ele_cnt, size), | ||||
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%lld], B[%lld]", total_ele_cnt, size); | |||||
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%d]", total_ele_cnt, size); | |||||
return INTERNAL_ERROR); | return INTERNAL_ERROR); | ||||
int64_t dst_size = total_ele_cnt * size; | int64_t dst_size = total_ele_cnt * size; | ||||
if (dst_size == 0) { | if (dst_size == 0) { | ||||
@@ -205,20 +205,20 @@ Status PaddingNC(const TransArgs &args, TransArgs &args_tmp, std::shared_ptr<uin | |||||
// data overflow check | // data overflow check | ||||
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(h_o, w_o), | GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(h_o, w_o), | ||||
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%lld], B[%lld]", h_o, w_o); | |||||
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", h_o, w_o); | |||||
return INTERNAL_ERROR); | return INTERNAL_ERROR); | ||||
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(n_o, c_o), | GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(n_o, c_o), | ||||
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%lld], B[%lld]", n_o, c_o); | |||||
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", n_o, c_o); | |||||
return INTERNAL_ERROR); | return INTERNAL_ERROR); | ||||
auto t1 = h_o * w_o; | auto t1 = h_o * w_o; | ||||
auto t2 = n_o * c_o; | auto t2 = n_o * c_o; | ||||
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(t1, t2), GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%lld], B[%lld]", t1, t2); | |||||
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(t1, t2), GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", t1, t2); | |||||
return INTERNAL_ERROR); | return INTERNAL_ERROR); | ||||
int64_t total_ele_cnt = n_o * c_o * h_o * w_o; | int64_t total_ele_cnt = n_o * c_o * h_o * w_o; | ||||
int size = GetSizeByDataType(args.src_data_type); | int size = GetSizeByDataType(args.src_data_type); | ||||
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(total_ele_cnt, size), | GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(total_ele_cnt, size), | ||||
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%lld], B[%lld]", total_ele_cnt, size); | |||||
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%d]", total_ele_cnt, size); | |||||
return INTERNAL_ERROR); | return INTERNAL_ERROR); | ||||
int64_t dst_size = total_ele_cnt * size; | int64_t dst_size = total_ele_cnt * size; | ||||
@@ -30,8 +30,10 @@ const uint8_t kPrefixIndex = 9; | |||||
namespace ge { | namespace ge { | ||||
void OpTilingManager::ClearHandles() noexcept { | void OpTilingManager::ClearHandles() noexcept { | ||||
for (const auto &handle : handles_) { | for (const auto &handle : handles_) { | ||||
if (dlclose(handle.second) != 0) { | |||||
GELOGE(FAILED, "Failed to close handle of %s: %s", handle.first.c_str(), dlerror()); | |||||
if (mmDlclose(handle.second) != 0) { | |||||
const char *error = mmDlerror(); | |||||
GE_IF_BOOL_EXEC(error == nullptr, error = ""); | |||||
GELOGE(FAILED, "Failed to close handle of %s: %s", handle.first.c_str(), error); | |||||
} | } | ||||
} | } | ||||
handles_.clear(); | handles_.clear(); | ||||
@@ -40,11 +42,12 @@ void OpTilingManager::ClearHandles() noexcept { | |||||
OpTilingManager::~OpTilingManager() { ClearHandles(); } | OpTilingManager::~OpTilingManager() { ClearHandles(); } | ||||
std::string OpTilingManager::GetPath() { | std::string OpTilingManager::GetPath() { | ||||
const char *opp_path_env = std::getenv(kEnvName); | |||||
char opp_path_env[MMPA_MAX_PATH] = {0x00}; | |||||
INT32 res = mmGetEnv(kEnvName, opp_path_env, MMPA_MAX_PATH); | |||||
std::string opp_path = kDefaultPath; | std::string opp_path = kDefaultPath; | ||||
if (opp_path_env != nullptr) { | |||||
char resolved_path[PATH_MAX]; | |||||
if (realpath(opp_path_env, resolved_path) == NULL) { | |||||
if (res == EN_OK) { | |||||
char resolved_path[MMPA_MAX_PATH]; | |||||
if (mmRealPath(opp_path_env, resolved_path, MMPA_MAX_PATH) != EN_OK) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E19024", {"env", "value", "situation"}, | ErrorManager::GetInstance().ATCReportErrMessage("E19024", {"env", "value", "situation"}, | ||||
{"ASCEND_OPP_PATH", opp_path_env, "loading the tiling lib"}); | {"ASCEND_OPP_PATH", opp_path_env, "loading the tiling lib"}); | ||||
GELOGE(PARAM_INVALID, "Failed load tiling lib as env 'ASCEND_OPP_PATH'[%s] is invalid path.", opp_path_env); | GELOGE(PARAM_INVALID, "Failed load tiling lib as env 'ASCEND_OPP_PATH'[%s] is invalid path.", opp_path_env); | ||||
@@ -66,16 +69,20 @@ void OpTilingManager::LoadSo() { | |||||
std::string built_in_name = kDefaultBuiltInTilingPath.substr(kPrefixIndex); | std::string built_in_name = kDefaultBuiltInTilingPath.substr(kPrefixIndex); | ||||
std::string custom_name = kDefaultCustomTilingPath.substr(kPrefixIndex); | std::string custom_name = kDefaultCustomTilingPath.substr(kPrefixIndex); | ||||
void *handle_bi = dlopen(built_in_tiling_lib.c_str(), RTLD_NOW | RTLD_GLOBAL); | |||||
void *handle_bi = mmDlopen(built_in_tiling_lib.c_str(), MMPA_RTLD_NOW | MMPA_RTLD_GLOBAL); | |||||
if (handle_bi == nullptr) { | if (handle_bi == nullptr) { | ||||
GELOGW("Failed to dlopen %s!", dlerror()); | |||||
const char *error = mmDlerror(); | |||||
GE_IF_BOOL_EXEC(error == nullptr, error = ""); | |||||
GELOGW("Failed to dlopen %s!", error); | |||||
} else { | } else { | ||||
handles_[built_in_name] = handle_bi; | handles_[built_in_name] = handle_bi; | ||||
} | } | ||||
void *handle_ct = dlopen(custom_tiling_lib.c_str(), RTLD_NOW | RTLD_GLOBAL); | |||||
void *handle_ct = mmDlopen(custom_tiling_lib.c_str(), MMPA_RTLD_NOW | MMPA_RTLD_GLOBAL); | |||||
if (handle_ct == nullptr) { | if (handle_ct == nullptr) { | ||||
GELOGW("Failed to dlopen %s!", dlerror()); | |||||
const char *error = mmDlerror(); | |||||
GE_IF_BOOL_EXEC(error == nullptr, error = ""); | |||||
GELOGW("Failed to dlopen %s!", error); | |||||
} else { | } else { | ||||
handles_[custom_name] = handle_ct; | handles_[custom_name] = handle_ct; | ||||
} | } | ||||
@@ -16,9 +16,7 @@ | |||||
#include "common/ge/plugin_manager.h" | #include "common/ge/plugin_manager.h" | ||||
#include <dirent.h> | |||||
#include <sys/stat.h> | #include <sys/stat.h> | ||||
#include <unistd.h> | |||||
#include <algorithm> | #include <algorithm> | ||||
#include <cstring> | #include <cstring> | ||||
#include <fstream> | #include <fstream> | ||||
@@ -38,8 +36,10 @@ const char *const kExt = ".so"; // supported extension of shared obje | |||||
namespace ge { | namespace ge { | ||||
void PluginManager::ClearHandles_() noexcept { | void PluginManager::ClearHandles_() noexcept { | ||||
for (const auto &handle : handles_) { | for (const auto &handle : handles_) { | ||||
if (dlclose(handle.second) != 0) { | |||||
GELOGW("Failed to close handle of %s: %s", handle.first.c_str(), dlerror()); | |||||
if (mmDlclose(handle.second) != 0) { | |||||
const char *error = mmDlerror(); | |||||
GE_IF_BOOL_EXEC(error == nullptr, error = ""); | |||||
GELOGW("Failed to close handle of %s: %s", handle.first.c_str(), error); | |||||
} | } | ||||
} | } | ||||
handles_.clear(); | handles_.clear(); | ||||
@@ -48,18 +48,18 @@ void PluginManager::ClearHandles_() noexcept { | |||||
PluginManager::~PluginManager() { ClearHandles_(); } | PluginManager::~PluginManager() { ClearHandles_(); } | ||||
string PluginManager::GetPath() { | string PluginManager::GetPath() { | ||||
Dl_info dl_info; | |||||
if (dladdr(reinterpret_cast<void *>(&PluginManager::GetPath), &dl_info) == 0) { | |||||
mmDlInfo dl_info; | |||||
if (mmDladdr(reinterpret_cast<void *>(&PluginManager::GetPath), &dl_info) != EN_OK) { | |||||
GELOGW("Failed to read the shared library file path!"); | GELOGW("Failed to read the shared library file path!"); | ||||
return string(); | return string(); | ||||
} else { | } else { | ||||
std::string so_path = dl_info.dli_fname; | std::string so_path = dl_info.dli_fname; | ||||
char path[PATH_MAX] = {0}; | |||||
if (so_path.length() >= PATH_MAX) { | |||||
char path[MMPA_MAX_PATH] = {0}; | |||||
if (so_path.length() >= MMPA_MAX_PATH) { | |||||
GELOGW("The shared library file path is too long!"); | GELOGW("The shared library file path is too long!"); | ||||
return string(); | return string(); | ||||
} | } | ||||
if (realpath(so_path.c_str(), path) == nullptr) { | |||||
if (mmRealPath(so_path.c_str(), path, MMPA_MAX_PATH) != EN_OK) { | |||||
GELOGW("Failed to get realpath of %s", so_path.c_str()); | GELOGW("Failed to get realpath of %s", so_path.c_str()); | ||||
return string(); | return string(); | ||||
} | } | ||||
@@ -93,7 +93,7 @@ Status PluginManager::LoadSo(const string &path, const vector<string> &func_chec | |||||
std::vector<std::string> path_vec; | std::vector<std::string> path_vec; | ||||
SplitPath(path, path_vec); | SplitPath(path, path_vec); | ||||
for (const auto &single_path : path_vec) { | for (const auto &single_path : path_vec) { | ||||
GE_IF_BOOL_EXEC(single_path.length() >= PATH_MAX, | |||||
GE_IF_BOOL_EXEC(single_path.length() >= MMPA_MAX_PATH, | |||||
GELOGE(GE_PLGMGR_PATH_INVALID, "The shared library file path is too long!"); | GELOGE(GE_PLGMGR_PATH_INVALID, "The shared library file path is too long!"); | ||||
continue); | continue); | ||||
// load break when number of loaded so reach maximum | // load break when number of loaded so reach maximum | ||||
@@ -121,16 +121,18 @@ Status PluginManager::LoadSo(const string &path, const vector<string> &func_chec | |||||
GELOGI("dlopen the shared library path name: %s.", file_path_dlopen.c_str()); | GELOGI("dlopen the shared library path name: %s.", file_path_dlopen.c_str()); | ||||
// load continue when dlopen is failed | // load continue when dlopen is failed | ||||
auto handle = dlopen(file_path_dlopen.c_str(), RTLD_NOW | RTLD_GLOBAL); | |||||
auto handle = mmDlopen(file_path_dlopen.c_str(), MMPA_RTLD_NOW | MMPA_RTLD_GLOBAL); | |||||
if (handle == nullptr) { | if (handle == nullptr) { | ||||
GELOGE(GE_PLGMGR_PATH_INVALID, "Failed to dlopen %s!", dlerror()); | |||||
const char *error = mmDlerror(); | |||||
GE_IF_BOOL_EXEC(error == nullptr, error = ""); | |||||
GELOGE(GE_PLGMGR_PATH_INVALID, "Failed to dlopen %s!", error); | |||||
continue; | continue; | ||||
} | } | ||||
// load continue when so is invalid | // load continue when so is invalid | ||||
bool is_valid = true; | bool is_valid = true; | ||||
for (const auto &func_name : func_check_list) { | for (const auto &func_name : func_check_list) { | ||||
auto real_fn = (void (*)())dlsym(handle, func_name.c_str()); | |||||
auto real_fn = (void (*)())mmDlsym(handle, const_cast<char *>(func_name.c_str())); | |||||
if (real_fn == nullptr) { | if (real_fn == nullptr) { | ||||
GELOGE(GE_PLGMGR_PATH_INVALID, "%s is skipped since function %s is not existed!", func_name.c_str(), | GELOGE(GE_PLGMGR_PATH_INVALID, "%s is skipped since function %s is not existed!", func_name.c_str(), | ||||
func_name.c_str()); | func_name.c_str()); | ||||
@@ -139,7 +141,7 @@ Status PluginManager::LoadSo(const string &path, const vector<string> &func_chec | |||||
} | } | ||||
} | } | ||||
if (!is_valid) { | if (!is_valid) { | ||||
GE_LOGE_IF(dlclose(handle), "Failed to dlclose."); | |||||
GE_LOGE_IF(mmDlclose(handle), "Failed to dlclose."); | |||||
continue; | continue; | ||||
} | } | ||||
@@ -199,22 +201,29 @@ Status PluginManager::Load(const string &path, const vector<string> &func_check_ | |||||
so_list_.clear(); | so_list_.clear(); | ||||
ClearHandles_(); | ClearHandles_(); | ||||
char canonical_path[PATH_MAX] = {0}; | |||||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(path.length() >= PATH_MAX, GELOGW("File path is too long!"); | |||||
char canonical_path[MMPA_MAX_PATH] = {0}; | |||||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(path.length() >= MMPA_MAX_PATH, GELOGW("File path is too long!"); | |||||
return FAILED, "File path is too long!"); | return FAILED, "File path is too long!"); | ||||
if (realpath(path.c_str(), canonical_path) == nullptr) { | |||||
if (mmRealPath(path.c_str(), canonical_path, MMPA_MAX_PATH) != EN_OK) { | |||||
GELOGW("Failed to get realpath of %s", path.c_str()); | GELOGW("Failed to get realpath of %s", path.c_str()); | ||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
DIR *dir = opendir(canonical_path); | |||||
if (dir == nullptr) { | |||||
INT32 is_dir = mmIsDir(canonical_path); | |||||
// Lib plugin path not exist | |||||
if (is_dir != EN_OK) { | |||||
GELOGW("Invalid path for load: %s", path.c_str()); | GELOGW("Invalid path for load: %s", path.c_str()); | ||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
struct dirent *entry = nullptr; | |||||
while ((entry = readdir(dir)) != nullptr) { | |||||
mmDirent **entries = nullptr; | |||||
auto ret = mmScandir(canonical_path, &entries, nullptr, nullptr); | |||||
if (ret < EN_OK) { | |||||
GELOGW("scan dir failed. path = %s, ret = %d", canonical_path, ret); | |||||
return FAILED; | |||||
} | |||||
for (int i = 0; i < ret; ++i) { | |||||
mmDirent *entry = entries[i]; | |||||
// read fileName and fileType | // read fileName and fileType | ||||
std::string file_name = entry->d_name; | std::string file_name = entry->d_name; | ||||
unsigned char file_type = entry->d_type; | unsigned char file_type = entry->d_type; | ||||
@@ -254,9 +263,11 @@ Status PluginManager::Load(const string &path, const vector<string> &func_check_ | |||||
GELOGI("Dlopen so path name: %s. ", file_path_dlopen.c_str()); | GELOGI("Dlopen so path name: %s. ", file_path_dlopen.c_str()); | ||||
// load continue when dlopen is failed | // load continue when dlopen is failed | ||||
auto handle = dlopen(file_path_dlopen.c_str(), RTLD_NOW | RTLD_GLOBAL); | |||||
auto handle = mmDlopen(file_path_dlopen.c_str(), MMPA_RTLD_NOW | MMPA_RTLD_GLOBAL); | |||||
if (handle == nullptr) { | if (handle == nullptr) { | ||||
GELOGW("Failed in dlopen %s!", dlerror()); | |||||
const char *error = mmDlerror(); | |||||
GE_IF_BOOL_EXEC(error == nullptr, error = ""); | |||||
GELOGW("Failed in dlopen %s!", error); | |||||
continue; | continue; | ||||
} | } | ||||
@@ -265,7 +276,7 @@ Status PluginManager::Load(const string &path, const vector<string> &func_check_ | |||||
// load continue when so is invalid | // load continue when so is invalid | ||||
bool is_valid = true; | bool is_valid = true; | ||||
for (const auto &func_name : func_check_list) { | for (const auto &func_name : func_check_list) { | ||||
auto real_fn = (void (*)())dlsym(handle, func_name.c_str()); | |||||
auto real_fn = (void (*)())mmDlsym(handle, const_cast<char *>(func_name.c_str())); | |||||
if (real_fn == nullptr) { | if (real_fn == nullptr) { | ||||
GELOGW("The %s is skipped since function %s is not existed!", file_name.c_str(), func_name.c_str()); | GELOGW("The %s is skipped since function %s is not existed!", file_name.c_str(), func_name.c_str()); | ||||
is_valid = false; | is_valid = false; | ||||
@@ -273,7 +284,7 @@ Status PluginManager::Load(const string &path, const vector<string> &func_check_ | |||||
} | } | ||||
} | } | ||||
if (!is_valid) { | if (!is_valid) { | ||||
GE_LOGE_IF(dlclose(handle), "Failed to dlclose."); | |||||
GE_LOGE_IF(mmDlclose(handle), "Failed to dlclose."); | |||||
continue; | continue; | ||||
} | } | ||||
@@ -283,7 +294,7 @@ Status PluginManager::Load(const string &path, const vector<string> &func_check_ | |||||
handles_[string(file_name)] = handle; | handles_[string(file_name)] = handle; | ||||
num_of_loaded_so++; | num_of_loaded_so++; | ||||
} | } | ||||
closedir(dir); | |||||
mmScandirFree(entries, ret); | |||||
if (num_of_loaded_so == 0) { | if (num_of_loaded_so == 0) { | ||||
GELOGW("No loadable shared library found in the path: %s", path.c_str()); | GELOGW("No loadable shared library found in the path: %s", path.c_str()); | ||||
return SUCCESS; | return SUCCESS; | ||||
@@ -17,7 +17,6 @@ | |||||
#ifndef GE_COMMON_GE_PLUGIN_MANAGER_H_ | #ifndef GE_COMMON_GE_PLUGIN_MANAGER_H_ | ||||
#define GE_COMMON_GE_PLUGIN_MANAGER_H_ | #define GE_COMMON_GE_PLUGIN_MANAGER_H_ | ||||
#include <dlfcn.h> | |||||
#include <functional> | #include <functional> | ||||
#include <iostream> | #include <iostream> | ||||
#include <map> | #include <map> | ||||
@@ -30,6 +29,7 @@ | |||||
#include "common/ge_inner_error_codes.h" | #include "common/ge_inner_error_codes.h" | ||||
#include "engine/dnnengine.h" | #include "engine/dnnengine.h" | ||||
#include "framework/common/debug/ge_log.h" | #include "framework/common/debug/ge_log.h" | ||||
#include "mmpa/mmpa_api.h" | |||||
namespace ge { | namespace ge { | ||||
using SoToHandleMap = std::map<std::string, void *>; | using SoToHandleMap = std::map<std::string, void *>; | ||||
@@ -57,7 +57,7 @@ class PluginManager { | |||||
template <typename R, typename... Types> | template <typename R, typename... Types> | ||||
Status GetAllFunctions(const string &func_name, map<string, function<R(Types... args)>> &funcs) { | Status GetAllFunctions(const string &func_name, map<string, function<R(Types... args)>> &funcs) { | ||||
for (const auto &handle : handles_) { | for (const auto &handle : handles_) { | ||||
auto real_fn = (R(*)(Types...))dlsym(handle.second, func_name.c_str()); | |||||
auto real_fn = (R(*)(Types...))mmDlsym(handle.second, const_cast<char *>(func_name.c_str())); | |||||
if (real_fn == nullptr) { | if (real_fn == nullptr) { | ||||
GELOGW("Failed to get function %s in %s!", func_name.c_str(), handle.first.c_str()); | GELOGW("Failed to get function %s in %s!", func_name.c_str(), handle.first.c_str()); | ||||
return GE_PLGMGR_FUNC_NOT_EXIST; | return GE_PLGMGR_FUNC_NOT_EXIST; | ||||
@@ -72,7 +72,7 @@ class PluginManager { | |||||
Status InvokeAll(const string &func_name, Types... args) { | Status InvokeAll(const string &func_name, Types... args) { | ||||
for (const auto &handle : handles_) { | for (const auto &handle : handles_) { | ||||
// If the funcName is existed, signature of realFn can be casted to any type | // If the funcName is existed, signature of realFn can be casted to any type | ||||
auto real_fn = (void (*)(Types...))dlsym(handle.second, func_name.c_str()); | |||||
auto real_fn = (void (*)(Types...))mmDlsym(handle.second, const_cast<char *>(func_name.c_str())); | |||||
if (real_fn == nullptr) { | if (real_fn == nullptr) { | ||||
GELOGW("Failed to invoke function %s in %s!", func_name.c_str(), handle.first.c_str()); | GELOGW("Failed to invoke function %s in %s!", func_name.c_str(), handle.first.c_str()); | ||||
return GE_PLGMGR_INVOKE_FAILED; | return GE_PLGMGR_INVOKE_FAILED; | ||||
@@ -87,7 +87,7 @@ class PluginManager { | |||||
Status InvokeAll(const string &func_name, T arg) { | Status InvokeAll(const string &func_name, T arg) { | ||||
for (const auto &handle : handles_) { | for (const auto &handle : handles_) { | ||||
// If the funcName is existed, signature of realFn can be casted to any type | // If the funcName is existed, signature of realFn can be casted to any type | ||||
auto real_fn = (void (*)(T))dlsym(handle.second, func_name.c_str()); | |||||
auto real_fn = (void (*)(T))mmDlsym(handle.second, const_cast<char *>(func_name.c_str())); | |||||
if (real_fn == nullptr) { | if (real_fn == nullptr) { | ||||
GELOGW("Failed to invoke function %s in %s!", func_name.c_str(), handle.first.c_str()); | GELOGW("Failed to invoke function %s in %s!", func_name.c_str(), handle.first.c_str()); | ||||
return GE_PLGMGR_INVOKE_FAILED; | return GE_PLGMGR_INVOKE_FAILED; | ||||
@@ -112,7 +112,7 @@ class PluginManager { | |||||
Status InvokeAll(const string &func_name, T1 arg) { | Status InvokeAll(const string &func_name, T1 arg) { | ||||
for (const auto &handle : handles_) { | for (const auto &handle : handles_) { | ||||
// If the funcName is existed, signature of realFn can be casted to any type | // If the funcName is existed, signature of realFn can be casted to any type | ||||
auto real_fn = (T2(*)(T1))dlsym(handle.second, func_name.c_str()); | |||||
auto real_fn = (T2(*)(T1))mmDlsym(handle.second, const_cast<char *>(func_name.c_str())); | |||||
if (real_fn == nullptr) { | if (real_fn == nullptr) { | ||||
GELOGW("Failed to invoke function %s in %s!", func_name.c_str(), handle.first.c_str()); | GELOGW("Failed to invoke function %s in %s!", func_name.c_str(), handle.first.c_str()); | ||||
return GE_PLGMGR_INVOKE_FAILED; | return GE_PLGMGR_INVOKE_FAILED; | ||||
@@ -130,7 +130,7 @@ class PluginManager { | |||||
Status InvokeAll(const string &func_name) { | Status InvokeAll(const string &func_name) { | ||||
for (const auto &handle : handles_) { | for (const auto &handle : handles_) { | ||||
// If the funcName is existed, signature of realFn can be casted to any type | // If the funcName is existed, signature of realFn can be casted to any type | ||||
auto real_fn = (T(*)())dlsym(handle.second, func_name.c_str()); | |||||
auto real_fn = (T(*)())mmDlsym(handle.second, const_cast<char *>(func_name.c_str())); | |||||
if (real_fn == nullptr) { | if (real_fn == nullptr) { | ||||
GELOGW("Failed to invoke function %s in %s!", func_name.c_str(), handle.first.c_str()); | GELOGW("Failed to invoke function %s in %s!", func_name.c_str(), handle.first.c_str()); | ||||
return GE_PLGMGR_INVOKE_FAILED; | return GE_PLGMGR_INVOKE_FAILED; | ||||
@@ -16,8 +16,6 @@ | |||||
#include "common/ge/tbe_plugin_manager.h" | #include "common/ge/tbe_plugin_manager.h" | ||||
#include <dirent.h> | |||||
#include <unistd.h> | |||||
#include <algorithm> | #include <algorithm> | ||||
#include <cstring> | #include <cstring> | ||||
#include <fstream> | #include <fstream> | ||||
@@ -50,9 +48,11 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY TBEPluginManager &TBEPluginMana | |||||
Status TBEPluginManager::ClearHandles_() { | Status TBEPluginManager::ClearHandles_() { | ||||
Status ret = SUCCESS; | Status ret = SUCCESS; | ||||
for (const auto &handle : handles_vec_) { | for (const auto &handle : handles_vec_) { | ||||
if (dlclose(handle) != 0) { | |||||
if (mmDlclose(handle) != 0) { | |||||
ret = FAILED; | ret = FAILED; | ||||
GELOGW("Failed to close handle: %s", dlerror()); | |||||
const char *error = mmDlerror(); | |||||
GE_IF_BOOL_EXEC(error == nullptr, error = ""); | |||||
GELOGW("Failed to close handle: %s", error); | |||||
} | } | ||||
} | } | ||||
handles_vec_.clear(); | handles_vec_.clear(); | ||||
@@ -65,18 +65,18 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status TBEPluginManager::Finali | |||||
} | } | ||||
string TBEPluginManager::GetPath() { | string TBEPluginManager::GetPath() { | ||||
Dl_info dl_info; | |||||
if (dladdr(reinterpret_cast<void *>(&TBEPluginManager::GetPath), &dl_info) == 0) { | |||||
mmDlInfo dl_info; | |||||
if (mmDladdr(reinterpret_cast<void *>(&TBEPluginManager::GetPath), &dl_info) != EN_OK) { | |||||
GELOGW("Failed to read so path!"); | GELOGW("Failed to read so path!"); | ||||
return string(); | return string(); | ||||
} else { | } else { | ||||
string so_path = dl_info.dli_fname; | string so_path = dl_info.dli_fname; | ||||
char path[PATH_MAX] = {0}; | |||||
if (so_path.length() >= PATH_MAX) { | |||||
char path[MMPA_MAX_PATH] = {0}; | |||||
if (so_path.length() >= MMPA_MAX_PATH) { | |||||
GELOGW("File path is too long!"); | GELOGW("File path is too long!"); | ||||
return string(); | return string(); | ||||
} | } | ||||
if (realpath(so_path.c_str(), path) == nullptr) { | |||||
if (mmRealPath(so_path.c_str(), path, MMPA_MAX_PATH) != EN_OK) { | |||||
GELOGW("Failed to get realpath of %s", so_path.c_str()); | GELOGW("Failed to get realpath of %s", so_path.c_str()); | ||||
return string(); | return string(); | ||||
} | } | ||||
@@ -108,20 +108,21 @@ void TBEPluginManager::FindParserSo(const string &path, vector<string> &file_lis | |||||
GELOGW("RealPath is empty."); | GELOGW("RealPath is empty."); | ||||
return; | return; | ||||
} | } | ||||
struct stat stat_buf; | |||||
if ((stat(real_path.c_str(), &stat_buf) != 0) || (!S_ISDIR(stat_buf.st_mode))) { | |||||
INT32 is_dir = mmIsDir(real_path.c_str()); | |||||
// Lib plugin path not exist | |||||
if (is_dir != EN_OK) { | |||||
GELOGW("%s is not a dir.", real_path.c_str()); | GELOGW("%s is not a dir.", real_path.c_str()); | ||||
return; | return; | ||||
} | } | ||||
struct dirent *dent(0); | |||||
DIR *dir = opendir(real_path.c_str()); | |||||
// Plugin path does not exist | |||||
if (dir == nullptr) { | |||||
GELOGW("Open directory %s failed.", real_path.c_str()); | |||||
mmDirent **entries = nullptr; | |||||
auto ret = mmScandir(real_path.c_str(), &entries, nullptr, nullptr); | |||||
if (ret < EN_OK) { | |||||
GELOGW("scan dir failed. path = %s, ret = %d", real_path.c_str(), ret); | |||||
return; | return; | ||||
} | } | ||||
while ((dent = readdir(dir)) != nullptr) { | |||||
for (int i = 0; i < ret; ++i) { | |||||
mmDirent *dent = entries[i]; | |||||
if (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0) continue; | if (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0) continue; | ||||
string name = dent->d_name; | string name = dent->d_name; | ||||
string full_name = real_path + "/" + name; | string full_name = real_path + "/" + name; | ||||
@@ -136,7 +137,7 @@ void TBEPluginManager::FindParserSo(const string &path, vector<string> &file_lis | |||||
FindParserSo(full_name, file_list, caffe_parser_path); | FindParserSo(full_name, file_list, caffe_parser_path); | ||||
} | } | ||||
} | } | ||||
closedir(dir); | |||||
mmScandirFree(entries, ret); | |||||
} | } | ||||
void TBEPluginManager::GetPluginSoFileList(const string &path, vector<string> &file_list, string &caffe_parser_path) { | void TBEPluginManager::GetPluginSoFileList(const string &path, vector<string> &file_list, string &caffe_parser_path) { | ||||
@@ -159,8 +160,9 @@ void TBEPluginManager::GetCustomOpPath(std::string &customop_path) { | |||||
fmk_type = ge::TypeUtils::FmkTypeToSerialString(type); | fmk_type = ge::TypeUtils::FmkTypeToSerialString(type); | ||||
GELOGI("Framework type is %s.", fmk_type.c_str()); | GELOGI("Framework type is %s.", fmk_type.c_str()); | ||||
const char *path_env = std::getenv("ASCEND_OPP_PATH"); | |||||
if (path_env != nullptr) { | |||||
char path_env[MMPA_MAX_PATH] = {0x00}; | |||||
INT32 res = mmGetEnv("ASCEND_OPP_PATH", path_env, MMPA_MAX_PATH); | |||||
if (res == EN_OK) { | |||||
std::string path = path_env; | std::string path = path_env; | ||||
customop_path = (path + "/framework/custom" + "/:") + (path + "/framework/built-in/" + fmk_type); | customop_path = (path + "/framework/custom" + "/:") + (path + "/framework/built-in/" + fmk_type); | ||||
GELOGI("Get custom so path from env : %s", path_env); | GELOGI("Get custom so path from env : %s", path_env); | ||||
@@ -210,9 +212,11 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void TBEPluginManager::LoadPlug | |||||
for (auto elem : file_list) { | for (auto elem : file_list) { | ||||
StringUtils::Trim(elem); | StringUtils::Trim(elem); | ||||
void *handle = dlopen(elem.c_str(), RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE); | |||||
void *handle = mmDlopen(elem.c_str(), MMPA_RTLD_NOW | MMPA_RTLD_GLOBAL | MMPA_RTLD_NODELETE); | |||||
if (handle == nullptr) { | if (handle == nullptr) { | ||||
GELOGW("dlopen failed, plugin name:%s. Message(%s).", elem.c_str(), dlerror()); | |||||
const char *error = mmDlerror(); | |||||
GE_IF_BOOL_EXEC(error == nullptr, error = ""); | |||||
GELOGW("dlopen failed, plugin name:%s. Message(%s).", elem.c_str(), error); | |||||
} else if (find(handles_vec_.begin(), handles_vec_.end(), handle) == handles_vec_.end()) { | } else if (find(handles_vec_.begin(), handles_vec_.end(), handle) == handles_vec_.end()) { | ||||
// Close dl when the program exist, not close here | // Close dl when the program exist, not close here | ||||
GELOGI("Plugin load %s success.", elem.c_str()); | GELOGI("Plugin load %s success.", elem.c_str()); | ||||
@@ -17,7 +17,6 @@ | |||||
#ifndef GE_COMMON_GE_TBE_PLUGIN_MANAGER_H_ | #ifndef GE_COMMON_GE_TBE_PLUGIN_MANAGER_H_ | ||||
#define GE_COMMON_GE_TBE_PLUGIN_MANAGER_H_ | #define GE_COMMON_GE_TBE_PLUGIN_MANAGER_H_ | ||||
#include <dlfcn.h> | |||||
#include <functional> | #include <functional> | ||||
#include <iostream> | #include <iostream> | ||||
#include <map> | #include <map> | ||||
@@ -82,8 +82,9 @@ include $(CLEAR_VARS) | |||||
LOCAL_MODULE := libge_common | LOCAL_MODULE := libge_common | ||||
LOCAL_CFLAGS += -Werror -DFMK_SUPPORT_DUMP | |||||
LOCAL_CFLAGS += -Werror -DFMK_SUPPORT_DUMP -Wno-deprecated-declarations | |||||
LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -O2 -Dgoogle=ascend_private | LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -O2 -Dgoogle=ascend_private | ||||
ifeq ($(DEBUG), 1) | ifeq ($(DEBUG), 1) | ||||
LOCAL_CFLAGS += -g -O0 | LOCAL_CFLAGS += -g -O0 | ||||
else | else | ||||
@@ -109,11 +110,12 @@ LOCAL_SHARED_LIBRARIES := \ | |||||
libascend_protobuf \ | libascend_protobuf \ | ||||
libc_sec \ | libc_sec \ | ||||
libslog \ | libslog \ | ||||
libmmpa \ | |||||
libgraph \ | libgraph \ | ||||
libregister \ | libregister \ | ||||
liberror_manager \ | liberror_manager \ | ||||
LOCAL_STATIC_LIBRARIES += libmmpa | |||||
LOCAL_LDFLAGS := -lrt -ldl | LOCAL_LDFLAGS := -lrt -ldl | ||||
include $(BUILD_HOST_SHARED_LIBRARY) | include $(BUILD_HOST_SHARED_LIBRARY) | ||||
@@ -123,8 +125,9 @@ include $(CLEAR_VARS) | |||||
LOCAL_MODULE := libge_common | LOCAL_MODULE := libge_common | ||||
LOCAL_CFLAGS += -Werror -DFMK_SUPPORT_DUMP | |||||
LOCAL_CFLAGS += -Werror -DFMK_SUPPORT_DUMP -Wno-deprecated-declarations | |||||
LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -O2 -Dgoogle=ascend_private | LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -O2 -Dgoogle=ascend_private | ||||
ifeq ($(DEBUG), 1) | ifeq ($(DEBUG), 1) | ||||
LOCAL_CFLAGS += -g -O0 | LOCAL_CFLAGS += -g -O0 | ||||
else | else | ||||
@@ -150,11 +153,12 @@ LOCAL_SHARED_LIBRARIES := \ | |||||
libascend_protobuf \ | libascend_protobuf \ | ||||
libc_sec \ | libc_sec \ | ||||
libslog \ | libslog \ | ||||
libmmpa \ | |||||
libgraph \ | libgraph \ | ||||
libregister \ | libregister \ | ||||
liberror_manager \ | liberror_manager \ | ||||
LOCAL_STATIC_LIBRARIES += libmmpa | |||||
ifeq ($(device_os),android) | ifeq ($(device_os),android) | ||||
LOCAL_LDFLAGS += -ldl | LOCAL_LDFLAGS += -ldl | ||||
LOCAL_LDLIBS += -L$(PWD)/prebuilts/clang/linux-x86/aarch64/android-ndk-r21/sysroot/usr/lib/aarch64-linux-android/29 -llog | LOCAL_LDLIBS += -L$(PWD)/prebuilts/clang/linux-x86/aarch64/android-ndk-r21/sysroot/usr/lib/aarch64-linux-android/29 -llog | ||||
@@ -169,8 +173,9 @@ include $(CLEAR_VARS) | |||||
LOCAL_MODULE := libge_common | LOCAL_MODULE := libge_common | ||||
LOCAL_CFLAGS += -Werror -DFMK_SUPPORT_DUMP | |||||
LOCAL_CFLAGS += -Werror -DFMK_SUPPORT_DUMP -Wno-deprecated-declarations | |||||
LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -O2 -Dgoogle=ascend_private | LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -O2 -Dgoogle=ascend_private | ||||
ifeq ($(DEBUG), 1) | ifeq ($(DEBUG), 1) | ||||
LOCAL_CFLAGS += -g -O0 | LOCAL_CFLAGS += -g -O0 | ||||
endif | endif | ||||
@@ -211,8 +216,9 @@ include $(CLEAR_VARS) | |||||
LOCAL_MODULE := libge_common | LOCAL_MODULE := libge_common | ||||
LOCAL_CFLAGS += -Werror -DFMK_SUPPORT_DUMP | |||||
LOCAL_CFLAGS += -Werror -DFMK_SUPPORT_DUMP -Wno-deprecated-declarations | |||||
LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -O2 -Dgoogle=ascend_private | LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -O2 -Dgoogle=ascend_private | ||||
ifeq ($(DEBUG), 1) | ifeq ($(DEBUG), 1) | ||||
LOCAL_CFLAGS += -g -O0 | LOCAL_CFLAGS += -g -O0 | ||||
endif | endif | ||||
@@ -14,8 +14,6 @@ | |||||
* limitations under the License. | * limitations under the License. | ||||
*/ | */ | ||||
#include <fcntl.h> | |||||
#include <unistd.h> | |||||
#include <climits> | #include <climits> | ||||
#include <cstdio> | #include <cstdio> | ||||
#include <fstream> | #include <fstream> | ||||
@@ -448,12 +446,12 @@ Status ModelCacheHelper::SaveJsonToFile(const string &file_name, const Json &jso | |||||
} | } | ||||
const string path = cache_path_ + file_name; | const string path = cache_path_ + file_name; | ||||
const int FILE_AUTHORITY = 0600; | const int FILE_AUTHORITY = 0600; | ||||
int fd = open(path.c_str(), O_WRONLY | O_CREAT | O_TRUNC, FILE_AUTHORITY); | |||||
int fd = mmOpen2(path.c_str(), M_WRONLY | M_CREAT | O_TRUNC, FILE_AUTHORITY); | |||||
if (fd < 0) { | if (fd < 0) { | ||||
GELOGW("Fail to open the file: %s.", path.c_str()); | GELOGW("Fail to open the file: %s.", path.c_str()); | ||||
return INTERNAL_ERROR; | return INTERNAL_ERROR; | ||||
} | } | ||||
if (close(fd) != 0) { | |||||
if (mmClose(fd) != 0) { | |||||
GELOGW("Fail to close the file: %s.", path.c_str()); | GELOGW("Fail to close the file: %s.", path.c_str()); | ||||
return INTERNAL_ERROR; | return INTERNAL_ERROR; | ||||
} | } | ||||
@@ -97,7 +97,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmMod | |||||
ge::Buffer model_buffer; | ge::Buffer model_buffer; | ||||
(void)model_tmp->Save(model_buffer); | (void)model_tmp->Save(model_buffer); | ||||
GELOGI("MODEL_DEF size is %zu", model_buffer.GetSize()); | |||||
GELOGD("MODEL_DEF size is %zu", model_buffer.GetSize()); | |||||
if (model_buffer.GetSize() > 0) { | if (model_buffer.GetSize() > 0) { | ||||
if (SaveModelPartition(om_file_save_helper, ModelPartitionType::MODEL_DEF, model_buffer.GetData(), | if (SaveModelPartition(om_file_save_helper, ModelPartitionType::MODEL_DEF, model_buffer.GetData(), | ||||
model_buffer.GetSize()) != SUCCESS) { | model_buffer.GetSize()) != SUCCESS) { | ||||
@@ -106,7 +106,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmMod | |||||
} | } | ||||
} | } | ||||
auto ge_model_weight = ge_model->GetWeight(); | auto ge_model_weight = ge_model->GetWeight(); | ||||
GELOGI("WEIGHTS_DATA size is %zu, %p", ge_model_weight.GetSize(), ge_model_weight.GetData()); | |||||
GELOGD("WEIGHTS_DATA size is %zu, %p", ge_model_weight.GetSize(), ge_model_weight.GetData()); | |||||
// weight is not necessary | // weight is not necessary | ||||
if (ge_model_weight.GetSize() > 0) { | if (ge_model_weight.GetSize() > 0) { | ||||
GE_CHK_STATUS_RET(SaveModelPartition(om_file_save_helper, ModelPartitionType::WEIGHTS_DATA, | GE_CHK_STATUS_RET(SaveModelPartition(om_file_save_helper, ModelPartitionType::WEIGHTS_DATA, | ||||
@@ -115,7 +115,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmMod | |||||
} | } | ||||
TBEKernelStore tbe_kernel_store = ge_model->GetTBEKernelStore(); | TBEKernelStore tbe_kernel_store = ge_model->GetTBEKernelStore(); | ||||
GELOGI("TBE_KERNELS size is %zu", tbe_kernel_store.DataSize()); | |||||
GELOGD("TBE_KERNELS size is %zu", tbe_kernel_store.DataSize()); | |||||
if (tbe_kernel_store.DataSize() > 0) { | if (tbe_kernel_store.DataSize() > 0) { | ||||
GE_CHK_STATUS_RET(SaveModelPartition(om_file_save_helper, ModelPartitionType::TBE_KERNELS, tbe_kernel_store.Data(), | GE_CHK_STATUS_RET(SaveModelPartition(om_file_save_helper, ModelPartitionType::TBE_KERNELS, tbe_kernel_store.Data(), | ||||
tbe_kernel_store.DataSize()), | tbe_kernel_store.DataSize()), | ||||
@@ -126,7 +126,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmMod | |||||
(void)tbe_kernel_store.Load(tbe_kernel_store.Data(), tbe_kernel_store.DataSize()); | (void)tbe_kernel_store.Load(tbe_kernel_store.Data(), tbe_kernel_store.DataSize()); | ||||
CustAICPUKernelStore cust_aicpu_kernel_store = ge_model->GetCustAICPUKernelStore(); | CustAICPUKernelStore cust_aicpu_kernel_store = ge_model->GetCustAICPUKernelStore(); | ||||
GELOGI("cust aicpu kernels size is %zu", cust_aicpu_kernel_store.DataSize()); | |||||
GELOGD("cust aicpu kernels size is %zu", cust_aicpu_kernel_store.DataSize()); | |||||
if (cust_aicpu_kernel_store.DataSize() > 0) { | if (cust_aicpu_kernel_store.DataSize() > 0) { | ||||
GE_CHK_STATUS_RET(SaveModelPartition(om_file_save_helper, ModelPartitionType::CUST_AICPU_KERNELS, | GE_CHK_STATUS_RET(SaveModelPartition(om_file_save_helper, ModelPartitionType::CUST_AICPU_KERNELS, | ||||
cust_aicpu_kernel_store.Data(), cust_aicpu_kernel_store.DataSize()), | cust_aicpu_kernel_store.Data(), cust_aicpu_kernel_store.DataSize()), | ||||
@@ -150,8 +150,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmMod | |||||
} | } | ||||
(void)model_task_def->SerializePartialToArray(task_buffer.GetData(), static_cast<int>(partition_task_size)); | (void)model_task_def->SerializePartialToArray(task_buffer.GetData(), static_cast<int>(partition_task_size)); | ||||
GELOGI("TASK_INFO op_size:%d, stream_num:%u", model_task_def->op().size(), model_task_def->stream_num()); | |||||
GELOGI("TASK_INFO size is %zu", partition_task_size); | |||||
GELOGD("TASK_INFO op_size:%d, stream_num:%u", model_task_def->op().size(), model_task_def->stream_num()); | |||||
GELOGD("TASK_INFO size is %zu", partition_task_size); | |||||
if (SaveModelPartition(om_file_save_helper, ModelPartitionType::TASK_INFO, task_buffer.GetData(), | if (SaveModelPartition(om_file_save_helper, ModelPartitionType::TASK_INFO, task_buffer.GetData(), | ||||
partition_task_size) != SUCCESS) { | partition_task_size) != SUCCESS) { | ||||
@@ -163,7 +163,6 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmMod | |||||
model_header.platform_type = ge_model->GetPlatformType(); | model_header.platform_type = ge_model->GetPlatformType(); | ||||
model_header.om_ir_version = ge_model->GetVersion(); | model_header.om_ir_version = ge_model->GetVersion(); | ||||
std::string platform_version = ge_model->GetPlatformVersion(); | std::string platform_version = ge_model->GetPlatformVersion(); | ||||
GELOGI("Platform version save: %s", platform_version.c_str()); | |||||
errno_t err; | errno_t err; | ||||
err = memcpy_s(model_header.platform_version, PLATFORM_VERSION_LEN, platform_version.c_str(), | err = memcpy_s(model_header.platform_version, PLATFORM_VERSION_LEN, platform_version.c_str(), | ||||
@@ -173,7 +172,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmMod | |||||
return MEMALLOC_FAILED; | return MEMALLOC_FAILED; | ||||
} | } | ||||
string version = reinterpret_cast<char *>(model_header.platform_version); | string version = reinterpret_cast<char *>(model_header.platform_version); | ||||
GELOGI("Platform version save: %s", version.c_str()); | |||||
GELOGD("Platform version save: %s", version.c_str()); | |||||
size_t name_size = ge_model->GetName().size(); | size_t name_size = ge_model->GetName().size(); | ||||
name_size = name_size > (MODEL_NAME_LENGTH - 1) ? (MODEL_NAME_LENGTH - 1) : name_size; | name_size = name_size > (MODEL_NAME_LENGTH - 1) ? (MODEL_NAME_LENGTH - 1) : name_size; | ||||
@@ -183,7 +182,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmMod | |||||
return MEMALLOC_FAILED; | return MEMALLOC_FAILED; | ||||
} | } | ||||
string model_name = reinterpret_cast<char *>(model_header.name); | string model_name = reinterpret_cast<char *>(model_header.name); | ||||
GELOGI("Model name save:%s", model_name.c_str()); | |||||
GELOGD("Model name save:%s", model_name.c_str()); | |||||
Status ret = om_file_save_helper->SaveModel(save_param, output_file.c_str(), model, is_offline_); | Status ret = om_file_save_helper->SaveModel(save_param, output_file.c_str(), model, is_offline_); | ||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
@@ -263,18 +262,18 @@ ModelHelper::SaveOriginalGraphToOmModel(const ge::Graph &graph, const std::strin | |||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadModel(const ge::ModelData &model_data) { | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadModel(const ge::ModelData &model_data) { | ||||
if (model_data.model_data == nullptr || model_data.model_len == 0) { | if (model_data.model_data == nullptr || model_data.model_len == 0) { | ||||
GELOGE(GE_EXEC_MODEL_DATA_SIZE_INVALID, "Model_data is nullptr, or model_data_size is 0"); | |||||
return GE_EXEC_MODEL_DATA_SIZE_INVALID; | |||||
GELOGE(ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID, "Model_data is nullptr, or model_data_size is 0"); | |||||
return ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID; | |||||
} | } | ||||
if (is_assign_model_) { | if (is_assign_model_) { | ||||
GELOGE(GE_EXEC_LOAD_MODEL_REPEATED, "Model helper has already loaded!"); | |||||
return GE_EXEC_LOAD_MODEL_REPEATED; | |||||
GELOGE(ACL_ERROR_GE_EXEC_LOAD_MODEL_REPEATED, "Model helper has already loaded!"); | |||||
return ACL_ERROR_GE_EXEC_LOAD_MODEL_REPEATED; | |||||
} | } | ||||
if (ReleaseLocalModelData() != SUCCESS) { | if (ReleaseLocalModelData() != SUCCESS) { | ||||
GELOGE(INTERNAL_ERROR, "ReleaseLocalModelData failed."); | |||||
return INTERNAL_ERROR; | |||||
GELOGE(ACL_ERROR_GE_EXEC_RELEASE_MODEL_DATA, "ReleaseLocalModelData failed."); | |||||
return ACL_ERROR_GE_EXEC_RELEASE_MODEL_DATA; | |||||
} | } | ||||
Status status = ge::DavinciModelParser::ParseModelContent(model_data, model_addr_tmp_, model_len_tmp_); | Status status = ge::DavinciModelParser::ParseModelContent(model_data, model_addr_tmp_, model_len_tmp_); | ||||
@@ -295,8 +294,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadModel(c | |||||
auto partition_table = reinterpret_cast<ModelPartitionTable *>(model_addr_tmp_); | auto partition_table = reinterpret_cast<ModelPartitionTable *>(model_addr_tmp_); | ||||
if (partition_table->num == kOriginalOmPartitionNum) { | if (partition_table->num == kOriginalOmPartitionNum) { | ||||
model_addr_tmp_ = nullptr; | model_addr_tmp_ = nullptr; | ||||
GELOGE(GE_EXEC_MODEL_PARTITION_NUM_INVALID, "om model is error,please use executable om model"); | |||||
return GE_EXEC_MODEL_PARTITION_NUM_INVALID; | |||||
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PARTITION_NUM_INVALID, "om model is error,please use executable om model"); | |||||
return ACL_ERROR_GE_EXEC_MODEL_PARTITION_NUM_INVALID; | |||||
} | } | ||||
// Encrypt model need to del temp model/no encrypt model don't need to del model | // Encrypt model need to del temp model/no encrypt model don't need to del model | ||||
model_addr_tmp_ = nullptr; | model_addr_tmp_ = nullptr; | ||||
@@ -316,23 +315,23 @@ Status ModelHelper::GenerateGeModel(OmFileLoadHelper &om_load_helper) { | |||||
GE_CHECK_NOTNULL(model_); | GE_CHECK_NOTNULL(model_); | ||||
Status ret = LoadModelData(om_load_helper); | Status ret = LoadModelData(om_load_helper); | ||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
return GE_EXEC_LOAD_MODEL_PARTITION_FAILED; | |||||
return ACL_ERROR_GE_EXEC_LOAD_MODEL_PARTITION_FAILED; | |||||
} | } | ||||
ret = LoadWeights(om_load_helper); | ret = LoadWeights(om_load_helper); | ||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
return GE_EXEC_LOAD_WEIGHT_PARTITION_FAILED; | |||||
return ACL_ERROR_GE_EXEC_LOAD_WEIGHT_PARTITION_FAILED; | |||||
} | } | ||||
ret = LoadTask(om_load_helper); | ret = LoadTask(om_load_helper); | ||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
return GE_EXEC_LOAD_TASK_PARTITION_FAILED; | |||||
return ACL_ERROR_GE_EXEC_LOAD_TASK_PARTITION_FAILED; | |||||
} | } | ||||
ret = LoadTBEKernelStore(om_load_helper); | ret = LoadTBEKernelStore(om_load_helper); | ||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
return GE_EXEC_LOAD_KERNEL_PARTITION_FAILED; | |||||
return ACL_ERROR_GE_EXEC_LOAD_KERNEL_PARTITION_FAILED; | |||||
} | } | ||||
ret = LoadCustAICPUKernelStore(om_load_helper); | ret = LoadCustAICPUKernelStore(om_load_helper); | ||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
return GE_EXEC_LOAD_KERNEL_PARTITION_FAILED; | |||||
return ACL_ERROR_GE_EXEC_LOAD_KERNEL_PARTITION_FAILED; | |||||
} | } | ||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
@@ -341,7 +340,7 @@ Status ModelHelper::LoadModelData(OmFileLoadHelper &om_load_helper) { | |||||
ModelPartition partition_model_def; | ModelPartition partition_model_def; | ||||
// no need to check value, DATA->NetOutput | // no need to check value, DATA->NetOutput | ||||
om_load_helper.GetModelPartition(ModelPartitionType::MODEL_DEF, partition_model_def); | om_load_helper.GetModelPartition(ModelPartitionType::MODEL_DEF, partition_model_def); | ||||
GELOGI("Model_def partition addr:%p,size:%u", partition_model_def.data, partition_model_def.size); | |||||
GELOGD("Model_def partition addr:%p,size:%u", partition_model_def.data, partition_model_def.size); | |||||
ge::Model model; | ge::Model model; | ||||
if (ge::Model::Load(partition_model_def.data, partition_model_def.size, model) != SUCCESS) { | if (ge::Model::Load(partition_model_def.data, partition_model_def.size, model) != SUCCESS) { | ||||
@@ -371,7 +370,7 @@ Status ModelHelper::LoadWeights(OmFileLoadHelper &om_load_helper) { | |||||
ge::Buffer weight = ge::Buffer::CopyFrom(partition.data, partition.size); | ge::Buffer weight = ge::Buffer::CopyFrom(partition.data, partition.size); | ||||
model_->SetWeight(weight); | model_->SetWeight(weight); | ||||
GELOGI("GetWeight size:%u", partition.size); | |||||
GELOGD("GetWeight size:%u", partition.size); | |||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
@@ -388,7 +387,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadTask(Om | |||||
GELOGE(INTERNAL_ERROR, "ReadProtoFromArray failed."); | GELOGE(INTERNAL_ERROR, "ReadProtoFromArray failed."); | ||||
return INTERNAL_ERROR; | return INTERNAL_ERROR; | ||||
} | } | ||||
GELOGI("TASK_INFO op_size:%zu, stream_num:%u", task->op().size(), task->stream_num()); | |||||
GELOGD("TASK_INFO op_size:%d, stream_num:%u", task->op().size(), task->stream_num()); | |||||
} | } | ||||
model_->SetModelTaskDef(task); | model_->SetModelTaskDef(task); | ||||
return SUCCESS; | return SUCCESS; | ||||
@@ -399,9 +398,9 @@ Status ModelHelper::LoadTBEKernelStore(OmFileLoadHelper &om_load_helper) { | |||||
ModelPartition partition_kernel_def; | ModelPartition partition_kernel_def; | ||||
TBEKernelStore kernel_store; | TBEKernelStore kernel_store; | ||||
if (om_load_helper.GetModelPartition(ModelPartitionType::TBE_KERNELS, partition_kernel_def) == SUCCESS) { | if (om_load_helper.GetModelPartition(ModelPartitionType::TBE_KERNELS, partition_kernel_def) == SUCCESS) { | ||||
GELOGI("Kernels partition size:%u", partition_kernel_def.size); | |||||
GELOGD("Kernels partition size:%u", partition_kernel_def.size); | |||||
if (kernel_store.Load(partition_kernel_def.data, partition_kernel_def.size)) { | if (kernel_store.Load(partition_kernel_def.data, partition_kernel_def.size)) { | ||||
GELOGI("Load tbe kernels success"); | |||||
GELOGD("Load tbe kernels success"); | |||||
} else { | } else { | ||||
GELOGW("Load tbe kernels failed"); | GELOGW("Load tbe kernels failed"); | ||||
} | } | ||||
@@ -415,11 +414,9 @@ Status ModelHelper::LoadCustAICPUKernelStore(OmFileLoadHelper &om_load_helper) { | |||||
ModelPartition partition_kernel_def; | ModelPartition partition_kernel_def; | ||||
CustAICPUKernelStore kernel_store; | CustAICPUKernelStore kernel_store; | ||||
if (om_load_helper.GetModelPartition(ModelPartitionType::CUST_AICPU_KERNELS, partition_kernel_def) == SUCCESS) { | if (om_load_helper.GetModelPartition(ModelPartitionType::CUST_AICPU_KERNELS, partition_kernel_def) == SUCCESS) { | ||||
GELOGI("Kernels partition size:%u", partition_kernel_def.size); | |||||
GELOGD("Kernels partition size:%u", partition_kernel_def.size); | |||||
if (kernel_store.Load(partition_kernel_def.data, partition_kernel_def.size)) { | if (kernel_store.Load(partition_kernel_def.data, partition_kernel_def.size)) { | ||||
GELOGI("Load cust aicpu kernels success"); | GELOGI("Load cust aicpu kernels success"); | ||||
} else { | |||||
GELOGW("Load cust aicpu kernels failed"); | |||||
} | } | ||||
} | } | ||||
model_->SetCustAICPUKernelStore(kernel_store); | model_->SetCustAICPUKernelStore(kernel_store); | ||||
@@ -110,8 +110,8 @@ Status OmFileLoadHelper::CheckModelValid(const ge::ModelData &model) const { | |||||
Status OmFileLoadHelper::LoadModelPartitionTable(uint8_t *model_data, const uint32_t model_data_size) { | Status OmFileLoadHelper::LoadModelPartitionTable(uint8_t *model_data, const uint32_t model_data_size) { | ||||
if (model_data == nullptr) { | if (model_data == nullptr) { | ||||
GELOGE(PARAM_INVALID, "Param model_data must not be null!"); | |||||
return PARAM_INVALID; | |||||
GELOGE(ACL_ERROR_GE_EXEC_MODEL_ADDR_INVALID, "Param model_data must not be null!"); | |||||
return ACL_ERROR_GE_EXEC_MODEL_ADDR_INVALID; | |||||
} | } | ||||
// Init partition table | // Init partition table | ||||
auto partition_table = reinterpret_cast<ModelPartitionTable *>(model_data); | auto partition_table = reinterpret_cast<ModelPartitionTable *>(model_data); | ||||
@@ -119,16 +119,16 @@ Status OmFileLoadHelper::LoadModelPartitionTable(uint8_t *model_data, const uint | |||||
// Original model partition include graph-info | // Original model partition include graph-info | ||||
if ((partition_table->num != PARTITION_SIZE) && (partition_table->num != (PARTITION_SIZE - 1)) && | if ((partition_table->num != PARTITION_SIZE) && (partition_table->num != (PARTITION_SIZE - 1)) && | ||||
(partition_table->num != (PARTITION_SIZE - kOptionalNum)) && (partition_table->num != 1)) { | (partition_table->num != (PARTITION_SIZE - kOptionalNum)) && (partition_table->num != 1)) { | ||||
GELOGE(GE_EXEC_MODEL_PARTITION_NUM_INVALID, "Invalid partition_table->num:%u", partition_table->num); | |||||
return GE_EXEC_MODEL_PARTITION_NUM_INVALID; | |||||
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PARTITION_NUM_INVALID, "Invalid partition_table->num:%u", partition_table->num); | |||||
return ACL_ERROR_GE_EXEC_MODEL_PARTITION_NUM_INVALID; | |||||
} | } | ||||
size_t mem_offset = SIZE_OF_MODEL_PARTITION_TABLE(*partition_table); | size_t mem_offset = SIZE_OF_MODEL_PARTITION_TABLE(*partition_table); | ||||
GELOGI("ModelPartitionTable num :%u, ModelFileHeader length :%zu, ModelPartitionTable length :%zu", | |||||
GELOGD("ModelPartitionTable num :%u, ModelFileHeader length :%zu, ModelPartitionTable length :%zu", | |||||
partition_table->num, sizeof(ModelFileHeader), mem_offset); | partition_table->num, sizeof(ModelFileHeader), mem_offset); | ||||
if (model_data_size <= mem_offset) { | if (model_data_size <= mem_offset) { | ||||
GELOGE(GE_EXEC_MODEL_DATA_SIZE_INVALID, "invalid model data, partition_table->num:%u, model data size %u", | |||||
GELOGE(ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID, "invalid model data, partition_table->num:%u, model data size %u", | |||||
partition_table->num, model_data_size); | partition_table->num, model_data_size); | ||||
return GE_EXEC_MODEL_DATA_SIZE_INVALID; | |||||
return ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID; | |||||
} | } | ||||
for (uint32_t i = 0; i < partition_table->num; i++) { | for (uint32_t i = 0; i < partition_table->num; i++) { | ||||
ModelPartition partition; | ModelPartition partition; | ||||
@@ -138,12 +138,13 @@ Status OmFileLoadHelper::LoadModelPartitionTable(uint8_t *model_data, const uint | |||||
context_.partition_datas_.push_back(partition); | context_.partition_datas_.push_back(partition); | ||||
if (partition.size > model_data_size || mem_offset > model_data_size - partition.size) { | if (partition.size > model_data_size || mem_offset > model_data_size - partition.size) { | ||||
GELOGE(GE_EXEC_MODEL_DATA_SIZE_INVALID, "The partition size %zu is greater than the model data size %u.", | |||||
partition.size + mem_offset, model_data_size); | |||||
return GE_EXEC_MODEL_DATA_SIZE_INVALID; | |||||
GELOGE(ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID, | |||||
"The partition size %zu is greater than the model data size %u.", partition.size + mem_offset, | |||||
model_data_size); | |||||
return ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID; | |||||
} | } | ||||
mem_offset += partition.size; | mem_offset += partition.size; | ||||
GELOGI("Partition, type:%d, size:%u", static_cast<int>(partition.type), partition.size); | |||||
GELOGD("Partition, type:%d, size:%u", static_cast<int>(partition.type), partition.size); | |||||
} | } | ||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
@@ -167,7 +168,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelPartitionTable *OmFileSave | |||||
ModelPartition partition = context_.partition_datas_[i]; | ModelPartition partition = context_.partition_datas_[i]; | ||||
partition_table->partition[i] = {partition.type, mem_offset, partition.size}; | partition_table->partition[i] = {partition.type, mem_offset, partition.size}; | ||||
mem_offset += partition.size; | mem_offset += partition.size; | ||||
GELOGI("Partition, type:%d, size:%u", static_cast<int>(partition.type), partition.size); | |||||
GELOGD("Partition, type:%d, size:%u", static_cast<int>(partition.type), partition.size); | |||||
} | } | ||||
return partition_table; | return partition_table; | ||||
} | } | ||||
@@ -191,7 +192,7 @@ Status OmFileSaveHelper::SaveModel(const SaveParam &save_param, const char *outp | |||||
(void)save_param.pri_key_file; | (void)save_param.pri_key_file; | ||||
Status ret = SaveModelToFile(output_file, model, is_offline); | Status ret = SaveModelToFile(output_file, model, is_offline); | ||||
if (ret == SUCCESS) { | if (ret == SUCCESS) { | ||||
GELOGI("Generate model with encrypt."); | |||||
GELOGD("Generate model with encrypt."); | |||||
} | } | ||||
return ret; | return ret; | ||||
} | } | ||||
@@ -213,7 +214,7 @@ Status OmFileSaveHelper::SaveModelToFile(const char *output_file, ModelBufferDat | |||||
FMK_UINT32_ADDCHECK(size_of_table, model_data_len) | FMK_UINT32_ADDCHECK(size_of_table, model_data_len) | ||||
model_header_.length = size_of_table + model_data_len; | model_header_.length = size_of_table + model_data_len; | ||||
GELOGI("Sizeof(ModelFileHeader):%zu,sizeof(ModelPartitionTable):%u, model_data_len:%u, model_total_len:%zu", | |||||
GELOGD("Sizeof(ModelFileHeader):%zu,sizeof(ModelPartitionTable):%u, model_data_len:%u, model_total_len:%zu", | |||||
sizeof(ModelFileHeader), size_of_table, model_data_len, model_header_.length + sizeof(ModelFileHeader)); | sizeof(ModelFileHeader), size_of_table, model_data_len, model_header_.length + sizeof(ModelFileHeader)); | ||||
std::vector<ModelPartition> partition_datas = context_.partition_datas_; | std::vector<ModelPartition> partition_datas = context_.partition_datas_; | ||||
@@ -224,7 +225,7 @@ Status OmFileSaveHelper::SaveModelToFile(const char *output_file, ModelBufferDat | |||||
ret = FileSaver::SaveToBuffWithFileHeader(model_header_, *partition_table, partition_datas, model); | ret = FileSaver::SaveToBuffWithFileHeader(model_header_, *partition_table, partition_datas, model); | ||||
} | } | ||||
if (ret == SUCCESS) { | if (ret == SUCCESS) { | ||||
GELOGI("Save model success without encrypt."); | |||||
GELOGD("Save model success without encrypt."); | |||||
} | } | ||||
return ret; | return ret; | ||||
#else | #else | ||||
@@ -51,7 +51,7 @@ bool KernelStore::Build() { | |||||
kernel_head.name_len = static_cast<uint32_t>(kernel->GetName().length()); | kernel_head.name_len = static_cast<uint32_t>(kernel->GetName().length()); | ||||
kernel_head.bin_len = static_cast<uint32_t>(kernel->GetBinDataSize()); | kernel_head.bin_len = static_cast<uint32_t>(kernel->GetBinDataSize()); | ||||
GELOGI("get kernel bin name %s, addr %p, size %u", kernel->GetName().c_str(), kernel->GetBinData(), | |||||
GELOGD("get kernel bin name %s, addr %p, size %u", kernel->GetName().c_str(), kernel->GetBinData(), | |||||
kernel->GetBinDataSize()); | kernel->GetBinDataSize()); | ||||
mem_ret = memcpy_s(next_buffer, remain_len, &kernel_head, sizeof(kernel_head)); | mem_ret = memcpy_s(next_buffer, remain_len, &kernel_head, sizeof(kernel_head)); | ||||
GE_CHK_BOOL_EXEC_NOLOG(mem_ret == EOK, return false); | GE_CHK_BOOL_EXEC_NOLOG(mem_ret == EOK, return false); | ||||
@@ -95,7 +95,7 @@ bool KernelStore::Load(const uint8_t *data, const size_t &len) { | |||||
std::string name(next_buffer, kernel_head->name_len); | std::string name(next_buffer, kernel_head->name_len); | ||||
next_buffer += kernel_head->name_len; | next_buffer += kernel_head->name_len; | ||||
GELOGI("Load kernel from om:%s,%u,%u", name.c_str(), kernel_head->name_len, kernel_head->bin_len); | |||||
GELOGD("Load kernel from om:%s,%u,%u", name.c_str(), kernel_head->name_len, kernel_head->bin_len); | |||||
std::vector<char> kernel_bin(next_buffer, next_buffer + kernel_head->bin_len); | std::vector<char> kernel_bin(next_buffer, next_buffer + kernel_head->bin_len); | ||||
KernelBinPtr teb_kernel_ptr = ge::MakeShared<KernelBin>(name, std::move(kernel_bin)); | KernelBinPtr teb_kernel_ptr = ge::MakeShared<KernelBin>(name, std::move(kernel_bin)); | ||||
if (teb_kernel_ptr != nullptr) { | if (teb_kernel_ptr != nullptr) { | ||||
@@ -17,7 +17,6 @@ | |||||
#include "common/model_parser/base.h" | #include "common/model_parser/base.h" | ||||
#include "common/helper/model_helper.h" | #include "common/helper/model_helper.h" | ||||
#include <securec.h> | #include <securec.h> | ||||
#include <sys/sysinfo.h> | |||||
#include <fstream> | #include <fstream> | ||||
#include <memory> | #include <memory> | ||||
#include <string> | #include <string> | ||||
@@ -36,15 +35,19 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::LoadFro | |||||
std::string real_path = RealPath(model_path); | std::string real_path = RealPath(model_path); | ||||
if (real_path.empty()) { | if (real_path.empty()) { | ||||
GELOGE(GE_EXEC_MODEL_PATH_INVALID, "Model file path '%s' is invalid", model_path); | GELOGE(GE_EXEC_MODEL_PATH_INVALID, "Model file path '%s' is invalid", model_path); | ||||
return GE_EXEC_MODEL_PATH_INVALID; | |||||
return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID; | |||||
} | } | ||||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(GetFileLength(model_path) == -1, return GE_EXEC_READ_MODEL_FILE_FAILED, | |||||
"File size not valid."); | |||||
if (GetFileLength(model_path) == -1) { | |||||
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "File size not valid, file: %s.", model_path); | |||||
return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID; | |||||
} | |||||
std::ifstream fs(real_path.c_str(), std::ifstream::binary); | std::ifstream fs(real_path.c_str(), std::ifstream::binary); | ||||
GE_CHK_BOOL_RET_STATUS(fs.is_open(), GE_EXEC_READ_MODEL_FILE_FAILED, "Open file failed! path:%s", model_path); | |||||
if (!fs.is_open()) { | |||||
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "Open file: %s failed, error: %s", model_path, strerror(errno)); | |||||
return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID; | |||||
} | |||||
// get length of file: | // get length of file: | ||||
(void)fs.seekg(0, std::ifstream::end); | (void)fs.seekg(0, std::ifstream::end); | ||||
@@ -56,8 +59,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::LoadFro | |||||
char *data = new (std::nothrow) char[len]; | char *data = new (std::nothrow) char[len]; | ||||
if (data == nullptr) { | if (data == nullptr) { | ||||
GELOGE(MEMALLOC_FAILED, "Load model From file failed, bad memory allocation occur. (need:%u)", len); | |||||
return MEMALLOC_FAILED; | |||||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Load model From file failed, bad memory allocation occur. (need:%u)", len); | |||||
return ACL_ERROR_GE_MEMORY_ALLOCATION; | |||||
} | } | ||||
// read data as a block: | // read data as a block: | ||||
@@ -80,7 +83,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::ParseMo | |||||
GE_CHECK_NOTNULL(model.model_data); | GE_CHECK_NOTNULL(model.model_data); | ||||
// Model length too small | // Model length too small | ||||
GE_CHK_BOOL_RET_STATUS(model.model_len >= sizeof(ModelFileHeader), GE_EXEC_MODEL_DATA_SIZE_INVALID, | |||||
GE_CHK_BOOL_RET_STATUS(model.model_len >= sizeof(ModelFileHeader), ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID, | |||||
"Invalid model. Model data size %u must be greater than or equal to %zu.", model.model_len, | "Invalid model. Model data size %u must be greater than or equal to %zu.", model.model_len, | ||||
sizeof(ModelFileHeader)); | sizeof(ModelFileHeader)); | ||||
// Get file header | // Get file header | ||||
@@ -88,7 +91,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::ParseMo | |||||
// Determine whether the file length and magic number match | // Determine whether the file length and magic number match | ||||
GE_CHK_BOOL_RET_STATUS( | GE_CHK_BOOL_RET_STATUS( | ||||
file_header->length == model.model_len - sizeof(ModelFileHeader) && file_header->magic == MODEL_FILE_MAGIC_NUM, | file_header->length == model.model_len - sizeof(ModelFileHeader) && file_header->magic == MODEL_FILE_MAGIC_NUM, | ||||
GE_EXEC_MODEL_DATA_SIZE_INVALID, | |||||
ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID, | |||||
"Invalid model. file_header->length[%u] + sizeof(ModelFileHeader)[%zu] != model->model_len[%u] || " | "Invalid model. file_header->length[%u] + sizeof(ModelFileHeader)[%zu] != model->model_len[%u] || " | ||||
"MODEL_FILE_MAGIC_NUM[%u] != file_header->magic[%u]", | "MODEL_FILE_MAGIC_NUM[%u] != file_header->magic[%u]", | ||||
file_header->length, sizeof(ModelFileHeader), model.model_len, MODEL_FILE_MAGIC_NUM, file_header->magic); | file_header->length, sizeof(ModelFileHeader), model.model_len, MODEL_FILE_MAGIC_NUM, file_header->magic); | ||||
@@ -98,15 +101,15 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::ParseMo | |||||
// Get data address | // Get data address | ||||
uint8_t *data = reinterpret_cast<uint8_t *>(model.model_data) + sizeof(ModelFileHeader); | uint8_t *data = reinterpret_cast<uint8_t *>(model.model_data) + sizeof(ModelFileHeader); | ||||
if (file_header->is_encrypt == ModelEncryptType::UNENCRYPTED) { // Unencrypted model | if (file_header->is_encrypt == ModelEncryptType::UNENCRYPTED) { // Unencrypted model | ||||
GE_CHK_BOOL_RET_STATUS(model.key.empty(), GE_EXEC_MODEL_NOT_SUPPORT_ENCRYPTION, | |||||
GE_CHK_BOOL_RET_STATUS(model.key.empty(), ACL_ERROR_GE_EXEC_MODEL_NOT_SUPPORT_ENCRYPTION, | |||||
"Invalid param. model is unencrypted, but key is not empty."); | "Invalid param. model is unencrypted, but key is not empty."); | ||||
model_data = data; | model_data = data; | ||||
model_len = file_header->length; | model_len = file_header->length; | ||||
GELOGI("Model_len is %u, model_file_head_len is %zu.", model_len, sizeof(ModelFileHeader)); | |||||
GELOGD("Model_len is %u, model_file_head_len is %zu.", model_len, sizeof(ModelFileHeader)); | |||||
} else { | } else { | ||||
GELOGE(GE_EXEC_MODEL_NOT_SUPPORT_ENCRYPTION, "Invalid model. ModelEncryptType not supported."); | |||||
res = GE_EXEC_MODEL_NOT_SUPPORT_ENCRYPTION; | |||||
GELOGE(ACL_ERROR_GE_EXEC_MODEL_NOT_SUPPORT_ENCRYPTION, "Invalid model. ModelEncryptType not supported."); | |||||
res = ACL_ERROR_GE_EXEC_MODEL_NOT_SUPPORT_ENCRYPTION; | |||||
} | } | ||||
return res; | return res; | ||||
@@ -16,9 +16,7 @@ | |||||
#include "common/model_saver.h" | #include "common/model_saver.h" | ||||
#include <fcntl.h> | |||||
#include <securec.h> | #include <securec.h> | ||||
#include <unistd.h> | |||||
#include <cstdlib> | #include <cstdlib> | ||||
#include <fstream> | #include <fstream> | ||||
#include <string> | #include <string> | ||||
@@ -51,14 +49,14 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
char real_path[PATH_MAX] = {0}; | |||||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(file_path) >= PATH_MAX, return FAILED, "file path is too long!"); | |||||
GE_IF_BOOL_EXEC(realpath(file_path, real_path) == nullptr, | |||||
char real_path[MMPA_MAX_PATH] = {0}; | |||||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(file_path) >= MMPA_MAX_PATH, return FAILED, "file path is too long!"); | |||||
GE_IF_BOOL_EXEC(mmRealPath(file_path, real_path, MMPA_MAX_PATH) != EN_OK, | |||||
GELOGI("File %s does not exit, it will be created.", file_path)); | GELOGI("File %s does not exit, it will be created.", file_path)); | ||||
// Open file | // Open file | ||||
mode_t mode = S_IRUSR | S_IWUSR; | |||||
int32_t fd = mmOpen2(real_path, O_RDWR | O_CREAT | O_TRUNC, mode); | |||||
mmMode_t mode = M_IRUSR | M_IWUSR; | |||||
int32_t fd = mmOpen2(real_path, M_RDWR | M_CREAT | O_TRUNC, mode); | |||||
if (fd == EN_ERROR || fd == EN_INVALID_PARAM) { | if (fd == EN_ERROR || fd == EN_INVALID_PARAM) { | ||||
ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"}, {file_path, strerror(errno)}); | ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"}, {file_path, strerror(errno)}); | ||||
GELOGE(FAILED, "Open file[%s] failed. %s", file_path, strerror(errno)); | GELOGE(FAILED, "Open file[%s] failed. %s", file_path, strerror(errno)); | ||||
@@ -71,7 +69,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi | |||||
if (mmpa_ret == EN_ERROR || mmpa_ret == EN_INVALID_PARAM) { | if (mmpa_ret == EN_ERROR || mmpa_ret == EN_INVALID_PARAM) { | ||||
ErrorManager::GetInstance().ATCReportErrMessage("E19004", {"file", "errmsg"}, {file_path, strerror(errno)}); | ErrorManager::GetInstance().ATCReportErrMessage("E19004", {"file", "errmsg"}, {file_path, strerror(errno)}); | ||||
// Need to both print the error info of mmWrite and mmClose, so return ret after mmClose | // Need to both print the error info of mmWrite and mmClose, so return ret after mmClose | ||||
GELOGE(FAILED, "Write to file failed. errno = %d, %s", mmpa_ret, strerror(errno)); | |||||
GELOGE(FAILED, "Write to file failed. errno = %ld, %s", mmpa_ret, strerror(errno)); | |||||
ret = FAILED; | ret = FAILED; | ||||
} | } | ||||
// Close file | // Close file | ||||
@@ -212,8 +212,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::Pa | |||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::InitFromOptions(const Options &options) { | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::InitFromOptions(const Options &options) { | ||||
#ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
// enable profiling support two ways: env and front end | // enable profiling support two ways: env and front end | ||||
const char *profiling_mode = std::getenv("PROFILING_MODE"); | |||||
const char *prof_options = std::getenv("PROFILING_OPTIONS"); | |||||
char profiling_mode_temp[MMPA_MAX_PATH] = {0x00}; | |||||
char prof_options_temp[MMPA_MAX_PATH] = {0x00}; | |||||
(void)mmGetEnv("PROFILING_MODE", profiling_mode_temp, MMPA_MAX_PATH); | |||||
(void)mmGetEnv("PROFILING_OPTIONS", prof_options_temp, MMPA_MAX_PATH); | |||||
const char *profiling_mode = profiling_mode_temp; | |||||
const char *prof_options = prof_options_temp; | |||||
if ((profiling_mode == nullptr) || (strcmp("true", profiling_mode) != 0) || (prof_options == nullptr)) { | if ((profiling_mode == nullptr) || (strcmp("true", profiling_mode) != 0) || (prof_options == nullptr)) { | ||||
is_load_profiling_ = false; | is_load_profiling_ = false; | ||||
is_execute_profiling_ = false; | is_execute_profiling_ = false; | ||||
@@ -553,7 +557,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ReportPr | |||||
GELOGE(rt_ret, "runtime get logic_device_id failed, current logic_device_id:%d", logic_device_id); | GELOGE(rt_ret, "runtime get logic_device_id failed, current logic_device_id:%d", logic_device_id); | ||||
return; | return; | ||||
} | } | ||||
GELOGI("current logic_device_id:%d", logic_device_id); | |||||
GELOGD("current logic_device_id:%d", logic_device_id); | |||||
if (check_device) { | if (check_device) { | ||||
auto ret = std::find(device_id_.begin(), device_id_.end(), logic_device_id); | auto ret = std::find(device_id_.begin(), device_id_.end(), logic_device_id); | ||||
if (ret == device_id_.end()) { | if (ret == device_id_.end()) { | ||||
@@ -561,11 +565,11 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ReportPr | |||||
return; | return; | ||||
} | } | ||||
} | } | ||||
GELOGI("start ProfilingTaskDescInfo."); | |||||
GELOGD("start ProfilingTaskDescInfo."); | |||||
ProfilingTaskDescInfo(model_id, task_desc_info, logic_device_id); | ProfilingTaskDescInfo(model_id, task_desc_info, logic_device_id); | ||||
GELOGI("start ProfilingGraphDescInfo."); | |||||
GELOGD("start ProfilingGraphDescInfo."); | |||||
ProfilingGraphDescInfo(model_id, compute_graph_desc_info, logic_device_id); | ProfilingGraphDescInfo(model_id, compute_graph_desc_info, logic_device_id); | ||||
GELOGI("Report profiling data for GE end."); | |||||
GELOGD("Report profiling data for GE end."); | |||||
#endif | #endif | ||||
} | } | ||||
@@ -844,7 +848,7 @@ ProfilingManager::ProfStartProfiling(uint64_t module, const std::map<std::string | |||||
for (int32_t i = 0; i < device_num; i++) { | for (int32_t i = 0; i < device_num; i++) { | ||||
device_id_ptr[i] = static_cast<uint32_t>(device_list[i]); | device_id_ptr[i] = static_cast<uint32_t>(device_list[i]); | ||||
} | } | ||||
GELOGI("Runtime config param: 0x%llx, device num: %d.", module, device_num); | |||||
GELOGD("Runtime config param: 0x%llx, device num: %d.", module, device_num); | |||||
rtError_t rt_ret = rtProfilerStart(module, device_num, device_id_ptr.get()); | rtError_t rt_ret = rtProfilerStart(module, device_num, device_id_ptr.get()); | ||||
if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
@@ -863,7 +867,7 @@ ProfilingManager::ProfStartProfiling(uint64_t module, const std::map<std::string | |||||
GELOGW("Prof start: load model module is invalid."); | GELOGW("Prof start: load model module is invalid."); | ||||
} | } | ||||
UpdateDeviceIdModuleMap(kProfStart, module, device_list); | UpdateDeviceIdModuleMap(kProfStart, module, device_list); | ||||
GELOGI("Prof start profiling success."); | |||||
GELOGD("Prof start profiling success."); | |||||
#endif | #endif | ||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
@@ -886,7 +890,7 @@ ProfilingManager::ProfStopProfiling(uint64_t module, const std::map<std::string, | |||||
for (int32_t i = 0; i < device_num; i++) { | for (int32_t i = 0; i < device_num; i++) { | ||||
device_id_ptr[i] = static_cast<uint32_t>(device_list[i]); | device_id_ptr[i] = static_cast<uint32_t>(device_list[i]); | ||||
} | } | ||||
GELOGI("Prof stop: runtime config param: 0x%llx, device num: %d", module, device_num); | |||||
GELOGD("Prof stop: runtime config param: 0x%llx, device num: %d", module, device_num); | |||||
rtError_t rt_ret = rtProfilerStop(module, device_num, device_id_ptr.get()); | rtError_t rt_ret = rtProfilerStop(module, device_num, device_id_ptr.get()); | ||||
if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
GELOGE(FAILED, "Prof stop: runtime profiler config proc failed."); | GELOGE(FAILED, "Prof stop: runtime profiler config proc failed."); | ||||
@@ -906,7 +910,7 @@ ProfilingManager::ProfStopProfiling(uint64_t module, const std::map<std::string, | |||||
GELOGW("Prof stop: load model module is invalid."); | GELOGW("Prof stop: load model module is invalid."); | ||||
} | } | ||||
UpdateDeviceIdModuleMap(kProfStop, module, device_list); | UpdateDeviceIdModuleMap(kProfStop, module, device_list); | ||||
GELOGI("Prof stop profiling success."); | |||||
GELOGD("Prof stop profiling success."); | |||||
#endif | #endif | ||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
@@ -948,14 +952,14 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ProfilingManager::Profilin | |||||
if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
GELOGE(rt_ret, "Runtime get logic_device_id failed, current logic_device_id:%d", logic_device_id); | GELOGE(rt_ret, "Runtime get logic_device_id failed, current logic_device_id:%d", logic_device_id); | ||||
} | } | ||||
GELOGI("Current logic_device_id:%d", logic_device_id); | |||||
GELOGD("Current logic_device_id:%d", logic_device_id); | |||||
bool execute_model_prof_on = false; | bool execute_model_prof_on = false; | ||||
auto iter = std::find(device_id_.begin(), device_id_.end(), logic_device_id); | auto iter = std::find(device_id_.begin(), device_id_.end(), logic_device_id); | ||||
if (iter != device_id_.end()) { | if (iter != device_id_.end()) { | ||||
execute_model_prof_on = true; | execute_model_prof_on = true; | ||||
} | } | ||||
GELOGI("Flag is_execute_profiling: %d, execute_model_prof_on: %d", is_execute_profiling_, execute_model_prof_on); | |||||
GELOGD("Flag is_execute_profiling: %d, execute_model_prof_on: %d", is_execute_profiling_, execute_model_prof_on); | |||||
return is_execute_profiling_ || execute_model_prof_on; | return is_execute_profiling_ || execute_model_prof_on; | ||||
} | } | ||||
@@ -25,13 +25,14 @@ | |||||
#include "common/dump/dump_properties.h" | #include "common/dump/dump_properties.h" | ||||
#include "graph/op_desc.h" | #include "graph/op_desc.h" | ||||
#include "common/ge_compiler_options.h" | |||||
namespace ge { | namespace ge { | ||||
// Configuration property management | // Configuration property management | ||||
static const char *SYSMODE __attribute__((unused)) = "FMK_SYSMODE"; | |||||
static const char *USE_FUSION __attribute__((unused)) = "FMK_USE_FUSION"; | |||||
static const char *TIMESTAT_ENABLE __attribute__((unused)) = "DAVINCI_TIMESTAT_ENABLE"; | |||||
static const char *ANNDROID_DEBUG __attribute__((unused)) = "ANNDROID_DEBUG"; | |||||
static const char *SYSMODE GE_ATTRIBUTE_UNUSED = "FMK_SYSMODE"; | |||||
static const char *USE_FUSION GE_ATTRIBUTE_UNUSED = "FMK_USE_FUSION"; | |||||
static const char *TIMESTAT_ENABLE GE_ATTRIBUTE_UNUSED = "DAVINCI_TIMESTAT_ENABLE"; | |||||
static const char *ANNDROID_DEBUG GE_ATTRIBUTE_UNUSED = "ANNDROID_DEBUG"; | |||||
class PropertiesManager { | class PropertiesManager { | ||||
public: | public: | ||||
@@ -476,6 +476,9 @@ REGISTER_OPTYPE_DEFINE(HVDCALLBACKALLGATHER, "HorovodAllgather"); | |||||
REGISTER_OPTYPE_DEFINE(HVDCALLBACKBROADCAST, "HorovodBroadcast"); | REGISTER_OPTYPE_DEFINE(HVDCALLBACKBROADCAST, "HorovodBroadcast"); | ||||
REGISTER_OPTYPE_DEFINE(HVDWAIT, "HorovodWait"); | REGISTER_OPTYPE_DEFINE(HVDWAIT, "HorovodWait"); | ||||
// aicpu op for online_infer dynamic_dims | |||||
REGISTER_OPTYPE_DEFINE(GETDYNAMICDIMS, "GetDynamicDims"); | |||||
const std::string MODEL_ATTR_TASKS = "tasks"; | const std::string MODEL_ATTR_TASKS = "tasks"; | ||||
const std::string MODEL_ATTR_TASK_GEN_BASE_ADDR = "task_gen_base_addr"; | const std::string MODEL_ATTR_TASK_GEN_BASE_ADDR = "task_gen_base_addr"; | ||||
const std::string MODEL_ATTR_TASK_GEN_WEIGHT_ADDR = "task_gen_weight_addr"; | const std::string MODEL_ATTR_TASK_GEN_WEIGHT_ADDR = "task_gen_weight_addr"; | ||||
@@ -16,11 +16,12 @@ | |||||
#include "framework/common/util.h" | #include "framework/common/util.h" | ||||
#include <fcntl.h> | |||||
#include <sys/stat.h> | #include <sys/stat.h> | ||||
#ifdef __GNUC__ | |||||
#include <regex.h> | #include <regex.h> | ||||
#include <unistd.h> | |||||
#else | |||||
#include <regex> | |||||
#endif | |||||
#include <algorithm> | #include <algorithm> | ||||
#include <climits> | #include <climits> | ||||
#include <cstdlib> | #include <cstdlib> | ||||
@@ -207,18 +208,18 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadBytesFromBinaryFile(co | |||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY int CreateDirectory(const std::string &directory_path) { | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY int CreateDirectory(const std::string &directory_path) { | ||||
GE_CHK_BOOL_EXEC(!directory_path.empty(), return -1, "directory path is empty."); | GE_CHK_BOOL_EXEC(!directory_path.empty(), return -1, "directory path is empty."); | ||||
auto dir_path_len = directory_path.length(); | auto dir_path_len = directory_path.length(); | ||||
if (dir_path_len >= PATH_MAX) { | |||||
if (dir_path_len >= MMPA_MAX_PATH) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E19002", {"filepath", "size"}, | ErrorManager::GetInstance().ATCReportErrMessage("E19002", {"filepath", "size"}, | ||||
{directory_path, std::to_string(PATH_MAX)}); | |||||
GELOGW("Path[%s] len is too long, it must be less than %d", directory_path.c_str(), PATH_MAX); | |||||
{directory_path, std::to_string(MMPA_MAX_PATH)}); | |||||
GELOGW("Path[%s] len is too long, it must be less than %d", directory_path.c_str(), MMPA_MAX_PATH); | |||||
return -1; | return -1; | ||||
} | } | ||||
char tmp_dir_path[PATH_MAX] = {0}; | |||||
char tmp_dir_path[MMPA_MAX_PATH] = {0}; | |||||
for (size_t i = 0; i < dir_path_len; i++) { | for (size_t i = 0; i < dir_path_len; i++) { | ||||
tmp_dir_path[i] = directory_path[i]; | tmp_dir_path[i] = directory_path[i]; | ||||
if ((tmp_dir_path[i] == '\\') || (tmp_dir_path[i] == '/')) { | if ((tmp_dir_path[i] == '\\') || (tmp_dir_path[i] == '/')) { | ||||
if (access(tmp_dir_path, F_OK) != 0) { | |||||
int32_t ret = mmMkdir(tmp_dir_path, S_IRUSR | S_IWUSR | S_IXUSR); // 700 | |||||
if (mmAccess2(tmp_dir_path, M_F_OK) != EN_OK) { | |||||
int32_t ret = mmMkdir(tmp_dir_path, M_IRUSR | M_IWUSR | M_IXUSR); // 700 | |||||
if (ret != 0) { | if (ret != 0) { | ||||
if (errno != EEXIST) { | if (errno != EEXIST) { | ||||
ErrorManager::GetInstance().ATCReportErrMessage("E19006", {"path"}, {directory_path}); | ErrorManager::GetInstance().ATCReportErrMessage("E19006", {"path"}, {directory_path}); | ||||
@@ -229,7 +230,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY int CreateDirectory(const std:: | |||||
} | } | ||||
} | } | ||||
} | } | ||||
int32_t ret = mmMkdir(const_cast<char *>(directory_path.c_str()), S_IRUSR | S_IWUSR | S_IXUSR); // 700 | |||||
int32_t ret = mmMkdir(const_cast<char *>(directory_path.c_str()), M_IRUSR | M_IWUSR | M_IXUSR); // 700 | |||||
if (ret != 0) { | if (ret != 0) { | ||||
if (errno != EEXIST) { | if (errno != EEXIST) { | ||||
ErrorManager::GetInstance().ATCReportErrMessage("E19006", {"path"}, {directory_path}); | ErrorManager::GetInstance().ATCReportErrMessage("E19006", {"path"}, {directory_path}); | ||||
@@ -304,9 +305,9 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromMem(const cha | |||||
} | } | ||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint64_t GetCurrentTimestamp() { | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint64_t GetCurrentTimestamp() { | ||||
struct timeval tv {}; | |||||
int ret = gettimeofday(&tv, nullptr); | |||||
GE_LOGE_IF(ret != 0, "Func gettimeofday may failed: ret=%d", ret); | |||||
mmTimeval tv{}; | |||||
int ret = mmGetTimeOfDay(&tv, nullptr); | |||||
GE_LOGE_IF(ret != EN_OK, "Func gettimeofday may failed: ret=%d", ret); | |||||
auto total_use_time = tv.tv_usec + tv.tv_sec * 1000000; // 1000000: seconds to microseconds | auto total_use_time = tv.tv_usec + tv.tv_sec * 1000000; // 1000000: seconds to microseconds | ||||
return static_cast<uint64_t>(total_use_time); | return static_cast<uint64_t>(total_use_time); | ||||
} | } | ||||
@@ -346,16 +347,16 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInt64MulOverflow(int6 | |||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string RealPath(const char *path) { | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string RealPath(const char *path) { | ||||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(path == nullptr, return "", "path pointer is NULL."); | GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(path == nullptr, return "", "path pointer is NULL."); | ||||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | |||||
strlen(path) >= PATH_MAX, | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E19002", {"filepath", "size"}, {path, std::to_string(PATH_MAX)}); | |||||
return "", "Path[%s] len is too long, it must be less than %d", path, PATH_MAX); | |||||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(path) >= MMPA_MAX_PATH, | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E19002", {"filepath", "size"}, | |||||
{path, std::to_string(MMPA_MAX_PATH)}); | |||||
return "", "Path[%s] len is too long, it must be less than %d", path, MMPA_MAX_PATH); | |||||
// Nullptr is returned when the path does not exist or there is no permission | // Nullptr is returned when the path does not exist or there is no permission | ||||
// Return absolute path when path is accessible | // Return absolute path when path is accessible | ||||
std::string res; | std::string res; | ||||
char resolved_path[PATH_MAX] = {0}; | |||||
if (realpath(path, resolved_path) != nullptr) { | |||||
char resolved_path[MMPA_MAX_PATH] = {0}; | |||||
if (mmRealPath(path, resolved_path, MMPA_MAX_PATH) == EN_OK) { | |||||
res = resolved_path; | res = resolved_path; | ||||
} | } | ||||
@@ -382,7 +383,11 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInputPathValid(const | |||||
// A regular matching expression to verify the validity of the input file path | // A regular matching expression to verify the validity of the input file path | ||||
// Path section: Support upper and lower case letters, numbers dots(.) chinese and underscores | // Path section: Support upper and lower case letters, numbers dots(.) chinese and underscores | ||||
// File name section: Support upper and lower case letters, numbers, underscores chinese and dots(.) | // File name section: Support upper and lower case letters, numbers, underscores chinese and dots(.) | ||||
#ifdef __GNUC__ | |||||
std::string mode = "^[\u4e00-\u9fa5A-Za-z0-9./_-]+$"; | std::string mode = "^[\u4e00-\u9fa5A-Za-z0-9./_-]+$"; | ||||
#else | |||||
std::string mode = "^[a-zA-Z]:([\\\\/][^\\s\\\\/:*?<>\"|][^\\\\/:*?<>\"|]*)*([/\\\\][^\\s\\\\/:*?<>\"|])?$"; | |||||
#endif | |||||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | ||||
!ValidateStr(real_path, mode), | !ValidateStr(real_path, mode), | ||||
@@ -391,7 +396,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInputPathValid(const | |||||
return false, "Invalid value for %s[%s], %s.", atc_param.c_str(), real_path.c_str(), kPathValidReason); | return false, "Invalid value for %s[%s], %s.", atc_param.c_str(), real_path.c_str(), kPathValidReason); | ||||
// The absolute path points to a file that is not readable | // The absolute path points to a file that is not readable | ||||
if (access(real_path.c_str(), R_OK) != 0) { | |||||
if (mmAccess2(real_path.c_str(), M_R_OK) != EN_OK) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E19003", {"file", "errmsg"}, {file_path.c_str(), strerror(errno)}); | ErrorManager::GetInstance().ATCReportErrMessage("E19003", {"file", "errmsg"}, {file_path.c_str(), strerror(errno)}); | ||||
GELOGW("Read file[%s] failed, errmsg[%s]", file_path.c_str(), strerror(errno)); | GELOGW("Read file[%s] failed, errmsg[%s]", file_path.c_str(), strerror(errno)); | ||||
return false; | return false; | ||||
@@ -409,15 +414,20 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const | |||||
return false; | return false; | ||||
} | } | ||||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | |||||
strlen(file_path.c_str()) >= PATH_MAX, ErrorManager::GetInstance().ATCReportErrMessage( | |||||
"E19002", {"filepath", "size"}, {file_path, std::to_string(PATH_MAX)}); | |||||
return "", "Path[%s] len is too long, it must be less than %d", file_path.c_str(), PATH_MAX); | |||||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(file_path.c_str()) >= MMPA_MAX_PATH, | |||||
ErrorManager::GetInstance().ATCReportErrMessage( | |||||
"E19002", {"filepath", "size"}, {file_path, std::to_string(MMPA_MAX_PATH)}); | |||||
return "", "Path[%s] len is too long, it must be less than %d", file_path.c_str(), | |||||
MMPA_MAX_PATH); | |||||
// A regular matching expression to verify the validity of the input file path | // A regular matching expression to verify the validity of the input file path | ||||
// Path section: Support upper and lower case letters, numbers dots(.) chinese and underscores | // Path section: Support upper and lower case letters, numbers dots(.) chinese and underscores | ||||
// File name section: Support upper and lower case letters, numbers, underscores chinese and dots(.) | // File name section: Support upper and lower case letters, numbers, underscores chinese and dots(.) | ||||
#ifdef __GNUC__ | |||||
std::string mode = "^[\u4e00-\u9fa5A-Za-z0-9./_-]+$"; | std::string mode = "^[\u4e00-\u9fa5A-Za-z0-9./_-]+$"; | ||||
#else | |||||
std::string mode = "^[a-zA-Z]:([\\\\/][^\\s\\\\/:*?<>\"|][^\\\\/:*?<>\"|]*)*([/\\\\][^\\s\\\\/:*?<>\"|])?$"; | |||||
#endif | |||||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | ||||
!ValidateStr(file_path, mode), | !ValidateStr(file_path, mode), | ||||
@@ -429,7 +439,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const | |||||
// Can get absolute path (file exists) | // Can get absolute path (file exists) | ||||
if (!real_path.empty()) { | if (!real_path.empty()) { | ||||
// File is not readable or writable | // File is not readable or writable | ||||
if (access(real_path.c_str(), W_OK | F_OK) != 0) { | |||||
if (mmAccess2(real_path.c_str(), M_W_OK | M_F_OK) != EN_OK) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E19004", {"file", "errmsg"}, {real_path, strerror(errno)}); | ErrorManager::GetInstance().ATCReportErrMessage("E19004", {"file", "errmsg"}, {real_path, strerror(errno)}); | ||||
GELOGW("Write file[%s] failed, errmsg[%s]", real_path.c_str(), strerror(errno)); | GELOGW("Write file[%s] failed, errmsg[%s]", real_path.c_str(), strerror(errno)); | ||||
return false; | return false; | ||||
@@ -460,6 +470,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const | |||||
} | } | ||||
FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &str, const std::string &mode) { | FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &str, const std::string &mode) { | ||||
#ifdef __GNUC__ | |||||
char ebuff[kMaxBuffSize]; | char ebuff[kMaxBuffSize]; | ||||
regex_t reg; | regex_t reg; | ||||
int cflags = REG_EXTENDED | REG_NOSUB; | int cflags = REG_EXTENDED | REG_NOSUB; | ||||
@@ -481,6 +492,23 @@ FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &str, const std::str | |||||
regfree(®); | regfree(®); | ||||
return true; | return true; | ||||
#else | |||||
std::wstring wstr(str.begin(), str.end()); | |||||
std::wstring wmode(mode.begin(), mode.end()); | |||||
std::wsmatch match; | |||||
bool res = false; | |||||
try { | |||||
std::wregex reg(wmode, std::regex::icase); | |||||
// Matching string part | |||||
res = regex_match(wstr, match, reg); | |||||
res = regex_search(str, std::regex("[`!@#$%^&*()|{}';',<>?]")); | |||||
} catch (std::exception &ex) { | |||||
GELOGW("The directory %s is invalid, error: %s.", str.c_str(), ex.what()); | |||||
return false; | |||||
} | |||||
return !(res) && (str.size() == match.str().size()); | |||||
#endif | |||||
} | } | ||||
FMK_FUNC_HOST_VISIBILITY bool IsValidFile(const char *file_path) { | FMK_FUNC_HOST_VISIBILITY bool IsValidFile(const char *file_path) { | ||||
@@ -434,7 +434,7 @@ Status DNNEngineManager::ReadJsonFile(const std::string &file_path, JsonHandle h | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
const char *file = file_path.data(); | const char *file = file_path.data(); | ||||
if ((access(file, F_OK)) == -1) { | |||||
if ((mmAccess2(file, M_F_OK)) != EN_OK) { | |||||
if (engines_map_.size() != 0) { | if (engines_map_.size() != 0) { | ||||
GELOGE(FAILED, "The json file %s is not exist, %s", file_path.c_str(), strerror(errno)); | GELOGE(FAILED, "The json file %s is not exist, %s", file_path.c_str(), strerror(errno)); | ||||
return FAILED; | return FAILED; | ||||
@@ -50,19 +50,6 @@ const size_t kDynamicImageSizeVecSize = 2; | |||||
const size_t kDynamicImageSizeInputSize = 2; | const size_t kDynamicImageSizeInputSize = 2; | ||||
const char *const kBatchLabel = "Batch_"; | const char *const kBatchLabel = "Batch_"; | ||||
ge::Status TransferDomiErrorCode(const uint32_t errorCode) { | |||||
switch (errorCode) { | |||||
case ge::PARAM_INVALID: | |||||
case domi::PARAM_INVALID: | |||||
return ge::PARAM_INVALID; | |||||
case ge::INTERNAL_ERROR: | |||||
case domi::INTERNAL_ERROR: | |||||
return ge::INTERNAL_ERROR; | |||||
default: | |||||
return ge::FAILED; | |||||
} | |||||
} | |||||
void GetGeTensorDescFromDomiInfo(std::vector<ge::TensorDesc> &ge_descs, | void GetGeTensorDescFromDomiInfo(std::vector<ge::TensorDesc> &ge_descs, | ||||
const std::vector<ge::InputOutputDescInfo> &domi_descs, | const std::vector<ge::InputOutputDescInfo> &domi_descs, | ||||
const std::vector<uint32_t> &formats) { | const std::vector<uint32_t> &formats) { | ||||
@@ -79,6 +66,7 @@ void GetGeTensorDescFromDomiInfo(std::vector<ge::TensorDesc> &ge_descs, | |||||
ge::Shape ge_shape(shape_dims); | ge::Shape ge_shape(shape_dims); | ||||
ge_desc.SetShape(ge_shape); | ge_desc.SetShape(ge_shape); | ||||
ge_desc.SetSize(desc_item.size); | ge_desc.SetSize(desc_item.size); | ||||
ge_desc.SetShapeRange(desc_item.shape_info.shape_ranges); | |||||
ge_descs.emplace_back(ge_desc); | ge_descs.emplace_back(ge_desc); | ||||
++idx; | ++idx; | ||||
} | } | ||||
@@ -285,14 +273,14 @@ Status GeExecutor::Finalize() { | |||||
Status GeExecutor::SetDynamicBatchSize(uint32_t model_id, void *dynamic_input_addr, uint64_t length, | Status GeExecutor::SetDynamicBatchSize(uint32_t model_id, void *dynamic_input_addr, uint64_t length, | ||||
uint64_t batch_size) { | uint64_t batch_size) { | ||||
if (dynamic_input_addr == nullptr) { | if (dynamic_input_addr == nullptr) { | ||||
GELOGE(PARAM_INVALID, "Dynamic input addr is nullptr!"); | |||||
return PARAM_INVALID; | |||||
GELOGE(ACL_ERROR_GE_DYNAMIC_INPUT_ADDR_INVALID, "Dynamic input addr is nullptr!"); | |||||
return ACL_ERROR_GE_DYNAMIC_INPUT_ADDR_INVALID; | |||||
} | } | ||||
uint64_t size = sizeof(uint32_t); | uint64_t size = sizeof(uint32_t); | ||||
if (length < size) { | if (length < size) { | ||||
GELOGE(PARAM_INVALID, "Dynamic input size [%lu] is less than [%lu]!", length, size); | |||||
return PARAM_INVALID; | |||||
GELOGE(ACL_ERROR_GE_DYNAMIC_INPUT_LENGTH_INVALID, "Dynamic input size [%lu] is less than [%lu]!", length, size); | |||||
return ACL_ERROR_GE_DYNAMIC_INPUT_LENGTH_INVALID; | |||||
} | } | ||||
if (length >= sizeof(uint64_t)) { | if (length >= sizeof(uint64_t)) { | ||||
size = sizeof(uint64_t); | size = sizeof(uint64_t); | ||||
@@ -309,8 +297,8 @@ Status GeExecutor::SetDynamicBatchSize(uint32_t model_id, void *dynamic_input_ad | |||||
} | } | ||||
if (!IsDynamicBatchSizeMatchModel(batch_size, batch_info)) { | if (!IsDynamicBatchSizeMatchModel(batch_size, batch_info)) { | ||||
GELOGE(PARAM_INVALID, "The current dynamic input does not match the gear of the model."); | |||||
return PARAM_INVALID; | |||||
GELOGE(ACL_ERROR_GE_DYNAMIC_BATCH_SIZE_INVALID, "The current dynamic input does not match the gear of the model."); | |||||
return ACL_ERROR_GE_DYNAMIC_BATCH_SIZE_INVALID; | |||||
} | } | ||||
ret = GraphExecutor::SetDynamicSize(model_id, batch_num, static_cast<int32_t>(DYNAMIC_BATCH)); | ret = GraphExecutor::SetDynamicSize(model_id, batch_num, static_cast<int32_t>(DYNAMIC_BATCH)); | ||||
@@ -321,7 +309,7 @@ Status GeExecutor::SetDynamicBatchSize(uint32_t model_id, void *dynamic_input_ad | |||||
// memcpy dynamic_batch_size from host to device | // memcpy dynamic_batch_size from host to device | ||||
rtError_t rt_ret = rtMemcpy(dynamic_input_addr, length, &batch_size, size, RT_MEMCPY_HOST_TO_DEVICE); | rtError_t rt_ret = rtMemcpy(dynamic_input_addr, length, &batch_size, size, RT_MEMCPY_HOST_TO_DEVICE); | ||||
if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
GELOGE(RT_FAILED, "memcpy dynamic batch input data failed! ret: 0x%X", rt_ret); | |||||
GELOGE(rt_ret, "memcpy dynamic batch input data failed! ret: 0x%X", rt_ret); | |||||
return RT_ERROR_TO_GE_STATUS(rt_ret); | return RT_ERROR_TO_GE_STATUS(rt_ret); | ||||
} | } | ||||
return SUCCESS; | return SUCCESS; | ||||
@@ -330,14 +318,15 @@ Status GeExecutor::SetDynamicBatchSize(uint32_t model_id, void *dynamic_input_ad | |||||
Status GeExecutor::SetDynamicImageSize(uint32_t model_id, void *dynamic_input_addr, uint64_t length, | Status GeExecutor::SetDynamicImageSize(uint32_t model_id, void *dynamic_input_addr, uint64_t length, | ||||
uint64_t image_height, uint64_t image_width) { | uint64_t image_height, uint64_t image_width) { | ||||
if (dynamic_input_addr == nullptr) { | if (dynamic_input_addr == nullptr) { | ||||
GELOGE(PARAM_INVALID, "Dynamic input addr is nullptr!"); | |||||
return PARAM_INVALID; | |||||
GELOGE(ACL_ERROR_GE_DYNAMIC_INPUT_ADDR_INVALID, "Dynamic input addr is nullptr!"); | |||||
return ACL_ERROR_GE_DYNAMIC_INPUT_ADDR_INVALID; | |||||
} | } | ||||
uint64_t dynamic_input_size = kDynamicImageSizeInputSize * sizeof(uint32_t); | uint64_t dynamic_input_size = kDynamicImageSizeInputSize * sizeof(uint32_t); | ||||
if (length < dynamic_input_size) { | if (length < dynamic_input_size) { | ||||
GELOGE(PARAM_INVALID, "Dynamic input size [%lu] is less than [%lu]!", length, dynamic_input_size); | |||||
return PARAM_INVALID; | |||||
GELOGE(ACL_ERROR_GE_DYNAMIC_INPUT_LENGTH_INVALID, "Dynamic input size [%lu] is less than [%lu]!", length, | |||||
dynamic_input_size); | |||||
return ACL_ERROR_GE_DYNAMIC_INPUT_LENGTH_INVALID; | |||||
} | } | ||||
uint64_t size = sizeof(uint32_t); | uint64_t size = sizeof(uint32_t); | ||||
if (length >= kDynamicImageSizeInputSize * sizeof(uint64_t)) { | if (length >= kDynamicImageSizeInputSize * sizeof(uint64_t)) { | ||||
@@ -354,8 +343,8 @@ Status GeExecutor::SetDynamicImageSize(uint32_t model_id, void *dynamic_input_ad | |||||
} | } | ||||
if (!IsDynamicImageSizeMatchModel(image_height, image_width, batch_info)) { | if (!IsDynamicImageSizeMatchModel(image_height, image_width, batch_info)) { | ||||
GELOGE(PARAM_INVALID, "The current dynamic input does not match the gear of the model."); | |||||
return PARAM_INVALID; | |||||
GELOGE(ACL_ERROR_GE_DYNAMIC_BATCH_SIZE_INVALID, "The current dynamic input does not match the gear of the model."); | |||||
return ACL_ERROR_GE_DYNAMIC_BATCH_SIZE_INVALID; | |||||
} | } | ||||
ret = GraphExecutor::SetDynamicSize(model_id, batch_num, static_cast<int32_t>(DYNAMIC_IMAGE)); | ret = GraphExecutor::SetDynamicSize(model_id, batch_num, static_cast<int32_t>(DYNAMIC_IMAGE)); | ||||
@@ -367,16 +356,17 @@ Status GeExecutor::SetDynamicImageSize(uint32_t model_id, void *dynamic_input_ad | |||||
// Memcpy dynamic resolution height from host to device | // Memcpy dynamic resolution height from host to device | ||||
rtError_t rt_ret = rtMemcpy(dynamic_input_addr, size, &image_height, size, RT_MEMCPY_HOST_TO_DEVICE); | rtError_t rt_ret = rtMemcpy(dynamic_input_addr, size, &image_height, size, RT_MEMCPY_HOST_TO_DEVICE); | ||||
if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
GELOGE(RT_FAILED, "memcpy dynamic resolution input data failed! ret: 0x%X", rt_ret); | |||||
GELOGE(rt_ret, "memcpy dynamic resolution input data failed! ret: 0x%X", rt_ret); | |||||
return RT_ERROR_TO_GE_STATUS(rt_ret); | return RT_ERROR_TO_GE_STATUS(rt_ret); | ||||
} | } | ||||
uint64_t remain_size = length - size; | uint64_t remain_size = length - size; | ||||
// Memcpy dynamic resolution width from host to device | // Memcpy dynamic resolution width from host to device | ||||
if (rtMemcpy(reinterpret_cast<void *>(reinterpret_cast<uint8_t *>(dynamic_input_addr) + size), remain_size, | |||||
&image_width, size, RT_MEMCPY_HOST_TO_DEVICE) != RT_ERROR_NONE) { | |||||
GELOGE(FAILED, "memcpy dynamic resolution input data failed!"); | |||||
return FAILED; | |||||
rt_ret = rtMemcpy(reinterpret_cast<void *>(reinterpret_cast<uint8_t *>(dynamic_input_addr) + size), remain_size, | |||||
&image_width, size, RT_MEMCPY_HOST_TO_DEVICE); | |||||
if (rt_ret != RT_ERROR_NONE) { | |||||
GELOGE(rt_ret, "memcpy dynamic resolution input data failed!"); | |||||
return RT_ERROR_TO_GE_STATUS(rt_ret); | |||||
} | } | ||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
@@ -384,15 +374,15 @@ Status GeExecutor::SetDynamicImageSize(uint32_t model_id, void *dynamic_input_ad | |||||
Status GeExecutor::SetDynamicDims(uint32_t model_id, void *dynamic_input_addr, uint64_t length, | Status GeExecutor::SetDynamicDims(uint32_t model_id, void *dynamic_input_addr, uint64_t length, | ||||
const vector<uint64_t> &dynamic_dims) { | const vector<uint64_t> &dynamic_dims) { | ||||
if (dynamic_input_addr == nullptr) { | if (dynamic_input_addr == nullptr) { | ||||
GELOGE(FAILED, "Dynamic input addr is nullptr!"); | |||||
return FAILED; | |||||
GELOGE(ACL_ERROR_GE_DYNAMIC_INPUT_ADDR_INVALID, "Dynamic input addr is nullptr!"); | |||||
return ACL_ERROR_GE_DYNAMIC_INPUT_ADDR_INVALID; | |||||
} | } | ||||
vector<uint64_t> cur_dynamic_dims; | vector<uint64_t> cur_dynamic_dims; | ||||
Status ret = GetCurDynamicDims(model_id, dynamic_dims, cur_dynamic_dims); | Status ret = GetCurDynamicDims(model_id, dynamic_dims, cur_dynamic_dims); | ||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
GELOGE(FAILED, "Set cur gear dynamic dims failed"); | |||||
return FAILED; | |||||
GELOGE(ret, "Set cur gear dynamic dims failed"); | |||||
return ret; | |||||
} | } | ||||
std::vector<std::vector<int64_t>> batch_info; | std::vector<std::vector<int64_t>> batch_info; | ||||
int32_t dynamic_type = static_cast<int32_t>(FIXED); | int32_t dynamic_type = static_cast<int32_t>(FIXED); | ||||
@@ -403,32 +393,35 @@ Status GeExecutor::SetDynamicDims(uint32_t model_id, void *dynamic_input_addr, u | |||||
} | } | ||||
if (!IsDynmaicDimsSizeMatchModel(cur_dynamic_dims, batch_info)) { | if (!IsDynmaicDimsSizeMatchModel(cur_dynamic_dims, batch_info)) { | ||||
GELOGE(PARAM_INVALID, "The current dynamic input does not match the gear of the model."); | |||||
return PARAM_INVALID; | |||||
GELOGE(ACL_ERROR_GE_DYNAMIC_BATCH_SIZE_INVALID, "The current dynamic input does not match the gear of the model."); | |||||
return ACL_ERROR_GE_DYNAMIC_BATCH_SIZE_INVALID; | |||||
} | } | ||||
ret = GraphExecutor::SetDynamicSize(model_id, cur_dynamic_dims, static_cast<int32_t>(DYNAMIC_DIMS)); | ret = GraphExecutor::SetDynamicSize(model_id, cur_dynamic_dims, static_cast<int32_t>(DYNAMIC_DIMS)); | ||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
GELOGE(FAILED, "Set dynamic size failed"); | |||||
return FAILED; | |||||
GELOGE(ret, "Set dynamic size failed"); | |||||
return ret; | |||||
} | } | ||||
size_t dynamic_dim_num = cur_dynamic_dims.size(); | size_t dynamic_dim_num = cur_dynamic_dims.size(); | ||||
uint64_t dynamic_input_size = static_cast<uint64_t>(dynamic_dim_num * sizeof(uint32_t)); | uint64_t dynamic_input_size = static_cast<uint64_t>(dynamic_dim_num * sizeof(uint32_t)); | ||||
if (length < dynamic_input_size) { | if (length < dynamic_input_size) { | ||||
GELOGE(FAILED, "Dynamic input size [%lu] is less than [%lu]!", length, dynamic_input_size); | |||||
return FAILED; | |||||
GELOGE(ACL_ERROR_GE_DYNAMIC_INPUT_LENGTH_INVALID, "Dynamic input size [%lu] is less than [%lu]!", length, | |||||
dynamic_input_size); | |||||
return ACL_ERROR_GE_DYNAMIC_INPUT_LENGTH_INVALID; | |||||
} | } | ||||
uint64_t size = sizeof(uint32_t); | uint64_t size = sizeof(uint32_t); | ||||
if (length >= dynamic_dim_num * sizeof(uint64_t)) { | if (length >= dynamic_dim_num * sizeof(uint64_t)) { | ||||
size = sizeof(uint64_t); | size = sizeof(uint64_t); | ||||
} | } | ||||
rtError_t rt_ret; | |||||
for (uint32_t i = 0; i < dynamic_dim_num; ++i) { | for (uint32_t i = 0; i < dynamic_dim_num; ++i) { | ||||
// Memcpy dynamic dim[i] from host to device | // Memcpy dynamic dim[i] from host to device | ||||
if (rtMemcpy(reinterpret_cast<void *>(reinterpret_cast<uint8_t *>(dynamic_input_addr) + size * i), | |||||
length - size * i, &cur_dynamic_dims[i], size, RT_MEMCPY_HOST_TO_DEVICE) != RT_ERROR_NONE) { | |||||
GELOGE(FAILED, "memcpy dynamic resolution input data failed!"); | |||||
return FAILED; | |||||
rt_ret = rtMemcpy(reinterpret_cast<void *>(reinterpret_cast<uint8_t *>(dynamic_input_addr) + size * i), | |||||
length - size * i, &cur_dynamic_dims[i], size, RT_MEMCPY_HOST_TO_DEVICE); | |||||
if (rt_ret != RT_ERROR_NONE) { | |||||
GELOGE(rt_ret, "memcpy dynamic resolution input data failed!"); | |||||
return RT_ERROR_TO_GE_STATUS(rt_ret); | |||||
} | } | ||||
} | } | ||||
return SUCCESS; | return SUCCESS; | ||||
@@ -441,15 +434,15 @@ Status GeExecutor::GetCurDynamicDims(uint32_t model_id, const vector<uint64_t> & | |||||
vector<ge::TensorDesc> output_desc; | vector<ge::TensorDesc> output_desc; | ||||
auto ret = GetModelDescInfo(model_id, input_desc, output_desc); | auto ret = GetModelDescInfo(model_id, input_desc, output_desc); | ||||
if (ret != ge::SUCCESS) { | if (ret != ge::SUCCESS) { | ||||
GELOGE(FAILED, "GetModelDescInfo failed."); | |||||
return FAILED; | |||||
GELOGE(ret, "GetModelDescInfo failed."); | |||||
return ret; | |||||
} | } | ||||
vector<string> user_designate_shape_order; | vector<string> user_designate_shape_order; | ||||
vector<int64_t> all_data_dims; | vector<int64_t> all_data_dims; | ||||
ret = GetUserDesignateShapeOrder(model_id, user_designate_shape_order); | ret = GetUserDesignateShapeOrder(model_id, user_designate_shape_order); | ||||
if (ret != ge::SUCCESS) { | if (ret != ge::SUCCESS) { | ||||
GELOGE(FAILED, "GetUserDesignateShapeOrder failed."); | |||||
return FAILED; | |||||
GELOGE(ret, "GetUserDesignateShapeOrder failed."); | |||||
return ret; | |||||
} | } | ||||
for (auto &data_name : user_designate_shape_order) { | for (auto &data_name : user_designate_shape_order) { | ||||
for (auto &desc : input_desc) { | for (auto &desc : input_desc) { | ||||
@@ -462,17 +455,18 @@ Status GeExecutor::GetCurDynamicDims(uint32_t model_id, const vector<uint64_t> & | |||||
} | } | ||||
} | } | ||||
if (dynamic_dims.size() != all_data_dims.size()) { | if (dynamic_dims.size() != all_data_dims.size()) { | ||||
GELOGE(FAILED, "Dynamic input size [%lu] is not equal with all data dims size [%lu]!", dynamic_dims.size(), | |||||
GELOGE(ACL_ERROR_GE_DYNAMIC_INPUT_LENGTH_INVALID, | |||||
"Dynamic input size [%lu] is not equal with all data dims size [%lu]!", dynamic_dims.size(), | |||||
all_data_dims.size()); | all_data_dims.size()); | ||||
return FAILED; | |||||
return ACL_ERROR_GE_DYNAMIC_INPUT_LENGTH_INVALID; | |||||
} | } | ||||
for (std::size_t i = 0; i < all_data_dims.size(); ++i) { | for (std::size_t i = 0; i < all_data_dims.size(); ++i) { | ||||
if (all_data_dims[i] < 0) { | if (all_data_dims[i] < 0) { | ||||
cur_dynamic_dims.push_back(dynamic_dims[i]); | cur_dynamic_dims.push_back(dynamic_dims[i]); | ||||
} else if (static_cast<uint64_t>(all_data_dims[i]) != dynamic_dims[i]) { | } else if (static_cast<uint64_t>(all_data_dims[i]) != dynamic_dims[i]) { | ||||
GELOGE(PARAM_INVALID, "Static dims should be same, index: %zu value: %d should be %d", i, dynamic_dims[i], | |||||
all_data_dims[i]); | |||||
return PARAM_INVALID; | |||||
GELOGE(ACL_ERROR_GE_DYNAMIC_INPUT_LENGTH_INVALID, "Static dims should be same, index: %zu value: %d should be %d", | |||||
i, dynamic_dims[i], all_data_dims[i]); | |||||
return ACL_ERROR_GE_DYNAMIC_INPUT_LENGTH_INVALID; | |||||
} | } | ||||
} | } | ||||
return SUCCESS; | return SUCCESS; | ||||
@@ -481,8 +475,8 @@ Status GeExecutor::GetCurDynamicDims(uint32_t model_id, const vector<uint64_t> & | |||||
Status GeExecutor::GetCurShape(const uint32_t model_id, std::vector<int64_t> &batch_info, int32_t &dynamic_type) { | Status GeExecutor::GetCurShape(const uint32_t model_id, std::vector<int64_t> &batch_info, int32_t &dynamic_type) { | ||||
GELOGI("Begin to get current shape"); | GELOGI("Begin to get current shape"); | ||||
if (!isInit_) { | if (!isInit_) { | ||||
GELOGE(GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return GE_EXEC_NOT_INIT; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
Status ret = GraphExecutor::GetCurShape(model_id, batch_info, dynamic_type); | Status ret = GraphExecutor::GetCurShape(model_id, batch_info, dynamic_type); | ||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
@@ -497,12 +491,12 @@ Status GeExecutor::SetDynamicAippData(uint32_t model_id, void *dynamic_input_add | |||||
const kAippDynamicPara &aippParms) { | const kAippDynamicPara &aippParms) { | ||||
GELOGI("Enter to SetDynamicAippData."); | GELOGI("Enter to SetDynamicAippData."); | ||||
if (dynamic_input_addr == nullptr) { | if (dynamic_input_addr == nullptr) { | ||||
GELOGE(PARAM_INVALID, "Dynamic aipp input addr is nullptr!"); | |||||
return PARAM_INVALID; | |||||
GELOGE(ACL_ERROR_GE_DYNAMIC_INPUT_ADDR_INVALID, "Dynamic aipp input addr is nullptr!"); | |||||
return ACL_ERROR_GE_DYNAMIC_INPUT_ADDR_INVALID; | |||||
} | } | ||||
if (aippBatchPara.empty()) { | if (aippBatchPara.empty()) { | ||||
GELOGE(PARAM_INVALID, "aippBatchPara is empty."); | |||||
return PARAM_INVALID; | |||||
GELOGE(ACL_ERROR_GE_AIPP_BATCH_EMPTY, "aippBatchPara is empty."); | |||||
return ACL_ERROR_GE_AIPP_BATCH_EMPTY; | |||||
} | } | ||||
uint64_t batch_num = aippBatchPara.size(); | uint64_t batch_num = aippBatchPara.size(); | ||||
uint64_t real_aippParms_size = sizeof(kAippDynamicPara) - sizeof(kAippDynamicBatchPara); | uint64_t real_aippParms_size = sizeof(kAippDynamicPara) - sizeof(kAippDynamicBatchPara); | ||||
@@ -512,13 +506,14 @@ Status GeExecutor::SetDynamicAippData(uint32_t model_id, void *dynamic_input_add | |||||
"batch num is %lu, struct_len is %lu", | "batch num is %lu, struct_len is %lu", | ||||
model_id, length, batch_num, struct_len); | model_id, length, batch_num, struct_len); | ||||
if (struct_len > length) { | if (struct_len > length) { | ||||
GELOGE(PARAM_INVALID, "input dynamic aipp param len [%lu] is larger than aipp_data size [%lu]", struct_len, length); | |||||
return PARAM_INVALID; | |||||
GELOGE(ACL_ERROR_GE_DYNAMIC_INPUT_LENGTH_INVALID, | |||||
"input dynamic aipp param len [%lu] is larger than aipp_data size [%lu]", struct_len, length); | |||||
return ACL_ERROR_GE_DYNAMIC_INPUT_LENGTH_INVALID; | |||||
} | } | ||||
// Memcpy real kAippDynamicBatchPara from host to device | // Memcpy real kAippDynamicBatchPara from host to device | ||||
rtError_t rt_ret = rtMemcpy(dynamic_input_addr, length, &aippParms, real_aippParms_size, RT_MEMCPY_HOST_TO_DEVICE); | rtError_t rt_ret = rtMemcpy(dynamic_input_addr, length, &aippParms, real_aippParms_size, RT_MEMCPY_HOST_TO_DEVICE); | ||||
if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
GELOGE(RT_FAILED, "memcpy real_aippParms_size failed! ret: 0x%X", rt_ret); | |||||
GELOGE(rt_ret, "memcpy real_aippParms_size failed! ret: 0x%X", rt_ret); | |||||
return RT_ERROR_TO_GE_STATUS(rt_ret); | return RT_ERROR_TO_GE_STATUS(rt_ret); | ||||
} | } | ||||
uint64_t remain_len = length - real_aippParms_size; | uint64_t remain_len = length - real_aippParms_size; | ||||
@@ -529,7 +524,7 @@ Status GeExecutor::SetDynamicAippData(uint32_t model_id, void *dynamic_input_add | |||||
(remain_len - i * sizeof(kAippDynamicBatchPara)), &(aippBatchPara[i]), | (remain_len - i * sizeof(kAippDynamicBatchPara)), &(aippBatchPara[i]), | ||||
sizeof(kAippDynamicBatchPara), RT_MEMCPY_HOST_TO_DEVICE); | sizeof(kAippDynamicBatchPara), RT_MEMCPY_HOST_TO_DEVICE); | ||||
if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
GELOGE(RT_FAILED, "memcpy kAippDynamicBatchPara input data failed! ret: 0x%X", rt_ret); | |||||
GELOGE(rt_ret, "memcpy kAippDynamicBatchPara input data failed! ret: 0x%X", rt_ret); | |||||
return RT_ERROR_TO_GE_STATUS(rt_ret); | return RT_ERROR_TO_GE_STATUS(rt_ret); | ||||
} | } | ||||
} | } | ||||
@@ -541,27 +536,28 @@ Status GeExecutor::LoadModelOffline(uint32_t &model_id, const std::string &path, | |||||
int32_t priority, std::shared_ptr<ge::ModelListener> listener) { | int32_t priority, std::shared_ptr<ge::ModelListener> listener) { | ||||
GELOGI("load model offline begin."); | GELOGI("load model offline begin."); | ||||
if (!isInit_) { | if (!isInit_) { | ||||
GELOGE(GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return GE_EXEC_NOT_INIT; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
string filePath = RealPath(path.c_str()); | string filePath = RealPath(path.c_str()); | ||||
if (filePath.empty()) { | if (filePath.empty()) { | ||||
GELOGE(ge::FAILED, "File path is invalid. please check your text file '%s'.", path.c_str()); | |||||
return ge::FAILED; | |||||
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "File path is invalid. please check your text file '%s'.", | |||||
path.c_str()); | |||||
return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID; | |||||
} | } | ||||
std::shared_ptr<ModelListenerAdapter> listener_adapter = MakeShared<ModelListenerAdapter>(); | std::shared_ptr<ModelListenerAdapter> listener_adapter = MakeShared<ModelListenerAdapter>(); | ||||
if (listener_adapter == nullptr) { | if (listener_adapter == nullptr) { | ||||
GELOGE(MEMALLOC_FAILED, "ModelListenerAdapter make shared failed!"); | |||||
return ge::FAILED; | |||||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "ModelListenerAdapter make shared failed!"); | |||||
return ACL_ERROR_GE_MEMORY_ALLOCATION; | |||||
} | } | ||||
listener_adapter->listener = listener; | listener_adapter->listener = listener; | ||||
Status ret = GraphLoader::LoadModelFromFile(path, key, priority, listener_adapter, model_id); | Status ret = GraphLoader::LoadModelFromFile(path, key, priority, listener_adapter, model_id); | ||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
GELOGE(ret, "[GeExecutor] LoadModelFromFile failed"); | GELOGE(ret, "[GeExecutor] LoadModelFromFile failed"); | ||||
return TransferDomiErrorCode(ret); | |||||
return ACL_ERROR_GE_LOAD_MODEL; | |||||
} | } | ||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
@@ -570,35 +566,35 @@ Status GeExecutor::LoadModel(uint32_t &model_id, const ModelData &model_data, | |||||
std::shared_ptr<ge::ModelListener> listener) { | std::shared_ptr<ge::ModelListener> listener) { | ||||
GELOGI("Load model begin."); | GELOGI("Load model begin."); | ||||
if (!isInit_) { | if (!isInit_) { | ||||
GELOGE(GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return GE_EXEC_NOT_INIT; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
std::shared_ptr<ModelListenerAdapter> listener_adapter = MakeShared<ModelListenerAdapter>(); | std::shared_ptr<ModelListenerAdapter> listener_adapter = MakeShared<ModelListenerAdapter>(); | ||||
if (listener_adapter == nullptr) { | if (listener_adapter == nullptr) { | ||||
GELOGE(MEMALLOC_FAILED, "ModelListenerAdapter make shared failed!"); | |||||
return ge::FAILED; | |||||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "ModelListenerAdapter make shared failed!"); | |||||
return ACL_ERROR_GE_MEMORY_ALLOCATION; | |||||
} | } | ||||
listener_adapter->listener = listener; | listener_adapter->listener = listener; | ||||
Status ret = GraphLoader::LoadModel(model_data, listener_adapter, model_id); | Status ret = GraphLoader::LoadModel(model_data, listener_adapter, model_id); | ||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
GELOGE(ret, "[GeExecutor] LoadModel failed."); | GELOGE(ret, "[GeExecutor] LoadModel failed."); | ||||
return TransferDomiErrorCode(ret); | |||||
return ACL_ERROR_GE_LOAD_MODEL; | |||||
} | } | ||||
return ret; | return ret; | ||||
} | } | ||||
Status GeExecutor::UnloadModel(uint32_t model_id) { | Status GeExecutor::UnloadModel(uint32_t model_id) { | ||||
GELOGI("unload model %u begin.", model_id); | |||||
GELOGD("unload model %u begin.", model_id); | |||||
if (!isInit_) { | if (!isInit_) { | ||||
GELOGE(GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return GE_EXEC_NOT_INIT; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
Status ret = GraphLoader::DestroyAicpuSessionForInfer(model_id); | Status ret = GraphLoader::DestroyAicpuSessionForInfer(model_id); | ||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
GELOGE(ret, "[GraphLoader] DestroyAicpuSessionForInfer failed. model id: %u", model_id); | GELOGE(ret, "[GraphLoader] DestroyAicpuSessionForInfer failed. model id: %u", model_id); | ||||
return FAILED; | |||||
return ACL_ERROR_GE_INTERNAL_ERROR; | |||||
} | } | ||||
std::shared_ptr<DavinciModel> davinci_model = ModelManager::GetInstance()->GetModel(model_id); | std::shared_ptr<DavinciModel> davinci_model = ModelManager::GetInstance()->GetModel(model_id); | ||||
@@ -606,14 +602,19 @@ Status GeExecutor::UnloadModel(uint32_t model_id) { | |||||
uint64_t session_id = davinci_model->GetSessionId(); | uint64_t session_id = davinci_model->GetSessionId(); | ||||
VarManagerPool::Instance().RemoveVarManager(session_id); | VarManagerPool::Instance().RemoveVarManager(session_id); | ||||
} | } | ||||
return GraphLoader::UnloadModel(model_id); | |||||
ret = GraphLoader::UnloadModel(model_id); | |||||
if (ret != SUCCESS) { | |||||
GELOGE(ret, "[GraphLoader] DestroyAicpuSessionForInfer failed. model id: %u", model_id); | |||||
return ACL_ERROR_GE_UNLOAD_MODEL; | |||||
} | |||||
return SUCCESS; | |||||
} | } | ||||
Status GeExecutor::RunModel(const ge::RunModelData &input_data, ge::RunModelData &output_data) { | Status GeExecutor::RunModel(const ge::RunModelData &input_data, ge::RunModelData &output_data) { | ||||
GELOGI("run model begin."); | GELOGI("run model begin."); | ||||
if (!isInit_) { | if (!isInit_) { | ||||
GELOGE(GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return GE_EXEC_NOT_INIT; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
InputData inputs; | InputData inputs; | ||||
@@ -627,10 +628,9 @@ Status GeExecutor::RunModel(const ge::RunModelData &input_data, ge::RunModelData | |||||
// Get input and output descriptor | // Get input and output descriptor | ||||
Status GeExecutor::GetModelDescInfo(uint32_t model_id, std::vector<ge::TensorDesc> &input_desc, | Status GeExecutor::GetModelDescInfo(uint32_t model_id, std::vector<ge::TensorDesc> &input_desc, | ||||
std::vector<ge::TensorDesc> &output_desc, bool new_model_desc) { | std::vector<ge::TensorDesc> &output_desc, bool new_model_desc) { | ||||
GELOGI("get model desc info begin."); | |||||
if (!isInit_) { | if (!isInit_) { | ||||
GELOGE(GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return GE_EXEC_NOT_INIT; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
std::vector<InputOutputDescInfo> input_desc_infos; | std::vector<InputOutputDescInfo> input_desc_infos; | ||||
@@ -642,26 +642,25 @@ Status GeExecutor::GetModelDescInfo(uint32_t model_id, std::vector<ge::TensorDes | |||||
output_formats, new_model_desc); | output_formats, new_model_desc); | ||||
if (ret != domi::SUCCESS) { | if (ret != domi::SUCCESS) { | ||||
GELOGE(ret, "GetInputOutputDescInfo failed. ret = %u", ret); | GELOGE(ret, "GetInputOutputDescInfo failed. ret = %u", ret); | ||||
return ret; | |||||
return ACL_ERROR_GE_GET_TENSOR_INFO; | |||||
} | } | ||||
if (input_formats.size() != input_desc_infos.size()) { | if (input_formats.size() != input_desc_infos.size()) { | ||||
GELOGE(ge::PARAM_INVALID, "input_formats size %zu is not equal to input_desc_infos size %zu.", input_formats.size(), | |||||
input_desc_infos.size()); | |||||
return ge::PARAM_INVALID; | |||||
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "input_formats size %zu is not equal to input_desc_infos size %zu.", | |||||
input_formats.size(), input_desc_infos.size()); | |||||
return ACL_ERROR_GE_PARAM_INVALID; | |||||
} | } | ||||
if (output_formats.size() != output_desc_infos.size()) { | if (output_formats.size() != output_desc_infos.size()) { | ||||
GELOGE(ge::PARAM_INVALID, "output_formats size %zu is not equal to output_desc_infos size %zu.", | |||||
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "output_formats size %zu is not equal to output_desc_infos size %zu.", | |||||
output_formats.size(), output_desc_infos.size()); | output_formats.size(), output_desc_infos.size()); | ||||
return ge::PARAM_INVALID; | |||||
return ACL_ERROR_GE_PARAM_INVALID; | |||||
} | } | ||||
// Transfer data to TensorDesc | // Transfer data to TensorDesc | ||||
GetGeTensorDescFromDomiInfo(input_desc, input_desc_infos, input_formats); | GetGeTensorDescFromDomiInfo(input_desc, input_desc_infos, input_formats); | ||||
GetGeTensorDescFromDomiInfo(output_desc, output_desc_infos, output_formats); | GetGeTensorDescFromDomiInfo(output_desc, output_desc_infos, output_formats); | ||||
GELOGI("get model desc info end."); | |||||
return ge::SUCCESS; | return ge::SUCCESS; | ||||
} | } | ||||
@@ -675,10 +674,9 @@ Status GeExecutor::GetModelDescInfo(uint32_t model_id, std::vector<ge::TensorDes | |||||
/// | /// | ||||
Status GeExecutor::GetDynamicBatchInfo(uint32_t model_id, std::vector<std::vector<int64_t>> &batch_info, | Status GeExecutor::GetDynamicBatchInfo(uint32_t model_id, std::vector<std::vector<int64_t>> &batch_info, | ||||
int32_t &dynamic_type) { | int32_t &dynamic_type) { | ||||
GELOGI("Begin to get dynamic batch info."); | |||||
if (!isInit_) { | if (!isInit_) { | ||||
GELOGE(GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return GE_EXEC_NOT_INIT; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
Status ret = GraphExecutor::GetDynamicBatchInfo(model_id, batch_info, dynamic_type); | Status ret = GraphExecutor::GetDynamicBatchInfo(model_id, batch_info, dynamic_type); | ||||
@@ -686,8 +684,6 @@ Status GeExecutor::GetDynamicBatchInfo(uint32_t model_id, std::vector<std::vecto | |||||
GELOGE(ret, "GetDynamicBatchInfo failed."); | GELOGE(ret, "GetDynamicBatchInfo failed."); | ||||
return ret; | return ret; | ||||
} | } | ||||
GELOGI("Get dynamic batch info succ."); | |||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
@@ -701,8 +697,8 @@ Status GeExecutor::GetDynamicBatchInfo(uint32_t model_id, std::vector<std::vecto | |||||
Status GeExecutor::GetCombinedDynamicDims(uint32_t model_id, vector<vector<int64_t>> &batch_info) { | Status GeExecutor::GetCombinedDynamicDims(uint32_t model_id, vector<vector<int64_t>> &batch_info) { | ||||
GELOGI("Begin to get combined dynamic dims info."); | GELOGI("Begin to get combined dynamic dims info."); | ||||
if (!isInit_) { | if (!isInit_) { | ||||
GELOGE(GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return GE_EXEC_NOT_INIT; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
Status ret = GraphExecutor::GetCombinedDynamicDims(model_id, batch_info); | Status ret = GraphExecutor::GetCombinedDynamicDims(model_id, batch_info); | ||||
@@ -723,10 +719,9 @@ Status GeExecutor::GetCombinedDynamicDims(uint32_t model_id, vector<vector<int64 | |||||
/// @return execute result | /// @return execute result | ||||
/// | /// | ||||
Status GeExecutor::GetUserDesignateShapeOrder(uint32_t model_id, vector<string> &user_designate_shape_order) { | Status GeExecutor::GetUserDesignateShapeOrder(uint32_t model_id, vector<string> &user_designate_shape_order) { | ||||
GELOGI("Begin to get user designate shape info."); | |||||
if (!isInit_) { | if (!isInit_) { | ||||
GELOGE(GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return GE_EXEC_NOT_INIT; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
Status ret = GraphExecutor::GetUserDesignateShapeOrder(model_id, user_designate_shape_order); | Status ret = GraphExecutor::GetUserDesignateShapeOrder(model_id, user_designate_shape_order); | ||||
@@ -735,7 +730,6 @@ Status GeExecutor::GetUserDesignateShapeOrder(uint32_t model_id, vector<string> | |||||
return ret; | return ret; | ||||
} | } | ||||
GELOGI("Get user designate shape order succ."); | |||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
@@ -750,8 +744,8 @@ Status GeExecutor::GetUserDesignateShapeOrder(uint32_t model_id, vector<string> | |||||
Status GeExecutor::GetAIPPInfo(uint32_t model_id, uint32_t index, AippConfigInfo &aipp_info) { | Status GeExecutor::GetAIPPInfo(uint32_t model_id, uint32_t index, AippConfigInfo &aipp_info) { | ||||
GELOGI("Begin to GetAIPPInfo."); | GELOGI("Begin to GetAIPPInfo."); | ||||
if (!isInit_) { | if (!isInit_) { | ||||
GELOGE(GE_EXEC_NOT_INIT, "not inited yet!"); | |||||
return GE_EXEC_NOT_INIT; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "not inited yet!"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
Status ret = GraphExecutor::GetAIPPInfo(model_id, index, aipp_info); | Status ret = GraphExecutor::GetAIPPInfo(model_id, index, aipp_info); | ||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
@@ -765,8 +759,8 @@ Status GeExecutor::GetAIPPInfo(uint32_t model_id, uint32_t index, AippConfigInfo | |||||
Status GeExecutor::GetAippType(uint32_t model_id, uint32_t index, InputAippType &type, size_t &aipp_index) { | Status GeExecutor::GetAippType(uint32_t model_id, uint32_t index, InputAippType &type, size_t &aipp_index) { | ||||
GELOGI("Begin to get aipp type."); | GELOGI("Begin to get aipp type."); | ||||
if (!isInit_) { | if (!isInit_) { | ||||
GELOGE(GE_EXEC_NOT_INIT, "not inited yet!"); | |||||
return GE_EXEC_NOT_INIT; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "not inited yet!"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
Status ret = GraphExecutor::GetAippType(model_id, index, type, aipp_index); | Status ret = GraphExecutor::GetAippType(model_id, index, type, aipp_index); | ||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
@@ -778,18 +772,15 @@ Status GeExecutor::GetAippType(uint32_t model_id, uint32_t index, InputAippType | |||||
} | } | ||||
Status GeExecutor::GetModelAttr(uint32_t model_id, std::vector<std::string> &dynamic_output_shape_info) { | Status GeExecutor::GetModelAttr(uint32_t model_id, std::vector<std::string> &dynamic_output_shape_info) { | ||||
GELOGI("Begin to get dynamic batch output shape info"); | |||||
if (!isInit_) { | if (!isInit_) { | ||||
GELOGE(GE_EXEC_NOT_INIT, "not inited yet!"); | |||||
return GE_EXEC_NOT_INIT; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "not inited yet!"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
Status ret = GraphExecutor::GetModelAttr(model_id, dynamic_output_shape_info); | Status ret = GraphExecutor::GetModelAttr(model_id, dynamic_output_shape_info); | ||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
GELOGE(ret, "Get dynamic batch output shape info failed."); | GELOGE(ret, "Get dynamic batch output shape info failed."); | ||||
return ret; | return ret; | ||||
} | } | ||||
GELOGI("Get dynamic batch output shape info succ."); | |||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
@@ -797,8 +788,8 @@ Status GeExecutor::GetModelDescInfoForZeroCopy(uint32_t model_id, std::vector<ge | |||||
std::vector<TensorDesc> &output_desc) { | std::vector<TensorDesc> &output_desc) { | ||||
GELOGI("get model desc info for zero copy begin."); | GELOGI("get model desc info for zero copy begin."); | ||||
if (!isInit_) { | if (!isInit_) { | ||||
GELOGE(GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return GE_EXEC_NOT_INIT; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
std::vector<InputOutputDescInfo> input_desc_infos; | std::vector<InputOutputDescInfo> input_desc_infos; | ||||
@@ -810,17 +801,17 @@ Status GeExecutor::GetModelDescInfoForZeroCopy(uint32_t model_id, std::vector<ge | |||||
input_formats, output_formats); | input_formats, output_formats); | ||||
if (ret != domi::SUCCESS) { | if (ret != domi::SUCCESS) { | ||||
GELOGE(ret, "Get DescInfo from zero copy failed. ret = %u", ret); | GELOGE(ret, "Get DescInfo from zero copy failed. ret = %u", ret); | ||||
return TransferDomiErrorCode(ret); | |||||
return ACL_ERROR_GE_GET_TENSOR_INFO; | |||||
} | } | ||||
if (input_formats.size() != input_desc_infos.size()) { | if (input_formats.size() != input_desc_infos.size()) { | ||||
GELOGE(ge::FAILED, "input_formats.size() != input_desc_infos.size()."); | |||||
return ge::FAILED; | |||||
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "input_formats.size() != input_desc_infos.size()."); | |||||
return ACL_ERROR_GE_PARAM_INVALID; | |||||
} | } | ||||
if (output_formats.size() != output_desc_infos.size()) { | if (output_formats.size() != output_desc_infos.size()) { | ||||
GELOGE(ge::FAILED, "output_formats.size() != output_desc_infos.size()."); | |||||
return ge::FAILED; | |||||
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "output_formats.size() != output_desc_infos.size()."); | |||||
return ACL_ERROR_GE_PARAM_INVALID; | |||||
} | } | ||||
GetGeTensorDescFromDomiInfo(input_desc, input_desc_infos, input_formats); | GetGeTensorDescFromDomiInfo(input_desc, input_desc_infos, input_formats); | ||||
@@ -831,12 +822,10 @@ Status GeExecutor::GetModelDescInfoForZeroCopy(uint32_t model_id, std::vector<ge | |||||
} | } | ||||
Status GeExecutor::CommandHandle(const Command &command) { | Status GeExecutor::CommandHandle(const Command &command) { | ||||
GELOGI("command handle begin."); | |||||
Status ret = GraphLoader::CommandHandle(command); | Status ret = GraphLoader::CommandHandle(command); | ||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
GELOGE(ret, "CommandHandle: Command Handle failed."); | |||||
return TransferDomiErrorCode(ret); | |||||
GELOGE(ACL_ERROR_GE_COMMAND_HANDLE, "CommandHandle: Command Handle failed."); | |||||
return ACL_ERROR_GE_COMMAND_HANDLE; | |||||
} | } | ||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
@@ -844,8 +833,8 @@ Status GeExecutor::CommandHandle(const Command &command) { | |||||
Status GeExecutor::GetMaxUsedMemory(uint32_t model_id, uint32_t &max_size) { | Status GeExecutor::GetMaxUsedMemory(uint32_t model_id, uint32_t &max_size) { | ||||
GELOGI("Get max used memory begin."); | GELOGI("Get max used memory begin."); | ||||
if (!isInit_) { | if (!isInit_) { | ||||
GELOGE(GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return GE_EXEC_NOT_INIT; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
uint64_t max_mem_size = 0; | uint64_t max_mem_size = 0; | ||||
@@ -864,14 +853,15 @@ Status GeExecutor::GetMaxUsedMemory(uint32_t model_id, uint32_t &max_size) { | |||||
Status GeExecutor::LoadDataFromFile(const std::string &path, ModelData &model_data) { | Status GeExecutor::LoadDataFromFile(const std::string &path, ModelData &model_data) { | ||||
GELOGI("Load data from file begin."); | GELOGI("Load data from file begin."); | ||||
if (!isInit_) { | if (!isInit_) { | ||||
GELOGE(GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return GE_EXEC_NOT_INIT; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
string filePath = RealPath(path.c_str()); | string filePath = RealPath(path.c_str()); | ||||
if (filePath.empty()) { | if (filePath.empty()) { | ||||
GELOGE(GE_EXEC_MODEL_PATH_INVALID, "File path is invalid. please check your text file '%s'.", path.c_str()); | |||||
return GE_EXEC_MODEL_PATH_INVALID; | |||||
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "File path is invalid. please check your text file '%s'.", | |||||
path.c_str()); | |||||
return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID; | |||||
} | } | ||||
GELOGI("load modelData from file: %s.", path.c_str()); | GELOGI("load modelData from file: %s.", path.c_str()); | ||||
std::string key_path; | std::string key_path; | ||||
@@ -899,10 +889,9 @@ Status GeExecutor::LoadDataFromFile(const std::string &path, ModelData &model_da | |||||
*/ | */ | ||||
Status GeExecutor::LoadModelFromData(uint32_t &model_id, const ModelData &model_data, void *dev_ptr, size_t mem_size, | Status GeExecutor::LoadModelFromData(uint32_t &model_id, const ModelData &model_data, void *dev_ptr, size_t mem_size, | ||||
void *weight_ptr, size_t weight_size) { | void *weight_ptr, size_t weight_size) { | ||||
GELOGI("Load model from data begin."); | |||||
if (!isInit_) { | if (!isInit_) { | ||||
GELOGE(GE_EXEC_NOT_INIT, "not inited yet!"); | |||||
return GE_EXEC_NOT_INIT; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "not inited yet!"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
return GraphLoader::LoadModelFromData(model_id, model_data, dev_ptr, mem_size, weight_ptr, weight_size); | return GraphLoader::LoadModelFromData(model_id, model_data, dev_ptr, mem_size, weight_ptr, weight_size); | ||||
@@ -922,8 +911,8 @@ Status GeExecutor::LoadModelWithQ(uint32_t &model_id, const ModelData &model_dat | |||||
const std::vector<uint32_t> &output_queue_ids) { | const std::vector<uint32_t> &output_queue_ids) { | ||||
GELOGI("Load model with queue begin."); | GELOGI("Load model with queue begin."); | ||||
if (!isInit_) { | if (!isInit_) { | ||||
GELOGE(GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return GE_EXEC_NOT_INIT; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
return GraphLoader::LoadModelWithQ(model_id, model_data, input_queue_ids, output_queue_ids); | return GraphLoader::LoadModelWithQ(model_id, model_data, input_queue_ids, output_queue_ids); | ||||
} | } | ||||
@@ -940,10 +929,9 @@ Status GeExecutor::LoadModelWithQ(uint32_t &model_id, const ModelData &model_dat | |||||
*/ | */ | ||||
Status GeExecutor::ExecModel(uint32_t model_id, void *stream, const ge::RunModelData &run_input_data, | Status GeExecutor::ExecModel(uint32_t model_id, void *stream, const ge::RunModelData &run_input_data, | ||||
ge::RunModelData &run_output_data, bool async_mode) { | ge::RunModelData &run_output_data, bool async_mode) { | ||||
GELOGI("Execute model begin."); | |||||
if (!isInit_) { | if (!isInit_) { | ||||
GELOGE(GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return GE_EXEC_NOT_INIT; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
InputData input_data; | InputData input_data; | ||||
@@ -979,8 +967,8 @@ Status GeExecutor::ExecModel(uint32_t model_id, void *stream, const ge::RunModel | |||||
Status GeExecutor::GetMemAndWeightSize(const std::string &path, size_t &mem_size, size_t &weight_size) { | Status GeExecutor::GetMemAndWeightSize(const std::string &path, size_t &mem_size, size_t &weight_size) { | ||||
GELOGI("Get memory and weight size from file begin."); | GELOGI("Get memory and weight size from file begin."); | ||||
if (!isInit_) { | if (!isInit_) { | ||||
GELOGE(GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return GE_EXEC_NOT_INIT; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
ModelData model; | ModelData model; | ||||
@@ -1012,13 +1000,13 @@ Status GeExecutor::GetMemAndWeightSize(const void *model_data, size_t model_size | |||||
size_t &weight_size) { | size_t &weight_size) { | ||||
GELOGI("Get memory and weight size from data begin."); | GELOGI("Get memory and weight size from data begin."); | ||||
if (!isInit_) { | if (!isInit_) { | ||||
GELOGE(GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return GE_EXEC_NOT_INIT; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "GeExecutor has not been initialized!"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
if (model_data == nullptr) { | if (model_data == nullptr) { | ||||
GELOGE(PARAM_INVALID, "invalid model data!"); | |||||
return PARAM_INVALID; | |||||
GELOGE(ACL_ERROR_GE_EXEC_MODEL_ADDR_INVALID, "invalid model data!"); | |||||
return ACL_ERROR_GE_EXEC_MODEL_ADDR_INVALID; | |||||
} | } | ||||
ModelData model; | ModelData model; | ||||
@@ -1041,8 +1029,8 @@ Status GeExecutor::LoadDynamicSingleOp(const std::string &model_name, const ge:: | |||||
Status GeExecutor::ExecuteAsync(SingleOp *executor, const std::vector<DataBuffer> &inputs, | Status GeExecutor::ExecuteAsync(SingleOp *executor, const std::vector<DataBuffer> &inputs, | ||||
std::vector<DataBuffer> &outputs) { | std::vector<DataBuffer> &outputs) { | ||||
if (executor == nullptr) { | if (executor == nullptr) { | ||||
GELOGE(PARAM_INVALID, "param is NULL"); | |||||
return PARAM_INVALID; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "param is NULL"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
return executor->ExecuteAsync(inputs, outputs); | return executor->ExecuteAsync(inputs, outputs); | ||||
@@ -1065,8 +1053,8 @@ Status GeExecutor::GetDeviceIdByModelId(uint32_t model_id, uint32_t &device_id) | |||||
GE_CHECK_NOTNULL(model_manager); | GE_CHECK_NOTNULL(model_manager); | ||||
auto davinci_model = model_manager->GetModel(model_id); | auto davinci_model = model_manager->GetModel(model_id); | ||||
if (davinci_model == nullptr) { | if (davinci_model == nullptr) { | ||||
GELOGE(FAILED, "Model id: %d is invaild or model is not loaded.", model_id); | |||||
return FAILED; | |||||
GELOGE(ACL_ERROR_GE_EXEC_MODEL_ID_INVALID, "Model id: %d is invaild or model is not loaded.", model_id); | |||||
return ACL_ERROR_GE_EXEC_MODEL_ID_INVALID; | |||||
} | } | ||||
device_id = davinci_model->GetDeviceId(); | device_id = davinci_model->GetDeviceId(); | ||||
@@ -1092,8 +1080,8 @@ Status GeExecutor::GetBatchInfoSize(uint32_t model_id, size_t &shape_count) { | |||||
Status GeExecutor::GetOrigInputInfo(uint32_t model_id, uint32_t index, OriginInputInfo &orig_input_info) { | Status GeExecutor::GetOrigInputInfo(uint32_t model_id, uint32_t index, OriginInputInfo &orig_input_info) { | ||||
GELOGI("Begin to GetOrigInputInfo."); | GELOGI("Begin to GetOrigInputInfo."); | ||||
if (!isInit_) { | if (!isInit_) { | ||||
GELOGE(GE_EXEC_NOT_INIT, "not inited yet!"); | |||||
return GE_EXEC_NOT_INIT; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "not inited yet!"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
Status ret = GraphExecutor::GetOrigInputInfo(model_id, index, orig_input_info); | Status ret = GraphExecutor::GetOrigInputInfo(model_id, index, orig_input_info); | ||||
@@ -1111,8 +1099,8 @@ Status GeExecutor::GetAllAippInputOutputDims(uint32_t model_id, uint32_t index, | |||||
std::vector<InputOutputDims> &output_dims) { | std::vector<InputOutputDims> &output_dims) { | ||||
GELOGI("Begin to GetAllAippInputOutputDims."); | GELOGI("Begin to GetAllAippInputOutputDims."); | ||||
if (!isInit_) { | if (!isInit_) { | ||||
GELOGE(GE_EXEC_NOT_INIT, "not inited yet!"); | |||||
return GE_EXEC_NOT_INIT; | |||||
GELOGE(ACL_ERROR_GE_EXEC_NOT_INIT, "not inited yet!"); | |||||
return ACL_ERROR_GE_EXEC_NOT_INIT; | |||||
} | } | ||||
Status ret = GraphExecutor::GetAllAippInputOutputDims(model_id, index, input_dims, output_dims); | Status ret = GraphExecutor::GetAllAippInputOutputDims(model_id, index, input_dims, output_dims); | ||||
@@ -63,6 +63,7 @@ local_ge_executor_src_files := \ | |||||
../single_op/task/aicpu_kernel_task_builder.cc \ | ../single_op/task/aicpu_kernel_task_builder.cc \ | ||||
../hybrid/hybrid_davinci_model_stub.cc\ | ../hybrid/hybrid_davinci_model_stub.cc\ | ||||
../hybrid/node_executor/aicpu/aicpu_ext_info.cc \ | ../hybrid/node_executor/aicpu/aicpu_ext_info.cc \ | ||||
../graph/common/local_context.cc \ | |||||
local_ge_executor_c_include := \ | local_ge_executor_c_include := \ | ||||
proto/insert_op.proto \ | proto/insert_op.proto \ | ||||
@@ -104,7 +105,7 @@ local_ge_executor_ldflags := -lrt -ldl \ | |||||
include $(CLEAR_VARS) | include $(CLEAR_VARS) | ||||
LOCAL_MODULE := libge_executor | LOCAL_MODULE := libge_executor | ||||
LOCAL_CFLAGS += -Werror | |||||
LOCAL_CFLAGS += -Werror -Wno-deprecated-declarations | |||||
LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -O2 -DDAVINCI_SUPPORT_PROFILING -Dgoogle=ascend_private | LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -O2 -DDAVINCI_SUPPORT_PROFILING -Dgoogle=ascend_private | ||||
LOCAL_SRC_FILES := $(local_ge_executor_src_files) | LOCAL_SRC_FILES := $(local_ge_executor_src_files) | ||||
@@ -130,7 +131,7 @@ include $(BUILD_SHARED_LIBRARY) | |||||
include $(CLEAR_VARS) | include $(CLEAR_VARS) | ||||
LOCAL_MODULE := libge_executor | LOCAL_MODULE := libge_executor | ||||
LOCAL_CFLAGS += -Werror | |||||
LOCAL_CFLAGS += -Werror -Wno-deprecated-declarations | |||||
LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -DDAVINCI_SUPPORT_PROFILING -Dgoogle=ascend_private | LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -DDAVINCI_SUPPORT_PROFILING -Dgoogle=ascend_private | ||||
ifeq ($(DEBUG), 1) | ifeq ($(DEBUG), 1) | ||||
LOCAL_CFLAGS += -g -O0 | LOCAL_CFLAGS += -g -O0 | ||||
@@ -166,7 +167,7 @@ include $(BUILD_HOST_SHARED_LIBRARY) | |||||
include $(CLEAR_VARS) | include $(CLEAR_VARS) | ||||
LOCAL_MODULE := libge_executor | LOCAL_MODULE := libge_executor | ||||
LOCAL_CFLAGS += -Werror | |||||
LOCAL_CFLAGS += -Werror -Wno-deprecated-declarations | |||||
LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -DDAVINCI_SUPPORT_PROFILING -Dgoogle=ascend_private | LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -DDAVINCI_SUPPORT_PROFILING -Dgoogle=ascend_private | ||||
ifeq ($(DEBUG), 1) | ifeq ($(DEBUG), 1) | ||||
LOCAL_CFLAGS += -g -O0 | LOCAL_CFLAGS += -g -O0 | ||||
@@ -199,7 +200,7 @@ include $(BUILD_HOST_STATIC_LIBRARY) | |||||
include $(CLEAR_VARS) | include $(CLEAR_VARS) | ||||
LOCAL_MODULE := libge_executor | LOCAL_MODULE := libge_executor | ||||
LOCAL_CFLAGS += -Werror | |||||
LOCAL_CFLAGS += -Werror -Wno-deprecated-declarations | |||||
LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -DDAVINCI_SUPPORT_PROFILING -Dgoogle=ascend_private | LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -DDAVINCI_SUPPORT_PROFILING -Dgoogle=ascend_private | ||||
ifeq ($(DEBUG), 1) | ifeq ($(DEBUG), 1) | ||||
LOCAL_CFLAGS += -g -O0 | LOCAL_CFLAGS += -g -O0 | ||||
@@ -387,12 +387,12 @@ LOCAL_SRC_FILES += $(BUILER_SRC_FILES) | |||||
LOCAL_SRC_FILES += $(ANALYZER_SRC_FILES) | LOCAL_SRC_FILES += $(ANALYZER_SRC_FILES) | ||||
LOCAL_STATIC_LIBRARIES := libge_memory \ | LOCAL_STATIC_LIBRARIES := libge_memory \ | ||||
libmmpa \ | |||||
LOCAL_SHARED_LIBRARIES := \ | LOCAL_SHARED_LIBRARIES := \ | ||||
libc_sec \ | libc_sec \ | ||||
libascend_protobuf \ | libascend_protobuf \ | ||||
libslog \ | libslog \ | ||||
libmmpa \ | |||||
libgraph \ | libgraph \ | ||||
libregister \ | libregister \ | ||||
libge_common \ | libge_common \ | ||||
@@ -451,12 +451,12 @@ LOCAL_C_INCLUDES := $(DEVICE_LOCAL_C_INCLUDES) | |||||
LOCAL_C_INCLUDES += $(ANALYZER_LOCAL_INCLUDES) | LOCAL_C_INCLUDES += $(ANALYZER_LOCAL_INCLUDES) | ||||
LOCAL_STATIC_LIBRARIES := libge_memory \ | LOCAL_STATIC_LIBRARIES := libge_memory \ | ||||
libmmpa \ | |||||
LOCAL_SHARED_LIBRARIES := \ | LOCAL_SHARED_LIBRARIES := \ | ||||
libc_sec \ | libc_sec \ | ||||
libascend_protobuf \ | libascend_protobuf \ | ||||
libslog \ | libslog \ | ||||
libmmpa \ | |||||
libgraph \ | libgraph \ | ||||
libregister \ | libregister \ | ||||
libresource \ | libresource \ | ||||
@@ -200,9 +200,8 @@ Status HostCpuEngine::PrepareOutputs(const ge::ConstOpDescPtr &op_desc, vector<G | |||||
CREATE_OUTPUT_CASE(DT_FLOAT, float) | CREATE_OUTPUT_CASE(DT_FLOAT, float) | ||||
CREATE_OUTPUT_CASE(DT_DOUBLE, double) | CREATE_OUTPUT_CASE(DT_DOUBLE, double) | ||||
default: | default: | ||||
GELOGE(PARAM_INVALID, "data type %s not support.", | |||||
TypeUtils::DataTypeToSerialString(out_desc.GetDataType()).c_str()); | |||||
return PARAM_INVALID; | |||||
GELOGW("data type %s not support.", TypeUtils::DataTypeToSerialString(out_desc.GetDataType()).c_str()); | |||||
return NOT_CHANGED; | |||||
} | } | ||||
} | } | ||||
@@ -216,7 +215,7 @@ Status HostCpuEngine::RunInternal(const ge::OpDescPtr &op_desc, HostCpuOp &op_ke | |||||
Operator op = ge::OpDescUtils::CreateOperatorFromOpDesc(op_desc); | Operator op = ge::OpDescUtils::CreateOperatorFromOpDesc(op_desc); | ||||
auto ret = op_kernel.Compute(op, named_inputs, named_outputs); | auto ret = op_kernel.Compute(op, named_inputs, named_outputs); | ||||
if (ret != GRAPH_SUCCESS) { | if (ret != GRAPH_SUCCESS) { | ||||
GELOGE(FAILED, "Failed to compute host cpu op. node = %s, ret = %u", op_desc->GetName().c_str(), ret); | |||||
GELOGW("Failed to compute host cpu op. node = %s", op_desc->GetName().c_str()); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
op.BreakConnect(); | op.BreakConnect(); | ||||
@@ -88,6 +88,25 @@ LOCAL_C_INCLUDES := $(local_lib_inc_path) | |||||
include ${BUILD_HOST_SHARED_LIBRARY} | include ${BUILD_HOST_SHARED_LIBRARY} | ||||
#compiler for device libge_local_opskernel_builder.so | |||||
include $(CLEAR_VARS) | |||||
LOCAL_MODULE := libge_local_opskernel_builder | |||||
LOCAL_CFLAGS += -Werror | |||||
LOCAL_CFLAGS += -std=c++11 -Dgoogle=ascend_private | |||||
LOCAL_LDFLAGS := | |||||
LOCAL_STATIC_LIBRARIES := | |||||
LOCAL_SHARED_LIBRARIES := libascend_protobuf \ | |||||
libc_sec \ | |||||
libslog \ | |||||
libregister \ | |||||
libgraph | |||||
LOCAL_SRC_FILES := $(ops_kernel_builder_src_files) | |||||
LOCAL_C_INCLUDES := $(local_lib_inc_path) | |||||
include ${BUILD_SHARED_LIBRARY} | |||||
#compiler for libge_local_opskernel_builder.so in atc | #compiler for libge_local_opskernel_builder.so in atc | ||||
include $(CLEAR_VARS) | include $(CLEAR_VARS) | ||||
@@ -105,7 +105,7 @@ Status GeLocalOpsKernelBuilder::CalcOpRunningParam(Node &ge_node) { | |||||
TypeUtils::DataTypeToSerialString(data_type).c_str(), output_mem_size); | TypeUtils::DataTypeToSerialString(data_type).c_str(), output_mem_size); | ||||
return FAILED; | return FAILED; | ||||
} | } | ||||
GELOGI( | |||||
GELOGD( | |||||
"Calc op[%s:%s] out[%zu] mem size is %ld," | "Calc op[%s:%s] out[%zu] mem size is %ld," | ||||
" format=%s, data_type=%s.", | " format=%s, data_type=%s.", | ||||
node_name.c_str(), node_type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), | node_name.c_str(), node_type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), | ||||
@@ -167,7 +167,7 @@ Status GeLocalOpsKernelBuilder::GenerateTask(const Node &node, RunContext &conte | |||||
GELOGE(ret, "Node:%s(%s) op run failed.", name.c_str(), type.c_str()); | GELOGE(ret, "Node:%s(%s) op run failed.", name.c_str(), type.c_str()); | ||||
return ret; | return ret; | ||||
} | } | ||||
GELOGI("Ge local generate task for node:%s(%s) end, tasks.size()=%zu.", name.c_str(), type.c_str(), tasks.size()); | |||||
GELOGD("Ge local generate task for node:%s(%s) end, tasks.size()=%zu.", name.c_str(), type.c_str(), tasks.size()); | |||||
return ret; | return ret; | ||||
} | } | ||||
} // namespace ge_local | } // namespace ge_local | ||||
@@ -24,7 +24,7 @@ namespace ge_local { | |||||
NoOp::NoOp(const Node &node, RunContext &run_context) : Op(node, run_context) {} | NoOp::NoOp(const Node &node, RunContext &run_context) : Op(node, run_context) {} | ||||
Status NoOp::Run() { | Status NoOp::Run() { | ||||
GELOGI("Node:%s type is %s, no need generate task.", name_.c_str(), type_.c_str()); | |||||
GELOGD("Node:%s type is %s, no need generate task.", name_.c_str(), type_.c_str()); | |||||
// Do nothing | // Do nothing | ||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||