Browse Source

add error msg

pull/295/head
wangxiaotian22 5 years ago
parent
commit
1a07fd931d
23 changed files with 658 additions and 133 deletions
  1. +1
    -1
      metadef
  2. +51
    -3
      parser/tensorflow/graph_functiondef.cc
  3. +414
    -79
      parser/tensorflow/graph_optimizer.cc
  4. +1
    -0
      parser/tensorflow/iterator_fusion_pass.cc
  5. +2
    -0
      parser/tensorflow/scope/scope_pass_manager.cc
  6. +7
    -0
      parser/tensorflow/tensorflow_auto_mapping_parser_adapter.cc
  7. +5
    -1
      parser/tensorflow/tensorflow_constant_parser.cc
  8. +15
    -5
      parser/tensorflow/tensorflow_custom_parser_adapter.cc
  9. +6
    -2
      parser/tensorflow/tensorflow_data_parser.cc
  10. +8
    -0
      parser/tensorflow/tensorflow_enter_parser.cc
  11. +3
    -0
      parser/tensorflow/tensorflow_fill_parser.cc
  12. +4
    -0
      parser/tensorflow/tensorflow_frameworkop_parser.cc
  13. +20
    -4
      parser/tensorflow/tensorflow_fusion_custom_parser_adapter.cc
  14. +35
    -22
      parser/tensorflow/tensorflow_fusion_op_parser.cc
  15. +2
    -0
      parser/tensorflow/tensorflow_merge_parser.cc
  16. +26
    -4
      parser/tensorflow/tensorflow_parser.cc
  17. +6
    -2
      parser/tensorflow/tensorflow_ref_switch_parser.cc
  18. +5
    -2
      parser/tensorflow/tensorflow_reshape_parser.cc
  19. +16
    -4
      parser/tensorflow/tensorflow_shape_n_parser.cc
  20. +12
    -1
      parser/tensorflow/tensorflow_squeeze_parser.cc
  21. +17
    -2
      parser/tensorflow/tensorflow_variable_v2_parser.cc
  22. +1
    -1
      tests/depends/error_manager/src/error_manager_stub.cc
  23. +1
    -0
      tests/ut/parser/CMakeLists.txt

+ 1
- 1
metadef

@@ -1 +1 @@
Subproject commit c1aea328cc04340188e796e639cd55a907488365
Subproject commit 620e9b9ac3210db3e4cf47babfb23d248bb9f17e

+ 51
- 3
parser/tensorflow/graph_functiondef.cc View File

@@ -92,6 +92,7 @@ domi::Status ComputeArgRange(const domi::tensorflow::NodeDef &node_def, const do
GE_IF_BOOL_EXEC(
!GraphToFunctionDef::FindAttrValue(&node_def, arg_def.number_attr(), attr_value),
GELOGE(domi::INTERNAL_ERROR, "In NodeDef %s Attr number_attr is not exist.", node_def.name().c_str());
REPORT_INNER_ERROR("E19999", "Attr:number_attr not exist in node:%s, check invalid", node_def.name().c_str());
return domi::INTERNAL_ERROR);
*num = attr_value.i();
} else if (!arg_def.type_list_attr().empty()) {
@@ -101,12 +102,15 @@ domi::Status ComputeArgRange(const domi::tensorflow::NodeDef &node_def, const do
GE_IF_BOOL_EXEC(
!GraphToFunctionDef::FindAttrValue(&node_def, arg_def.type_list_attr(), attr_value),
GELOGE(domi::INTERNAL_ERROR, "In NodeDef %s Attr type_list_attr is not exist.", node_def.name().c_str());
REPORT_INNER_ERROR("E19999", "Attr:type_list_attr not exist in node:%s, check invalid", node_def.name().c_str());
return domi::INTERNAL_ERROR);
*num = attr_value.list().type_size();
} else if ((!arg_def.type_attr().empty()) || (arg_def.type() != DT_INVALID)) {
*num = 1;
} else {
GELOGE(domi::INTERNAL_ERROR, "In NodeDef %s Attr type_list_attr is not exist.", node_def.name().c_str());
REPORT_INNER_ERROR("E19999", "arg_def for node:%s is invalid, number_attr type_list_attr type_attr all empty",
node_def.name().c_str());
return domi::INTERNAL_ERROR;
}
return SUCCESS;
@@ -143,6 +147,8 @@ domi::Status RemapFunctionDef(FunctionDef *fdef, const string &name, NameMapHelp
for (int i = 0; i < fdef->signature().input_arg_size(); ++i) {
const string &input_name = fdef->signature().input_arg(i).name();
GE_IF_BOOL_EXEC(input_name.empty(),
REPORT_INNER_ERROR("E19999", "In fdef %s, index:%d input_name is empty, check invalid",
fdef->signature().name().c_str(), i);
GELOGE(domi::INTERNAL_ERROR, "In fdef %s input_name null .", fdef->signature().name().c_str());
return domi::INTERNAL_ERROR);
}
@@ -157,6 +163,8 @@ domi::Status RemapFunctionDef(FunctionDef *fdef, const string &name, NameMapHelp
const string normalized = node_names.Renormalize(node_def->input(i).substr(1));

GE_IF_BOOL_EXEC(normalized.empty(),
REPORT_INNER_ERROR("E19999", "Could not remap control input %s of node %s in function %s",
node_def->input(i).c_str(), node_def->name().c_str(), name.c_str());
GELOGE(domi::INTERNAL_ERROR, "Could not remap control input %s of node %s in function %s .",
node_def->input(i).c_str(), node_def->name().c_str(), name.c_str());
return domi::INTERNAL_ERROR);
@@ -166,6 +174,8 @@ domi::Status RemapFunctionDef(FunctionDef *fdef, const string &name, NameMapHelp
const auto iter = tensor_renaming.find(node_def->input(i));

GE_IF_BOOL_EXEC(iter == tensor_renaming.end(),
REPORT_INNER_ERROR("E19999", "Could not remap input %s of node %s in function %s",
node_def->input(i).c_str(), node_def->name().c_str(), name.c_str());
GELOGE(domi::INTERNAL_ERROR, "Could not remap input %s of node %s in function %s .",
node_def->input(i).c_str(), node_def->name().c_str(), name.c_str());
return domi::INTERNAL_ERROR);
@@ -180,19 +190,25 @@ domi::Status RemapFunctionDef(FunctionDef *fdef, const string &name, NameMapHelp
const string &ret_name = fdef->signature().output_arg(r).name();

GE_IF_BOOL_EXEC(ret_name.empty(),
REPORT_INNER_ERROR("E19999", "Missing output %d to function %s", r, name.c_str());
GELOGE(domi::INTERNAL_ERROR, "Missing output %d to function %s .", r, name.c_str());
return domi::INTERNAL_ERROR);

const string &return_value = return_values[ret_name];

GE_IF_BOOL_EXEC(return_value.empty(),
REPORT_INNER_ERROR("E19999", "Could not remap return value %d ,%s of %s in function %s", r,
ret_name.c_str(), return_value.c_str(), name.c_str());
GELOGE(domi::INTERNAL_ERROR, "Could not remap return value %d ,%s of %s in function %s .", r,
ret_name.c_str(), return_value.c_str(), name.c_str());
return domi::INTERNAL_ERROR);

const auto iter = tensor_renaming.find(return_value);

GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(iter == tensor_renaming.end(), return domi::INTERNAL_ERROR,
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(iter == tensor_renaming.end(),
REPORT_INNER_ERROR("E19999", "can not find value[%s] in tensor_renaming map",
return_value.c_str());
return domi::INTERNAL_ERROR,
"can not find value[%s] in tensor_renaming map.", return_value.c_str());

(*fdef->mutable_ret())[ret_name] = iter->second;
@@ -213,6 +229,9 @@ domi::Status GraphToFunctionDef::RecordResult(ge::ComputeGraphPtr graph,
int32_t type = anchor->GetOwnerNode()->GetOpDesc()->GetOutputDesc(anchor->GetIdx()).GetDataType();
auto iter = GE_TENSORFLOW_DATA_TYPE_MAP.find(type);
GE_IF_BOOL_EXEC(iter == GE_TENSORFLOW_DATA_TYPE_MAP.end(),
REPORT_INNER_ERROR("E19999", "datatype:%d of output:%d in node:%s:%s is not supported",
type, anchor->GetIdx(), anchor->GetOwnerNode()->GetName().c_str(),
anchor->GetOwnerNode()->GetName().c_str());
GELOGE(PARAM_INVALID, "data_type %d not supported", type);
return PARAM_INVALID);
int32_t dtype = iter->second;
@@ -222,11 +241,13 @@ domi::Status GraphToFunctionDef::RecordResult(ge::ComputeGraphPtr graph,
GE_MAKE_SHARED(op = std::make_shared<ge::OpDesc>(op_name, ge::parser::NETOUTPUT), return FAILED);
graphStatus status = op->AddInputDesc(ge::GeTensorDesc());
if (status != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed", op->GetName().c_str(), op->GetType().c_str());
GELOGE(FAILED, "Add input desc for op:%s failed.", op->GetName().c_str());
return FAILED;
}
status = op->AddOutputDesc(ge::GeTensorDesc());
if (status != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed", op->GetName().c_str(), op->GetType().c_str());
GELOGE(FAILED, "Add output desc for op:%s failed.", op->GetName().c_str());
return FAILED;
}
@@ -244,6 +265,11 @@ domi::Status GraphToFunctionDef::RecordResult(ge::ComputeGraphPtr graph,
GE_CHECK_NOTNULL(in_archor_ptr);
ge::graphStatus ret = ge::GraphUtils::AddEdge(out_archor_ptr, in_archor_ptr);
if (ret != ge::GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
out_archor_ptr->GetOwnerNode()->GetName().c_str(),
out_archor_ptr->GetOwnerNode()->GetType().c_str(), out_archor_ptr->GetIdx(),
in_archor_ptr->GetOwnerNode()->GetName().c_str(),
in_archor_ptr->GetOwnerNode()->GetType().c_str(), in_archor_ptr->GetIdx());
GELOGE(domi::INTERNAL_ERROR, "Add edge failed,src op:%s,dst op:%s", node->GetName().c_str(),
res_node->GetName().c_str());
return FAILED;
@@ -251,7 +277,13 @@ domi::Status GraphToFunctionDef::RecordResult(ge::ComputeGraphPtr graph,
node_exists = true;
}
}
GE_IF_BOOL_EXEC(!node_exists, GELOGE(FAILED, "node not exists!"); return FAILED);
GE_IF_BOOL_EXEC(!node_exists,
GELOGE(FAILED, "node not exists!");
REPORT_CALL_ERROR("E19999", "Node:%s(%s) not found in graph:%s, check invalid",
anchor->GetOwnerNode()->GetName().c_str(),
anchor->GetOwnerNode()->GetType().c_str(),
graph->GetName().c_str());
return FAILED);
result_datetypes_.emplace_back(domi::tensorflow::DataType(dtype));

index++;
@@ -274,6 +306,9 @@ domi::Status GraphToFunctionDef::RecordArg(ge::ComputeGraphPtr graph, const vect
int32_t type = tensor_desc_ptr->GetDataType();
auto iter = GE_TENSORFLOW_DATA_TYPE_MAP.find(type);
GE_IF_BOOL_EXEC(iter == GE_TENSORFLOW_DATA_TYPE_MAP.end(),
REPORT_INNER_ERROR("E19999", "datatype:%d of input:%d in node:%s:%s is not supported",
type, anchor->GetIdx(), anchor->GetOwnerNode()->GetName().c_str(),
anchor->GetOwnerNode()->GetName().c_str());
GELOGE(PARAM_INVALID, "data_type %d not supported", type);
return PARAM_INVALID);
int32_t dtype = iter->second;
@@ -285,6 +320,7 @@ domi::Status GraphToFunctionDef::RecordArg(ge::ComputeGraphPtr graph, const vect
GE_MAKE_SHARED(op = std::make_shared<ge::OpDesc>(op_name, ge::parser::DATA), return FAILED);
graphStatus status = op->AddOutputDesc(ge::GeTensorDesc());
if (status != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed", op->GetName().c_str(), op->GetType().c_str());
GELOGE(FAILED, "Add output desc for op:%s failed.", op->GetName().c_str());
return FAILED;
}
@@ -303,6 +339,11 @@ domi::Status GraphToFunctionDef::RecordArg(ge::ComputeGraphPtr graph, const vect
(void)ge::GraphUtils::RemoveEdge(in_archor_ptr->GetPeerOutAnchor(), in_archor_ptr);
ge::graphStatus ret = ge::GraphUtils::AddEdge(out_archor_ptr, in_archor_ptr);
if (ret != ge::GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
out_archor_ptr->GetOwnerNode()->GetName().c_str(),
out_archor_ptr->GetOwnerNode()->GetType().c_str(), out_archor_ptr->GetIdx(),
in_archor_ptr->GetOwnerNode()->GetName().c_str(),
in_archor_ptr->GetOwnerNode()->GetType().c_str(), in_archor_ptr->GetIdx());
GELOGE(domi::INTERNAL_ERROR, "Add edge failed,src op:%s,dst op:%s", arg_node->GetName().c_str(),
node->GetName().c_str());
return FAILED;
@@ -310,7 +351,12 @@ domi::Status GraphToFunctionDef::RecordArg(ge::ComputeGraphPtr graph, const vect
node_exists = true;
}
}
GE_IF_BOOL_EXEC(!node_exists, GELOGE(FAILED, "node not exists!"); return FAILED);
GE_IF_BOOL_EXEC(!node_exists,
REPORT_CALL_ERROR("E19999", "Node:%s(%s) not found in graph:%s, check invalid",
anchor->GetOwnerNode()->GetName().c_str(),
anchor->GetOwnerNode()->GetType().c_str(),
graph->GetName().c_str());
GELOGE(FAILED, "node not exists!"); return FAILED);
arg_datetypes_.emplace_back(domi::tensorflow::DataType(dtype));
index++;
}
@@ -422,6 +468,8 @@ domi::Status GraphToFunctionDef::DavGraphToFunctionDef(ge::ComputeGraphPtr graph
// Add regular inputs
for (auto anchor : in_anchors) {
GE_IF_BOOL_EXEC(anchor == nullptr,
REPORT_CALL_ERROR("E19999", "Nonconsecutive input edges; missing input edge for node %s",
node_def_.name().c_str());
GELOGE(domi::INTERNAL_ERROR, "Nonconsecutive input edges; missing input edge , for node %s .",
node_def_.name().c_str());
return domi::INTERNAL_ERROR);


+ 414
- 79
parser/tensorflow/graph_optimizer.cc View File

@@ -413,6 +413,8 @@ Status SetTensorAttr(ge::OpDescPtr &opDesc, google::protobuf::Map<string, domi::
data_count = ge_tensor->GetData().size() / sizeof(bool);
break;
default:
REPORT_INNER_ERROR("E19999", "datatype:%d of Attr:%s in node:%s:%s is not supported",
ge_datatype, attr.first.c_str(), opDesc->GetName().c_str(), opDesc->GetName().c_str());
GELOGE(PARAM_INVALID, "NO SUPPORT datatype = %s", ge::TypeUtils::DataTypeToSerialString(ge_datatype).c_str());
return PARAM_INVALID;
}
@@ -519,11 +521,20 @@ typedef Status (*PIOListHandle)(ge::GeAttrValue::LIST_INT &input_list, ge::GeAtt
Status GatherV2IOList(ge::GeAttrValue::LIST_INT &input_list, ge::GeAttrValue::LIST_INT &output_list,
ge::OpDescPtr &opDesc) {
int tparams;
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "Tparams", tparams)), return PARAM_INVALID, "Get Tparams error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "Tparams", tparams)),
REPORT_CALL_ERROR("E19999", "Get Attr:Tparams from op:%s(%s) failed",
opDesc->GetName().c_str(), opDesc->GetType().c_str());
return PARAM_INVALID, "Get Tparams error.");
int tindices;
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "Tindices", tindices)), return PARAM_INVALID, "Get Tindices error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "Tindices", tindices)),
REPORT_CALL_ERROR("E19999", "Get Attr:Tindices from op:%s(%s) failed",
opDesc->GetName().c_str(), opDesc->GetType().c_str());
return PARAM_INVALID, "Get Tindices error.");
int taxis;
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "Taxis", taxis)), return PARAM_INVALID, "Get Taxis error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "Taxis", taxis)),
REPORT_CALL_ERROR("E19999", "Get Attr:Taxis from op:%s(%s) failed",
opDesc->GetName().c_str(), opDesc->GetType().c_str());
return PARAM_INVALID, "Get Taxis error.");

// input_list - eg:{1, 3, 3}
input_list.push_back(tparams);
@@ -548,7 +559,10 @@ Status ConstIOList(ge::GeAttrValue::LIST_INT &input_list, ge::GeAttrValue::LIST_
Status MaxMinIOList(ge::GeAttrValue::LIST_INT &input_list, ge::GeAttrValue::LIST_INT &output_list,
ge::OpDescPtr &opDesc) {
int attrT;
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "T", attrT)), return PARAM_INVALID, "Get Tparams error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "T", attrT)),
REPORT_CALL_ERROR("E19999", "Get Attr:T from op:%s(%s) failed",
opDesc->GetName().c_str(), opDesc->GetType().c_str());
return PARAM_INVALID, "Get Tparams error.");

// input_list
input_list.push_back(attrT);
@@ -564,8 +578,14 @@ Status CastIOList(ge::GeAttrValue::LIST_INT &input_list, ge::GeAttrValue::LIST_I
ge::OpDescPtr &opDesc) {
int srcT;
int dstT;
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "SrcT", srcT)), return PARAM_INVALID, "Get srcT error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "DstT", dstT)), return PARAM_INVALID, "Get dstT error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "SrcT", srcT)),
REPORT_CALL_ERROR("E19999", "Get Attr:SrcT from op:%s(%s) failed",
opDesc->GetName().c_str(), opDesc->GetType().c_str());
return PARAM_INVALID, "Get srcT error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "DstT", dstT)),
REPORT_CALL_ERROR("E19999", "Get Attr:DstT from op:%s(%s) failed",
opDesc->GetName().c_str(), opDesc->GetType().c_str());
return PARAM_INVALID, "Get dstT error.");
input_list.push_back(srcT);
output_list.push_back(dstT);

