|
|
|
@@ -154,6 +154,51 @@ static bool CheckDigitStr(std::string &str) { |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
// Remove the space and tab before and after the string |
|
|
|
std::string TrimConf(const std::string &str) { |
|
|
|
if (str.empty()) { |
|
|
|
return str; |
|
|
|
} |
|
|
|
|
|
|
|
std::string::size_type start = str.find_first_not_of(" \t\r\n"); |
|
|
|
if (start == std::string::npos) { |
|
|
|
return str; |
|
|
|
} |
|
|
|
|
|
|
|
std::string::size_type end = str.find_last_not_of(" \t\r\n") + 1; |
|
|
|
return str.substr(start, end); |
|
|
|
} |
|
|
|
|
|
|
|
// Parsing the command line |
|
|
|
bool ParseSingleLine(const std::string &line, std::map<std::string, std::string> &op_conf_map) { |
|
|
|
std::string temp = TrimConf(line); |
|
|
|
std::string delimiter = ":"; |
|
|
|
// Comment or newline returns true directly |
|
|
|
if (temp.find_first_of('#') == 0 || *(temp.c_str()) == '\n') { |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
if (!temp.empty()) { |
|
|
|
std::string::size_type pos = temp.find_first_of(delimiter); |
|
|
|
if (pos == std::string::npos) { |
|
|
|
GELOGE(PARAM_INVALID, "Incorrect line [%s], it must include [%s].Perhaps you use illegal chinese symbol", |
|
|
|
line.c_str(), delimiter.c_str()); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
std::string map_key = TrimConf(temp.substr(0, pos)); |
|
|
|
std::string value = TrimConf(temp.substr(pos + 1)); |
|
|
|
if (map_key.empty() || value.empty()) { |
|
|
|
GELOGE(PARAM_INVALID, "Map_key or value empty. %s", line.c_str()); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
op_conf_map[map_key] = value; |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
} // namespace |
|
|
|
|
|
|
|
namespace ge { |
|
|
|
@@ -555,19 +600,35 @@ domi::Status AclGrphParseUtil::ParseAclOutputFp16NodesFormat(const string &is_ou |
|
|
|
return SUCCESS; |
|
|
|
} |
|
|
|
|
|
|
|
domi::Status AclGrphParseUtil::ParseAclOpConf(const char *op_conf) { |
|
|
|
// parse configuration item |
|
|
|
if (op_conf != nullptr && *op_conf != '\0') { |
|
|
|
// divided by ":" |
|
|
|
PropertiesManager::Instance().SetPropertyDelimiter(OP_CONF_DELIMITER); |
|
|
|
// Parsing the op_conf configuration item file |
|
|
|
GE_IF_BOOL_EXEC(!PropertiesManager::Instance().Init(op_conf), |
|
|
|
ErrorManager::GetInstance().ATCReportErrMessage("E10003", {"parameter", "value", "reason"}, |
|
|
|
{"op_name_map", op_conf, "file content error"}); |
|
|
|
GELOGE(FAILED, "op_name_map init failed!"); return FAILED); |
|
|
|
// Return map and put it into ATC global variable |
|
|
|
ge::GetParserContext().op_conf_map = PropertiesManager::Instance().GetPropertyMap(); |
|
|
|
domi::Status AclGrphParseUtil::ParseAclOpConf(const std::string &op_conf) { |
|
|
|
if (op_conf.empty()) { |
|
|
|
return SUCCESS; |
|
|
|
} |
|
|
|
// Normalize the path |
|
|
|
string resolved_file_path = ge::parser::RealPath(op_conf.c_str()); |
|
|
|
if (resolved_file_path.empty()) { |
|
|
|
GELOGE(domi::FAILED, "Invalid input file path [%s], make sure that the file path is correct.", op_conf.c_str()); |
|
|
|
return FAILED; |
|
|
|
} |
|
|
|
std::ifstream fs(resolved_file_path, std::ifstream::in); |
|
|
|
|
|
|
|
if (!fs.is_open()) { |
|
|
|
GELOGE(PARAM_INVALID, "Open %s failed.", op_conf.c_str()); |
|
|
|
return FAILED; |
|
|
|
} |
|
|
|
|
|
|
|
std::string line; |
|
|
|
|
|
|
|
while (getline(fs, line)) { // line not with \n |
|
|
|
if (!ParseSingleLine(line, ge::GetParserContext().op_conf_map)) { |
|
|
|
GELOGE(PARAM_INVALID, "Parse line failed. content is [%s].", line.c_str()); |
|
|
|
fs.close(); |
|
|
|
return FAILED; |
|
|
|
} |
|
|
|
} |
|
|
|
fs.close(); // close the file |
|
|
|
|
|
|
|
GELOGI("LoadFileContent success."); |
|
|
|
return SUCCESS; |
|
|
|
} |
|
|
|
|
|
|
|
@@ -625,7 +686,7 @@ domi::Status AclGrphParseUtil::ParseAclInputFp16Nodes(const ComputeGraphPtr &gra |
|
|
|
} |
|
|
|
auto op_desc = node->GetOpDesc(); |
|
|
|
GE_CHECK_NOTNULL(op_desc); |
|
|
|
if (op_desc->GetType() != DATA) { |
|
|
|
if (op_desc->GetType() != ge::parser::DATA) { |
|
|
|
ErrorManager::GetInstance().ATCReportErrMessage("E10017", {"parameter", "opname"}, |
|
|
|
{"input_fp16_nodes", input_fp16_nodes_vec[i]}); |
|
|
|
GELOGE(PARAM_INVALID, "Input parameter[--input_fp16_nodes]'s opname[%s] is not a input opname", |
|
|
|
@@ -643,7 +704,7 @@ domi::Status AclGrphParseUtil::ParseAclWeightCompressConf(const ComputeGraphPtr |
|
|
|
if (compress_weight_conf.empty()) { |
|
|
|
return SUCCESS; |
|
|
|
} |
|
|
|
std::string real_path = RealPath(compress_weight_conf.c_str()); |
|
|
|
std::string real_path = ge::parser::RealPath(compress_weight_conf.c_str()); |
|
|
|
if (real_path.empty()) { |
|
|
|
GELOGE(PARAM_INVALID, "Can not get real path for %s.", compress_weight_conf.c_str()); |
|
|
|
return PARAM_INVALID; |
|
|
|
@@ -757,7 +818,7 @@ domi::Status AclGrphParseUtil::GetOutputLeaf(NodePtr node, |
|
|
|
return domi::FAILED; |
|
|
|
} |
|
|
|
size_t size = tmpDescPtr->GetOutputsSize(); |
|
|
|
if (node->GetType() != NETOUTPUT) { |
|
|
|
if (node->GetType() != ge::parser::NETOUTPUT) { |
|
|
|
for (size_t index = 0; index < size; ++index) { |
|
|
|
output_nodes_info.push_back(std::make_pair(node, index)); |
|
|
|
GELOGD("Get output leaf node:%s.", node->GetName().c_str()); |
|
|
|
@@ -936,12 +997,12 @@ domi::Status AclGrphParseUtil::ParseParamsBeforeGraph(const std::map<std::string |
|
|
|
|
|
|
|
string op_conf_str; |
|
|
|
GetAclParams(parser_params, "op_name_map", op_conf_str); |
|
|
|
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(ParseAclOpConf(op_conf_str.c_str()) != SUCCESS, |
|
|
|
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(ParseAclOpConf(op_conf_str) != SUCCESS, |
|
|
|
return PARAM_INVALID, "Parse op_name_map failed"); |
|
|
|
|
|
|
|
string tmp_name; |
|
|
|
GetAclParams(parser_params, "output", tmp_name); |
|
|
|
graph_name = tmp_name.empty() ? (kGraphDefaultName + "_" + CurrentTimeInStr()) : tmp_name; |
|
|
|
graph_name = tmp_name.empty() ? (kGraphDefaultName + "_" + ge::parser::CurrentTimeInStr()) : tmp_name; |
|
|
|
|
|
|
|
string enable_scope_fusion_passes; |
|
|
|
GetAclParams(parser_params, "enable_scope_fusion_passes", enable_scope_fusion_passes); |
|
|
|
|