@@ -574,7 +594,10 @@ Status CastIOList(ge::GeAttrValue::LIST_INT &input_list, ge::GeAttrValue::LIST_I

Status AddIOList(ge::GeAttrValue::LIST_INT &input_list, ge::GeAttrValue::LIST_INT &output_list, ge::OpDescPtr &opDesc) {
int type;
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "T", type)), return PARAM_INVALID, "Get T error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "T", type)),
REPORT_CALL_ERROR("E19999", "Get Attr:T from op:%s(%s) failed",
opDesc->GetName().c_str(), opDesc->GetType().c_str());
return PARAM_INVALID, "Get T error.");

input_list.push_back(type);
input_list.push_back(type);
@@ -587,7 +610,10 @@ Status AddIOList(ge::GeAttrValue::LIST_INT &input_list, ge::GeAttrValue::LIST_IN
Status LessIOList(ge::GeAttrValue::LIST_INT &input_list, ge::GeAttrValue::LIST_INT &output_list,
ge::OpDescPtr &opDesc) {
int dtype;
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "T", dtype)), return PARAM_INVALID, "Get dtype error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "T", dtype)),
REPORT_CALL_ERROR("E19999", "Get Attr:T from op:%s(%s) failed",
opDesc->GetName().c_str(), opDesc->GetType().c_str());
return PARAM_INVALID, "Get dtype error.");

input_list.push_back(dtype);
input_list.push_back(dtype);
@@ -598,7 +624,10 @@ Status LessIOList(ge::GeAttrValue::LIST_INT &input_list, ge::GeAttrValue::LIST_I

Status MulIOList(ge::GeAttrValue::LIST_INT &input_list, ge::GeAttrValue::LIST_INT &output_list, ge::OpDescPtr &opDesc) {
int dataType;
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, ge::ATTR_NAME_T, dataType)), return PARAM_INVALID,
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, ge::ATTR_NAME_T, dataType)),
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ge::ATTR_NAME_T.c_str(),
opDesc->GetName().c_str(), opDesc->GetType().c_str());
return PARAM_INVALID,
"Get Tparams error.");

input_list.push_back(dataType);
@@ -612,7 +641,10 @@ Status MulIOList(ge::GeAttrValue::LIST_INT &input_list, ge::GeAttrValue::LIST_IN
Status RealDivIOList(ge::GeAttrValue::LIST_INT &input_list, ge::GeAttrValue::LIST_INT &output_list,
ge::OpDescPtr &opDesc) {
int t;
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "T", t)), return PARAM_INVALID, "Get beta error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "T", t)),
REPORT_CALL_ERROR("E19999", "Get Attr:T from op:%s(%s) failed",
opDesc->GetName().c_str(), opDesc->GetType().c_str());
return PARAM_INVALID, "Get beta error.");

input_list.push_back(t);
input_list.push_back(t);
@@ -625,7 +657,10 @@ Status RealDivIOList(ge::GeAttrValue::LIST_INT &input_list, ge::GeAttrValue::LIS
Status SelectIOList(ge::GeAttrValue::LIST_INT &input_list, ge::GeAttrValue::LIST_INT &output_list,
ge::OpDescPtr &opDesc) {
int t;
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "T", t)), return PARAM_INVALID, "Get e error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "T", t)),
REPORT_CALL_ERROR("E19999", "Get Attr:T from op:%s(%s) failed",
opDesc->GetName().c_str(), opDesc->GetType().c_str());
return PARAM_INVALID, "Get e error.");

input_list.push_back(domi::tensorflow::DataType::DT_BOOL);
input_list.push_back(t);
@@ -639,7 +674,10 @@ Status SelectIOList(ge::GeAttrValue::LIST_INT &input_list, ge::GeAttrValue::LIST
Status SqrtIOList(ge::GeAttrValue::LIST_INT &input_list, ge::GeAttrValue::LIST_INT &output_list,
ge::OpDescPtr &opDesc) {
int dataType;
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, ge::ATTR_NAME_T, dataType)), return PARAM_INVALID,
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, ge::ATTR_NAME_T, dataType)),
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ge::ATTR_NAME_T.c_str(),
opDesc->GetName().c_str(), opDesc->GetType().c_str());
return PARAM_INVALID,
"Get Tparam error.");

input_list.push_back(dataType);
@@ -653,8 +691,14 @@ Status TruncatedNormalIOList(ge::GeAttrValue::LIST_INT &input_list, ge::GeAttrVa
ge::OpDescPtr &opDesc) {
int t;
int dtype;
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "T", t)), return PARAM_INVALID, "Get T error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "dtype", dtype)), return PARAM_INVALID, "Get e error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "T", t)),
REPORT_CALL_ERROR("E19999", "Get Attr:T from op:%s(%s) failed",
opDesc->GetName().c_str(), opDesc->GetType().c_str());
return PARAM_INVALID, "Get T error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "dtype", dtype)),
REPORT_CALL_ERROR("E19999", "Get Attr:dtype from op:%s(%s) failed",
opDesc->GetName().c_str(), opDesc->GetType().c_str());
return PARAM_INVALID, "Get e error.");

input_list.push_back(t);

@@ -667,8 +711,14 @@ Status PackIOList(ge::GeAttrValue::LIST_INT &input_list, ge::GeAttrValue::LIST_I
ge::OpDescPtr &opDesc) {
int t;
int n;
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "T", t)), return PARAM_INVALID, "Get T error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "N", n)), return PARAM_INVALID, "Get N error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "T", t)),
REPORT_CALL_ERROR("E19999", "Get Attr:T from op:%s(%s) failed",
opDesc->GetName().c_str(), opDesc->GetType().c_str());
return PARAM_INVALID, "Get T error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "N", n)),
REPORT_CALL_ERROR("E19999", "Get Attr:N from op:%s(%s) failed",
opDesc->GetName().c_str(), opDesc->GetType().c_str());
return PARAM_INVALID, "Get N error.");

for (int i = 0; i < n; i++) {
input_list.push_back(t);
@@ -692,8 +742,14 @@ Status ExpandDimsIOList(ge::GeAttrValue::LIST_INT &input_list, ge::GeAttrValue::
ge::OpDescPtr &opDesc) {
int dataType;
int dimType;
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "T", dataType)), return PARAM_INVALID, "Get T error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "Tdim", dimType)), return PARAM_INVALID, "Get Tdim error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "T", dataType)),
REPORT_CALL_ERROR("E19999", "Get Attr:T from op:%s(%s) failed",
opDesc->GetName().c_str(), opDesc->GetType().c_str());
return PARAM_INVALID, "Get T error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "Tdim", dimType)),
REPORT_CALL_ERROR("E19999", "Get Attr:Tdim from op:%s(%s) failed",
opDesc->GetName().c_str(), opDesc->GetType().c_str());
return PARAM_INVALID, "Get Tdim error.");
// input_list - x y data type
input_list.push_back(dataType);
input_list.push_back(dimType);
@@ -708,8 +764,14 @@ Status SqueezeIOList(ge::GeAttrValue::LIST_INT &input_list, ge::GeAttrValue::LIS
// Set - TENSORFLOW_IN_DATATYPE/TENSORFLOW_OUT_DATATYPE
int dataType;
vector<int> dimTypeList;
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "T", dataType)), return PARAM_INVALID, "Get T error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetListInt(opDesc, "squeeze_dims", dimTypeList)), return PARAM_INVALID,
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "T", dataType)),
REPORT_CALL_ERROR("E19999", "Get Attr:T from op:%s(%s) failed",
opDesc->GetName().c_str(), opDesc->GetType().c_str());
return PARAM_INVALID, "Get T error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetListInt(opDesc, "squeeze_dims", dimTypeList)),
REPORT_CALL_ERROR("E19999", "Get Attr:squeeze_dims from op:%s(%s) failed",
opDesc->GetName().c_str(), opDesc->GetType().c_str());
return PARAM_INVALID,
"Get squeeze_dims error.");
for (auto i : dimTypeList) {
GELOGI("squeeze_dims = %d.\n", i);
@@ -726,7 +788,10 @@ Status SqueezeIOList(ge::GeAttrValue::LIST_INT &input_list, ge::GeAttrValue::LIS
Status TopKV2IOList(ge::GeAttrValue::LIST_INT &inputList, ge::GeAttrValue::LIST_INT &outputList,
ge::OpDescPtr &opDesc) {
int t;
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "T", t)), return PARAM_INVALID, "Get T error.");
GE_CHK_BOOL_EXEC((ge::AttrUtils::GetInt(opDesc, "T", t)),
REPORT_CALL_ERROR("E19999", "Get Attr:T from op:%s(%s) failed",
opDesc->GetName().c_str(), opDesc->GetType().c_str());
return PARAM_INVALID, "Get T error.");

// input_list - eg:{1, 3}
inputList.push_back(t);
@@ -798,8 +863,12 @@ Status CreateNodeDefBytes(ge::NodePtr n, string originalType, map<string, PIOLis

uint32_t size_type = 1;
bool type_ret = ge::TypeUtils::GetDataTypeLength(data_type, size_type);
GE_IF_BOOL_EXEC(!type_ret, GELOGE(PARAM_INVALID, "Can't GetDataTypeLength of data_type: %s",
ge::TypeUtils::DataTypeToSerialString(data_type).c_str());
GE_IF_BOOL_EXEC(!type_ret,
REPORT_CALL_ERROR("E19999", "Can't get DataType:%s length of op:%s(%s)",
ge::TypeUtils::DataTypeToSerialString(data_type).c_str(),
n->GetName().c_str(), n->GetType().c_str());
GELOGE(PARAM_INVALID, "Can't GetDataTypeLength of data_type: %s",
ge::TypeUtils::DataTypeToSerialString(data_type).c_str());
return PARAM_INVALID);

// calculate size
@@ -815,7 +884,10 @@ Status CreateNodeDefBytes(ge::NodePtr n, string originalType, map<string, PIOLis

// Serial - nodedef proto
string nodefStr;
GE_IF_BOOL_EXEC(!proto.SerializeToString(&nodefStr), GELOGE(PARAM_INVALID, "Serialize nodedef to string failed.");
GE_IF_BOOL_EXEC(!proto.SerializeToString(&nodefStr),
REPORT_CALL_ERROR("E19999", "Serialize nodedef to string failed, op:%s(%s)",
n->GetName().c_str(), n->GetType().c_str());
GELOGE(PARAM_INVALID, "Serialize nodedef to string failed.");
return PARAM_INVALID);

// Set - ATTR_NAME_FRAMEWORK_NODE_DEF
@@ -1167,7 +1239,10 @@ Status CreateOpDefBytes(ge::NodePtr n, string original_type) {
}
// set - opdef
string opdefString;
GE_IF_BOOL_EXEC(!proto.SerializeToString(&opdefString), GELOGE(PARAM_INVALID, "Serialize opdef to string failed.");
GE_IF_BOOL_EXEC(!proto.SerializeToString(&opdefString),
REPORT_CALL_ERROR("E19999", "Serialize opdef to string failed, op:%s(%s)",
n->GetName().c_str(), n->GetType().c_str());
GELOGE(PARAM_INVALID, "Serialize opdef to string failed.");
return PARAM_INVALID);

(void)ge::AttrUtils::SetStr(opDesc, ge::ATTR_NAME_FRAMEWORK_OP_DEF, opdefString);
@@ -1197,7 +1272,9 @@ Status CreateFuncDefBytes(ge::NodePtr n, string original_type, string func_bin_p

char *buf = nullptr;
int32_t len = 0;
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(!ge::parser::ReadBytesFromBinaryFile(file.c_str(), &buf, len), return false,
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(!ge::parser::ReadBytesFromBinaryFile(file.c_str(), &buf, len),
REPORT_CALL_ERROR("E19999", "Read bytes for file:%s failed", file.c_str());
return false,
"read bytes file error!");

GELOGI("len =%d\n", len);
@@ -1408,7 +1485,9 @@ Status ParserGraphOptimizer::UpdateGraph(vector<NodePtr> &nodes) {
std::unique_ptr<FunctionDefLibrary> func_def_lib(new (std::nothrow) FunctionDefLibrary());
GE_CHECK_NOTNULL(func_def_lib);
// convert graph to FunctionDef
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(nodes.size() == 0, return PARAM_INVALID, "node size must greater than 0 .");
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(nodes.size() == 0,
REPORT_INNER_ERROR("E19999", "Param nodes size must greater than 0");
return PARAM_INVALID, "node size must greater than 0 .");
GE_CHK_STATUS_RET(CollectNodeFuncs(nodes, func_def_lib.get()), "Collect functionDef in nodes failed.");
GE_CHK_STATUS_RET(GraphToFunctionDef::BuildFunctionDef(sub_graph, nodes[0]->GetName(), func_def_lib.get(),
node_def.get(), input_anchors, output_anchors),
@@ -1416,10 +1495,13 @@ Status ParserGraphOptimizer::UpdateGraph(vector<NodePtr> &nodes) {
string nodefStr;
string funcdefStr;

GE_IF_BOOL_EXEC(!node_def->SerializeToString(&nodefStr), GELOGE(PARAM_INVALID, "Serialize nodedef to string failed.");
GE_IF_BOOL_EXEC(!node_def->SerializeToString(&nodefStr),
REPORT_CALL_ERROR("E19999", "Serialize nodedef to string failed");
GELOGE(PARAM_INVALID, "Serialize nodedef to string failed.");
return PARAM_INVALID);

GE_IF_BOOL_EXEC(!func_def_lib->SerializeToString(&funcdefStr),
REPORT_CALL_ERROR("E19999", "Serialize func_def to string failed, ");
GELOGE(PARAM_INVALID, "Serialize func_def to string failed.");
return PARAM_INVALID);

@@ -1521,6 +1603,9 @@ Status ParserGraphOptimizer::LinkInnerAnchor(unordered_map<string, ge::NodePtr>

GE_IF_BOOL_EXEC(ge::GraphUtils::AddEdge(src->GetOutDataAnchor(peer_out_anchor->GetIdx()),
dst->GetInDataAnchor(in_anchor->GetIdx())) != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
src->GetName().c_str(), src->GetType().c_str(), peer_out_anchor->GetIdx(),
dst->GetName().c_str(), dst->GetType().c_str(), in_anchor->GetIdx());
GELOGE(FAILED,
"LinkInnerAnchor Link data anchor failed, src node: %s, "
"dst node: %s.",
@@ -1536,6 +1621,9 @@ Status ParserGraphOptimizer::LinkInnerAnchor(unordered_map<string, ge::NodePtr>
NodePtr src_ctrl = node_map[peer_out_ctl_anchor->GetOwnerNode()->GetName()];
GE_IF_BOOL_EXEC(
ge::GraphUtils::AddEdge(src_ctrl->GetOutControlAnchor(), dst->GetInControlAnchor()) != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
src_ctrl->GetName().c_str(), src_ctrl->GetType().c_str(),
dst->GetName().c_str(), dst->GetType().c_str());
GELOGE(FAILED,
"LinkInnerAnchor Link control anchor failed, src node: "
"%s, dst node: %s.",
@@ -1564,6 +1652,8 @@ Status ParserGraphOptimizer::RebuildOutputAnchors(vector<ge::OutDataAnchorPtr> &
auto iter = GE_TENSORFLOW_DATA_TYPE_MAP.find((int32_t)data_type);
GE_IF_BOOL_EXEC(
iter == GE_TENSORFLOW_DATA_TYPE_MAP.end(),
REPORT_INNER_ERROR("E19999", "datatype:%d of output:%d in node:%s:%s is not supported",
data_type, out_anchor->GetIdx(), src_node->GetName().c_str(), src_node->GetName().c_str());
GELOGE(PARAM_INVALID, "data_type %s not supported", ge::TypeUtils::DataTypeToSerialString(data_type).c_str());
return PARAM_INVALID);

@@ -1588,12 +1678,18 @@ Status ParserGraphOptimizer::RebuildInputAnchors(vector<ge::InDataAnchorPtr> &in
auto tensorDescPtr = dst_node->GetOpDesc()->GetInputDescPtr(in_anchor->GetIdx());
GE_CHECK_NOTNULL_EXEC(tensorDescPtr, return domi::FAILED);

GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((fusion_op_desc->AddInputDesc(*tensorDescPtr)) != GRAPH_SUCCESS, return FAILED,
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((fusion_op_desc->AddInputDesc(*tensorDescPtr)) != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
fusion_op_desc->GetName().c_str(),
fusion_op_desc->GetType().c_str());
return FAILED,
"Add fusion_op_desc AddInputDesc failed");
ge::DataType data_type = tensorDescPtr->GetDataType();
auto iter = GE_TENSORFLOW_DATA_TYPE_MAP.find((int32_t)data_type);
GE_IF_BOOL_EXEC(
iter == GE_TENSORFLOW_DATA_TYPE_MAP.end(),
REPORT_INNER_ERROR("E19999", "datatype:%d of input:%d in node:%s:%s is not supported",
data_type, in_anchor->GetIdx(), dst_node->GetName().c_str(), dst_node->GetName().c_str());
GELOGE(PARAM_INVALID, "data_type %s not supported", ge::TypeUtils::DataTypeToSerialString(data_type).c_str());
return PARAM_INVALID);

@@ -1658,12 +1754,20 @@ Status ParserGraphOptimizer::Insert4DTo5DTransOp(OutDataAnchorPtr src_anchor, In
if (src_out_data_type != dst_in_data_type) {
OpDescPtr cast_opdesc = CreateCastOp(src_out_data_type, dst_in_data_type, ge::FORMAT_NCHW);
cast_node = graph_->AddNode(cast_opdesc);
GE_CHK_BOOL_EXEC(cast_node != nullptr, return INTERNAL_ERROR, "graph add cast node fail.");
GE_CHK_BOOL_EXEC(cast_node != nullptr,
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
cast_opdesc->GetName().c_str(), cast_opdesc->GetType().c_str(),
graph_->GetName().c_str());
return INTERNAL_ERROR, "graph add cast node fail.");
}

OpDescPtr trans_data_opdesc = CreateTransDataOp(FORMAT_NCHW);
NodePtr trans_data_node = graph_->AddNode(trans_data_opdesc);
GE_CHK_BOOL_EXEC(trans_data_node != nullptr, return INTERNAL_ERROR, "graph add TransData node node fail.");
GE_CHK_BOOL_EXEC(trans_data_node != nullptr,
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
trans_data_opdesc->GetName().c_str(), trans_data_opdesc->GetType().c_str(),
graph_->GetName().c_str());
return INTERNAL_ERROR, "graph add TransData node node fail.");
GE_CHK_STATUS_RET(NewNodeAddEdges(src_anchor, dst_anchor, nullptr, cast_node, trans_data_node),
"NewNodeAddEdges ret fail.");

@@ -1676,8 +1780,18 @@ Status ParserGraphOptimizer::Insert4DTo5DTransOp(OutDataAnchorPtr src_anchor, In
GE_CHECK_NOTNULL(transNode);
GELOGI("Create 4D To 5D fp32 node susscess!");

GE_IF_BOOL_EXEC(GraphUtils::AddEdge(src_anchor, transNode->GetInDataAnchor(0)), return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(transNode->GetOutDataAnchor(0), dst_anchor), return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(src_anchor, transNode->GetInDataAnchor(0)),
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed",
src_anchor->GetOwnerNode()->GetName().c_str(),
src_anchor->GetOwnerNode()->GetType().c_str(), src_anchor->GetIdx(),
transNode->GetName().c_str(), transNode->GetType().c_str());
return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(transNode->GetOutDataAnchor(0), dst_anchor),
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed",
transNode->GetName().c_str(), transNode->GetType().c_str(),
dst_anchor->GetOwnerNode()->GetName().c_str(),
dst_anchor->GetOwnerNode()->GetType().c_str(), dst_anchor->GetIdx());
return INTERNAL_ERROR);

GELOGI("Create 4D To 5D susscess!");
return SUCCESS;
@@ -1701,14 +1815,39 @@ Status ParserGraphOptimizer::InsertFZ2HWCK(OutDataAnchorPtr src_anchor, InDataAn
OpDescPtr translatetoHWCK = CreateTranslateOp(srcOutFormat, ge::DT_FLOAT16, dstInFormat, dstInDatatype);
NodePtr transHWCKNode = graph_->AddNode(translatetoHWCK); GELOGI("Create FZ 16 to HWCK fp32 node susscess!");
GE_CHECK_NOTNULL(transHWCKNode); if (transHalfNode) {
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(src_anchor, transHalfNode->GetInDataAnchor(0)), return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(src_anchor, transHalfNode->GetInDataAnchor(0)),
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed",
src_anchor->GetOwnerNode()->GetName().c_str(),
src_anchor->GetOwnerNode()->GetType().c_str(), src_anchor->GetIdx(),
transHalfNode->GetName().c_str(), transHalfNode->GetType().c_str());
return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(transHalfNode->GetOutDataAnchor(0), transHWCKNode->GetInDataAnchor(0)),
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed",
transHalfNode->GetName().c_str(), transHalfNode->GetType().c_str(),
transHWCKNode->GetName().c_str(), transHWCKNode->GetType().c_str());
return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(transHWCKNode->GetOutDataAnchor(0), dst_anchor) != SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed",
transHWCKNode->GetName().c_str(), transHWCKNode->GetType().c_str(),
dst_anchor->GetOwnerNode()->GetName().c_str(),
dst_anchor->GetOwnerNode()->GetType().c_str(), dst_anchor->GetIdx());
return INTERNAL_ERROR);
} else {
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(src_anchor, transHWCKNode->GetInDataAnchor(0)), return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(src_anchor, transHWCKNode->GetInDataAnchor(0)),
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed",
src_anchor->GetOwnerNode()->GetName().c_str(),
src_anchor->GetOwnerNode()->GetType().c_str(), src_anchor->GetIdx(),
transHWCKNode->GetName().c_str(), transHWCKNode->GetType().c_str());
return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(transHWCKNode->GetOutDataAnchor(0), dst_anchor) != SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed",
transHWCKNode->GetName().c_str(), transHWCKNode->GetType().c_str(),
dst_anchor->GetOwnerNode()->GetName().c_str(),
dst_anchor->GetOwnerNode()->GetType().c_str(), dst_anchor->GetIdx());
return INTERNAL_ERROR);
} GELOGI("Create InsertFZ2HWCK success!");)
return SUCCESS;
@@ -1731,14 +1870,40 @@ Status ParserGraphOptimizer::InsertVar5DTo4D(ge::OutDataAnchorPtr src_anchor, ge
GE_CHECK_NOTNULL(trans4DNode);

if (cast_node) {
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(src_anchor, cast_node->GetInDataAnchor(0)), return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(src_anchor, cast_node->GetInDataAnchor(0)),
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed",
src_anchor->GetOwnerNode()->GetName().c_str(),
src_anchor->GetOwnerNode()->GetType().c_str(), src_anchor->GetIdx(),
cast_node->GetName().c_str(), cast_node->GetType().c_str());
return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(cast_node->GetOutDataAnchor(0), trans4DNode->GetInDataAnchor(0)),
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed",
cast_node->GetName().c_str(), cast_node->GetType().c_str(),
trans4DNode->GetName().c_str(), trans4DNode->GetType().c_str());
return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(trans4DNode->GetOutDataAnchor(0), dst_anchor) != SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed",
trans4DNode->GetName().c_str(), trans4DNode->GetType().c_str(),
dst_anchor->GetOwnerNode()->GetName().c_str(),
dst_anchor->GetOwnerNode()->GetType().c_str(), dst_anchor->GetIdx());
return INTERNAL_ERROR);
} else {
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(src_anchor, trans4DNode->GetInDataAnchor(0)), return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(src_anchor, trans4DNode->GetInDataAnchor(0)),
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed",
src_anchor->GetOwnerNode()->GetName().c_str(),
src_anchor->GetOwnerNode()->GetType().c_str(), src_anchor->GetIdx(),
trans4DNode->GetName().c_str(), trans4DNode->GetType().c_str());
return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(trans4DNode->GetOutDataAnchor(0), dst_anchor) != SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed",
trans4DNode->GetName().c_str(), trans4DNode->GetType().c_str(),
dst_anchor->GetOwnerNode()->GetName().c_str(),
dst_anchor->GetOwnerNode()->GetType().c_str(), dst_anchor->GetIdx());
return INTERNAL_ERROR);
} GELOGI("Create 5D To 4D susscess!");)
return SUCCESS;
@@ -1764,15 +1929,40 @@ Status ParserGraphOptimizer::InsertHWCK2FZ(OutDataAnchorPtr src_anchor, InDataAn
}

if (translateHalftoFp32Node) {
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(src_anchor, transHWCK2FZNode->GetInDataAnchor(0)), return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(src_anchor, transHWCK2FZNode->GetInDataAnchor(0)),
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed",
src_anchor->GetOwnerNode()->GetName().c_str(),
src_anchor->GetOwnerNode()->GetType().c_str(), src_anchor->GetIdx(),
transHWCK2FZNode->GetName().c_str(), transHWCK2FZNode->GetType().c_str());
return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(
GraphUtils::AddEdge(transHWCK2FZNode->GetOutDataAnchor(0), translateHalftoFp32Node->GetInDataAnchor(0)),
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed",
transHWCK2FZNode->GetName().c_str(), transHWCK2FZNode->GetType().c_str(),
translateHalftoFp32Node->GetName().c_str(), translateHalftoFp32Node->GetType().c_str());
return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(translateHalftoFp32Node->GetOutDataAnchor(0), dst_anchor) != SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed",
translateHalftoFp32Node->GetName().c_str(), translateHalftoFp32Node->GetType().c_str(),
dst_anchor->GetOwnerNode()->GetName().c_str(),
dst_anchor->GetOwnerNode()->GetType().c_str(), dst_anchor->GetIdx());
return INTERNAL_ERROR);
} else {
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(src_anchor, transHWCK2FZNode->GetInDataAnchor(0)), return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(src_anchor, transHWCK2FZNode->GetInDataAnchor(0)),
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed",
src_anchor->GetOwnerNode()->GetName().c_str(),
src_anchor->GetOwnerNode()->GetType().c_str(), src_anchor->GetIdx(),
transHWCK2FZNode->GetName().c_str(), transHWCK2FZNode->GetType().c_str());
return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(GraphUtils::AddEdge(transHWCK2FZNode->GetOutDataAnchor(0), dst_anchor) != SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed",
transHWCK2FZNode->GetName().c_str(), transHWCK2FZNode->GetType().c_str(),
dst_anchor->GetOwnerNode()->GetName().c_str(),
dst_anchor->GetOwnerNode()->GetType().c_str(), dst_anchor->GetIdx());
return INTERNAL_ERROR);
} GELOGI("Create InsertHWCK2FZ success!");)
return SUCCESS;
@@ -1787,18 +1977,30 @@ Status ParserGraphOptimizer::Insert5DTo4DTransOp(OutDataAnchorPtr src_anchor, In

OpDescPtr trans_data_opdesc = CreateTransDataOp(FORMAT_NC1HWC0);
NodePtr trans_data_node = graph_->AddNode(trans_data_opdesc);
GE_CHK_BOOL_EXEC(trans_data_node != nullptr, return INTERNAL_ERROR, "graph add TransData node node fail.");
GE_CHK_BOOL_EXEC(trans_data_node != nullptr,
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
trans_data_opdesc->GetName().c_str(), trans_data_opdesc->GetType().c_str(),
graph_->GetName().c_str());
return INTERNAL_ERROR, "graph add TransData node node fail.");

if (src_out_data_type != dst_in_data_type) {
OpDescPtr cast_opdesc = CreateCastOp(src_out_data_type, dst_in_data_type, ge::FORMAT_NCHW);
cast_node = graph_->AddNode(cast_opdesc);
GE_CHK_BOOL_EXEC(cast_node != nullptr, return INTERNAL_ERROR, "graph add cast node fail.");
GE_CHK_BOOL_EXEC(cast_node != nullptr,
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
cast_opdesc->GetName().c_str(), cast_opdesc->GetType().c_str(),
graph_->GetName().c_str());
return INTERNAL_ERROR, "graph add cast node fail.");
}

if (dst_in_format == FORMAT_NHWC) {
OpDescPtr permute_opdec = CreatePermuteOp(FORMAT_NCHW, dst_in_format);
permute_node = graph_->AddNode(permute_opdec);
GE_CHK_BOOL_EXEC(permute_node != nullptr, return INTERNAL_ERROR, "graph add permute node fail.");
GE_CHK_BOOL_EXEC(permute_node != nullptr,
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
permute_opdec->GetName().c_str(), permute_opdec->GetType().c_str(),
graph_->GetName().c_str());
return INTERNAL_ERROR, "graph add permute node fail.");
}

GE_CHK_STATUS_RET(NewNodeAddEdges(src_anchor, dst_anchor, trans_data_node, cast_node, permute_node),
@@ -1818,60 +2020,136 @@ Status ParserGraphOptimizer::NewNodeAddEdges(OutDataAnchorPtr src_anchor, InData

if (first != nullptr) {
Status status = GraphUtils::AddEdge(src_anchor, first->GetInDataAnchor(0));
GE_CHK_BOOL_EXEC(status == SUCCESS, return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.",
GE_CHK_BOOL_EXEC(status == SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed",
src_anchor->GetOwnerNode()->GetName().c_str(),
src_anchor->GetOwnerNode()->GetType().c_str(), src_anchor->GetIdx(),
first->GetName().c_str(), first->GetType().c_str());
return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.",
src_anchor->GetIdx(), 0);
if (second != nullptr) {
status = GraphUtils::AddEdge(first->GetOutDataAnchor(0), second->GetInDataAnchor(0));
GE_CHK_BOOL_EXEC(status == SUCCESS, return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.", 0,
0);
GE_CHK_BOOL_EXEC(status == SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed",
first->GetName().c_str(), first->GetType().c_str(),
second->GetName().c_str(), second->GetType().c_str());
return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.", 0, 0);
if (third != nullptr) {
status = GraphUtils::AddEdge(second->GetOutDataAnchor(0), third->GetInDataAnchor(0));
GE_CHK_BOOL_EXEC(status == SUCCESS, return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.",
0, 0);
GE_CHK_BOOL_EXEC(status == SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed",
second->GetName().c_str(), second->GetType().c_str(),
third->GetName().c_str(), third->GetType().c_str());
return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.", 0, 0);
status = GraphUtils::AddEdge(third->GetOutDataAnchor(0), dst_anchor);
GE_CHK_BOOL_EXEC(status == SUCCESS, return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.",
GE_CHK_BOOL_EXEC(status == SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed",
third->GetName().c_str(), third->GetType().c_str(),
dst_anchor->GetOwnerNode()->GetName().c_str(),
dst_anchor->GetOwnerNode()->GetType().c_str(), dst_anchor->GetIdx());
return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.",
0, dst_anchor->GetIdx());
} else {
status = GraphUtils::AddEdge(second->GetOutDataAnchor(0), dst_anchor);
GE_CHK_BOOL_EXEC(status == SUCCESS, return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.",
GE_CHK_BOOL_EXEC(status == SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed",
second->GetName().c_str(), second->GetType().c_str(),
dst_anchor->GetOwnerNode()->GetName().c_str(),
dst_anchor->GetOwnerNode()->GetType().c_str(), dst_anchor->GetIdx());
return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.",
0, dst_anchor->GetIdx());
}
} else {
if (third != nullptr) {
status = GraphUtils::AddEdge(first->GetOutDataAnchor(0), third->GetInDataAnchor(0));
GE_CHK_BOOL_EXEC(status == SUCCESS, return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.",
0, 0);
GE_CHK_BOOL_EXEC(status == SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed",
first->GetName().c_str(), first->GetType().c_str(),
third->GetName().c_str(), third->GetType().c_str());
return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.", 0, 0);
status = GraphUtils::AddEdge(third->GetOutDataAnchor(0), dst_anchor);
GE_CHK_BOOL_EXEC(status == SUCCESS, return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.",
GE_CHK_BOOL_EXEC(status == SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed",
third->GetName().c_str(), third->GetType().c_str(),
dst_anchor->GetOwnerNode()->GetName().c_str(),
dst_anchor->GetOwnerNode()->GetType().c_str(), dst_anchor->GetIdx());
return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.",
0, dst_anchor->GetIdx());
} else {
status = GraphUtils::AddEdge(first->GetOutDataAnchor(0), dst_anchor);
GE_CHK_BOOL_EXEC(status == SUCCESS, return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.",
GE_CHK_BOOL_EXEC(status == SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed",
first->GetName().c_str(), first->GetType().c_str(),
dst_anchor->GetOwnerNode()->GetName().c_str(),
dst_anchor->GetOwnerNode()->GetType().c_str(), dst_anchor->GetIdx());
return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.",
0, dst_anchor->GetIdx());
}
}
} else {
if (second != nullptr) {
Status status = GraphUtils::AddEdge(src_anchor, second->GetInDataAnchor(0));
GE_CHK_BOOL_EXEC(status == SUCCESS, return INTERNAL_ERROR,
GE_CHK_BOOL_EXEC(status == SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed",
src_anchor->GetOwnerNode()->GetName().c_str(),
src_anchor->GetOwnerNode()->GetType().c_str(), src_anchor->GetIdx(),
second->GetName().c_str(), second->GetType().c_str());
return INTERNAL_ERROR,
"graph add src to cast edge fail, src index:%d, dst index:%d.", src_anchor->GetIdx(), 0);
GE_IF_BOOL_EXEC(
third != nullptr, status = GraphUtils::AddEdge(second->GetOutDataAnchor(0), third->GetInDataAnchor(0));
GE_CHK_BOOL_EXEC(status == SUCCESS, return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.",
0, 0);
GE_CHK_BOOL_EXEC(status == SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed",
second->GetName().c_str(), second->GetType().c_str(),
third->GetName().c_str(), third->GetType().c_str());
return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.", 0, 0);
status = GraphUtils::AddEdge(third->GetOutDataAnchor(0), dst_anchor);
GE_CHK_BOOL_EXEC(status == SUCCESS, return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.",
GE_CHK_BOOL_EXEC(status == SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed",
third->GetName().c_str(), third->GetType().c_str(),
dst_anchor->GetOwnerNode()->GetName().c_str(),
dst_anchor->GetOwnerNode()->GetType().c_str(), dst_anchor->GetIdx());
return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.",
0, dst_anchor->GetIdx()););
GE_IF_BOOL_EXEC(third == nullptr, status = GraphUtils::AddEdge(second->GetOutDataAnchor(0), dst_anchor);
GE_CHK_BOOL_EXEC(status == SUCCESS, return INTERNAL_ERROR,
"graph add edge fail, src index:%d, dst index:%d.", 0, 0););
GE_CHK_BOOL_EXEC(
status == SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed",
second->GetName().c_str(), second->GetType().c_str(),
dst_anchor->GetOwnerNode()->GetName().c_str(),
dst_anchor->GetOwnerNode()->GetType().c_str(), dst_anchor->GetIdx());
return INTERNAL_ERROR,
"graph add edge fail, src index:%d, dst index:%d.", 0, 0););
} else {
if (third != nullptr) {
Status status = GraphUtils::AddEdge(src_anchor, third->GetInDataAnchor(0));
GE_CHK_BOOL_EXEC(status == SUCCESS, return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.",
0, 0);
GE_CHK_BOOL_EXEC(status == SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed",
src_anchor->GetOwnerNode()->GetName().c_str(),
src_anchor->GetOwnerNode()->GetType().c_str(), src_anchor->GetIdx(),
third->GetName().c_str(), third->GetType().c_str());
return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.", 0, 0);
status = GraphUtils::AddEdge(third->GetOutDataAnchor(0), dst_anchor);
GE_CHK_BOOL_EXEC(status == SUCCESS, return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.",
GE_CHK_BOOL_EXEC(status == SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed",
third->GetName().c_str(), third->GetType().c_str(),
dst_anchor->GetOwnerNode()->GetName().c_str(),
dst_anchor->GetOwnerNode()->GetType().c_str(), dst_anchor->GetIdx());
return INTERNAL_ERROR, "graph add edge fail, src index:%d, dst index:%d.",
0, dst_anchor->GetIdx());
}
}
@@ -1902,26 +2180,49 @@ OpDescPtr ParserGraphOptimizer::CreateTranslateOp(enum ge::Format inFormat, enum
ge::TypeUtils::DataTypeToSerialString(inDatatype).c_str(), ge::TypeUtils::FormatToSerialString(outFormat).c_str(),
ge::TypeUtils::DataTypeToSerialString(outDatatype).c_str());

GE_CHK_BOOL_EXEC(AttrUtils::SetInt(op_def, ge::ATTR_NAME_INPUT_FORMAT, inFormat), return nullptr,
GE_CHK_BOOL_EXEC(AttrUtils::SetInt(op_def, ge::ATTR_NAME_INPUT_FORMAT, inFormat),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_INPUT_FORMAT.c_str(),
op_def->GetName().c_str(), op_def->GetType().c_str());
return nullptr,
"SetInt ATTR_NAME_INPUT_FORMAT failed.");
GE_CHK_BOOL_EXEC(AttrUtils::SetInt(op_def, ATTR_NAME_INPUT_DATATYPE, inDatatype), return nullptr,
GE_CHK_BOOL_EXEC(AttrUtils::SetInt(op_def, ATTR_NAME_INPUT_DATATYPE, inDatatype),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_INPUT_DATATYPE.c_str(),
op_def->GetName().c_str(), op_def->GetType().c_str());
return nullptr,
"SetInt ATTR_NAME_INPUT_DATATYPE failed.");
GE_CHK_BOOL_EXEC(AttrUtils::SetInt(op_def, ge::ATTR_NAME_OUTPUT_FORMAT, outFormat), return nullptr,
GE_CHK_BOOL_EXEC(AttrUtils::SetInt(op_def, ge::ATTR_NAME_OUTPUT_FORMAT, outFormat),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_OUTPUT_FORMAT.c_str(),
op_def->GetName().c_str(), op_def->GetType().c_str());
return nullptr,
"SetInt ATTR_NAME_INPUT_DATATYPE failed.");
GE_CHK_BOOL_EXEC(AttrUtils::SetInt(op_def, ATTR_NAME_OUTPUT_DATATYPE, outDatatype), return nullptr,
GE_CHK_BOOL_EXEC(AttrUtils::SetInt(op_def, ATTR_NAME_OUTPUT_DATATYPE, outDatatype),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_OUTPUT_DATATYPE.c_str(),
op_def->GetName().c_str(), op_def->GetType().c_str());
return nullptr,
"SetInt ATTR_NAME_INPUT_DATATYPE failed.");
if (inDatatype != ge::DT_FLOAT16) {
GE_CHK_BOOL_EXEC(SUCCESS == op_def->AddInputDesc(GeTensorDesc(GeShape(), inFormat)), return nullptr,
GE_CHK_BOOL_EXEC(SUCCESS == op_def->AddInputDesc(GeTensorDesc(GeShape(), inFormat)),
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
op_def->GetName().c_str(), op_def->GetType().c_str());
return nullptr,
"create translate op:add input desc fail.");
} else {
GE_CHK_BOOL_EXEC(SUCCESS == op_def->AddInputDesc(GeTensorDesc(GeShape(), inFormat, ge::DT_FLOAT16)), return nullptr,
GE_CHK_BOOL_EXEC(SUCCESS == op_def->AddInputDesc(GeTensorDesc(GeShape(), inFormat, ge::DT_FLOAT16)),
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
op_def->GetName().c_str(), op_def->GetType().c_str());
return nullptr,
"create translate op:add input desc fail.");
}
if (outDatatype != ge::DT_FLOAT16) {
GE_CHK_BOOL_EXEC(SUCCESS == op_def->AddOutputDesc(GeTensorDesc(GeShape(), outFormat)), return nullptr,
GE_CHK_BOOL_EXEC(SUCCESS == op_def->AddOutputDesc(GeTensorDesc(GeShape(), outFormat)),
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed",
op_def->GetName().c_str(), op_def->GetType().c_str());
return nullptr,
"create translate op:add output desc fail.");
} else {
GE_CHK_BOOL_EXEC(SUCCESS == op_def->AddOutputDesc(GeTensorDesc(GeShape(), outFormat, ge::DT_FLOAT16)),
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed",
op_def->GetName().c_str(), op_def->GetType().c_str());
return nullptr, "create translate op:add output desc fail.");
}
return op_def;
@@ -1938,17 +2239,29 @@ OpDescPtr ParserGraphOptimizer::CreatePermuteOp(enum ge::Format input_format, en
return op_desc);
GELOGI("create permute op:%s", op_desc->GetName().c_str());

GE_CHK_BOOL_EXEC(AttrUtils::SetInt(op_desc, ge::ATTR_NAME_INPUT_FORMAT, (int64_t)input_format), return nullptr,
GE_CHK_BOOL_EXEC(AttrUtils::SetInt(op_desc, ge::ATTR_NAME_INPUT_FORMAT, (int64_t)input_format),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_INPUT_FORMAT.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr,
"SetInt ATTR_NAME_INPUT_FORMAT failed.");
GE_CHK_BOOL_EXEC(AttrUtils::SetInt(op_desc, ge::ATTR_NAME_OUTPUT_FORMAT, (int64_t)output_format), return nullptr,
GE_CHK_BOOL_EXEC(AttrUtils::SetInt(op_desc, ge::ATTR_NAME_OUTPUT_FORMAT, (int64_t)output_format),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_OUTPUT_FORMAT.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr,
"SetInt ATTR_NAME_OUTPUT_FORMAT failed.");

GE_IF_BOOL_EXEC(input_format == FORMAT_NCHW, (void)AttrUtils::SetInt(op_desc, "NCHW_to_NHWC", (int64_t)1));
GE_IF_BOOL_EXEC(input_format == FORMAT_NHWC, (void)AttrUtils::SetInt(op_desc, "NHWC_to_NCHW", (int64_t)1));

GE_CHK_BOOL_EXEC(SUCCESS == op_desc->AddInputDesc(GeTensorDesc(GeShape(), input_format)), return nullptr,
GE_CHK_BOOL_EXEC(SUCCESS == op_desc->AddInputDesc(GeTensorDesc(GeShape(), input_format)),
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr,
"create permute op:add input desc fail.");
GE_CHK_BOOL_EXEC(SUCCESS == op_desc->AddOutputDesc(GeTensorDesc(GeShape(), output_format)), return nullptr,
GE_CHK_BOOL_EXEC(SUCCESS == op_desc->AddOutputDesc(GeTensorDesc(GeShape(), output_format)),
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr,
"create permute op:add output desc fail.");

return op_desc;
@@ -1971,14 +2284,24 @@ OpDescPtr ParserGraphOptimizer::CreateCastOp(enum ge::DataType input_data_type,
AttrUtils::SetInt(op_desc, ge::CAST_ATTR_DSTT, (int64_t)output_data_type) &&
AttrUtils::SetInt(op_desc, ge::CAST_ATTR_DST_TYPE, (int64_t)output_data_type) &&
AttrUtils::SetBool(op_desc, ge::CAST_ATTR_TRUNCATE, false))) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s or %s or %s or %s to op:%s(%s) failed",
CAST_ATTR_SRCT.c_str(), CAST_ATTR_DSTT.c_str(),
CAST_ATTR_DST_TYPE.c_str(), CAST_ATTR_TRUNCATE.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Set CAST_ATTR_SRCT or CAST_ATTR_DSTT or CAST_ATTR_DST_TYPE or CAST_ATTR_TRUNCATE fail, node: %s.",
op_desc->GetName().c_str());
return nullptr;
}

GE_CHK_BOOL_EXEC(SUCCESS == op_desc->AddInputDesc(GeTensorDesc(GeShape(), format, input_data_type)), return nullptr,
GE_CHK_BOOL_EXEC(SUCCESS == op_desc->AddInputDesc(GeTensorDesc(GeShape(), format, input_data_type)),
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr,
"create cast op:add input desc fail.");
GE_CHK_BOOL_EXEC(SUCCESS == op_desc->AddOutputDesc(GeTensorDesc(GeShape(), format, output_data_type)), return nullptr,
GE_CHK_BOOL_EXEC(SUCCESS == op_desc->AddOutputDesc(GeTensorDesc(GeShape(), format, output_data_type)),
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr,
"create cast op:add output desc fail.");

return op_desc;
@@ -2000,13 +2323,25 @@ OpDescPtr ParserGraphOptimizer::CreateTransDataOp(enum ge::Format input_format)
output_format = FORMAT_NCHW;
}

GE_CHK_BOOL_EXEC(AttrUtils::SetInt(op_desc, ge::ATTR_NAME_INPUT_FORMAT, (int64_t)input_format), return nullptr,
GE_CHK_BOOL_EXEC(AttrUtils::SetInt(op_desc, ge::ATTR_NAME_INPUT_FORMAT, (int64_t)input_format),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_INPUT_FORMAT.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr,
"SetInt of ATTR_NAME_INPUT_FORMAT failed.");
GE_CHK_BOOL_EXEC(AttrUtils::SetInt(op_desc, ge::ATTR_NAME_OUTPUT_FORMAT, (int64_t)output_format), return nullptr,
GE_CHK_BOOL_EXEC(AttrUtils::SetInt(op_desc, ge::ATTR_NAME_OUTPUT_FORMAT, (int64_t)output_format),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_OUTPUT_FORMAT.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr,
"SetInt of ATTR_NAME_OUTPUT_FORMAT failed.");
GE_CHK_BOOL_EXEC(SUCCESS == op_desc->AddInputDesc(GeTensorDesc(GeShape(), input_format)), return nullptr,
GE_CHK_BOOL_EXEC(SUCCESS == op_desc->AddInputDesc(GeTensorDesc(GeShape(), input_format)),
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr,
"create transdata op:add input desc fail.");
GE_CHK_BOOL_EXEC(SUCCESS == op_desc->AddOutputDesc(GeTensorDesc(GeShape(), output_format)), return nullptr,
GE_CHK_BOOL_EXEC(SUCCESS == op_desc->AddOutputDesc(GeTensorDesc(GeShape(), output_format)),
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr,
"create transdata op:add output desc fail.");

return op_desc;


+ 1
- 0
parser/tensorflow/iterator_fusion_pass.cc View File

@@ -29,6 +29,7 @@ Status IteratorFusionPass::Run(ge::ComputeGraphPtr graph) {
domi::FrameworkType fmk_type = static_cast<domi::FrameworkType>(fmk_type_);
std::unique_ptr<ParserGraphOptimizer> graph_optimizer(new (std::nothrow) ParserGraphOptimizer(graph, fmk_type));
if (graph_optimizer == nullptr) {
REPORT_CALL_ERROR("E19999", "New ParserGraphOptimizer failed");
return FAILED;
}



+ 2
- 0
parser/tensorflow/scope/scope_pass_manager.cc View File

@@ -27,6 +27,7 @@ shared_ptr<ScopeGraph> ScopePassManager::BuildScopeGraph(domi::tensorflow::Graph
GE_CHK_BOOL_EXEC(graph_def != nullptr, return nullptr, "graph_def is nullptr");
scope_graph_ = ge::parser::MakeShared<ScopeGraph>();
if (scope_graph_ == nullptr) {
REPORT_CALL_ERROR("E19999", "New ScopeGraph failed");
GELOGE(FAILED, "Scope graph make shared failed.");
return nullptr;
}
@@ -59,6 +60,7 @@ Status ScopePassManager::Run(shared_ptr<ScopeGraph> &graph) {
auto &impl = pass->impl_;
if (impl == nullptr) {
GELOGE(ge::MEMALLOC_FAILED, "ScopeBasePass is not properly initialized.");
REPORT_INNER_ERROR("E19999", "ScopeBasePass is not properly initialized");
continue;
}



+ 7
- 0
parser/tensorflow/tensorflow_auto_mapping_parser_adapter.cc View File

@@ -38,12 +38,14 @@ const char *const kShapeAttrDtype = "dtype";

Status TensorFlowAutoMappingParserAdapter::ParseParams(const Message *op_src, ge::OpDescPtr &op_dest) {
if (op_src == nullptr) {
REPORT_INNER_ERROR("E19999", "Param op_src is nullptr, check invalid");
GELOGE(PARAM_INVALID, "Op src is null");
return PARAM_INVALID;
}
const NodeDef *node = reinterpret_cast<const NodeDef *>(op_src);
GELOGD("TF op node name = %s, op type= %s, parse params", node->name().c_str(), node->op().c_str());
if (op_dest == nullptr) {
REPORT_INNER_ERROR("E19999", "Param op_dest is nullptr, check invalid");
GELOGE(FAILED, "Op dest is null");
return PARAM_INVALID;
}
@@ -51,6 +53,7 @@ Status TensorFlowAutoMappingParserAdapter::ParseParams(const Message *op_src, ge
ge::Operator op = ge::OpDescUtils::CreateOperatorFromOpDesc(op_dest);
Status ret = domi::AutoMappingFn(op_src, op);
if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "call auto mapping failed for node:%s", op.GetName().c_str());
GELOGE(FAILED, "Tensorflow auto mapping parser params failed");
return FAILED;
}
@@ -86,6 +89,8 @@ Status TensorFlowAutoMappingParserAdapter::ParseParams(const Message *op_src, ge
ge::DataType out_type = DT_INT32;
if (AttrUtils::GetDataType(op_dest, kShapeAttrOutType, out_type)) {
if (!AttrUtils::SetInt(op_dest, kShapeAttrDtype, static_cast<int64_t>(out_type))) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", kShapeAttrDtype,
op_dest->GetName().c_str(), op_dest->GetType().c_str());
GELOGE(FAILED, "Set attr dtype for op:%s failed.", op_dest->GetName().c_str());
return FAILED;
}
@@ -104,6 +109,8 @@ Status TensorFlowAutoMappingParserAdapter::ParseParams(const Message *op_src, ge
// Serialize nodedef into string and package as a whole
string serialized_node;
GE_IF_BOOL_EXEC(!pkg_node->SerializeToString(&serialized_node),
REPORT_CALL_ERROR("E19999", "Trans NodeDef:%s(%s) to string failed",
pkg_node->name().c_str(), pkg_node->op().c_str());
GELOGE(PARAM_INVALID, "In FrameworkOp trans NodeDef to string failed.");
return PARAM_INVALID);



+ 5
- 1
parser/tensorflow/tensorflow_constant_parser.cc View File

@@ -68,7 +68,11 @@ Status TensorFlowConstantParser::ParseValue(const domi::tensorflow::NodeDef *nod
const domi::tensorflow::TensorProto &tensor = attr_value.tensor();

GeTensorPtr weight = ge::parser::MakeShared<ge::GeTensor>();
GE_CHECK_NOTNULL(weight);
if (weight == nullptr) {
REPORT_CALL_ERROR("E19999", "New GeTensor failed when parse node:%s", node->name().c_str());
GELOGE(FAILED, "Create GeTensor fail when parse node:%s", node->name().c_str());
return FAILED;
}
int64_t dataType = 0;
GE_CHK_BOOL_RET_STATUS(ge::AttrUtils::GetInt(opDesc, TENSORFLOW_ATTR_DTYPE, dataType), INTERNAL_ERROR,
"get dtype fail");


+ 15
- 5
parser/tensorflow/tensorflow_custom_parser_adapter.cc View File

@@ -32,9 +32,14 @@ Status TensorFlowCustomParserAdapter::ParseParams(const Message *op_src, ge::OpD
GE_CHECK_NOTNULL(op_dest);

ParseParamFunc custom_op_parser = domi::OpRegistry::Instance()->GetParseParamFunc(op_dest->GetType(), node_src->op());
GE_CHECK_NOTNULL(custom_op_parser);
if (custom_op_parser == nullptr) {
REPORT_CALL_ERROR("E19999", "No ParseParamFunc of node:%s exist in OpRegistry", node_src->name().c_str());
GELOGE(FAILED, "No ParseParamFunc of node:%s exist in OpRegistry", node_src->name().c_str());
return FAILED;
}
ge::Operator op = ge::OpDescUtils::CreateOperatorFromOpDesc(op_dest);
GE_CHK_BOOL_RET_STATUS(custom_op_parser(op_src, op) == SUCCESS, FAILED, "Custom parser params failed");
GE_CHK_BOOL_RET_STATUS(custom_op_parser(op_src, op) == SUCCESS, FAILED, "Custom parser params failed for node:%s",
node_src->name().c_str());

op.BreakConnect();

@@ -47,10 +52,15 @@ Status TensorFlowCustomParserAdapter::ParseParams(const Operator &op_src, ge::Op
GE_CHECK_NOTNULL(op_dest);

ParseParamByOpFunc custom_op_parser = domi::OpRegistry::Instance()->GetParseParamByOperatorFunc(op_src.GetOpType());
GE_CHECK_NOTNULL(custom_op_parser);
ge::Operator op = ge::OpDescUtils::CreateOperatorFromOpDesc(op_dest);
GE_CHK_BOOL_RET_STATUS(custom_op_parser(op_src, op) == SUCCESS, FAILED, "Custom parser params failed");
if (custom_op_parser == nullptr) {
REPORT_CALL_ERROR("E19999", "No ParseParamByOperatorFunc of node:%s exist in OpRegistry", op_src.GetName().c_str());
GELOGE(FAILED, "No ParseParamByOperatorFunc of node:%s exist in OpRegistry", op_src.GetName().c_str());
return FAILED;
}

ge::Operator op = ge::OpDescUtils::CreateOperatorFromOpDesc(op_dest);
GE_CHK_BOOL_RET_STATUS(custom_op_parser(op_src, op) == SUCCESS, FAILED, "Custom parser params failed or node:%s",
op_src.GetName().c_str());
op_src.BreakConnect();

return SUCCESS;


+ 6
- 2
parser/tensorflow/tensorflow_data_parser.cc View File

@@ -69,6 +69,9 @@ Status TensorFlowDataParser::ParseInputFromModel(const Message *op_src, ge::OpDe
domi::tensorflow::DataType tf_type = attr_value.type();
ge::DataType type = domi::TensorAssign::ConvertTensorflowDataType(tf_type);
CHECK_FALSE_EXEC(type != ge::DataType::DT_UNDEFINED,
REPORT_CALL_ERROR("E19999", "Data type %s of node %s is not supported",
DataType_Name(tf_type).c_str(),
node->name().c_str());
GELOGE(domi::PARAM_INVALID,
"Data type %s of node %s is not supported.",
DataType_Name(tf_type).c_str(),
@@ -76,7 +79,8 @@ Status TensorFlowDataParser::ParseInputFromModel(const Message *op_src, ge::OpDe
return domi::PARAM_INVALID);

GE_CHK_BOOL_RET_STATUS(ge::AttrUtils::SetInt(op_def, DATA_ATTR_NAME_DATA_TYPE, static_cast<int64_t>(type)), FAILED,
"SetInt failed");
"SetAttr:%s to node:%s(%s) failed", DATA_ATTR_NAME_DATA_TYPE.c_str(),
op_def->GetName().c_str(), op_def->GetType().c_str());
}

if (!TensorFlowUtil::FindAttrValue(node, TENSORFLOW_ATTR_SHAPE, attr_value)) {
@@ -139,7 +143,7 @@ Status TensorFlowDataParser::CheckInputShape(const std::string &name) {
// dim i = 0, means empty tensor.
// dim i = -1 or -2, means unknown shape.
GE_CHK_BOOL_RET_STATUS(user_input_dims_v[i] >= kValidShapeMinValue, domi::PARAM_INVALID,
"parse data node %s: shape contains placeholder ,but not designated by user", name.c_str());
"parse data node %s: shape contains placeholder, but not designated by user", name.c_str());
}
return SUCCESS;
}


+ 8
- 0
parser/tensorflow/tensorflow_enter_parser.cc View File

@@ -34,24 +34,32 @@ Status TensorFlowEnterParser::ParseParams(const Message *op_src, ge::OpDescPtr &
const NodeDef *node = reinterpret_cast<const NodeDef *>(op_src);
domi::tensorflow::AttrValue str_attr;
if (!TensorFlowUtil::FindAttrValue(node, ENTER_ATTR_FRAME_NAME, str_attr)) {
REPORT_CALL_ERROR("E19999", "In NodeDef:%s attr:%s not exist, check invalid",
name.c_str(), ENTER_ATTR_FRAME_NAME.c_str());
GELOGE(FAILED, "In NodeDef %s attr [%s] not exist.", name.c_str(), ENTER_ATTR_FRAME_NAME.c_str());
return FAILED;
}
std::string frame_name = str_attr.s();
GELOGI("Enter node: %s, attr frame_name: %s", name.c_str(), frame_name.c_str());
if (!ge::AttrUtils::SetStr(op_desc, ENTER_ATTR_FRAME_NAME, frame_name)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ENTER_ATTR_FRAME_NAME.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Set attr ENTER_ATTR_FRAME_NAME fail, node: %s", name.c_str());
return FAILED;
}

domi::tensorflow::AttrValue bool_attr;
if (!TensorFlowUtil::FindAttrValue(node, ENTER_ATTR_CONSTANT_FLAG, bool_attr)) {
REPORT_CALL_ERROR("E19999", "In NodeDef:%s attr:%s not exist, check invalid",
name.c_str(), ENTER_ATTR_CONSTANT_FLAG.c_str());
GELOGE(FAILED, "In NodeDef %s attr [%s] not exist.", name.c_str(), ENTER_ATTR_CONSTANT_FLAG.c_str());
return FAILED;
}
bool is_constant = bool_attr.b();
GELOGI("Enter node: %s, attr is_constant: %s", name.c_str(), is_constant ? "true" : "false");
if (!ge::AttrUtils::SetBool(op_desc, ENTER_ATTR_CONSTANT_FLAG, is_constant)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ENTER_ATTR_CONSTANT_FLAG.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Set attr ENTER_ATTR_CONSTANT_FLAG fail, node: %s", name.c_str());
return FAILED;
}


+ 3
- 0
parser/tensorflow/tensorflow_fill_parser.cc View File

@@ -48,6 +48,9 @@ domi::Status ParseParams(const NodeDef *node, FillOperator *op) {
ge::DataType type = domi::TensorAssign::ConvertTensorflowDataType(data_type);
CHECK_FALSE_EXEC(
type != ge::DataType::DT_UNDEFINED,
REPORT_CALL_ERROR("E19999", "Data type %s of node %s is not supported",
DataType_Name(data_type).c_str(),
node->name().c_str());
GELOGE(PARAM_INVALID, "Data type %s of node %s is not supported.", DataType_Name(data_type).c_str(),
node->name().c_str());
return PARAM_INVALID);


+ 4
- 0
parser/tensorflow/tensorflow_frameworkop_parser.cc View File

@@ -76,6 +76,8 @@ Status ParseParams(const Message *op_src, FrameworkOpOperator *op) {
} else {
GE_CHK_BOOL_EXEC(type == "_Retval",
GE_DELETE_NEW_SINGLE(pkg_node);
REPORT_INNER_ERROR("E19999", "In NodeDef:%s Attr:opdef is not exist, check invalid",
pkg_node->name().c_str());
return PARAM_INVALID, "In NodeDef %s Attr opdef is not exist.", pkg_node->name().c_str());
}

@@ -97,6 +99,8 @@ Status ParseParams(const Message *op_src, FrameworkOpOperator *op) {
// Serialize nodedef into string and package as a whole
string serialized_node;
GE_IF_BOOL_EXEC(!pkg_node->SerializeToString(&serialized_node),
REPORT_CALL_ERROR("E19999", "Trans NodeDef:%s(%s) to string failed",
pkg_node->name().c_str(), pkg_node->op().c_str());
GELOGE(PARAM_INVALID, "In FrameworkOp trans NodeDef to string failed.");
GE_DELETE_NEW_SINGLE(pkg_node); return PARAM_INVALID);



+ 20
- 4
parser/tensorflow/tensorflow_fusion_custom_parser_adapter.cc View File

@@ -40,10 +40,18 @@ Status TensorFlowFusionCustomParserAdapter::ParseParams(const vector<const NodeD
(void)ge::AttrUtils::GetStr(node->GetOpDesc(), ge::ATTR_NAME_FUSIONOP_ORIGINAL_TYPE, ori_type);
FusionParseParamFunc
custom_op_parser = domi::OpRegistry::Instance()->GetFusionParseParamFunc(op_dest->GetType(), ori_type);
GE_CHECK_NOTNULL(custom_op_parser);
if (custom_op_parser == nullptr) {
REPORT_CALL_ERROR("E19999", "No FusionParseParamFunc of node:%s(%s) exist in OpRegistry",
node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "No FusionParseParamFunc of node:%s(%s) exist in OpRegistry",
node->GetName().c_str(), node->GetType().c_str());
return FAILED;
}
GELOGI("Get fusion parser succ, node: %s.", node->GetName().c_str());
ge::Operator op = ge::OpDescUtils::CreateOperatorFromOpDesc(op_dest);
GE_CHK_BOOL_RET_STATUS(custom_op_parser(inside_nodes, op) == SUCCESS, FAILED, "Custom parser params failed");
GE_CHK_BOOL_RET_STATUS(custom_op_parser(inside_nodes, op) == SUCCESS, FAILED,
"Custom parse params failed for node:%s(%s)",
node->GetName().c_str(), node->GetType().c_str());

op.BreakConnect();
GELOGI("Run fusion parser succ, node: %s.", node->GetName().c_str());
@@ -61,9 +69,17 @@ Status TensorFlowFusionCustomParserAdapter::ParseParams(const std::vector<ge::Op
(void)ge::AttrUtils::GetStr(node->GetOpDesc(), ge::ATTR_NAME_FUSIONOP_ORIGINAL_TYPE, ori_type);
FusionParseParamByOpFunc
custom_op_parser = domi::OpRegistry::Instance()->GetFusionParseParamByOpFunc(op_dest->GetType(), ori_type);
GE_CHECK_NOTNULL(custom_op_parser);
if (custom_op_parser == nullptr) {
REPORT_CALL_ERROR("E19999", "No FusionParseParamByOpFunc of node:%s(%s) exist in OpRegistry",
node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "No FusionParseParamByOpFunc of node:%s(%s) exist in OpRegistry",
node->GetName().c_str(), node->GetType().c_str());
return FAILED;
}
ge::Operator op = ge::OpDescUtils::CreateOperatorFromOpDesc(op_dest);
GE_CHK_BOOL_RET_STATUS(custom_op_parser(v_input_const, op) == SUCCESS, FAILED, "Custom parser params failed");
GE_CHK_BOOL_RET_STATUS(custom_op_parser(v_input_const, op) == SUCCESS, FAILED,
"Custom parser params failedfor node:%s(%s)",
node->GetName().c_str(), node->GetType().c_str());

for (const auto &op_src : v_input_const) {
op_src.BreakConnect();


+ 35
- 22
parser/tensorflow/tensorflow_fusion_op_parser.cc View File

@@ -27,27 +27,31 @@ using domi::tensorflow::DataType;
using domi::tensorflow::NodeDef;

namespace ge {
#define GET_CONST_VALUE(tensor, param, index, FIELD) \
do { \
google::protobuf::RepeatedField<FIELD> val_vec; \
int32_t val_size = 0; \
val_vec = tensor.FIELD##_val(); \
val_size = val_vec.size(); \
if (index < val_size) { \
param = val_vec.Get(index); \
} else if (tensor.has_tensor_shape()) { \
const std::string tensor_content = tensor.tensor_content(); \
char *buf = const_cast<char *>(tensor_content.data()); \
FIELD *buf_v = reinterpret_cast<FIELD *>(buf); \
if (static_cast<uint32_t>(index) >= tensor_content.length() / sizeof(FIELD)) { \
GELOGE(domi::PARAM_INVALID, "Const data size is smaller than index :%d,not supported!", index); \
return domi::PARAM_INVALID; \
} \
param = buf_v[index]; \
} else { \
GELOGE(domi::PARAM_INVALID, "Const data size is smaller than index :%d,not supported!", index); \
return domi::PARAM_INVALID; \
} \
#define GET_CONST_VALUE(tensor, param, index, FIELD) \
do { \
google::protobuf::RepeatedField<FIELD> val_vec; \
int32_t val_size = 0; \
val_vec = tensor.FIELD##_val(); \
val_size = val_vec.size(); \
if (index < val_size) { \
param = val_vec.Get(index); \
} else if (tensor.has_tensor_shape()) { \
const std::string tensor_content = tensor.tensor_content(); \
char *buf = const_cast<char *>(tensor_content.data()); \
FIELD *buf_v = reinterpret_cast<FIELD *>(buf); \
if (static_cast<uint32_t>(index) >= tensor_content.length() / sizeof(FIELD)) { \
REPORT_INNER_ERROR("E19999", "Const data size of node:%s is smaller than index:%d, not supported!", \
node_def->name().c_str(), index); \
GELOGE(domi::PARAM_INVALID, "Const data size is smaller than index :%d,not supported!", index); \
return domi::PARAM_INVALID; \
} \
param = buf_v[index]; \
} else { \
REPORT_INNER_ERROR("E19999", "Const data size of node:%s is smaller than index:%d, not supported!", \
node_def->name().c_str(), index); \
GELOGE(domi::PARAM_INVALID, "Const data size is smaller than index :%d,not supported!", index); \
return domi::PARAM_INVALID; \
} \
} while (false)

Status TensorFlowFusionOpParser::GetTensorFromNode(const NodeDef *node_def, TensorProto &tensor) {
@@ -59,6 +63,8 @@ Status TensorFlowFusionOpParser::GetTensorFromNode(const NodeDef *node_def, Tens
domi::tensorflow::AttrValue attr_value;
// Check that the attribute value must exist and get the value.
if (!TensorFlowUtil::FindAttrValue(node_def, TENSORFLOW_ATTR_VALUE, attr_value)) {
REPORT_CALL_ERROR("E19999", "In NodeDef:%s attr:%s not exist, check invalid",
node_def->name().c_str(), TENSORFLOW_ATTR_VALUE.c_str());
GELOGE(domi::PARAM_INVALID, "NodeDef %s Attr %s is not exist.", node_name.c_str(), TENSORFLOW_ATTR_VALUE.c_str());
return domi::PARAM_INVALID;
}
@@ -116,10 +122,13 @@ Status TensorFlowFusionOpParser::ParseHalfFromConst(const NodeDef *node_def, flo
ge::parser::fp16_t fp16_value = static_cast<parser::fp16_t>(val_vec.Get(index));
param = fp16_value.ToFloat();
} else {
REPORT_INNER_ERROR("E19999", "Const data size of node:%s is smaller than index:%d, not supported!",
node_def->name().c_str(), index);
GELOGE(domi::PARAM_INVALID, "Const data size is smaller than index:%d, not supported.", index);
return domi::PARAM_INVALID;
}
} else {
REPORT_INNER_ERROR("E19999", "Node %s does not have half value, index:%d.", node_def->name().c_str(), index);
GELOGE(domi::PARAM_INVALID, "Node %s does not have half value, index:%d.", node_def->name().c_str(), index);
return domi::PARAM_INVALID;
}
@@ -131,7 +140,11 @@ Status TensorFlowFusionOpParser::ParseWeightFromConst(const NodeDef *node_def, g
TensorProto tensor;
GE_CHK_STATUS_RET(GetTensorFromNode(node_def, tensor), "get tensor failed.");
weight = ge::parser::MakeShared<ge::GeTensor>();
GE_CHECK_NOTNULL(weight);
if (weight == nullptr) {
REPORT_CALL_ERROR("E19999", "New GeTensor failed for node:%s", node_def->name().c_str());
GELOGE(domi::PARAM_INVALID, "New GeTensor failed for node:%s", node_def->name().c_str());
return domi::PARAM_INVALID;
}
domi::tensorflow::DataType data_type = tensor.dtype();
GE_CHK_STATUS_RET(
domi::TensorAssign::SetGeTensorDataType(domi::TensorAssign::ConvertTensorflowDataType(data_type), weight),


+ 2
- 0
parser/tensorflow/tensorflow_merge_parser.cc View File

@@ -40,6 +40,8 @@ Status TensorFlowMergeParser::ParseParams(const Message *op_src, ge::OpDescPtr &
// add dynamic input
graphStatus ret = op_desc->AddDynamicInputDesc("x", input_tensor_num);
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add Dynamic InputDesc name:x to node:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Add dynamic input:x for node:%s failed.", op_desc->GetName().c_str());
return FAILED;
}


+ 26
- 4
parser/tensorflow/tensorflow_parser.cc View File

@@ -104,11 +104,19 @@ graphStatus aclgrphParseTensorFlow(const char *model_file, ge::Graph &graph) {

// Create an empty computegraph
ge::ComputeGraphPtr compute_graph = ge::parser::MakeShared<ge::ComputeGraph>("tmpGraph");
GE_CHECK_NOTNULL(compute_graph);
if (compute_graph == nullptr) {
REPORT_CALL_ERROR("E19999", "New ComputeGraph failed");
GELOGE(FAILED, "Create ComputeGraph fail.");
return FAILED;
}

graph = ge::GraphUtils::CreateGraphFromComputeGraph(compute_graph);
auto model_parser = domi::ModelParserFactory::Instance()->CreateModelParser(domi::TENSORFLOW);
GE_CHECK_NOTNULL(model_parser);
if (model_parser == nullptr) {
REPORT_CALL_ERROR("E19999", "No Model Parser for tensorflow, check invalid");
GELOGE(GRAPH_FAILED, "No Model Parser for tensorflow, check invalid");
return FAILED;
}

// parse tensorflow model_file to GE graph
ge::graphStatus ret = model_parser->Parse(model_file, graph);
@@ -150,11 +158,19 @@ graphStatus aclgrphParseTensorFlow(const char *model_file, const std::map<Ascend
// Create an empty computegraph
string graph_name = output_name.empty() ? "tmpGraph" : output_name;
ge::ComputeGraphPtr compute_graph = ge::parser::MakeShared<ge::ComputeGraph>(graph_name);
GE_CHECK_NOTNULL(compute_graph);
if (compute_graph == nullptr) {
REPORT_CALL_ERROR("E19999", "New ComputeGraph failed");
GELOGE(FAILED, "Create ComputeGraph fail.");
return FAILED;
}

graph = ge::GraphUtils::CreateGraphFromComputeGraph(compute_graph);
auto model_parser = domi::ModelParserFactory::Instance()->CreateModelParser(domi::TENSORFLOW);
GE_CHECK_NOTNULL(model_parser);
if (model_parser == nullptr) {
REPORT_CALL_ERROR("E19999", "No Model Parser for tensorflow, check invalid");
GELOGE(GRAPH_FAILED, "No Model Parser for tensorflow, check invalid");
return FAILED;
}

// parse tensorflow model_file to GE graph
ge::graphStatus ret = model_parser->Parse(model_file, graph);
@@ -218,11 +234,14 @@ Status GenSubgraphParseTasks(const ge::ComputeGraphPtr &parent_graph, std::deque
auto unique_name = node->GetName() + std::to_string(i) + subgraph_iname;
auto subgraph = ge::parser::MakeShared<ge::ComputeGraph>(unique_name);
if (subgraph == nullptr) {
REPORT_CALL_ERROR("E19999", "New ComputeGraph failed when create subgraph:%s", subgraph_iname.c_str());
GELOGE(OUT_OF_MEMORY, "Failed to alloc subgraph %s", subgraph_iname.c_str());
return OUT_OF_MEMORY;
}
auto ret = ge::NodeUtils::SetSubgraph(*node, i, subgraph);
if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set subgraph:%s to node:%s(%s) failed, index:%s",
subgraph_iname.c_str(), node->GetName().c_str(), node->GetType().c_str(), i);
GELOGE(ret, "Failed to set subgraph %s to node %s index %u", subgraph_iname.c_str(), node->GetName().c_str(),
i);
return ret;
@@ -273,6 +292,9 @@ Status PostOpProcessForSubgraph(const ParseArg &arg) {
ret = parse_func_v2(arg.subgraph_name.c_str(), graph);
}
if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Call ParseSubgraphPostFunc:%s failed, subgraph:%s, node:%s(%s), ret:0x%X",
arg.function_name.c_str(), arg.subgraph_name.c_str(),
arg.parent_node->GetName().c_str(), arg.parent_node->GetType().c_str(), ret);
GELOGE(FAILED, "Failed to post-process subgraph %s on node %s type %s subgraph name %s", arg.function_name.c_str(),
arg.parent_node->GetName().c_str(), arg.parent_node->GetType().c_str(), arg.subgraph_name.c_str());
return FAILED;


+ 6
- 2
parser/tensorflow/tensorflow_ref_switch_parser.cc View File

@@ -42,8 +42,12 @@ Status TensorFlowRefSwitchParser::ParseT(const domi::tensorflow::NodeDef *node,

domi::tensorflow::DataType tfType = attr.type();
ge::DataType type = domi::TensorAssign::ConvertTensorflowDataType(tfType);
CHECK_FALSE_EXEC(type != ge::DataType::DT_UNDEFINED, GELOGE(FAILED, "Data type %s of node %s is not supported.",
DataType_Name(tfType).c_str(), node->name().c_str());
CHECK_FALSE_EXEC(type != ge::DataType::DT_UNDEFINED,
REPORT_CALL_ERROR("E19999", "Data type %s of node %s is not supported",
DataType_Name(tfType).c_str(),
node->name().c_str());
GELOGE(FAILED, "Data type %s of node %s is not supported.",
DataType_Name(tfType).c_str(), node->name().c_str());
return PARAM_INVALID);

op->T(type);


+ 5
- 2
parser/tensorflow/tensorflow_reshape_parser.cc View File

@@ -38,8 +38,11 @@ Status TensorFlowReshapeParser::ParseDesc(const domi::tensorflow::AttrValue &att

auto data_type = ge_desc.GetDataType();
bool type_ret = ge::TypeUtils::GetDataTypeLength(data_type, size_type);
GE_IF_BOOL_EXEC(!type_ret, GELOGE(FAILED, "Can't GetDataTypeLength of data_type: %s",
ge::TypeUtils::DataTypeToSerialString(data_type).c_str());
GE_IF_BOOL_EXEC(!type_ret,
REPORT_CALL_ERROR("E19999", "Data type %s is not supported",
ge::TypeUtils::DataTypeToSerialString(data_type).c_str());
GELOGE(FAILED, "Can't GetDataTypeLength of data_type: %s",
ge::TypeUtils::DataTypeToSerialString(data_type).c_str());
return PARAM_INVALID);
// calculate size
for (uint32_t j = 0; j < ge_desc.GetShape().GetDimNum(); ++j) {


+ 16
- 4
parser/tensorflow/tensorflow_shape_n_parser.cc View File

@@ -44,8 +44,11 @@ Status TensorFlowShapeNParser::ParseInType(const domi::tensorflow::NodeDef *node

domi::tensorflow::DataType tf_type = attr.type();
ge::DataType type = domi::TensorAssign::ConvertTensorflowDataType(tf_type);
CHECK_FALSE_EXEC(type != ge::DataType::DT_UNDEFINED, GELOGE(FAILED, "Data type %s of node %s is not supported.",
DataType_Name(tf_type).c_str(), node->name().c_str());
CHECK_FALSE_EXEC(type != ge::DataType::DT_UNDEFINED,
REPORT_CALL_ERROR("E19999", "Data type %s of node %s is not supported",
DataType_Name(tf_type).c_str(), node->name().c_str());
GELOGE(FAILED, "Data type %s of node %s is not supported.",
DataType_Name(tf_type).c_str(), node->name().c_str());
return PARAM_INVALID);

op->InType(type);
@@ -64,8 +67,11 @@ Status TensorFlowShapeNParser::ParseOutType(const domi::tensorflow::NodeDef *nod

domi::tensorflow::DataType tf_type = attr.type();
ge::DataType type = domi::TensorAssign::ConvertTensorflowDataType(tf_type);
CHECK_FALSE_EXEC(type != ge::DataType::DT_UNDEFINED, GELOGE(FAILED, "Data type %s of node %s is not supported.",
DataType_Name(tf_type).c_str(), node->name().c_str());
CHECK_FALSE_EXEC(type != ge::DataType::DT_UNDEFINED,
REPORT_CALL_ERROR("E19999", "Data type %s of node %s is not supported",
DataType_Name(tf_type).c_str(), node->name().c_str());
GELOGE(FAILED, "Data type %s of node %s is not supported.",
DataType_Name(tf_type).c_str(), node->name().c_str());
return PARAM_INVALID);

op->OutType(type);
@@ -106,6 +112,8 @@ Status TensorFlowShapeNParser::ParseParams(const Message *op_src, ge::OpDescPtr
// add dynamic input/output
domi::tensorflow::AttrValue attr_num;
CHECK_FALSE_EXEC(TensorFlowUtil::FindAttrValue(node, SHAPEN_ATTR_N, attr_num),
REPORT_CALL_ERROR("E19999", "In NodeDef:%s attr:%s not exist, check invalid",
node->name().c_str(), SHAPEN_ATTR_N.c_str());
GELOGE(FAILED, "Get Attr N failed in Node %s.", node->name().c_str());
return PARAM_INVALID);
int32_t dynamic_tensor_num = attr_num.i();
@@ -127,12 +135,16 @@ Status TensorFlowShapeNParser::ParseParams(const Message *op_src, ge::OpDescPtr
}
graphStatus status = op_dest->AddDynamicOutputDesc("y", dynamic_tensor_num);
if (status != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add Dynamic OuputDesc name:y to node:%s(%s) failed",
op_dest->GetName().c_str(), op_dest->GetType().c_str());
GELOGE(FAILED, "Add dynamic output:y for node:%s failed.", op_dest->GetName().c_str());
return FAILED;
}
}
graphStatus status = op_dest->AddDynamicInputDesc("x", dynamic_tensor_num);
if (status != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add Dynamic InputDesc name:x to node:%s(%s) failed",
op_dest->GetName().c_str(), op_dest->GetType().c_str());
GELOGE(FAILED, "Add dynamic input:x for node:%s failed.", op_dest->GetName().c_str());
return FAILED;
}


+ 12
- 1
parser/tensorflow/tensorflow_squeeze_parser.cc View File

@@ -42,8 +42,11 @@ Status TensorFlowSqueezeParser::ParseDesc(const domi::tensorflow::AttrValue &att

auto data_type = ge_desc.GetDataType();
bool type_ret = ge::TypeUtils::GetDataTypeLength(data_type, size_type);
GE_IF_BOOL_EXEC(!type_ret, GELOGE(domi::PARAM_INVALID, "Can't GetDataTypeLength of data_type: %s",
GE_IF_BOOL_EXEC(!type_ret,
REPORT_CALL_ERROR("E19999", "Data type %s is not supported",
ge::TypeUtils::DataTypeToSerialString(data_type).c_str());
GELOGE(domi::PARAM_INVALID, "Can't GetDataTypeLength of data_type: %s",
ge::TypeUtils::DataTypeToSerialString(data_type).c_str());
return domi::PARAM_INVALID);
// calculate size
for (uint32_t j = 0; j < ge_desc.GetShape().GetDimNum(); ++j) {
@@ -83,6 +86,8 @@ Status TensorFlowSqueezeParser::ParseParams(const Message *op_src, ge::OpDescPtr
return SUCCESS;
}
if (has_axis && has_dims) {
REPORT_CALL_ERROR("E19999", "In NodeDef %s, Attr %s or %s not exist, check invalid", node->name().c_str(),
SQUEEZE_ATTR_AXIS.c_str(), SQUEEZE_ATTR_DIMS.c_str());
GELOGE(FAILED, "In NodeDef %s dim and axis is error.", node->name().c_str());
return domi::PARAM_INVALID;
}
@@ -101,6 +106,8 @@ Status TensorFlowSqueezeParser::ParseParams(const Message *op_src, ge::OpDescPtr
v_result.push_back(result);
}
if (!ge::AttrUtils::SetListInt(op, SQUEEZE_ATTR_AXIS, v_result)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", SQUEEZE_ATTR_AXIS.c_str(),
op->GetName().c_str(), op->GetType().c_str());
GELOGE(FAILED, "Set squeeze axis attr failed");
return FAILED;
}
@@ -121,9 +128,13 @@ Status TensorFlowSqueezeParser::ParseParams(const Message *op_src, ge::OpDescPtr
}

if (!ge::AttrUtils::SetTensorDesc(op, RESHAPE_ATTR_NAME_INPUT_DESC, input_desc)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", RESHAPE_ATTR_NAME_INPUT_DESC.c_str(),
op->GetName().c_str(), op->GetType().c_str());
GELOGE(FAILED, "Set input desc failed");
return FAILED;
} if (!ge::AttrUtils::SetTensorDesc(op, RESHAPE_ATTR_NAME_OUTPUT_DESC, output_desc)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", RESHAPE_ATTR_NAME_OUTPUT_DESC.c_str(),
op->GetName().c_str(), op->GetType().c_str());
GELOGE(FAILED, "Set output desc failed");
return FAILED;
})


+ 17
- 2
parser/tensorflow/tensorflow_variable_v2_parser.cc View File

@@ -87,6 +87,8 @@ static Status ParseSrcType(const domi::tensorflow::NodeDef *node, VariableOperat
// The upper caller guarantees input params is not empty.
domi::tensorflow::AttrValue attr;
CHECK_FALSE_EXEC(TensorFlowUtil::FindAttrValue(node, VAR_ATTR_DTYPE, attr),
REPORT_CALL_ERROR("E19999", "In NodeDef:%s attr:%s not exist, check invalid",
node->name().c_str(), VAR_ATTR_DTYPE.c_str());
GELOGE(FAILED, "Attr %s does not exist in NodeDef %s.",
VAR_ATTR_DTYPE.c_str(), node->name().c_str());
return PARAM_INVALID);
@@ -97,8 +99,11 @@ static Status ParseSrcType(const domi::tensorflow::NodeDef *node, VariableOperat
domi::tensorflow::DataType tf_type = attr.type();
ge::DataType type = domi::TensorAssign::ConvertTensorflowDataType(tf_type);

CHECK_FALSE_EXEC(type != ge::DataType::DT_UNDEFINED, GELOGE(FAILED, "Data type %s of node %s is not supported.",
DataType_Name(tf_type).c_str(), node->name().c_str());
CHECK_FALSE_EXEC(type != ge::DataType::DT_UNDEFINED,
REPORT_CALL_ERROR("E19999", "Data type %s of node %s is not supported",
DataType_Name(tf_type).c_str(), node->name().c_str());
GELOGE(FAILED, "Data type %s of node %s is not supported.",
DataType_Name(tf_type).c_str(), node->name().c_str());
return PARAM_INVALID);

op->SrcType(type);
@@ -109,6 +114,8 @@ Status ParseContainer(const domi::tensorflow::NodeDef *node, VariableOperator *o
// The upper caller guarantees input params is not empty.
domi::tensorflow::AttrValue attr;
CHECK_FALSE_EXEC(TensorFlowUtil::FindAttrValue(node, VAR_ATTR_CONTAINER, attr),
REPORT_CALL_ERROR("E19999", "In NodeDef:%s attr:%s not exist, check invalid",
node->name().c_str(), VAR_ATTR_CONTAINER.c_str());
GELOGE(FAILED, "Attr %s does not exist in NodeDef %s.",
VAR_ATTR_CONTAINER.c_str(), node->name().c_str());
return PARAM_INVALID);
@@ -126,6 +133,8 @@ Status ParseSharedName(const domi::tensorflow::NodeDef *node, VariableOperator *
domi::tensorflow::AttrValue attr;
CHECK_FALSE_EXEC(
TensorFlowUtil::FindAttrValue(node, VAR_ATTR_SHARED_NAME, attr),
REPORT_CALL_ERROR("E19999", "In NodeDef:%s attr:%s not exist, check invalid",
node->name().c_str(), VAR_ATTR_SHARED_NAME.c_str());
GELOGE(FAILED, "Attr %s does not exist in NodeDef %s.", VAR_ATTR_SHARED_NAME.c_str(), node->name().c_str());
return PARAM_INVALID);
GE_RETURN_WITH_LOG_IF_ERROR(TensorFlowUtil::CheckAttrHasType(attr, TENSORFLOW_ATTR_TYPE_STRING),
@@ -141,6 +150,8 @@ static Status ParseVarName(const domi::tensorflow::NodeDef *node, VariableOperat
// The upper caller guarantees input params is not empty.
domi::tensorflow::AttrValue attr;
CHECK_FALSE_EXEC(TensorFlowUtil::FindAttrValue(node, ge::VAR_ATTR_NAME, attr),
REPORT_CALL_ERROR("E19999", "In NodeDef:%s attr:%s not exist, check invalid",
node->name().c_str(), VAR_ATTR_NAME.c_str());
GELOGE(FAILED, "Attr %s does not exist in NodeDef %s.", ge::VAR_ATTR_NAME.c_str(),
node->name().c_str()); return PARAM_INVALID);

@@ -174,6 +185,8 @@ static Status ParseVarShape(const domi::tensorflow::NodeDef *node, VariableOpera
domi::tensorflow::AttrValue attr_value;

if (!TensorFlowUtil::FindAttrValue(node, ge::ATTR_NAME_OUTPUT_TENSOR_DESC, attr_value)) {
REPORT_CALL_ERROR("E19999", "In NodeDef:%s attr:%s not exist, check invalid",
node->name().c_str(), ATTR_NAME_OUTPUT_TENSOR_DESC.c_str());
GELOGE(FAILED, "In NodeDef %s Attr %s is not exist.", node_src_name.c_str(),
ge::ATTR_NAME_OUTPUT_TENSOR_DESC.c_str());
return FAILED;
@@ -188,6 +201,8 @@ static Status ParseVarShape(const domi::tensorflow::NodeDef *node, VariableOpera
ge::Format src_format = ge::FORMAT_ND;

CHECK_FALSE_EXEC(TensorFlowUtil::FindAttrValue(node, VAR_ATTR_SHAPE, attr_value),
REPORT_CALL_ERROR("E19999", "In NodeDef:%s attr:%s not exist, check invalid",
node->name().c_str(), VAR_ATTR_SHAPE.c_str());
GELOGE(FAILED, "Attr %s does not exist in NodeDef %s.", VAR_ATTR_SHAPE.c_str(),
node->name().c_str()); return PARAM_INVALID);



+ 1
- 1
tests/depends/error_manager/src/error_manager_stub.cc View File

@@ -98,4 +98,4 @@ void ErrorManager::SetStage(const std::string &first_stage, const std::string &s
}

void ErrorManager::GenWorkStreamIdDefault() {
}
}

+ 1
- 0
tests/ut/parser/CMakeLists.txt View File

@@ -290,6 +290,7 @@ include_directories(${CMAKE_BINARY_DIR}/proto/ge)
include_directories(${PARSER_DIR})
include_directories(${PARSER_DIR}/inc)
include_directories(${PARSER_DIR}/parser)
include_directories(${PARSER_DIR}/parser/onnx)
include_directories(${PARSER_DIR}/metadef/inc)
include_directories(${PARSER_DIR}/metadef/inc/external)
include_directories(${PARSER_DIR}/metadef/inc/register)


Loading…
Cancel
Save