Browse Source

!285 日志整改

Merge pull request !285 from ldy2021/master
pull/285/MERGE
i-robot Gitee 4 years ago
parent
commit
dda9def8bd
21 changed files with 756 additions and 508 deletions
  1. +17
    -9
      parser/caffe/caffe_custom_parser_adapter.cc
  2. +23
    -25
      parser/caffe/caffe_data_parser.cc
  3. +32
    -36
      parser/caffe/caffe_op_parser.cc
  4. +247
    -198
      parser/caffe/caffe_parser.cc
  5. +14
    -5
      parser/caffe/caffe_reshape_parser.cc
  6. +124
    -81
      parser/common/acl_graph_parser_util.cc
  7. +35
    -13
      parser/common/data_op_parser.cc
  8. +14
    -9
      parser/common/model_saver.cc
  9. +20
    -6
      parser/common/op_def/ir_pb_converter.cc
  10. +20
    -8
      parser/common/op_def/op_schema.cc
  11. +6
    -5
      parser/common/op_parser_factory.cc
  12. +4
    -4
      parser/common/parser_factory.cc
  13. +50
    -16
      parser/common/parser_utils.cc
  14. +6
    -2
      parser/common/pass_manager.cc
  15. +18
    -15
      parser/common/pre_checker.cc
  16. +33
    -16
      parser/common/proto_file_parser.cc
  17. +12
    -5
      parser/common/register_tbe.cc
  18. +15
    -9
      parser/onnx/onnx_constant_parser.cc
  19. +1
    -1
      parser/onnx/onnx_custom_parser_adapter.cc
  20. +4
    -3
      parser/onnx/onnx_data_parser.cc
  21. +61
    -42
      parser/onnx/onnx_parser.cc

+ 17
- 9
parser/caffe/caffe_custom_parser_adapter.cc View File

@@ -49,7 +49,9 @@ Status CaffeCustomParserAdapter::ParseParams(const Message *op_src, ge::OpDescPt

op_dest->SetName(layer->name());
ge::Operator op = ge::OpDescUtils::CreateOperatorFromOpDesc(op_dest);
GE_CHK_BOOL_RET_STATUS(customOpParser(op_src, op) == SUCCESS, FAILED, "Custom parser params failed");
GE_CHK_BOOL_RET_STATUS(customOpParser(op_src, op) == SUCCESS, FAILED,
"[Invoke][CustomOpParser] failed, layer name:%s, layer type:%s",
layer->name().c_str(), layer->type().c_str());
return SUCCESS;
}

@@ -64,7 +66,9 @@ Status CaffeCustomParserAdapter::ParseParams(const Operator &op_src, ge::OpDescP
op_dest->SetName(op_src.GetName());
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,
"[Invoke][CustomOpParser] failed, layer name:%s, type:%s",
op_src.GetName().c_str(), op_src.GetOpType().c_str());
return SUCCESS;
}

@@ -75,7 +79,7 @@ Status CaffeCustomParserAdapter::ParseWeights(const Message *op_src, ge::NodePtr
GE_CHECK_NOTNULL(op);
const LayerParameter *layer = reinterpret_cast<const LayerParameter *>(op_src);

GE_CHK_BOOL_RET_STATUS(nullptr != layer, FAILED, "Dynamic cast op_src to LayerParameter failed");
GE_CHK_BOOL_RET_STATUS(nullptr != layer, FAILED, "[Convert][Type]Dynamic cast op_src to LayerParameter failed");
GELOGI("layer: %s blobs_size: %d bottom_size: %d", layer->name().c_str(), layer->blobs_size(), layer->bottom_size());
if (layer->blobs_size() == 0) {
return SUCCESS;
@@ -87,8 +91,8 @@ Status CaffeCustomParserAdapter::ParseWeights(const Message *op_src, ge::NodePtr
for (int i = 0; i < layer->blobs_size(); ++i) {
ge::GeTensorPtr weight = ge::parser::MakeShared<ge::GeTensor>();
GE_CHECK_NOTNULL(weight);
GE_CHK_STATUS_RET(ConvertWeight(layer->blobs(i), layer->name(), weight), "Convert blobs(%d) for layer %s failed", i,
layer->name().c_str());
GE_CHK_STATUS_RET(ConvertWeight(layer->blobs(i), layer->name(), weight),
"[Convert][Blobs] (%d) for layer %s failed", i, layer->name().c_str());
GE_IF_BOOL_EXEC(layer->type() == kConvolution && i == kBlobIndexOne,
const ConvolutionParameter &conv_params_src = layer->convolution_param();
bias_en = conv_params_src.bias_term(););
@@ -122,13 +126,17 @@ Status CaffeCustomParserAdapter::ParseWeights(const Message *op_src, ge::NodePtr
auto valid_input_name = op->GetValidInputNameByIndex(static_cast<uint32_t>(index));
if (update_in_turn || valid_input_name.empty()) {
if (node->AddLinkFrom(static_cast<const uint32_t &>(index), const_node) != GRAPH_SUCCESS) {
GELOGE(GRAPH_FAILED, "AddEdge failed of from Node %s output to Node %s input %d", const_node->GetName().c_str(),
node->GetName().c_str(), index);
REPORT_CALL_ERROR("E19999", "AddEdge failed of from Node %s output to Node %s input %d",
const_node->GetName().c_str(), node->GetName().c_str(), index);
GELOGE(GRAPH_FAILED, "[Invoke][AddLinkFrom] AddEdge failed of from Node %s output to Node %s input %d",
const_node->GetName().c_str(), node->GetName().c_str(), index);
}
} else {
if (node->AddLinkFrom(valid_input_name, const_node) != GRAPH_SUCCESS) {
GELOGE(GRAPH_FAILED, "AddEdge failed of from Node %s output to Node %s input %s", const_node->GetName().c_str(),
node->GetName().c_str(), valid_input_name.c_str());
REPORT_CALL_ERROR("E19999", "AddEdge failed of from Node %s output to Node %s input %s",
const_node->GetName().c_str(), node->GetName().c_str(), valid_input_name.c_str());
GELOGE(GRAPH_FAILED, "[Invoke][AddLinkFrom] AddEdge failed of from Node %s output to Node %s input %s",
const_node->GetName().c_str(), node->GetName().c_str(), valid_input_name.c_str());
}
}



+ 23
- 25
parser/caffe/caffe_data_parser.cc View File

@@ -37,7 +37,7 @@ Status CaffeDataParser::GetOutputDesc(const string &name, int dim_size, const st
GELOGW("SetInt failed for op %s.", op->GetName().c_str());); // no need to return

// Initialize input and output description of OP according to input_dims information
GE_RETURN_WITH_LOG_IF_ERROR(ParseShape(input_dims, op), "data layer %s ParseShape failed", name.c_str());
GE_RETURN_WITH_LOG_IF_ERROR(ParseShape(input_dims, op), "[Parse][Shape] failed for data layer %s", name.c_str());

return SUCCESS;
}
@@ -50,14 +50,14 @@ Status CaffeDataParser::ParseParams(const Message *op_src, ge::OpDescPtr &op) {
GELOGD("Caffe layer name = %s, layer type= %s, parse params", layer->name().c_str(), layer->type().c_str());

if (layer->type() == ge::parser::INPUT_TYPE) {
GE_CHK_STATUS_RET(ParseParamsForInput(layer, op), "Caffe layer name = %s, layer type= %s, parse params failed",
layer->name().c_str(), layer->type().c_str());
GE_CHK_STATUS_RET(ParseParamsForInput(layer, op), "[Parse][Params] failed, Caffe layer name = %s, "
"layer type= %s", layer->name().c_str(), layer->type().c_str());
} else if(layer->type() == ge::parser::DUMMY_DATA) {
GE_CHK_STATUS_RET(ParseParamsForDummyData(layer, op), "Caffe layer name = %s, layer type= %s, parse params failed",
layer->name().c_str(), layer->type().c_str());
GE_CHK_STATUS_RET(ParseParamsForDummyData(layer, op), "[Parse][Params] failed, Caffe layer name = %s, "
"layer type= %s", layer->name().c_str(), layer->type().c_str());
} else {
ErrorManager::GetInstance().ATCReportErrMessage("E11030");
GELOGE(PARAM_INVALID, "Caffe prototxt has no optype [Input]");
GELOGE(PARAM_INVALID, "[Check][Param] Caffe prototxt has no optype [Input]");
return FAILED;
}
return SUCCESS;
@@ -69,9 +69,8 @@ Status CaffeDataParser::ParseParamsForInput(const domi::caffe::LayerParameter *l
if (input_param.shape_size() == 0) {
ErrorManager::GetInstance().ATCReportErrMessage(
"E11027", {"layername", "layertype"}, {layer->name(), layer->type()});
GELOGE(PARAM_INVALID,
"input_param shape size is zero, caffe layer name [%s], layer type [%s].",
layer->name().c_str(), layer->type().c_str());
GELOGE(PARAM_INVALID, "[Check][Param]input_param shape size is zero, check invalid, "
"caffe layer name [%s], layer type [%s].", layer->name().c_str(), layer->type().c_str());
return FAILED;
}
for (int i = 0; i < input_param.shape_size(); i++) {
@@ -84,8 +83,8 @@ Status CaffeDataParser::ParseParamsForInput(const domi::caffe::LayerParameter *l
}
string name = layer->name();
GE_IF_BOOL_EXEC(shape_map.count(name) != 0, model_dims = shape_map.at(name));
GE_CHK_STATUS_RET(GetOutputDesc(name, model_dims.size(), model_dims, op), "Get output desc failed in layer %s",
name.c_str());
GE_CHK_STATUS_RET(GetOutputDesc(name, model_dims.size(), model_dims, op),
"[Get][OutputDesc] failed in layer %s", name.c_str());
}
} else {
// Get from external input
@@ -96,14 +95,14 @@ Status CaffeDataParser::ParseParamsForInput(const domi::caffe::LayerParameter *l
if (search == input_dims.end()) {
ErrorManager::GetInstance().ATCReportErrMessage(
"E11028", {"layername", "layertype"}, {layer->name(), layer->type()});
GELOGE(PARAM_INVALID,
"Caffe prototxt has no input_param or user should set --input_shape in atc parameter, "
"caffe layer name [%s], layer type [%s].", layer->name().c_str(), layer->type().c_str());
GELOGE(PARAM_INVALID, "[Check][Param] Caffe prototxt has no input_param or user "
"should set --input_shape in atc parameter, caffe layer name [%s], layer type [%s].",
layer->name().c_str(), layer->type().c_str());
return FAILED;
}
std::vector<int64_t> dims = search->second;
GE_CHK_STATUS_RET(GetOutputDesc(name, dims.size(), dims, op), "Get output desc failed in layer %s.",
name.c_str());
GE_CHK_STATUS_RET(GetOutputDesc(name, dims.size(), dims, op),
"[Get][OutputDesc] failed in layer %s.", name.c_str());
}
return SUCCESS;
}
@@ -114,8 +113,7 @@ Status CaffeDataParser::ParseParamsForDummyData(const domi::caffe::LayerParamete
if (dummy_data_param.shape_size() == 0) {
ErrorManager::GetInstance().ATCReportErrMessage(
"E11027", {"layername", "layertype"}, {layer->name(), layer->type()});
GELOGE(PARAM_INVALID,
"input_param shape size is zero, caffe layer name [%s], layer type [%s].",
GELOGE(PARAM_INVALID, "[Check][Param] input_param shape size is zero, caffe layer name [%s], layer type [%s].",
layer->name().c_str(), layer->type().c_str());
return FAILED;
}
@@ -131,8 +129,8 @@ Status CaffeDataParser::ParseParamsForDummyData(const domi::caffe::LayerParamete

string name = layer->name();
GE_IF_BOOL_EXEC(shape_map.count(name) != 0, model_dims = shape_map.at(name));
GE_CHK_STATUS_RET(GetOutputDesc(name, model_dims.size(), model_dims, op), "Get output desc failed in layer %s",
name.c_str());
GE_CHK_STATUS_RET(GetOutputDesc(name, model_dims.size(), model_dims, op),
"[Get][OutputDesc] failed in layer %s", name.c_str());
}
} else {
// Get from external input
@@ -143,14 +141,14 @@ Status CaffeDataParser::ParseParamsForDummyData(const domi::caffe::LayerParamete
if (search == input_dims.end()) {
ErrorManager::GetInstance().ATCReportErrMessage(
"E11028", {"layername", "layertype"}, {layer->name(), layer->type()});
GELOGE(PARAM_INVALID,
"Caffe prototxt has no input_param or user should set --input_shape in atc parameter, "
"caffe layer name [%s], layer type [%s].", layer->name().c_str(), layer->type().c_str());
GELOGE(PARAM_INVALID, "[Check][Param] Caffe prototxt has no input_param or user "
"should set --input_shape in atc parameter, caffe layer name [%s], layer type [%s].",
layer->name().c_str(), layer->type().c_str());
return FAILED;
}
std::vector<int64_t> dims = search->second;
GE_CHK_STATUS_RET(GetOutputDesc(name, dims.size(), dims, op), "Get output desc failed in layer %s.",
name.c_str());
GE_CHK_STATUS_RET(GetOutputDesc(name, dims.size(), dims, op),
"[Get][OutputDesc] failed in layer %s.", name.c_str());
}
return SUCCESS;
}


+ 32
- 36
parser/caffe/caffe_op_parser.cc View File

@@ -58,16 +58,17 @@ Status CaffeOpParser::ConvertWeight(const BlobProto &proto, const string &lay_na
for (size_t i = 0; i < shape.GetDimNum(); ++i) {
int dim = shape.GetDim(i);
if (dim <= 0) {
GELOGE(FAILED, "Convert weight fail, Blob size invalid");
REPORT_INNER_ERROR("E19999", "Convert weight fail, dim:%d of layer:%s <=0, check invalid", dim, lay_name.c_str());
GELOGE(FAILED, "[Check][Size]Convert weight fail, dim:%d of layer:%s <=0, check invalid", dim, lay_name.c_str());
return FAILED;
}

if (dim >= INT64_MAX / count) {
ErrorManager::GetInstance().ATCReportErrMessage(
"E11033", {"opname", "blobsize", "reason"},
{lay_name, std::to_string(dim) + "*" + std::to_string(count),
"it exceeds INT64_MAX[" + std::to_string(INT64_MAX) + "]"});
GELOGE(FAILED, "Convert weight fail, Blob size exceeds INT64_MAX, dim:%d, count:%d", dim, count);
ErrorManager::GetInstance().ATCReportErrMessage("E11033", {"opname", "blobsize", "reason"},
{lay_name, std::to_string(dim) + "*" + std::to_string(count),
"it exceeds INT64_MAX[" + std::to_string(INT64_MAX) + "]"});
GELOGE(FAILED, "[Check][Size]Convert weight fail, Blob size exceeds INT64_MAX, dim:%d, count:%d, layer name:%s",
dim, count, lay_name.c_str());
return FAILED;
}

@@ -84,12 +85,11 @@ Status CaffeOpParser::ParseWeightType(const BlobProto &proto, const ge::GeShape
if (proto.double_data_size() > 0) {
// Convert by double type
if (size != proto.double_data_size()) {
ErrorManager::GetInstance().ATCReportErrMessage(
"E11033", {"opname", "blobsize", "reason"},
{lay_name, std::to_string(proto.double_data_size()),
"it does not match shape size[" + std::to_string(size) + "]"});
GELOGE(FAILED, "Convert weight fail, Blob size does not match shape size, shape size:%d, blob size:%d", size,
proto.double_data_size());
ErrorManager::GetInstance().ATCReportErrMessage("E11033", {"opname", "blobsize", "reason"},
{lay_name, std::to_string(proto.double_data_size()),
"it does not match shape size[" + std::to_string(size) + "]"});
GELOGE(FAILED, "[Check][Param]Convert weight fail, Blob size does not match shape size, "
"shape size:%d, blob size:%d, layer name:%s", size, proto.double_data_size(), lay_name.c_str());
return FAILED;
}
std::unique_ptr<float[]> buf(new (std::nothrow) float[size]());
@@ -101,12 +101,11 @@ Status CaffeOpParser::ParseWeightType(const BlobProto &proto, const ge::GeShape
GELOGW("SetData failed for GeTensor.");); // no need to return
} else if (proto.int8_data().length() > 0) {
if (size != static_cast<int>(proto.int8_data().length())) {
ErrorManager::GetInstance().ATCReportErrMessage(
"E11033", {"opname", "blobsize", "reason"},
{lay_name, std::to_string(proto.int8_data().length()),
"it does not match shape size[" + std::to_string(size) + "]"});
GELOGE(FAILED, "Convert weight failed, Blob size does not match shape size, shape size:%d, blob size:%ld", size,
proto.int8_data().length());
ErrorManager::GetInstance().ATCReportErrMessage("E11033", {"opname", "blobsize", "reason"},
{lay_name, std::to_string(proto.int8_data().length()),
"it does not match shape size[" + std::to_string(size) + "]"});
GELOGE(FAILED, "[Check][Param]Convert weight failed, Blob size does not match shape size, "
"shape size:%d, blob size:%ld, layer name:%s", size, proto.int8_data().length(), lay_name.c_str());
return FAILED;
}
const char *data_ptr = proto.int8_data().data();
@@ -117,12 +116,11 @@ Status CaffeOpParser::ParseWeightType(const BlobProto &proto, const ge::GeShape
dtype = ge::DT_INT8;
} else if (proto.int32_data_size() > 0) {
if (size != proto.int32_data_size()) {
ErrorManager::GetInstance().ATCReportErrMessage(
"E11033", {"opname", "blobsize", "reason"},
{lay_name, std::to_string(proto.int32_data_size()),
"it does not match shape size[" + std::to_string(size) + "]"});
GELOGE(FAILED, "Convert weight failed, Blob size does not match shape size, shape size:%d, blob size:%d", size,
proto.int32_data_size());
ErrorManager::GetInstance().ATCReportErrMessage("E11033", {"opname", "blobsize", "reason"},
{lay_name, std::to_string(proto.int32_data_size()),
"it does not match shape size[" + std::to_string(size) + "]"});
GELOGE(FAILED, "[Check][Param]Convert weight failed, Blob size does not match shape size, "
"shape size:%d, blob size:%d, layer name:%s", size, proto.int32_data_size(), lay_name.c_str());
return FAILED;
}
std::unique_ptr<int32_t[]> int32_weight_buf(new (std::nothrow) int32_t[size]());
@@ -136,12 +134,11 @@ Status CaffeOpParser::ParseWeightType(const BlobProto &proto, const ge::GeShape
dtype = ge::DT_INT32;
} else if (proto.uint64_data_size() > 0) {
if (size != proto.uint64_data_size()) {
ErrorManager::GetInstance().ATCReportErrMessage(
"E11033", {"opname", "blobsize", "reason"},
{lay_name, std::to_string(proto.uint64_data_size()),
"it does not match shape size[" + std::to_string(size) + "]"});
GELOGE(FAILED, "Convert weight failed, Blob size does not match shape size, shape size:%d, blob size:%d", size,
proto.uint64_data_size());
ErrorManager::GetInstance().ATCReportErrMessage("E11033", {"opname", "blobsize", "reason"},
{lay_name, std::to_string(proto.uint64_data_size()),
"it does not match shape size[" + std::to_string(size) + "]"});
GELOGE(FAILED, "[Check][Param]Convert weight failed, Blob size does not match shape size, "
"shape size:%d, blob size:%d, layer name:%s", size, proto.uint64_data_size(), lay_name.c_str());
return FAILED;
}
std::unique_ptr<uint64_t[]> uint64_weight_buf(new (std::nothrow) uint64_t[size]());
@@ -156,12 +153,11 @@ Status CaffeOpParser::ParseWeightType(const BlobProto &proto, const ge::GeShape
} else {
// Convert by float type
if (size != proto.data_size()) {
ErrorManager::GetInstance().ATCReportErrMessage(
"E11033", {"opname", "blobsize", "reason"},
{lay_name, std::to_string(proto.data_size()),
"it does not match shape size[" + std::to_string(size) + "]"});
GELOGE(FAILED, "Convert weight fail, Blob size does not match shape size, shape size:%d, blob.data_size:%d", size,
proto.data_size());
ErrorManager::GetInstance().ATCReportErrMessage("E11033", {"opname", "blobsize", "reason"},
{lay_name, std::to_string(proto.data_size()),
"it does not match shape size[" + std::to_string(size) + "]"});
GELOGE(FAILED, "[Check][Param]Convert weight fail, Blob size does not match shape size, "
"shape size:%d, blob.data_size:%d, layer name:%s", size, proto.data_size(), lay_name.c_str());
return FAILED;
}
const float *data_ptr = proto.data().data();


+ 247
- 198
parser/caffe/caffe_parser.cc
File diff suppressed because it is too large
View File


+ 14
- 5
parser/caffe/caffe_reshape_parser.cc View File

@@ -40,7 +40,8 @@ Status CaffeReshapeParser::ParseParams(const Message *op_src, ge::OpDescPtr &op)
GE_CHECK_NOTNULL(op);
const LayerParameter *layer = DOMI_DYNAMIC_CAST<const LayerParameter *>(op_src);
if (layer == nullptr) {
GELOGE(FAILED, "Reshape Dynamic cast op_src to LayerParameter failed");
REPORT_INNER_ERROR("E19999", "Reshape Dynamic cast op_src to LayerParameter failed");
GELOGE(FAILED, "[Convert][DataType]Reshape Dynamic cast op_src to LayerParameter failed");
return FAILED;
}

@@ -53,7 +54,10 @@ Status CaffeReshapeParser::ParseParams(const Message *op_src, ge::OpDescPtr &op)
GELOGW("SetInt failed for op %s.", op->GetName().c_str());); // no need to return

if (!reshape_parameter.has_shape()) {
GELOGE(FAILED, "Reshape has no shape info, ret fail");
REPORT_INNER_ERROR("E19999", "Reshape has no shape info, ret fail, layer name = %s, layer type= %s",
layer->name().c_str(), layer->type().c_str());
GELOGE(FAILED, "[Check][Param]Reshape has no shape info, ret fail, layer name = %s, layer type= %s",
layer->name().c_str(), layer->type().c_str());
return FAILED;
}
const BlobShape &blob_shape = reshape_parameter.shape();
@@ -87,7 +91,8 @@ Status CaffeReshapeParser::AddConstInput(ge::NodePtr &node) {
GE_CHECK_NOTNULL(node);
auto owner_graph = node->GetOwnerComputeGraph();
if (owner_graph == nullptr) {
GELOGE(FAILED, "node's graph is empty, name: %s", node->GetName().c_str());
REPORT_INNER_ERROR("E19999", "node's graph is empty, name: %s", node->GetName().c_str());
GELOGE(FAILED, "[Get][OwnerComputeGraph]node's graph is empty, name: %s", node->GetName().c_str());
return FAILED;
}
ge::OpDescPtr op = node->GetOpDesc();
@@ -104,7 +109,8 @@ Status CaffeReshapeParser::AddConstInput(ge::NodePtr &node) {
const_desc.Update(shape, ge::FORMAT_NCHW, ge::DT_INT64);
ge::graphStatus state = op->UpdateInputDesc(RESHAPE_ATTR_SHAPE, const_desc);
if (state != ge::GRAPH_SUCCESS) {
GELOGE(FAILED, "Updata input_shape desc failed.");
REPORT_CALL_ERROR("E19999", "op:%s UpdateInputDesc failed.", op->GetName().c_str());
GELOGE(FAILED, "[Update][InputDesc] failed for op:%s.", op->GetName().c_str());
return FAILED;
}

@@ -133,7 +139,10 @@ Status CaffeReshapeParser::AddConstInput(ge::NodePtr &node) {
GE_CHECK_NOTNULL(in_archor_ptr);
state = ge::GraphUtils::AddEdge(out_archor_ptr, in_archor_ptr);
if (state != ge::GRAPH_SUCCESS) {
GELOGE(FAILED, "AddEdge failed of from Node %s to Node %s", const_node->GetName().c_str(), node->GetName().c_str());
REPORT_CALL_ERROR("E19999", "AddEdge failed of from Node %s to Node %s",
const_node->GetName().c_str(), node->GetName().c_str());
GELOGE(FAILED, "[Add][Edge] failed of from Node %s to Node %s",
const_node->GetName().c_str(), node->GetName().c_str());
return domi::FAILED;
}
return SUCCESS;


+ 124
- 81
parser/common/acl_graph_parser_util.cc View File

@@ -83,7 +83,8 @@ static void GetOpsProtoPath(string &opsproto_path) {
string path = path_env;
string file_path = ge::parser::RealPath(path.c_str());
if (file_path.empty()) {
GELOGE(ge::FAILED, "File path %s is invalid.", path.c_str());
REPORT_INNER_ERROR("E19999", "File path %s is invalid.", path.c_str());
GELOGE(ge::FAILED, "[Get][Path] File path %s is invalid.", path.c_str());
return;
}
opsproto_path = (path + "/op_proto/custom/" + ":") + (path + "/op_proto/built-in/");
@@ -124,7 +125,8 @@ static void GetAclParams(const std::map<ge::AscendString, ge::AscendString> &par
static bool CheckDigitStr(std::string &str) {
for (char c : str) {
if (!isdigit(c)) {
GELOGE(domi::FAILED, "Value[%s] is not positive integer", str.c_str());
REPORT_CALL_ERROR("E19999", "param str:%s is not positive integer", str.c_str());
GELOGE(domi::FAILED, "[Check][Param] Value[%s] is not positive integer", str.c_str());
return false;
}
}
@@ -138,7 +140,8 @@ static bool CheckInputTrueOrFalse(const std::string &s, const std::string &atc_p
return true;
} else {
ErrorManager::GetInstance().ATCReportErrMessage("E10005", {"parameter", "value"}, {atc_param, s});
GELOGE(PARAM_INVALID, "Input parameter[%s]'s value[%s] must be true or false.", atc_param.c_str(), s.c_str());
GELOGE(PARAM_INVALID, "[Check][Param] Input parameter[%s]'s value[%s] must be true or false.",
atc_param.c_str(), s.c_str());
return false;
}
}
@@ -146,10 +149,8 @@ static bool CheckInputTrueOrFalse(const std::string &s, const std::string &atc_p
static Status CheckOutNode(ge::OpDescPtr op_desc, int32_t index) {
int32_t out_size = op_desc->GetOutputsSize();
if (index < 0 || index >= out_size) {
GELOGE(domi::FAILED,
"out_node [%s] output index:%d must be smaller "
"than node output size:%d and can not be negative!",
op_desc->GetName().c_str(), index, out_size);
GELOGE(domi::FAILED, "[Check][Param]out_node [%s] output index:%d must be smaller "
"than node output size:%d and can not be negative!", op_desc->GetName().c_str(), index, out_size);
std::string fail_reason = "output index:" + to_string(index) +
" must be smaller than output size:" + to_string(out_size) + " and can not be negative!";
ErrorManager::GetInstance().ATCReportErrMessage("E10003", {"parameter", "value", "reason"},
@@ -168,7 +169,10 @@ domi::Status AclGrphParseUtil::LoadOpsProtoLib() {
option_tmp.emplace(std::pair<string, string>(string("ge.opsProtoLibPath"), opsproto_path));
bool is_proto_init = manager->Initialize(option_tmp);
if (!is_proto_init) {
GELOGE(FAILED, "Load ops_proto lib failed, ops proto path is invalid.");
REPORT_INNER_ERROR("E19999", "OpsProtoManager init failed because ops proto path:%s is invalid.",
opsproto_path.c_str());
GELOGE(FAILED, "[Invoke][Initialize] Load ops_proto lib failed, ops proto path:%s is invalid.",
opsproto_path.c_str());
return FAILED;
}
return SUCCESS;
@@ -214,13 +218,15 @@ domi::Status AclGrphParseUtil::AclParserInitialize(const std::map<std::string, s

auto op_registry = domi::OpRegistry::Instance();
if (op_registry == nullptr) {
GELOGE(FAILED, "Get OpRegistry instance failed");
REPORT_CALL_ERROR("E19999", "Call OpRegistry::Instance failed, ret nullptr.");
GELOGE(FAILED, "[Get][OpRegistry] instance failed");
return FAILED;
}

auto it = options.find(ge::FRAMEWORK_TYPE);
if (it == options.end()) {
GELOGE(FAILED, "Can not find ge.frameworkType in options");
REPORT_INNER_ERROR("E19999", "Can not find ge.frameworkType in param options");
GELOGE(FAILED, "[Check][Param]Can not find ge.frameworkType in options");
return FAILED;
}
std::string fmk_type = it->second;
@@ -269,25 +275,25 @@ domi::Status AclGrphParseUtil::ParseAclOutputNodes(const string &out_nodes) {
}
ErrorManager::GetInstance().ATCReportErrMessage(
"E10001", {"parameter", "value", "reason"},
{"out_nodes", node, "the correct format is \"node_name1:0;node_name1:1;node_name2:0\""});
GELOGE(PARAM_INVALID,
"The input format of out_nodes is invalid, the correct format is "
"\"node_name1:0;node_name1:1;node_name2:0\", while the actual input is %s.",
{"out_nodes", node, "the correct format is \"node_name1:0; node_name1:1; node_name2:0\""});
GELOGE(PARAM_INVALID, "[Check][Param] The input format of out_nodes is invalid, the correct format is "
"\"node_name1:0; node_name1:1; node_name2:0\", while the actual input is %s.",
node.c_str());
return PARAM_INVALID;
}
if (!ge::GetParserContext().user_out_nodes_top_vec.empty()) {
ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"},
{"out_nodes", out_nodes, "is not all index or top_name"});
GELOGE(PARAM_INVALID, "This out_nodes str must be all index or top_name, while the actual input is %s",
out_nodes.c_str());
GELOGE(PARAM_INVALID, "[Check][Param] This out_nodes str must be all index or top_name, "
"while the actual input is %s", out_nodes.c_str());
return PARAM_INVALID;
}
// stoi: The method may throw an exception: invalid_argument/out_of_range
if (!CheckDigitStr(key_value_v[1])) {
ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"},
{"out_nodes", out_nodes, "is not positive integer"});
GELOGE(PARAM_INVALID, "This str must be digit string, while the actual input is %s", out_nodes.c_str());
GELOGE(PARAM_INVALID, "[Check][Param] This str:%s must be digit string, while the actual input is %s",
key_value_v[1].c_str(), out_nodes.c_str());
return PARAM_INVALID;
}

@@ -305,11 +311,11 @@ domi::Status AclGrphParseUtil::ParseAclOutputNodes(const string &out_nodes) {
}
}
} catch (std::invalid_argument &) {
GELOGE(PARAM_INVALID, "Invalid of out_nodes: %s ", out_nodes.c_str());
GELOGE(PARAM_INVALID, "[Check][Param] Invalid of out_nodes: %s ", out_nodes.c_str());
ErrorManager::GetInstance().ATCReportErrMessage("E10014", {"parameter", "value"}, {"out_nodes", out_nodes});
return PARAM_INVALID;
} catch (std::out_of_range &) {
GELOGE(PARAM_INVALID, "Invalid of out_nodes: %s ", out_nodes.c_str());
GELOGE(PARAM_INVALID, "[Check][Param] Invalid of out_nodes: %s ", out_nodes.c_str());
ErrorManager::GetInstance().ATCReportErrMessage("E10013", {"parameter", "value"}, {"out_nodes", out_nodes});
return PARAM_INVALID;
}
@@ -327,8 +333,8 @@ domi::Status AclGrphParseUtil::ParseAclOutputFp16NodesFormat(const string &is_ou
for (auto &is_fp16 : node_format_vec) {
StringUtils::Trim(is_fp16);
if (!CheckInputTrueOrFalse(is_fp16, "is_output_adjust_hw_layout")) {
GELOGE(PARAM_INVALID, "Invalid Param, is_output_adjust_hw_layout only support true/false: but is [%s]",
is_output_fp16.c_str());
GELOGE(PARAM_INVALID, "[Check][Param]Invalid Param, is_output_adjust_hw_layout "
"only support true/false: but is [%s]", is_output_fp16.c_str());
return PARAM_INVALID;
}
if (is_fp16 == "false") {
@@ -370,8 +376,8 @@ domi::Status AclGrphParseUtil::ParseAclInputFp16Nodes(const ComputeGraphPtr &gra
for (auto &s : adjust_fp16_format_vec) {
StringUtils::Trim(s);
if (!CheckInputTrueOrFalse(s, "is_input_adjust_hw_layout")) {
GELOGE(PARAM_INVALID, "Invalid Param, is_input_adjust_hw_layout only support true/false: but is [%s]",
is_input_adjust_hw_layout.c_str());
GELOGE(PARAM_INVALID, "[Check][Param] Invalid Param, is_input_adjust_hw_layout "
"only support true/false: but is [%s]", is_input_adjust_hw_layout.c_str());
return PARAM_INVALID;
}
}
@@ -386,7 +392,7 @@ domi::Status AclGrphParseUtil::ParseAclInputFp16Nodes(const ComputeGraphPtr &gra
if (node == nullptr) {
ErrorManager::GetInstance().ATCReportErrMessage("E10016", {"parameter", "opname"},
{"input_fp16_nodes", input_fp16_nodes_vec[i]});
GELOGE(PARAM_INVALID, "Input parameter[input_fp16_nodes]'s opname[%s] is not exist in model",
GELOGE(PARAM_INVALID, "[Check][Param] Input parameter[input_fp16_nodes]'s opname[%s] is not exist in model",
input_fp16_nodes_vec[i].c_str());
return PARAM_INVALID;
}
@@ -395,7 +401,7 @@ domi::Status AclGrphParseUtil::ParseAclInputFp16Nodes(const ComputeGraphPtr &gra
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",
GELOGE(PARAM_INVALID, "[Check][Param] Input parameter[input_fp16_nodes]'s opname[%s] is not a input opname",
input_fp16_nodes_vec[i].c_str());
return PARAM_INVALID;
}
@@ -434,7 +440,8 @@ domi::Status AclGrphParseUtil::GetOutputLeaf(NodePtr node,
std::vector<std::pair<ge::NodePtr, int32_t>> &output_nodes_info) {
ge::OpDescPtr tmpDescPtr = node->GetOpDesc();
if (tmpDescPtr == nullptr) {
GELOGE(domi::FAILED, "Get outnode op desc fail.");
REPORT_INNER_ERROR("E19999", "param node has no opdesc.");
GELOGE(domi::FAILED, "[Get][OpDesc] param node has no opdesc.");
return domi::FAILED;
}
size_t size = tmpDescPtr->GetOutputsSize();
@@ -448,7 +455,8 @@ domi::Status AclGrphParseUtil::GetOutputLeaf(NodePtr node,
for (auto in_anchor : in_anchors) {
auto out_anchor = in_anchor->GetPeerOutAnchor();
if (out_anchor == nullptr) {
GELOGE(domi::FAILED, "Get leaf node op desc fail.");
REPORT_INNER_ERROR("E19999", "Get leaf node op desc fail.");
GELOGE(domi::FAILED, "[Invoke][GetPeerOutAnchor] Get leaf node op desc fail.");
return domi::FAILED;
}
auto out_node = out_anchor->GetOwnerNode();
@@ -467,7 +475,8 @@ domi::Status AclGrphParseUtil::GetDefaultOutInfo(ge::ComputeGraphPtr &compute_gr
if (out_node == nullptr) {
ErrorManager::GetInstance().ATCReportErrMessage("E10016", {"parameter", "opname"},
{"out_nodes", default_out_nodes[i].first});
GELOGE(domi::FAILED, "Can not find src node (%s) in graph.", default_out_nodes[i].first.c_str());
GELOGE(domi::FAILED, "[Check][Param] Can not find out_nodes(%d) (%s) in graph.",
i, default_out_nodes[i].first.c_str());
return domi::FAILED;
}
output_nodes_info.push_back(std::make_pair(out_node, default_out_nodes[i].second));
@@ -479,7 +488,7 @@ domi::Status AclGrphParseUtil::GetDefaultOutInfo(ge::ComputeGraphPtr &compute_gr
for (ge::NodePtr node : compute_graph->GetDirectNode()) {
if (!node->GetInAllNodes().empty() && node->GetOutAllNodes().empty()) {
Status ret = GetOutputLeaf(node, output_nodes_info);
GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, ret, "Find leaf fail.");
GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, ret, "[Invoke][GetOutputLeaf] Find leaf fail.");
}
}
return domi::SUCCESS;
@@ -501,13 +510,14 @@ domi::Status AclGrphParseUtil::SetOutputNodeInfo(ge::Graph &graph,
if (out_node == nullptr) {
ErrorManager::GetInstance().ATCReportErrMessage("E10016", {"parameter", "opname"},
{"out_nodes", user_out_nodes[i].first});
GELOGE(domi::FAILED, "Can not find src node (%s) in graph.", user_out_nodes[i].first.c_str());
GELOGE(domi::FAILED, "[Check][Param] Can not find out_nodes(%d) (%s) in graph.",
i, user_out_nodes[i].first.c_str());
return domi::FAILED;
}
auto op_desc = out_node->GetOpDesc();
GE_CHECK_NOTNULL(op_desc);
if (CheckOutNode(op_desc, user_out_nodes[i].second) != SUCCESS) {
GELOGE(domi::FAILED, "Check out node (%s) fail.", user_out_nodes[i].first.c_str());
GELOGE(domi::FAILED, "[CheckOut][Node] (%s) fail.", user_out_nodes[i].first.c_str());
return domi::FAILED;
}

@@ -528,7 +538,8 @@ domi::Status AclGrphParseUtil::SetOutputNodeInfo(ge::Graph &graph,
// default output node (leaf)
if (user_out_nodes.empty()) {
if (GetDefaultOutInfo(compute_graph, output_nodes_info) != SUCCESS) {
GELOGE(domi::FAILED, "Get default output info failed.");
REPORT_CALL_ERROR("E19999", "GetDefaultOutInfo failed for graph:%s", graph.GetName().c_str());
GELOGE(domi::FAILED, "[Invoke][GetDefaultOutInfo] failed, graph:%s.", graph.GetName().c_str());
return domi::FAILED;
}
}
@@ -545,7 +556,7 @@ domi::Status AclGrphParseUtil::CheckOptions(const std::map<AscendString, AscendS
if (key_ascend == nullptr) {
ErrorManager::GetInstance().ATCReportErrMessage("E10016", {"parameter", "opname"},
{"parser_params", "null AscendString"});
GELOGE(PARAM_INVALID, "Input options key is null, Please check!");
GELOGE(PARAM_INVALID, "[Check][Param] Input options key is null, Please check!");
return PARAM_INVALID;
}

@@ -553,7 +564,7 @@ domi::Status AclGrphParseUtil::CheckOptions(const std::map<AscendString, AscendS
auto it = ge::ir_option::ir_parser_suppported_options.find(key_str);
if (it == ge::ir_option::ir_parser_suppported_options.end()) {
ErrorManager::GetInstance().ATCReportErrMessage("E10016", {"parameter", "opname"}, {"parser_params", key_str});
GELOGE(PARAM_INVALID, "Input options include unsupported option(%s).Please check!", key_ascend);
GELOGE(PARAM_INVALID, "[Check][Param] Input options include unsupported option(%s).Please check!", key_ascend);
return PARAM_INVALID;
}
}
@@ -563,20 +574,24 @@ domi::Status AclGrphParseUtil::CheckOptions(const std::map<AscendString, AscendS
domi::Status AclGrphParseUtil::ParseParamsBeforeGraph(const std::map<AscendString, AscendString> &parser_params,
string &graph_name) {
GELOGI("Parse graph user options start.");
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(CheckOptions(parser_params) != SUCCESS, return PARAM_INVALID,
"Parse paragrams invalid.");
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(CheckOptions(parser_params) != SUCCESS,
return PARAM_INVALID, "[Check][Options] Parse paragrams invalid, graph:%s.",
graph_name.c_str());
// support paragrams: out_nodes, is_output_adjust_hw_layout, output, enable_scope_fusion_passes
SetDefaultFormat();

string out_nodes;
GetAclParams(parser_params, ge::ir_option::OUT_NODES, out_nodes);
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(ParseAclOutputNodes(out_nodes) != SUCCESS, return PARAM_INVALID,
"Parse out_nodes failed");
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(ParseAclOutputNodes(out_nodes) != SUCCESS,
return PARAM_INVALID,
"[Invoke][ParseAclOutputNodes] Parse out_nodes failed, graph:%s.", graph_name.c_str());

string is_output_adjust_hw_layout;
GetAclParams(parser_params, ge::ir_option::IS_OUTPUT_ADJUST_HW_LAYOUT, is_output_adjust_hw_layout);
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(ParseAclOutputFp16NodesFormat(is_output_adjust_hw_layout) != SUCCESS,
return PARAM_INVALID, "Parse is_output_adjust_hw_layout failed");
return PARAM_INVALID,
"[Invoke][ParseAclOutputFp16NodesFormat] Parse is_output_adjust_hw_layout failed, "
"graph:%s.", graph_name.c_str());

string tmp_name;
GetAclParams(parser_params, ge::ir_option::OUTPUT, tmp_name);
@@ -584,8 +599,10 @@ domi::Status AclGrphParseUtil::ParseParamsBeforeGraph(const std::map<AscendStrin

string enable_scope_fusion_passes;
GetAclParams(parser_params, ge::ir_option::ENABLE_SCOPE_FUSION_PASSES, enable_scope_fusion_passes);
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(ParseAclEnableScope(enable_scope_fusion_passes) != SUCCESS, return PARAM_INVALID,
"Parse enable_scope_fusion_passes failed");
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(ParseAclEnableScope(enable_scope_fusion_passes) != SUCCESS,
return PARAM_INVALID,
"[Invoke][ParseAclEnableScope] Parse enable_scope_fusion_passes failed, graph:%s.",
graph_name.c_str());

return SUCCESS;
}
@@ -603,7 +620,8 @@ domi::Status AclGrphParseUtil::ParseParamsAfterGraph(ge::Graph &graph,
GetAclParams(parser_params, ge::ir_option::IS_INPUT_ADJUST_HW_LAYOUT, is_input_adjust_hw_layout);
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(
ParseAclInputFp16Nodes(compute_graph, input_fp16_nodes, is_input_adjust_hw_layout) != SUCCESS,
return PARAM_INVALID, "Parse input_fp16_nodes failed");
return PARAM_INVALID, "[Invoke][ParseAclInputFp16Nodes] Parse input_fp16_nodes failed, graph:%s",
compute_graph->GetName().c_str());

return SUCCESS;
}
@@ -616,7 +634,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string RealPath(const char
}
if (strlen(path) >= PATH_MAX) {
ErrorManager::GetInstance().ATCReportErrMessage("E19002", {"filepath", "size"}, {path, std::to_string(PATH_MAX)});
GELOGE(ge::FAILED, "Path[%s] len is too long, it must be less than %d", path, PATH_MAX);
GELOGE(ge::FAILED, "[Check][Param] Path[%s] len is too long, it must be less than %d", path, PATH_MAX);
return "";
}
// Nullptr is returned when the path does not exist or there is no permission
@@ -632,26 +650,31 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string RealPath(const char

// Get file length
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY long GetFileLength(const std::string &input_file) {
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(input_file.empty(), return -1, "input_file path is null.");
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(input_file.empty(),
REPORT_INNER_ERROR("E19999", "input_file path is null, check invalid.");
return -1, "[Check][Param] input_file path is null.");

std::string real_path = RealPath(input_file.c_str());

GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(real_path.empty(), return -1, "input_file path '%s' not valid", input_file.c_str());
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(real_path.empty(),
REPORT_CALL_ERROR("E19999", "input_file path '%s' not valid, realpath failed",
input_file.c_str());
return -1, "[Get][Path] input_file path '%s' not valid", input_file.c_str());
unsigned long long file_length = 0;
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(mmGetFileSize(input_file.c_str(), &file_length) != EN_OK,
ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"},
{input_file, strerror(errno)});
return -1, "Open file[%s] failed. %s", input_file.c_str(), strerror(errno));
return -1, "[Open][File] [%s] failed. %s", input_file.c_str(), strerror(errno));

GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((file_length == 0),
ErrorManager::GetInstance().ATCReportErrMessage("E19015", {"filepath"}, {input_file});
return -1, "File[%s] size is 0, not valid.", input_file.c_str());
return -1, "[Check][Param] File[%s] size is 0, not valid.", input_file.c_str());

GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(file_length > kMaxFileSizeLimit,
ErrorManager::GetInstance().ATCReportErrMessage(
"E19016", {"filepath", "filesize", "maxlen"},
{input_file, std::to_string(file_length), std::to_string(kMaxFileSizeLimit)});
return -1, "File[%s] size %lld is out of limit: %d.",
return -1, "[Check][Param] File[%s] size %lld is out of limit: %d.",
input_file.c_str(), file_length, kMaxFileSizeLimit);
return static_cast<long>(file_length);
}
@@ -659,14 +682,15 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY long GetFileLength(const std::s
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint64_t GetCurrentTimestamp() {
struct timeval tv{};
int ret = gettimeofday(&tv, nullptr);
GE_LOGE_IF(ret != 0, "Func gettimeofday may failed: ret=%d", ret);
GE_LOGE_IF(ret != 0, "[Func][GetTimeOfDay] may failed: ret=%d", ret);
auto total_use_time = tv.tv_usec + tv.tv_sec * 1000000; // 1000000: seconds to microseconds
return static_cast<uint64_t>(total_use_time);
}

static bool ReadProtoFromCodedInputStream(CodedInputStream &coded_stream, Message *proto) {
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(proto == nullptr,
return false, "incorrect parameter. nullptr == proto");
REPORT_INNER_ERROR("E19999", "param proto is nullptr, check invalid");
return false, "[Check][Param] incorrect parameter. nullptr == proto");

coded_stream.SetTotalBytesLimit(kProtoReadBytesLimit, kWarningThreshold);
return proto->ParseFromCodedStream(&coded_stream);
@@ -682,26 +706,36 @@ static bool ReadProtoFromCodedInputStream(CodedInputStream &coded_stream, Messag
*/
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadBytesFromBinaryFile(const char *file_name, char **buffer,
int &length) {
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((file_name == nullptr), return false, "incorrect parameter. file is nullptr");
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((buffer == nullptr), return false, "incorrect parameter. buffer is nullptr");
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((file_name == nullptr),
REPORT_INNER_ERROR("E19999", "param file_name is nullptr, check invalid");
return false, "[Check][Param] incorrect parameter. file is nullptr");
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((buffer == nullptr),
REPORT_INNER_ERROR("E19999", "param buffer is nullptr, check invalid");
return false, "[Check][Param] incorrect parameter. buffer is nullptr");

std::string real_path = RealPath(file_name);
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(real_path.empty(), return false, "file path '%s' not valid", file_name);
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(real_path.empty(),
REPORT_INNER_ERROR("E19999", "file path '%s' not valid, realpath failed", file_name);
return false, "[Check][Param]file path '%s' not valid, realpath failed", file_name);

std::ifstream file(real_path.c_str(), std::ios::binary | std::ios::ate);
if (!file.is_open()) {
GELOGE(ge::FAILED, "Read file %s failed.", file_name);
REPORT_INNER_ERROR("E19999", "read file %s failed", file_name);
GELOGE(ge::FAILED, "[Read][File] %s failed.", file_name);
return false;
}

length = static_cast<int>(file.tellg());

GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((length <= 0), file.close(); return false, "file length <= 0");
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((length <= 0), file.close(); REPORT_INNER_ERROR("E19999", "file length <= 0");
return false, "[Check][Param] file length <= 0");

file.seekg(0, std::ios::beg);

*buffer = new(std::nothrow) char[length]();
GE_CHK_BOOL_TRUE_EXEC_RET_STATUS(*buffer == nullptr, false, file.close(), "new an object failed.");
GE_CHK_BOOL_TRUE_EXEC_RET_STATUS(*buffer == nullptr, false, file.close();
REPORT_CALL_ERROR("E19999", "new an object failed."),
"[Create][Buffer] new an object failed.");

file.read(*buffer, length);
file.close();
@@ -710,19 +744,20 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadBytesFromBinaryFile(co

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromBinaryFile(const char *file, Message *proto) {
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((file == nullptr || proto == nullptr),
return false,
"Input parameter file or proto is nullptr!");
REPORT_INNER_ERROR("E19999", "param file or proto is nullptr, check invalid");
return false, "[Check][Param] Input parameter file or proto is nullptr!");

std::string real_path = RealPath(file);
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(real_path.empty(),
return false, "pb file path '%s' not valid", file);
REPORT_INNER_ERROR("E19999", "file path '%s' not valid, realpath failed", file);
return false, "[Check][Param]pb file path '%s' not valid, realpath failed", file);

GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(GetFileLength(real_path) == -1, return false, "file size not valid.");
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(GetFileLength(real_path) == -1, return false, "[Get][FileLength]file size not valid.");

std::ifstream fs(real_path, std::ifstream::in | std::ifstream::binary);
if (!fs.is_open()) {
ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"}, {file, "ifstream is_open failed"});
GELOGE(ge::FAILED, "Open real path[%s] failed.", file);
GELOGE(ge::FAILED, "[Open][RealPath][%s] failed.", file);
return false;
}

@@ -735,7 +770,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromBinaryFile(co

if (!ret) {
ErrorManager::GetInstance().ATCReportErrMessage("E19005", {"file"}, {file});
GELOGE(ge::FAILED, "Parse file[%s] failed.", file);
GELOGE(ge::FAILED, "[Read][Proto] Parse file[%s] failed.", file);
return ret;
}

@@ -743,8 +778,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromBinaryFile(co
}

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromArray(const void *data, int size, Message *proto) {
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((proto == nullptr || data == nullptr || size == 0), return false,
"incorrect parameter. proto is nullptr || data is nullptr || size is 0");
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((proto == nullptr || data == nullptr || size == 0),
REPORT_INNER_ERROR("E19999", "param proto or data is nullptr "
"or size is 0, check invalid"); return false,
"[Check][Param]incorrect parameter. proto is nullptr || data is nullptr || size is 0");

google::protobuf::io::CodedInputStream coded_stream(reinterpret_cast<uint8_t *>(const_cast<void *>(data)), size);
return ReadProtoFromCodedInputStream(coded_stream, proto);
@@ -752,33 +789,34 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromArray(const v

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromText(const char *file,
google::protobuf::Message *message) {
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((file == nullptr || message == nullptr), return false,
"incorrect parameter. nullptr == file || nullptr == message");
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((file == nullptr || message == nullptr),
REPORT_INNER_ERROR("E19999", "param file or message is nullptr, check invalid");
return false,
"[Check][Param]incorrect parameter. nullptr == file || nullptr == message");

std::string real_path = RealPath(file);
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(real_path.empty(),
ErrorManager::GetInstance().ATCReportErrMessage("E19000", {"path", "errmsg"},
{file, strerror(errno)});
return false, "Path[%s]'s realpath is empty, errmsg[%s]", file,
return false, "[Check][Param]Path[%s]'s realpath is empty, errmsg[%s]", file,
strerror(errno));

GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(GetFileLength(real_path) == -1, return false, "file size not valid.");
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(GetFileLength(real_path) == -1, return false, "[Check][Param] file size not valid.");

std::ifstream fs(real_path.c_str(), std::ifstream::in);

if (!fs.is_open()) {
ErrorManager::GetInstance().ATCReportErrMessage("E19017", {"realpth", "protofile"}, {real_path, file});
GELOGE(ge::FAILED,
"Fail to open proto file real path is '%s' when orginal file path is '%s'.", real_path.c_str(), file);
GELOGE(ge::FAILED, "[Open][ProtoFile] failed, real path is '%s' when orginal file path is '%s'.",
real_path.c_str(), file);
return false;
}

google::protobuf::io::IstreamInputStream input(&fs);
bool ret = google::protobuf::TextFormat::Parse(&input, message);
GE_IF_BOOL_EXEC(!ret,
ErrorManager::GetInstance().ATCReportErrMessage("E19018", {"protofile"}, {file});
GELOGE(ret, "Parse file[%s] through [google::protobuf::TextFormat::Parse] failed, "
"please check whether the file is a valid protobuf format file.", file));
GE_IF_BOOL_EXEC(!ret, ErrorManager::GetInstance().ATCReportErrMessage("E19018", {"protofile"}, {file});
GELOGE(ret, "[Parse][File] [%s] through [google::protobuf::TextFormat::Parse] failed, "
"please check whether the file is a valid protobuf format file.", file));
fs.close();

return ret;
@@ -786,15 +824,17 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromText(const ch

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromMem(const char *data, int size,
google::protobuf::Message *message) {
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((data == nullptr || message == nullptr), return false,
"incorrect parameter. data is nullptr || message is nullptr");
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((data == nullptr || message == nullptr),
REPORT_INNER_ERROR("E19999", "param data or message is nullptr,check invalid");
return false,
"[Check][Param] incorrect parameter. data is nullptr || message is nullptr");
std::string str(data, static_cast<size_t>(size));
std::istringstream fs(str);

google::protobuf::io::IstreamInputStream input(&fs);
bool ret = google::protobuf::TextFormat::Parse(&input, message);
GE_IF_BOOL_EXEC(
!ret, GELOGE(ret, "Call [google::protobuf::TextFormat::Parse] func ret fail, please check your text file."));
GE_IF_BOOL_EXEC(!ret, REPORT_CALL_ERROR("E19999", "parse failed, please check your text file.");
GELOGE(ret, "[Call][Parse] ret fail, please check your text file."));

return ret;
}
@@ -812,7 +852,10 @@ Status GetOriginalType(const ge::NodePtr &node, string &type) {
GE_CHECK_NOTNULL(node->GetOpDesc());
bool ret = ge::AttrUtils::GetStr(node->GetOpDesc(), ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, type);
if (!ret) {
GELOGE(INTERNAL_ERROR, "Get FrameWorkOp original type [%s]", type.c_str());
REPORT_CALL_ERROR("E19999", "Get FrameWorkOp original type [%s] from node:%s failed.",
type.c_str(), node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Invoke][GetStr] Get FrameWorkOp original type [%s] from node:%s failed",
type.c_str(), node->GetName().c_str());
return INTERNAL_ERROR;
}
GELOGD("Get FrameWorkOp original type [%s]", type.c_str());
@@ -834,7 +877,7 @@ FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &str, const std::str
ret = regexec(&reg, str.c_str(), 0, nullptr, 0);
if (ret) {
regerror(ret, &reg, ebuff, kMaxBuffSize);
GELOGE(ge::PARAM_INVALID, "regexec failed, reason: %s", ebuff);
GELOGE(ge::PARAM_INVALID, "[Invoke][RegExec] failed, reason: %s", ebuff);
regfree(&reg);
return false;
}
@@ -847,7 +890,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string CurrentTimeInStr()
std::time_t now = std::time(nullptr);
std::tm *ptm = std::localtime(&now);
if (ptm == nullptr) {
GELOGE(ge::FAILED, "Localtime failed.");
GELOGE(ge::FAILED, "[Invoke][LocalTime] failed.");
return "";
}



+ 35
- 13
parser/common/data_op_parser.cc View File

@@ -31,7 +31,7 @@ const uint32_t kScalarLength = 1;

namespace ge {
FMK_FUNC_HOST_VISIBILITY Status DataOpParser::ParseShape(const vector<int64_t> &shape, ge::OpDescPtr op) {
GE_RETURN_WITH_LOG_IF_FALSE(op != nullptr, "ParseShape failed for data_op, op is null");
GE_RETURN_WITH_LOG_IF_FALSE(op != nullptr, "[Check][Param] ParseShape failed for data_op, op is null");

const string &data_op_name = op->GetName();
GetParserContext().input_dims.emplace(data_op_name, shape);
@@ -53,9 +53,11 @@ FMK_FUNC_HOST_VISIBILITY Status DataOpParser::ParseShape(const vector<int64_t> &
auto map_iter = input_nodes_format_map.find(data_op_name);
if (map_iter != input_nodes_format_map.end() && map_iter->second == domi::DOMI_TENSOR_NC1HWC0) {
// Input 5D NC1HWC0
GE_RETURN_WITH_LOG_IF_ERROR(Init5DInputTensor(def_format_shape, i_tensor_desc), "InitInputTensor failed");
GE_RETURN_WITH_LOG_IF_ERROR(Init5DInputTensor(def_format_shape, i_tensor_desc),
"[Invoke][Init5DInputTensor] failed");
// Output
GE_RETURN_WITH_LOG_IF_ERROR(Init5DOutputTensor(def_format_shape, o_tensor_desc), "InitOutputTensor failed");
GE_RETURN_WITH_LOG_IF_ERROR(Init5DOutputTensor(def_format_shape, o_tensor_desc),
"[Invoke][Init5DOutputTensor] failed");
} else {
// No need to consider AIPP here,
// The adjustdatanodedesc function of model_builder will process the
@@ -66,27 +68,31 @@ FMK_FUNC_HOST_VISIBILITY Status DataOpParser::ParseShape(const vector<int64_t> &
// To be modified after AICPU operators support pvmodel.
if (data_type == ge::DT_FLOAT) {
// Input
GE_RETURN_WITH_LOG_IF_ERROR(InitInputTensor(def_format_shape, i_tensor_desc), "InitInputTensor failed");
GE_RETURN_WITH_LOG_IF_ERROR(InitInputTensor(def_format_shape, i_tensor_desc),
"[Invoke][InitInputTensor] failed");
// Output
GE_RETURN_WITH_LOG_IF_ERROR(InitOutputTensor(def_format_shape, o_tensor_desc), "InitOutputTensor failed");
GE_RETURN_WITH_LOG_IF_ERROR(InitOutputTensor(def_format_shape, o_tensor_desc),
"[Invoke][InitOutputTensor] failed");
} else {
// Input
GE_RETURN_WITH_LOG_IF_ERROR(InitNDTensor(def_format_shape, data_type, i_tensor_desc),
"Init ND InputTensor failed");
"[Invoke][InitNDTensor] failed");
// Output
GE_RETURN_WITH_LOG_IF_ERROR(InitNDTensor(def_format_shape, data_type, o_tensor_desc),
"Init ND Output Tensor failed");
"[Invoke][InitNDTensor] failed");
}
}
i_tensor_desc.SetFormat(ge::TypeUtils::DomiFormatToFormat(GetParserContext().format));
i_tensor_desc.SetOriginFormat(ge::TypeUtils::DomiFormatToFormat(GetParserContext().format));
o_tensor_desc.SetFormat(ge::TypeUtils::DomiFormatToFormat(GetParserContext().format));
if (op->AddInputDesc(i_tensor_desc) != ge::GRAPH_SUCCESS) {
GELOGE(domi::INTERNAL_ERROR, "AddInputDesc failed for op %s.", op->GetName().c_str());
REPORT_CALL_ERROR("E19999", "AddInputDesc failed for op %s.", op->GetName().c_str());
GELOGE(domi::INTERNAL_ERROR, "[Invoke][AddInputDesc] failed for op %s.", op->GetName().c_str());
return FAILED;
}
if (op->AddOutputDesc(o_tensor_desc) != ge::GRAPH_SUCCESS) {
GELOGE(domi::INTERNAL_ERROR, "AddOutputDesc failed for op %s.", op->GetName().c_str());
REPORT_CALL_ERROR("E19999", "AddOutputDesc failed for op %s.", op->GetName().c_str());
GELOGE(domi::INTERNAL_ERROR, "[Invoke][AddOutputDesc] failed for op %s.", op->GetName().c_str());
return FAILED;
}
return SUCCESS;
@@ -102,7 +108,8 @@ Status DataOpParser::Init5DInputTensor(const vector<int64_t> &shape, ge::GeTenso
int64_t tensor_size = 0;
ge::graphStatus graph_status = ge::TensorUtils::GetTensorSizeInBytes(tensor_desc, tensor_size);
if (graph_status != ge::GRAPH_SUCCESS) {
GELOGE(FAILED, "GetTensorSizeInBytes failed!");
REPORT_CALL_ERROR("E19999", "GetTensorSizeInBytes failed");
GELOGE(FAILED, "[Invoke][GetTensorSizeInBytes] failed!");
return domi::FAILED;
}
// Set the actual occupied space size
@@ -146,7 +153,8 @@ Status DataOpParser::Init5DOutputTensor(const vector<int64_t> &shape, ge::GeTens
int64_t output_size = 0;
ge::graphStatus graph_status = ge::TensorUtils::GetTensorMemorySizeInBytes(output, output_size);
if (graph_status != ge::GRAPH_SUCCESS) {
GELOGE(FAILED, "GetTensorMemorySizeInBytes failed!");
REPORT_CALL_ERROR("E19999", "GetTensorMemorySizeInBytes failed!");
GELOGE(FAILED, "[Invoke][GetTensorMemorySizeInBytes] failed!");
return domi::FAILED;
}
// Set the actual occupied space size
@@ -186,7 +194,14 @@ Status DataOpParser::InitOutputTensor(const vector<int64_t> &shape, ge::GeTensor

ge::graphStatus graph_status = ge::TensorUtils::CalcTensorMemSize(output_shape, format, data_type, output_size);
if (graph_status != ge::GRAPH_SUCCESS) {
GELOGE(FAILED, "CalcTensorMemSize failed!");
REPORT_CALL_ERROR("E19999", "CalcTensorMemSize failed, shape:%s, format:%s, datatype:%s",
output_shape.ToString().c_str(),
ge::TypeUtils::FormatToSerialString(format).c_str(),
ge::TypeUtils::DataTypeToSerialString(data_type).c_str());
GELOGE(FAILED, "[Invoke][CalcTensorMemSize] failed, shape:%s, format:%s, datatype:%s",
output_shape.ToString().c_str(),
ge::TypeUtils::FormatToSerialString(format).c_str(),
ge::TypeUtils::DataTypeToSerialString(data_type).c_str());
return FAILED;
}

@@ -198,7 +213,14 @@ Status DataOpParser::InitOutputTensor(const vector<int64_t> &shape, ge::GeTensor
int64_t size = output_size;
auto valid_max_size = INT64_MAX - kTwoTimesAlign * kDataMemAlignSize;
if (size > valid_max_size || size < 0) {
GELOGE(FAILED, "The updated mem size is out of data range [0, %ld]", valid_max_size);
REPORT_INNER_ERROR("E19999", "updated mem size is out of data range [0, %ld], shape:%s, format:%s, datatype:%s",
valid_max_size, output_shape.ToString().c_str(),
ge::TypeUtils::FormatToSerialString(format).c_str(),
ge::TypeUtils::DataTypeToSerialString(data_type).c_str());
GELOGE(FAILED, "[Check][Size] updated mem size is out of data range [0, %ld], shape:%s, format:%s, datatype:%s",
valid_max_size, output_shape.ToString().c_str(),
ge::TypeUtils::FormatToSerialString(format).c_str(),
ge::TypeUtils::DataTypeToSerialString(data_type).c_str());
return FAILED;
} else {
size = ((size + kTwoTimesAlign * kDataMemAlignSize - 1) / kDataMemAlignSize) * kDataMemAlignSize;


+ 14
- 9
parser/common/model_saver.cc View File

@@ -35,7 +35,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi
const Json &model) {
Status ret = SUCCESS;
if (file_path == nullptr || SUCCESS != CheckPath(file_path)) {
GELOGE(FAILED, "Check output file failed.");
REPORT_INNER_ERROR("E19999", "param file_path is nullptr or checkpath not return success");
GELOGE(FAILED, "[Check][Param]Check output file failed.");
return FAILED;
}
std::string model_str;
@@ -43,16 +44,18 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi
model_str = model.dump(kInteval, ' ', false, Json::error_handler_t::ignore);
} catch (std::exception &e) {
ErrorManager::GetInstance().ATCReportErrMessage("E19007", {"exception"}, {e.what()});
GELOGE(FAILED, "Failed to convert JSON to string, reason: %s.", e.what());
GELOGE(FAILED, "[Invoke][Dump] Failed to convert JSON to string, reason: %s, savefile:%s.", e.what(), file_path);
return FAILED;
} catch (...) {
ErrorManager::GetInstance().ATCReportErrMessage("E19008");
GELOGE(FAILED, "Failed to convert JSON to string.");
GELOGE(FAILED, "[Invoke][Dump] Failed to convert JSON to string, savefile:%s.", file_path);
return FAILED;
}

char real_path[PATH_MAX] = {0};
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(file_path) >= PATH_MAX, return FAILED, "file path is too long!");
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(file_path) >= PATH_MAX,
REPORT_INNER_ERROR("E19999", "file path %s is too long!", file_path);
return FAILED, "[Check][Param] file path %s is too long!", file_path);
if (realpath(file_path, real_path) == nullptr) {
GELOGI("File %s does not exit, it will be created.", file_path);
}
@@ -62,7 +65,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi
int32_t fd = mmOpen2(real_path, O_RDWR | O_CREAT | O_TRUNC, mode);
if (fd == EN_ERROR || fd == EN_INVALID_PARAM) {
ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"}, {file_path, strerror(errno)});
GELOGE(FAILED, "Open file[%s] failed. %s", file_path, strerror(errno));
GELOGE(FAILED, "[Open][File] [%s] failed. %s", file_path, strerror(errno));
return FAILED;
}
const char *model_char = model_str.c_str();
@@ -73,12 +76,13 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi
ErrorManager::GetInstance().ATCReportErrMessage(
"E19004", {"file", "errmsg"}, {file_path, strerror(errno)});
// Need to both print the error info of mmWrite and mmClose, so return ret after mmClose
GELOGE(FAILED, "Write to file failed. errno = %ld, %s", mmpa_ret, strerror(errno));
GELOGE(FAILED, "[WriteTo][File] %s failed. errno = %ld, %s", file_path, mmpa_ret, strerror(errno));
ret = FAILED;
}
// Close file
if (mmClose(fd) != EN_OK) {
GELOGE(FAILED, "Close file failed.");
REPORT_INNER_ERROR("E19999", "close file:%s failed", file_path);
GELOGE(FAILED, "[Close][File] %s failed.", file_path);
ret = FAILED;
}
return ret;
@@ -87,7 +91,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::CheckPath(const std::string &file_path) {
// Determine file path length
if (file_path.size() >= PATH_MAX) {
GELOGE(FAILED, "Path is too long:%zu", file_path.size());
REPORT_INNER_ERROR("E19999", "Path is too long:%zu", file_path.size());
GELOGE(FAILED, "[Check][Param] Path is too long:%zu", file_path.size());
return FAILED;
}

@@ -106,7 +111,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::CheckPath(co
// If there is a path before the file name, create the path
if (path_split_pos != -1) {
if (CreateDirectory(std::string(file_path).substr(0, static_cast<size_t>(path_split_pos))) != kFileOpSuccess) {
GELOGE(FAILED, "CreateDirectory failed, file path:%s.", file_path.c_str());
GELOGE(FAILED, "[Create][Directory] failed, file path:%s.", file_path.c_str());
return FAILED;
}
}


+ 20
- 6
parser/common/op_def/ir_pb_converter.cc View File

@@ -94,8 +94,16 @@ static void UpdateTensorForOpDesc(const ParserOperator &op, ge::OpDescPtr op_def

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY domi::Status ConvertToOpDesc(const ParserOperator &op,
ge::OpDescPtr op_def) {
GE_RETURN_WITH_LOG_IF_TRUE(op_def == nullptr, "parameter is null.");
GE_CHK_BOOL_RET_STATUS(op.GetSchema(), domi::PARAM_INVALID, "Op schema is null, op type: %s", op.GetType().c_str());
if (op_def == nullptr) {
REPORT_INNER_ERROR("E19999", "param op_def is nullptr, check invalid.");
GELOGE(ge::FAILED, "[Check][Param] param op_def is nullptr, check invalid.");
return ge::FAILED;
}
if (op.GetSchema() == nullptr) {
REPORT_INNER_ERROR("E19999", "Op schema is nullptr, op type: %s", op.GetType().c_str());
GELOGE(domi::PARAM_INVALID, "[Get][Schema] Op schema is nullptr, op type: %s", op.GetType().c_str());
return domi::PARAM_INVALID;
}
op_def->SetName(op.GetName());
op_def->SetType(op.GetType());
GE_IF_BOOL_EXEC(op.GetType() == ge::parser::YOLO, op_def->SetType(ge::parser::REGION));
@@ -131,15 +139,21 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY domi::Status ConvertToOpDesc(co
}
}
}
GE_CHK_BOOL_RET_STATUS(op.GetSchema()->Verify(op_def), domi::PARAM_INVALID, "Op schema verify failed, op name: %s",
op.GetName().c_str());

if (!op.GetSchema()->Verify(op_def)) {
REPORT_CALL_ERROR("E19999", "Op schema verify failed, op name: %s", op.GetName().c_str());
GELOGE(domi::PARAM_INVALID, "[Invoke][Verify] Op schema verify failed, op name: %s", op.GetName().c_str());
return domi::PARAM_INVALID;
}
return domi::SUCCESS;
}

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY domi::Status ConvertFromOpDesc(const ge::OpDescPtr op_def,
ParserOperator &op) {
GE_RETURN_WITH_LOG_IF_TRUE(op_def == nullptr, "parameter is null.");
if (op_def == nullptr) {
REPORT_INNER_ERROR("E19999", "param op_def is nullptr, check invalid.");
GELOGE(ge::FAILED, "[Check][Param] param op_def is nullptr, check invalid.");
return ge::FAILED;
}
op.Name(op_def->GetName());

map<string, ge::GeAttrValue> allattrs = op_def->GetAllAttrs();


+ 20
- 8
parser/common/op_def/op_schema.cc View File

@@ -52,8 +52,10 @@ OpSchema &OpSchema::Attr(const Attribute &attr) {
#define ATTR_SETTER_WITH_SINGLE_VALUE(Type, field, attrtype) \
OpSchema &OpSchema::Attr(const std::string &name, AttributeType attr_type, const Type &default_value) { \
if (attrtype != attr_type) { \
GELOGE(FAILED, "Attribute specification param_type mismatch, input attr type %u, required attr type %u.", \
(uint32_t)attr_type, (uint32_t)attrtype); \
REPORT_INNER_ERROR("E19999", "Attribute specification param_type mismatch, input attr type %u, " \
"required attr type %u.", (uint32_t)attr_type, (uint32_t)attrtype); \
GELOGE(FAILED, "[Check][Param]Attribute specification param_type mismatch, " \
"input attr type %u, required attr type %u.", (uint32_t)attr_type, (uint32_t)attrtype); \
return *this; \
} \
\
@@ -80,8 +82,10 @@ OpSchema &OpSchema::Attr(const Attribute &attr) {
#define ATTR_SETTER_WITH_LIST_VALUE(Type, field, attrtype) \
OpSchema &OpSchema::Attr(const std::string &name, AttributeType attr_type, const std::vector<Type> &default_value) { \
if (attrtype != attr_type) { \
GELOGE(FAILED, "Attribute specification vector param_type mismatch, input attr type %u, required attr type %u.", \
(uint32_t)attr_type, (uint32_t)attrtype); \
REPORT_INNER_ERROR("E19999", "Attribute specification vector param_type mismatch, " \
"input attr type %u, required attr type %u.", (uint32_t)attr_type, (uint32_t)attrtype); \
GELOGE(FAILED, "[Check][Param]Attribute specification vector param_type mismatch, " \
"input attr type %u, required attr type %u.", (uint32_t)attr_type, (uint32_t)attrtype); \
return *this; \
} \
domi::AttrDef vec_a; \
@@ -93,8 +97,10 @@ OpSchema &OpSchema::Attr(const Attribute &attr) {
} \
OpSchema &OpSchema::Attr(const std::string &name, AttributeType attr_type, const Tuple<Type> &default_value) { \
if (attrtype != attr_type) { \
GELOGE(FAILED, "Attribute specification vector param_type mismatch, input attr type %u, required attr type %u.", \
(uint32_t)attr_type, (uint32_t)attrtype); \
REPORT_INNER_ERROR("E19999", "Attribute specification vector param_type mismatch, " \
"input attr type %u, required attr type %u.", (uint32_t)attr_type, (uint32_t)attrtype); \
GELOGE(FAILED, "[Check][Param]Attribute specification vector param_type mismatch, " \
"input attr type %u, required attr type %u.", (uint32_t)attr_type, (uint32_t)attrtype); \
return *this; \
} \
domi::AttrDef tuple_a; \
@@ -168,7 +174,10 @@ const domi::AttrDef &OpSchema::GetDefaultAttr(const std::string &name) const {

bool OpSchema::Verify(const ge::OpDescPtr op_def) const {
if (op_def->GetType() != name_) {
GELOGE(FAILED, "Name not math, op schema name: %s, opdef type: %s.", name_.c_str(), op_def->GetType().c_str());
REPORT_INNER_ERROR("E19999", "Name not math, op schema name: %s, opdef type: %s.",
name_.c_str(), op_def->GetType().c_str());
GELOGE(FAILED, "[Check][Param]Name not math, op schema name: %s, opdef type: %s.",
name_.c_str(), op_def->GetType().c_str());
return false;
}

@@ -179,7 +188,10 @@ bool OpSchema::Verify(const ge::OpDescPtr op_def) const {
continue;
}
if (!op_def->HasAttr(attr.name_)) {
GELOGE(FAILED, "Required attribute: %s of op: %s is missing.", attr.name_.c_str(), op_def->GetName().c_str());
REPORT_INNER_ERROR("E19999", "Required attribute: %s of op: %s is missing.",
attr.name_.c_str(), op_def->GetName().c_str());
GELOGE(FAILED, "[Invoke][HasAttr]Required attribute: %s of op: %s is missing.",
attr.name_.c_str(), op_def->GetName().c_str());
return false;
}
}


+ 6
- 5
parser/common/op_parser_factory.cc View File

@@ -54,7 +54,8 @@ FMK_FUNC_HOST_VISIBILITY std::shared_ptr<OpParserFactory> OpParserFactory::Insta
if (iter == instances.end()) {
std::shared_ptr<OpParserFactory> instance(new (std::nothrow) OpParserFactory());
if (instance == nullptr) {
GELOGE(INTERNAL_ERROR, "Create op parser factory failed.");
REPORT_CALL_ERROR("E19999", "create OpParserFactory failed");
GELOGE(INTERNAL_ERROR, "[Create][OpParserFactory] failed.");
return nullptr;
}
instances[framework] = instance;
@@ -70,8 +71,8 @@ FMK_FUNC_HOST_VISIBILITY std::shared_ptr<OpParser> OpParserFactory::CreateOpPars
if (iter != op_parser_creator_map_.end()) {
return iter->second();
}
GELOGE(FAILED, "OpParserFactory::CreateOpParser: Not supported type: %s", op_type.c_str());
REPORT_INNER_ERROR("E19999", "param op_type invalid, Not supported type: %s", op_type.c_str());
GELOGE(FAILED, "[Check][Param] OpParserFactory::CreateOpParser: Not supported type: %s", op_type.c_str());
return nullptr;
}

@@ -81,8 +82,8 @@ FMK_FUNC_HOST_VISIBILITY std::shared_ptr<OpParser> OpParserFactory::CreateFusion
if (iter != fusion_op_parser_creator_map_.end()) {
return iter->second();
}
GELOGE(FAILED, "OpParserFactory::CreateOpParser: Not supported fusion op type: %s", op_type.c_str());
REPORT_INNER_ERROR("E19999", "param op_type invalid, Not supported fusion op type: %s", op_type.c_str());
GELOGE(FAILED, "[Check][Param] OpParserFactory::CreateOpParser: Not supported fusion op type: %s", op_type.c_str());
return nullptr;
}



+ 4
- 4
parser/common/parser_factory.cc View File

@@ -28,8 +28,8 @@ std::shared_ptr<WeightsParser> WeightsParserFactory::CreateWeightsParser(const d
if (iter != creator_map_.end()) {
return iter->second();
}
GELOGE(FAILED, "WeightsParserFactory::CreateWeightsParser: Not supported Type: %d", type);
REPORT_INNER_ERROR("E19999", "param type invalid, Not supported Type: %d", type);
GELOGE(FAILED, "[Check][Param]WeightsParserFactory::CreateWeightsParser: Not supported Type: %d", type);
return nullptr;
}

@@ -58,8 +58,8 @@ std::shared_ptr<ModelParser> ModelParserFactory::CreateModelParser(const domi::F
if (iter != creator_map_.end()) {
return iter->second();
}
GELOGE(FAILED, "ModelParserFactory::CreateModelParser: Not supported Type: %d", type);
REPORT_INNER_ERROR("E19999", "param type invalid, Not supported Type: %d", type);
GELOGE(FAILED, "[Check][Param]ModelParserFactory::CreateModelParser: Not supported Type: %d", type);
return nullptr;
}



+ 50
- 16
parser/common/parser_utils.cc View File

@@ -47,7 +47,8 @@ Status HandleNewOp(const NodePtr &node,
GE_CHECK_NOTNULL(node);
GE_CHECK_NOTNULL(new_node);
if (new_node->SetOwnerComputeGraph(compute_graph) != GRAPH_SUCCESS) {
GELOGE(FAILED, "Set owner graph for node:%s failed.", new_node->GetName().c_str());
REPORT_CALL_ERROR("E19999", "SetOwnerComputeGraph failed for node:%s", new_node->GetName().c_str());
GELOGE(FAILED, "[Set][OwnerComputeGraph] for node:%s failed.", new_node->GetName().c_str());
return FAILED;
}
auto op_desc = new_node->GetOpDesc();
@@ -90,12 +91,13 @@ Status ParserUtils::ExpandOneToManyGraph(Graph &graph) {
Operator op = OpDescUtils::CreateOperatorFromNode(n);
Status ret = parse_op_to_graph_func(op, subgraph);
if (ret != SUCCESS) {
GELOGE(FAILED, "Get one to many graph failed for op:%s.", op.GetName().c_str());
REPORT_CALL_ERROR("E19999", "Get one to many graph failed for op:%s.", op.GetName().c_str());
GELOGE(FAILED, "[Invoke][ParseOpToGraphFunc]Get one to many graph failed for op:%s.", op.GetName().c_str());
return FAILED;
}
ret = ExpandNodeToSubgraph(subgraph, n, graph);
if (ret != SUCCESS) {
GELOGE(FAILED, "Expand one to many graph failed for op:%s.", op.GetName().c_str());
GELOGE(FAILED, "[Invoke][ExpandNodeToSubgraph]Expand one to many graph failed for op:%s.", op.GetName().c_str());
return FAILED;
}
}
@@ -116,7 +118,7 @@ Status ParserUtils::ExpandNodeToSubgraph(const Graph &subgraph, const NodePtr &n
auto new_node = compute_graph->AddNode(n);
GE_CHECK_NOTNULL(new_node);
if (HandleNewOp(node, compute_graph, new_node, no_need_change_name) != SUCCESS) {
GELOGE(FAILED, "Handle new op[%s] for node[%s] failed.", new_node->GetName().c_str(), node->GetName().c_str());
GELOGE(FAILED, "[Handle][NewOp][%s] for node[%s] failed.", new_node->GetName().c_str(), node->GetName().c_str());
return FAILED;
}
if (new_node->GetType() == ge::parser::DATA) {
@@ -127,7 +129,7 @@ Status ParserUtils::ExpandNodeToSubgraph(const Graph &subgraph, const NodePtr &n
// handle input context.
Status ret = HandleInputContext(node, input_nodes, compute_graph);
if (ret != SUCCESS) {
GELOGE(FAILED, "run ParserUtils::HandleInputContext failed.");
GELOGE(FAILED, "[Run][HandleInputContext] failed, node:%s.", node->GetName().c_str());
return FAILED;
}

@@ -135,18 +137,22 @@ Status ParserUtils::ExpandNodeToSubgraph(const Graph &subgraph, const NodePtr &n
std::vector<std::pair<NodePtr, int32_t>> out_node_index = sub_compute_graph->GetGraphOutNodesInfo();
ret = HandleOutputContext(node, out_node_index);
if (ret != SUCCESS) {
GELOGE(FAILED, "run ParserUtils::HandleOutputContext failed.");
GELOGE(FAILED, "[Run][HandleOutputContext] failed, node:%s.", node->GetName().c_str());
return FAILED;
}

graphStatus graph_status = GraphUtils::RemoveNodeWithoutRelink(compute_graph, node);
if (graph_status != GRAPH_SUCCESS) {
GELOGE(FAILED, "Remove node:%s failed.", node->GetName().c_str());
REPORT_CALL_ERROR("E19999", "Remove node:%s from graph:%s failed.", node->GetName().c_str(),
compute_graph->GetName().c_str());
GELOGE(FAILED, "[Remove][Node] %s from graph:%s failed.", node->GetName().c_str(),
compute_graph->GetName().c_str());
return FAILED;
}
graph_status = compute_graph->TopologicalSorting();
if (graph_status != GRAPH_SUCCESS) {
GELOGE(FAILED, "Topological sorting failed.");
REPORT_CALL_ERROR("E19999", "TopologicalSorting failed, graph:%s.", compute_graph->GetName().c_str());
GELOGE(FAILED, "[Invoke][TopologicalSorting] failed, graph:%s.", compute_graph->GetName().c_str());
return FAILED;
}
return SUCCESS;
@@ -160,7 +166,8 @@ Status ParserUtils::HandleInputContext(const NodePtr &node,
GE_CHECK_NOTNULL(in_n);
int index;
if (!AttrUtils::GetInt(in_n->GetOpDesc(), ATTR_NAME_INDEX, index)) {
GELOGE(FAILED, "Get attr index of node:%s failed.", in_n->GetName().c_str());
REPORT_INNER_ERROR("E19999", "GetInt failed, node:%s", in_n->GetName().c_str());
GELOGE(FAILED, "[Get][AttrIndex] of node:%s failed.", in_n->GetName().c_str());
return FAILED;
}
GELOGD("Begin to handle input node:%s with index:%d.", in_n->GetName().c_str(), index);
@@ -175,17 +182,29 @@ Status ParserUtils::HandleInputContext(const NodePtr &node,
// add data edge
graphStatus ret = GraphUtils::RemoveEdge(data_out_anchor, peer_in_anchor);
if (ret != GRAPH_SUCCESS) {
GELOGE(FAILED, "remove data out anchor and peer in anchor failed.");
REPORT_CALL_ERROR("E19999", "remove edge from %s to %s failed.",
data_out_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(FAILED, "[Remove][Edge] from %s to %s failed.", data_out_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str());
return FAILED;
}
ret = GraphUtils::RemoveEdge(src_out_anchor, node_in_anchor);
if (ret != GRAPH_SUCCESS) {
GELOGE(FAILED, "remove node in anchor and peer out anchor failed.");
REPORT_CALL_ERROR("E19999", "remove edge from %s to %s failed.",
src_out_anchor->GetOwnerNode()->GetName().c_str(),
node_in_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(FAILED, "[Remove][Edge] from %s to %s failed.", src_out_anchor->GetOwnerNode()->GetName().c_str(),
node_in_anchor->GetOwnerNode()->GetName().c_str());
return FAILED;
}
ret = GraphUtils::AddEdge(src_out_anchor, peer_in_anchor);
if (ret != GRAPH_SUCCESS) {
GELOGE(FAILED, "link node's peer out anchor and data's peer in anchor failed.");
REPORT_CALL_ERROR("E19999", "add edge from %s to %s failed.",
src_out_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(FAILED, "[Add][Edge] from %s to %s failed.", src_out_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str());
return FAILED;
}

@@ -194,7 +213,11 @@ Status ParserUtils::HandleInputContext(const NodePtr &node,
for (const auto &out_anchor : node->GetInControlAnchor()->GetPeerAnchors()) {
graphStatus ret = GraphUtils::AddEdge(out_anchor, peer_in_anchor->GetOwnerNode()->GetInControlAnchor());
if (ret != GRAPH_SUCCESS) {
GELOGE(FAILED, "add control edge failed.");
REPORT_CALL_ERROR("E19999", "add control edge from %s to %s failed.",
out_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(FAILED, "[Invoke][AddEdge]add control edge from %s to %s failed.",
out_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetOwnerNode()->GetName().c_str());
return FAILED;
}
}
@@ -202,7 +225,9 @@ Status ParserUtils::HandleInputContext(const NodePtr &node,
}
graphStatus ret = GraphUtils::RemoveNodeWithoutRelink(compute_graph, in_n);
if (ret != GRAPH_SUCCESS) {
GELOGE(FAILED, "remove node:%s failed.", in_n->GetName().c_str());
REPORT_CALL_ERROR("E19999", "RemoveNodeWithoutRelink failed, graph:%s, node:%s.",
compute_graph->GetName().c_str(), in_n->GetName().c_str());
GELOGE(FAILED, "[Remove][Node] %s failed, graph:%s.", in_n->GetName().c_str(), compute_graph->GetName().c_str());
return FAILED;
}
}
@@ -227,12 +252,21 @@ Status ParserUtils::HandleOutputContext(const NodePtr &node,
for (const auto &dest_in_anchor : node_out_anchor->GetPeerInDataAnchors()) {
graphStatus ret = GraphUtils::RemoveEdge(node_out_anchor, dest_in_anchor);
if (ret != GRAPH_SUCCESS) {
GELOGE(FAILED, "remove node's out anchor and peer in anchor failed.");
REPORT_CALL_ERROR("E19999", "remove edge from node %s to node %s failed.",
node_out_anchor->GetOwnerNode()->GetName().c_str(),
dest_in_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(FAILED, "[Remove][Edge] from node %s to node %s failed.",
node_out_anchor->GetOwnerNode()->GetName().c_str(),
dest_in_anchor->GetOwnerNode()->GetName().c_str());
return FAILED;
}
ret = GraphUtils::AddEdge(src_out_anchor, dest_in_anchor);
if (ret != GRAPH_SUCCESS) {
GELOGE(FAILED, "link node's peer out anchor and out node's out anchor failed.");
REPORT_CALL_ERROR("E19999", "Add edge from %s to %s failed.",
src_out_anchor->GetOwnerNode()->GetName().c_str(),
dest_in_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(FAILED, "[Add][Edge] from %s to %s failed.", src_out_anchor->GetOwnerNode()->GetName().c_str(),
dest_in_anchor->GetOwnerNode()->GetName().c_str());
return FAILED;
}
}


+ 6
- 2
parser/common/pass_manager.cc View File

@@ -55,7 +55,8 @@ Status PassManager::Run(const ComputeGraphPtr &graph, vector<std::pair<std::stri
}
for (const auto &subgraph :graph->GetAllSubgraphs()) {
GE_CHECK_NOTNULL(subgraph);
GE_CHK_STATUS_RET(pass->ClearStatus(), "pass clear status failed for subgraph %s", subgraph->GetName().c_str());
GE_CHK_STATUS_RET(pass->ClearStatus(), "[Invoke][ClearStatus]pass clear status failed for subgraph %s",
subgraph->GetName().c_str());
string subgraph_pass_name = pass_name + "::" + graph->GetName();
PARSER_TIMESTAMP_START(PassRunSubgraph);
status = pass->Run(subgraph);
@@ -63,7 +64,10 @@ Status PassManager::Run(const ComputeGraphPtr &graph, vector<std::pair<std::stri
if (status == SUCCESS) {
not_changed = false;
} else if (status != NOT_CHANGED) {
GELOGE(status, "Pass Run failed on subgraph %s", subgraph->GetName().c_str());
REPORT_CALL_ERROR("E19999", "Pass Run failed on subgraph %s, pass name:%s",
subgraph->GetName().c_str(), subgraph_pass_name.c_str());
GELOGE(status, "[Invoke][Run]Pass Run failed on subgraph %s, pass name:%s",
subgraph->GetName().c_str(), subgraph_pass_name.c_str());
return status;
}
}


+ 18
- 15
parser/common/pre_checker.cc View File

@@ -75,7 +75,8 @@ FMK_FUNC_HOST_VISIBILITY PreChecker &PreChecker::Instance() {
FMK_FUNC_HOST_VISIBILITY void PreChecker::SetModelName(const string &name) { model_name_ = name; }

FMK_FUNC_HOST_VISIBILITY Status PreChecker::AddOp(OpId id, const string &name, const string &type) {
GE_RETURN_WITH_LOG_IF_TRUE(op_map_.find(id) != op_map_.end(), "Id already exists.");
GE_RETURN_WITH_LOG_IF_TRUE(op_map_.find(id) != op_map_.end(),
"[Check][Param] Id already exists, name:%s, type:%s.", name.c_str(), type.c_str());

Info info;
info.id = id;
@@ -89,7 +90,7 @@ FMK_FUNC_HOST_VISIBILITY Status PreChecker::AddOp(OpId id, const string &name, c

Status PreChecker::CheckName(OpId id) {
auto iter = op_map_.find(id);
GE_RETURN_WITH_LOG_IF_TRUE(iter == op_map_.end(), "Id does not exist.");
GE_RETURN_WITH_LOG_IF_TRUE(iter == op_map_.end(), "[Check][Param] Id does not exist.");

Info &info = iter->second;
for (auto &v : op_map_) {
@@ -101,8 +102,8 @@ Status PreChecker::CheckName(OpId id) {

GELOGI("Name %s repeated.", info.name.c_str());
ErrorManager::GetInstance().ATCReportErrMessage("E19009", {"opname"}, {info.name});
GE_RETURN_WITH_LOG_IF_ERROR(AddCause(id, cause), "Add cause failed.");
GE_RETURN_WITH_LOG_IF_ERROR(AddCause(v.first, cause), "Add cause failed.");
GE_RETURN_WITH_LOG_IF_ERROR(AddCause(id, cause), "[Add][Cause] failed.");
GE_RETURN_WITH_LOG_IF_ERROR(AddCause(v.first, cause), "[Add][Cause] failed.");
break;
}
}
@@ -112,7 +113,7 @@ Status PreChecker::CheckName(OpId id) {

FMK_FUNC_HOST_VISIBILITY Status PreChecker::CheckType(OpId id, bool is_tensorflow) {
auto iter = op_map_.find(id);
GE_RETURN_WITH_LOG_IF_TRUE(iter == op_map_.end(), "Id does not exist.");
GE_RETURN_WITH_LOG_IF_TRUE(iter == op_map_.end(), "[Check][Param] Id does not exist.");

Info &info = iter->second;
string type = info.type;
@@ -125,8 +126,9 @@ FMK_FUNC_HOST_VISIBILITY Status PreChecker::CheckType(OpId id, bool is_tensorflo
}

// Judge whether the type is supported
GE_RETURN_WITH_LOG_IF_ERROR(
CheckTypeSupported(info.id, type, info.name, is_tensorflow), "Check type supported failed.");
GE_RETURN_WITH_LOG_IF_ERROR(CheckTypeSupported(info.id, type, info.name, is_tensorflow),
"[Invoke][CheckTypeSupported] failed, type:%s, name:%s.",
type.c_str(), info.name.c_str());

return SUCCESS;
}
@@ -151,7 +153,7 @@ FMK_FUNC_HOST_VISIBILITY void PreChecker::RefreshErrorMessageByName(const string

Status PreChecker::AddCause(OpId id, const Cause &cause) {
auto iter = op_map_.find(id);
GE_RETURN_WITH_LOG_IF_TRUE(iter == op_map_.end(), "Id does not exist.");
GE_RETURN_WITH_LOG_IF_TRUE(iter == op_map_.end(), "[Check][Param] Id does not exist.");

Info &info = iter->second;

@@ -171,7 +173,7 @@ void PreChecker::Clear() { Init(); }

Status PreChecker::Clear(OpId id, const string &message) {
auto iter = op_map_.find(id);
GE_RETURN_WITH_LOG_IF_TRUE(iter == op_map_.end(), "Id does not exist.");
GE_RETURN_WITH_LOG_IF_TRUE(iter == op_map_.end(), "[Check][Param] Id does not exist.");

Info &info = iter->second;
info.causes.clear();
@@ -181,7 +183,7 @@ Status PreChecker::Clear(OpId id, const string &message) {
Cause cause;
cause.code = ErrorCode::OK;
cause.message = message;
GE_RETURN_WITH_LOG_IF_ERROR(AddCause(id, cause), "Add cause failed.");
GE_RETURN_WITH_LOG_IF_ERROR(AddCause(id, cause), "[Add][Cause] failed.");
}

return SUCCESS;
@@ -216,7 +218,7 @@ Status PreChecker::Save(string file) {
// Constructing JSON information of operators in order of network
for (auto id : ops_) {
auto iter = op_map_.find(id);
GE_CHK_BOOL_RET_STATUS(iter != op_map_.end(), FAILED, "don't find this op.");
GE_CHK_BOOL_RET_STATUS(iter != op_map_.end(), FAILED, "[Check][Param] don't find this op.");
Info &info = iter->second;

// Initialization operator general information
@@ -233,7 +235,8 @@ Status PreChecker::Save(string file) {
}

// Save JSON data to a file
GE_RETURN_WITH_LOG_IF_ERROR(ge::parser::ModelSaver::SaveJsonToFile(file.c_str(), model), "Save failed.");
GE_RETURN_WITH_LOG_IF_ERROR(ge::parser::ModelSaver::SaveJsonToFile(file.c_str(), model),
"[Invoke][SaveJsonToFile]Save failed, file:%s.", file.c_str());

return SUCCESS;
}
@@ -250,7 +253,7 @@ Status PreChecker::CheckTypeSupported(OpId id, const string &type, const string
if (!is_tensorflow) {
ErrorManager::GetInstance().ATCReportErrMessage("E19010", {"opname", "optype"}, {name, type});
}
GE_RETURN_WITH_LOG_IF_ERROR(AddCause(id, cause), "Add cause failed.");
GE_RETURN_WITH_LOG_IF_ERROR(AddCause(id, cause), "[Add][Cause] failed.");
}
return SUCCESS;
}
@@ -265,7 +268,7 @@ Status PreChecker::CheckTypeSupported(OpId id, const string &type, const string
if (!is_tensorflow) {
ErrorManager::GetInstance().ATCReportErrMessage("E19010", {"opname", "optype"}, {name, type});
}
GE_RETURN_WITH_LOG_IF_ERROR(AddCause(id, cause), "Add cause failed.");
GE_RETURN_WITH_LOG_IF_ERROR(AddCause(id, cause), "[Add][Cause] failed.");
}

return SUCCESS;
@@ -273,7 +276,7 @@ Status PreChecker::CheckTypeSupported(OpId id, const string &type, const string

bool PreChecker::HasError(OpId id) {
auto iter = op_map_.find(id);
GE_RETURN_WITH_LOG_IF_TRUE(iter == op_map_.end(), "Id does not exist.");
GE_RETURN_WITH_LOG_IF_TRUE(iter == op_map_.end(), "[Check][Param] Id does not exist.");

Info &info = iter->second;
for (const Cause &cause : info.causes) {


+ 33
- 16
parser/common/proto_file_parser.cc View File

@@ -130,12 +130,16 @@ bool SaveIdentifierOpMapInfo(const string &line, std::map<int, std::pair<string
GetOpParamInfo(line, op_param_info);
int info_size = op_param_info.size();
if (info_size < kMinLineWordSize) {
GELOGE(ge::FAILED, "Words size of line[%s] is less than kMinLineWordSize[%d].", line.c_str(), kMinLineWordSize);
REPORT_INNER_ERROR("E19999", "Words size:%d of line[%s] is less than kMinLineWordSize[%d].",
info_size, line.c_str(), kMinLineWordSize);
GELOGE(ge::FAILED, "[Check][Size] Words size:%d of line[%s] is less than kMinLineWordSize[%d].",
info_size, line.c_str(), kMinLineWordSize);
return false;
}

if (op_param_info[0] != kOptional && op_param_info[0] != kRepeated && op_param_info[0] != kRequired) {
GELOGE(ge::FAILED, "Split line[%s] failed.", line.c_str());
REPORT_INNER_ERROR("E19999", "Split line[%s] failed.", line.c_str());
GELOGE(ge::FAILED, "[Check][Param] Split line[%s] failed.", line.c_str());
return false;
}

@@ -143,7 +147,7 @@ bool SaveIdentifierOpMapInfo(const string &line, std::map<int, std::pair<string
int identifier = 0;
bool ret = GetIdentifier(line, identifier);
if (!ret) {
GELOGE(ge::FAILED, "Get identifier of line[%s] failed.", line.c_str());
GELOGE(ge::FAILED, "[Get][Identifier] of line[%s] failed.", line.c_str());
return false;
}

@@ -185,7 +189,8 @@ Status ProtoFileParser::CreatProtoFile() {

int fd = open(fusion_proto_path.c_str(), O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP);
if (fd < kOpenRetValue) {
GELOGE(FAILED, "creat tmp proto file[%s] failed.", fusion_proto_path.c_str());
REPORT_INNER_ERROR("E19999", "creat tmp proto file[%s] failed.", fusion_proto_path.c_str());
GELOGE(FAILED, "[Open][File] creat tmp proto file[%s] failed.", fusion_proto_path.c_str());
return FAILED;
}
close(fd);
@@ -198,7 +203,8 @@ Status ProtoFileParser::ParseProtoFile(const string &proto_file,
ifstream read_file;
read_file.open(proto_file, std::ios::in);
if (read_file.fail()) {
GELOGE(FAILED, "ifsream open proto file[%s] failed.", proto_file.c_str());
REPORT_INNER_ERROR("E19999", "ifsream open proto file[%s] failed.", proto_file.c_str());
GELOGE(FAILED, "[Open][File] ifsream open proto file[%s] failed.", proto_file.c_str());
return FAILED;
}

@@ -235,7 +241,8 @@ Status ProtoFileParser::AddCustomAndConflictLayer(const char *custom_proto_file,
ifstream read_custom;
read_custom.open(custom_proto_file, std::ios::in);
if (read_custom.fail()) {
GELOGE(FAILED, "ifsream open custom proto file[%s] failed.", custom_proto_file);
REPORT_INNER_ERROR("E19999", "ifsream open custom proto file[%s] failed.", custom_proto_file);
GELOGE(FAILED, "[Open][File] ifsream open custom proto file[%s] failed.", custom_proto_file);
return FAILED;
}

@@ -273,7 +280,8 @@ Status ProtoFileParser::AddCustomAndConflictMessage(const char *custom_proto_fil
ifstream read_custom;
read_custom.open(custom_proto_file, std::ios::in);
if (read_custom.fail()) {
GELOGE(FAILED, "ifsream open custom proto file[%s] failed.", custom_proto_file);
REPORT_INNER_ERROR("E19999", "ifsream open custom proto file[%s] failed.", custom_proto_file);
GELOGE(FAILED, "[Open][File] ifsream open custom proto file[%s] failed.", custom_proto_file);
return FAILED;
}

@@ -324,7 +332,8 @@ Status ProtoFileParser::WriteCaffeProtoFile(const char *custom_proto_file,
}
if (caffe_in_layer && line_caffe.find(kCloseBrace) != std::string::npos) {
if (AddCustomAndConflictLayer(custom_proto_file, write_tmp) != SUCCESS) {
GELOGE(FAILED, "Add conflict and new layer line from custom proto to dest proto failed.");
GELOGE(FAILED, "[Invoke][AddCustomAndConflictLayer] Add conflict and new layer line "
"from custom proto to dest proto failed, protofile:%s.", custom_proto_file);
return FAILED;
}
caffe_in_layer = false;
@@ -346,12 +355,14 @@ Status ProtoFileParser::WriteProtoFile(const char *caffe_proto_file,
std::ofstream write_tmp;
read_caffe.open(caffe_proto_file, std::ios::in);
if (read_caffe.fail()) {
GELOGE(FAILED, "ifsream open proto file[%s] failed.", caffe_proto_file);
REPORT_INNER_ERROR("E19999", "ifsream open proto file[%s] failed.", caffe_proto_file);
GELOGE(FAILED, "[Open][File] ifsream open proto file[%s] failed.", caffe_proto_file);
return FAILED;
}
write_tmp.open(fusion_proto_path, std::ios::out);
if (write_tmp.fail()) {
GELOGE(FAILED, "ofstream open proto file[%s] failed.", fusion_proto_path.c_str());
REPORT_INNER_ERROR("E19999", "ofstream open proto file[%s] failed.", fusion_proto_path.c_str());
GELOGE(FAILED, "[Open][File] ofstream open proto file[%s] failed.", fusion_proto_path.c_str());
read_caffe.close();
return FAILED;
}
@@ -363,7 +374,8 @@ Status ProtoFileParser::WriteProtoFile(const char *caffe_proto_file,
}

if (AddCustomAndConflictMessage(custom_proto_file, write_tmp) != SUCCESS) {
GELOGE(FAILED, "Add conflict and new message from custom proto to dest proto failed.");
GELOGE(FAILED, "[Invoke][AddCustomAndConflictMessage] Add conflict and new message from custom proto "
"to dest proto failed, proto file:%s.", custom_proto_file);
read_caffe.close();
write_tmp.close();
return FAILED;
@@ -379,7 +391,8 @@ Status ProtoFileParser::FindConflictLine(const char *proto_file, int identifier,
ifstream read_file;
read_file.open(proto_file, std::ios::in);
if (read_file.fail()) {
GELOGE(FAILED, "open file[%s] failed.", proto_file);
REPORT_INNER_ERROR("E19999", "open file[%s] failed.", proto_file);
GELOGE(FAILED, "[Open][File] [%s] failed.", proto_file);
return FAILED;
}

@@ -404,7 +417,8 @@ Status ProtoFileParser::FindConflictLine(const char *proto_file, int identifier,
}
}
read_file.close();
GELOGE(FAILED, "find line according to identifier[%d] failed.", identifier);
REPORT_INNER_ERROR("E19999", "find line according to identifier[%d] failed.", identifier);
GELOGE(FAILED, "[Find][Line] according to identifier[%d] failed.", identifier);
return FAILED;
}

@@ -467,7 +481,8 @@ Status ProtoFileParser::RecordProtoMessage(const string &proto_file) {
ifstream read_file;
read_file.open(proto_file, std::ios::in);
if (read_file.fail()) {
GELOGE(FAILED, "ifsream open proto file[%s] failed.", proto_file.c_str());
REPORT_INNER_ERROR("E19999", "ifsream open proto file[%s] failed.", proto_file.c_str());
GELOGE(FAILED, "[Open][File] ifsream open proto file[%s] failed.", proto_file.c_str());
return FAILED;
}

@@ -490,7 +505,9 @@ Status ProtoFileParser::CombineProtoFile(const char *caffe_proto_file, const cha
GE_CHECK_NOTNULL(custom_proto_file);

if (!CheckRealPath(caffe_proto_file) || !CheckRealPath(custom_proto_file)) {
GELOGE(FAILED, "caffe proto[%s] and custom proto[%s] are not all existed.",
REPORT_CALL_ERROR("E19999", "caffe proto[%s] or custom proto[%s] is not existed.",
caffe_proto_file, custom_proto_file);
GELOGE(FAILED, "[Check][Param] caffe proto[%s] or custom proto[%s] is not existed.",
caffe_proto_file, custom_proto_file);
return FAILED;
}
@@ -516,7 +533,7 @@ Status ProtoFileParser::CombineProtoFile(const char *caffe_proto_file, const cha
}

if (WriteProtoFile(caffe_proto_file, custom_proto_file) != SUCCESS) {
GELOGE(FAILED, "Combine caffe proto and custom proto to dest proto file failed.");
GELOGE(FAILED, "[Write][ProtoFile] Combine caffe proto and custom proto to dest proto file failed.");
return FAILED;
}
dest_proto_file.assign(fusion_proto_path);


+ 12
- 5
parser/common/register_tbe.cc View File

@@ -67,7 +67,8 @@ bool OpRegistrationTbe::RegisterParser(const OpRegistrationData &reg_data) {
if (reg_data.GetFrameworkType() == domi::TENSORFLOW) {
std::shared_ptr<OpParserFactory> factory = OpParserFactory::Instance(domi::TENSORFLOW);
if (factory == nullptr) {
GELOGE(INTERNAL_ERROR, "Get op parser factory for tf failed.");
REPORT_CALL_ERROR("E19999", "Get OpParserFactory failed.");
GELOGE(INTERNAL_ERROR, "[Get][OpParserFactory] for tf failed.");
return false;
}
if (reg_data.GetParseParamFn() != nullptr || reg_data.GetParseParamByOperatorFn() != nullptr) {
@@ -79,7 +80,8 @@ bool OpRegistrationTbe::RegisterParser(const OpRegistrationData &reg_data) {
std::shared_ptr<TensorFlowCustomParserAdapter> tf_parser_adapter =
ge::parser::MakeShared<TensorFlowCustomParserAdapter>();
if (tf_parser_adapter == nullptr) {
GELOGE(PARAM_INVALID, "Create tf parser adapter failed.");
REPORT_CALL_ERROR("E19999", "Create TensorFlowCustomParserAdapter failed.");
GELOGE(PARAM_INVALID, "[Create][TensorFlowCustomParserAdapter] failed.");
return false;
}
OpParserRegisterar registerar __attribute__((unused)) = OpParserRegisterar(
@@ -95,7 +97,8 @@ bool OpRegistrationTbe::RegisterParser(const OpRegistrationData &reg_data) {
std::shared_ptr<TensorFlowFusionCustomParserAdapter> tf_fusion_parser_adapter =
ge::parser::MakeShared<TensorFlowFusionCustomParserAdapter>();
if (tf_fusion_parser_adapter == nullptr) {
GELOGE(PARAM_INVALID, "Create tf fusion parser adapter failed.");
REPORT_CALL_ERROR("E19999", "Create TensorFlowFusionCustomParserAdapter failed.");
GELOGE(PARAM_INVALID, "[Create][TensorFlowFusionCustomParserAdapter] failed.");
return false;
}
OpParserRegisterar registerar __attribute__((unused)) = OpParserRegisterar(
@@ -105,7 +108,9 @@ bool OpRegistrationTbe::RegisterParser(const OpRegistrationData &reg_data) {
} else {
std::shared_ptr<OpParserFactory> factory = OpParserFactory::Instance(reg_data.GetFrameworkType());
if (factory == nullptr) {
GELOGE(INTERNAL_ERROR, "Get op parser factory for %s failed.",
REPORT_CALL_ERROR("E19999", "Get OpParserFactory for %s failed.",
TypeUtils::FmkTypeToSerialString(reg_data.GetFrameworkType()).c_str());
GELOGE(INTERNAL_ERROR, "[Get][OpParserFactory] for %s failed.",
TypeUtils::FmkTypeToSerialString(reg_data.GetFrameworkType()).c_str());
return false;
}
@@ -117,7 +122,9 @@ bool OpRegistrationTbe::RegisterParser(const OpRegistrationData &reg_data) {

PARSER_CREATOR_FN func = CustomParserAdapterRegistry::Instance()->GetCreateFunc(reg_data.GetFrameworkType());
if (func == nullptr) {
GELOGE(INTERNAL_ERROR, "Get custom parser adapter failed for fmk type %s.",
REPORT_CALL_ERROR("E19999", "Get custom parser adapter failed for fmk type %s.",
TypeUtils::FmkTypeToSerialString(reg_data.GetFrameworkType()).c_str());
GELOGE(INTERNAL_ERROR, "[Get][CustomParserAdapter] failed for fmk type %s.",
TypeUtils::FmkTypeToSerialString(reg_data.GetFrameworkType()).c_str());
return false;
}


+ 15
- 9
parser/onnx/onnx_constant_parser.cc View File

@@ -36,7 +36,8 @@ namespace ge {
Status OnnxConstantParser::ParseConvertData(const ge::onnx::TensorProto &tensor_proto, ge::Tensor &tensor, int count) {
int64_t data_type = tensor_proto.data_type();
if (ge::OnnxUtil::ConvertOnnxDataType(data_type) == ge::DataType::DT_UNDEFINED) {
GELOGE(FAILED, "data_type %ld not support.", data_type);
REPORT_INNER_ERROR("E19999", "data_type %ld not support.", data_type);
GELOGE(FAILED, "[Check][Param] data_type %ld not support.", data_type);
return FAILED;
}

@@ -74,14 +75,16 @@ Status OnnxConstantParser::ParseConvertData(const ge::onnx::TensorProto &tensor_
if (iter != datatype_val_size_map.end()) {
datatype_val_size = iter->second;
} else {
GELOGE(domi::PARAM_INVALID, "data_type %ld not support.", data_type);
REPORT_INNER_ERROR("E19999", "data_type %ld not support.", data_type);
GELOGE(domi::PARAM_INVALID, "[Find][DataType]data_type %ld not support.", data_type);
return FAILED;
}

// find raw data
if (datatype_val_size == 0) {
if (tensor_proto.raw_data().empty()) {
GELOGE(domi::PARAM_INVALID, "tensor_proto has no data() elements or raw_data()");
REPORT_INNER_ERROR("E19999", "tensor_proto has no elements or raw_data");
GELOGE(domi::PARAM_INVALID, "[Check][Param]tensor_proto has no elements or raw_data");
return FAILED;
}

@@ -161,7 +164,8 @@ Status OnnxConstantParser::ParseConvertTensor(const ge::onnx::TensorProto &tenso
int64_t dim = tmp_shape[i];
// support weights shape [0],have no weights
if (dim < 0 || (count != 0 && (dim >= INT64_MAX / count))) {
GELOGE(FAILED, "Dim size is invalid, dim is less than zero or dim size exceeds INT64_MAX.");
REPORT_INNER_ERROR("E19999", "Dim size is invalid, dim is less than zero or dim size exceeds INT64_MAX.");
GELOGE(FAILED, "[Check][Param] Dim size is invalid, dim is less than zero or dim size exceeds INT64_MAX.");
return FAILED;
}
count *= dim;
@@ -172,7 +176,7 @@ Status OnnxConstantParser::ParseConvertTensor(const ge::onnx::TensorProto &tenso

// set data
if (ParseConvertData(tensor_proto, tensor, count) != SUCCESS) {
GELOGE(FAILED, "Convert ge tensor data and format failed.");
GELOGE(FAILED, "[Invoke][ParseConvertData]Convert ge tensor data and format failed.");
return FAILED;
}
return SUCCESS;
@@ -182,7 +186,8 @@ Status OnnxConstantParser::ParseConvertDataType(const ge::onnx::TensorProto &ten
int64_t data_type = tensor_proto.data_type();
ge::DataType type = ge::OnnxUtil::ConvertOnnxDataType(data_type);
if (type == ge::DataType::DT_UNDEFINED) {
GELOGE(domi::PARAM_INVALID, "tensor_proto date type %ld is undefined.", data_type);
REPORT_INNER_ERROR("E19999", "tensor_proto date type %ld is undefined.", data_type);
GELOGE(domi::PARAM_INVALID, "[Check][Param] tensor_proto date type %ld is undefined.", data_type);
return FAILED;
}

@@ -204,12 +209,13 @@ Status OnnxConstantParser::ParseConstFromInput(const ge::onnx::NodeProto *op_src
}
const ::ge::onnx::TensorProto it_tensor = it.t();
if (ParseConvertDataType(it_tensor, tensor) != SUCCESS) {
GELOGE(FAILED, "Convert ge tensor date type failed, attribute name is %s.", it.name().c_str());
GELOGE(FAILED, "[Check][Param] Convert ge tensor date type failed, attribute name is %s.", it.name().c_str());
return FAILED;
}

if (ParseConvertTensor(it_tensor, tensor) != SUCCESS) {
GELOGE(FAILED, "Convert ge tensor shape and format failed, attribute name is %s.", it.name().c_str());
GELOGE(FAILED, "[Check][Param] Convert ge tensor shape and format failed, attribute name is %s.",
it.name().c_str());
return FAILED;
}
}
@@ -225,7 +231,7 @@ Status OnnxConstantParser::ParseParams(const Message *op_src, ge::Operator &op_d
GELOGD("Onnx op node name = %s, op type= %s, parse params", node->name().c_str(), node->op_type().c_str());

if (ParseConstFromInput(node, op_def) != SUCCESS) {
GELOGE(FAILED, "Parse constant node %s failed", node->name().c_str());
GELOGE(FAILED, "[Parse][Constant] node %s failed", node->name().c_str());
return FAILED;
}
return SUCCESS;


+ 1
- 1
parser/onnx/onnx_custom_parser_adapter.cc View File

@@ -34,7 +34,7 @@ Status OnnxCustomParserAdapter::ParseParams(const Message *op_src, ge::Operator
custom_op_parser = domi::OpRegistry::Instance()->GetParseParamFunc(op_dest.GetOpType(), node_src->op_type());
GE_CHECK_NOTNULL(custom_op_parser);
if (custom_op_parser(op_src, op_dest) != SUCCESS) {
GELOGE(FAILED, "Custom parser params failed.");
GELOGE(FAILED, "[Invoke][Custom_Op_Parser] Custom parser params failed.");
return FAILED;
}
return SUCCESS;


+ 4
- 3
parser/onnx/onnx_data_parser.cc View File

@@ -32,7 +32,7 @@ Status OnnxDataParser::ParseParams(const Message *op_src, ge::Operator &op_def)
GE_CHECK_NOTNULL(node_src);
GELOGD("Onnx op node name = %s, op type= %s, parse params", node_src->name().c_str(), node_src->op_type().c_str());
if (ParseInputFromModel(op_src, op_def) != SUCCESS) {
GELOGE(FAILED, "parse shape of data op %s from model failed", op_def.GetName().c_str());
GELOGE(FAILED, "[Parse][Shape] of data op %s from model failed", op_def.GetName().c_str());
return FAILED;
}
// Subgraph data operator don't need parse input shape
@@ -42,7 +42,7 @@ Status OnnxDataParser::ParseParams(const Message *op_src, ge::Operator &op_def)
}

if (ParseInputFromUser(op_def) != SUCCESS) {
GELOGE(FAILED, "parse shape of data op %s from user failed", op_def.GetName().c_str());
GELOGE(FAILED, "[Parse][Shape] of data op %s from user failed", op_def.GetName().c_str());
return FAILED;
}

@@ -97,7 +97,8 @@ Status OnnxDataParser::ParseInputFromModel(const Message *op_src, ge::Operator &
// Trans onnx type to ge type
DataType type = OnnxUtil::ConvertOnnxDataType(data_type);
if (type == ge::DataType::DT_UNDEFINED) {
GELOGE(domi::PARAM_INVALID, "tensor_proto date type %ld is undefined.", data_type);
REPORT_INNER_ERROR("E19999", "tensor_proto date type %ld is undefined.", data_type);
GELOGE(domi::PARAM_INVALID, "[Check][Param]tensor_proto date type %ld is undefined.", data_type);
return FAILED;
}
op_def.SetAttr(ge::DATA_ATTR_NAME_DATA_TYPE, static_cast<int64_t>(type));


+ 61
- 42
parser/onnx/onnx_parser.cc View File

@@ -51,13 +51,15 @@ graphStatus PrepareBeforeParse(AclGrphParseUtil &acl_graph_parse_util,
options.insert(std::pair<string, string>(string(ge::FRAMEWORK_TYPE), to_string(domi::ONNX)));

if (acl_graph_parse_util.AclParserInitialize(options) != ge::SUCCESS) {
GELOGE(ge::FAILED, "Acl parser initialize failed.");
REPORT_CALL_ERROR("E19999", "AclParserInitialize failed.");
GELOGE(ge::FAILED, "[Init][AclParser] failed.");
return ge::FAILED;
}

string output_name;
if (acl_graph_parse_util.ParseParamsBeforeGraph(parser_params, output_name) != ge::SUCCESS) {
GELOGE(ge::FAILED, "Parser params before graph failed.");
REPORT_CALL_ERROR("E19999", "ParseParamsBeforeGraph failed.");
GELOGE(ge::FAILED, "[Parser][Params] before graph failed.");
return ge::FAILED;
}
// Create an empty computegraph
@@ -75,12 +77,14 @@ graphStatus HandleAfterParse(AclGrphParseUtil &acl_graph_parse_util,
const std::map<AscendString, AscendString> &parser_params,
ge::Graph &graph) {
if (acl_graph_parse_util.ParseParamsAfterGraph(graph, parser_params) != ge::SUCCESS) {
GELOGE(ge::FAILED, "Parser params after graph failed.");
REPORT_CALL_ERROR("E19999", "ParseParamsAfterGraph failed.");
GELOGE(ge::FAILED, "[Parser][Params] after graph failed.");
return ge::FAILED;
}

if (acl_graph_parse_util.SetOutputNodeInfo(graph, parser_params) != ge::SUCCESS) {
GELOGE(ge::FAILED, "Set graph %s default output node failed.", graph.GetName().c_str());
REPORT_CALL_ERROR("E19999", "Set graph default output node failed.");
GELOGE(ge::FAILED, "[Update][NodeInfo] Set graph %s default output node failed.", graph.GetName().c_str());
return ge::FAILED;
}
return ge::SUCCESS;
@@ -94,7 +98,7 @@ graphStatus aclgrphParseONNX(const char *model_file,
std::shared_ptr<domi::ModelParser> model_parser;

if (PrepareBeforeParse(acl_graph_parse_util, parser_params, graph, model_parser) != ge::SUCCESS) {
GELOGE(ge::FAILED, "Prepare before parse failed.");
GELOGE(ge::FAILED, "[Invoke][PrepareBeforeParse] failed.");
return ge::FAILED;
}

@@ -102,13 +106,14 @@ graphStatus aclgrphParseONNX(const char *model_file,
// parse onnx model_file to GE graph
ge::graphStatus ret = model_parser->Parse(model_file, graph);
if (ret != ge::SUCCESS) {
GELOGE(ret, "Parser graph %s failed.", graph.GetName().c_str());
REPORT_CALL_ERROR("E19999", "parse modelfile %s failed, graph:%s", model_file, graph.GetName().c_str());
GELOGE(ret, "[Parse][ModelFile] %s failed, graph %s.", model_file, graph.GetName().c_str());
return ge::FAILED;
}
GELOGI("Parser graph %s success.", graph.GetName().c_str());

if (HandleAfterParse(acl_graph_parse_util, parser_params, graph) != ge::SUCCESS) {
GELOGE(ge::FAILED, "Handle after parse failed.");
GELOGE(ge::FAILED, "[Invoke][HandleAfterParse] failed.");
return ge::FAILED;
}

@@ -124,20 +129,21 @@ graphStatus aclgrphParseONNXFromMem(const char *buffer, size_t size,
std::shared_ptr<domi::ModelParser> model_parser;

if (PrepareBeforeParse(acl_graph_parse_util, parser_params, graph, model_parser) != ge::SUCCESS) {
GELOGE(ge::FAILED, "Prepare before parse failed.");
GELOGE(ge::FAILED, "[Invoke][PrepareBeforeParse] failed.");
return ge::FAILED;
}

// parse caffe model_file to GE graph
ge::graphStatus ret = model_parser->ParseFromMemory(buffer, (uint32_t)size, graph);
if (ret != ge::SUCCESS) {
GELOGE(ret, "Parser graph %s failed.", graph.GetName().c_str());
REPORT_CALL_ERROR("E19999", "ParseFromMemory failed");
GELOGE(ret, "[Parser][Graph] %s failed.", graph.GetName().c_str());
return ge::FAILED;
}
GELOGI("Parser graph %s success.", graph.GetName().c_str());

if (HandleAfterParse(acl_graph_parse_util, parser_params, graph) != ge::SUCCESS) {
GELOGE(ge::FAILED, "Handle after parse failed.");
GELOGE(ge::FAILED, "[Invoke][HandleAfterParse] failed.");
return ge::FAILED;
}
GELOGI("AclgrphParse graph %s success.", graph.GetName().c_str());
@@ -380,7 +386,8 @@ Status OnnxModelParser::ConstructOriType(const ge::onnx::NodeProto *node_proto,
if (it != domain_verseion_.end()) {
version = it->second;
} else {
GELOGE(PARAM_INVALID, "The opset of domain[%s] has no responding version.", domain.c_str());
REPORT_INNER_ERROR("E19999", "The opset of domain[%s] has no responding version.", domain.c_str());
GELOGE(PARAM_INVALID, "[Check][Param]The opset of domain[%s] has no responding version.", domain.c_str());
return PARAM_INVALID;
}
} else {
@@ -389,9 +396,9 @@ Status OnnxModelParser::ConstructOriType(const ge::onnx::NodeProto *node_proto,
domain = domain_verseion_.begin()->first;
version = domain_verseion_.begin()->second;
} else {
GELOGE(PARAM_INVALID, "The size of domain_version[%zu] should be equal to one.", domain_version_size);
ErrorManager::GetInstance().ATCReportErrMessage("E16005",
{"domain_version_size"},
GELOGE(PARAM_INVALID, "[Check][Param]The size of domain_version[%zu] should be equal to one.",
domain_version_size);
ErrorManager::GetInstance().ATCReportErrMessage("E16005", {"domain_version_size"},
{to_string(domain_version_size)});
return PARAM_INVALID;
}
@@ -419,13 +426,13 @@ Status OnnxModelParser::AdapterOpType(const ge::onnx::NodeProto *node_proto, std

Status ret = ConstructOriType(node_proto, ori_type);
if (ret != SUCCESS) {
GELOGE(ret, "Construct ori type for [%s] failed.", ori_type.c_str());
GELOGE(ret, "[Construct][OriType] for [%s] failed.", ori_type.c_str());
return ret;
}

if (!domi::OpRegistry::Instance()->GetOmTypeByOriOpType(ori_type, op_type)) {
ErrorManager::GetInstance().ATCReportErrMessage("E16002", {"optype"}, {ori_type});
GELOGE(PARAM_INVALID, "Get omType according ori_type : %s failed.", ori_type.c_str());
GELOGE(PARAM_INVALID, "[Get][OmType] according ori_type : %s failed.", ori_type.c_str());
return PARAM_INVALID;
}

@@ -440,7 +447,8 @@ Status OnnxModelParser::TransNodeToOperator(const ge::onnx::NodeProto *node_prot
op = ge::OperatorFactory::CreateOperator(node_name, op_type);
if (op.GetName() != node_name) {
ErrorManager::GetInstance().ATCReportErrMessage("E16003", {"opname", "optype"}, {node_name, op_type});
GELOGE(INTERNAL_ERROR, "[Creat][Op] IR for op[%s] optype[%s] is not registered.", node_name.c_str(), op_type.c_str());
GELOGE(INTERNAL_ERROR, "[Creat][Op] IR for op[%s] optype[%s] is not registered.",
node_name.c_str(), op_type.c_str());
REPORT_INNER_ERROR("E19999", "IR for op[%s] optype[%s] is not registered.", node_name.c_str(), op_type.c_str());
return INTERNAL_ERROR;
}
@@ -484,12 +492,16 @@ Status OnnxModelParser::SetOperatorInputs() {
for (auto out_node_index : output_node_indexs) {
auto input_op_iter = name_operator_.find(input_node_index.first);
if (input_op_iter == name_operator_.end()) {
GELOGE(INTERNAL_ERROR, "Node: %s can not find in name_operator map.", input_node_index.first.c_str());
REPORT_INNER_ERROR("E19999", "Node: %s can not find in name_operator map.", input_node_index.first.c_str());
GELOGE(INTERNAL_ERROR, "[Check][Param] Node: %s can not find in name_operator map.",
input_node_index.first.c_str());
return INTERNAL_ERROR;
}
auto output_op_iter = name_operator_.find(out_node_index.first);
if (output_op_iter == name_operator_.end()) {
GELOGE(INTERNAL_ERROR, "Node: %s can not find in name_operator map.", out_node_index.first.c_str());
REPORT_INNER_ERROR("E19999", "Node: %s can not find in name_operator map.", out_node_index.first.c_str());
GELOGE(INTERNAL_ERROR, "[Check][Param] Node: %s can not find in name_operator map.",
out_node_index.first.c_str());
return INTERNAL_ERROR;
}

@@ -518,21 +530,24 @@ Status OnnxModelParser::Prechecker(ge::onnx::GraphProto &onnx_graph) {
std::string ori_type;
Status ret = ConstructOriType(node, ori_type);
if (ret != SUCCESS) {
GELOGE(ret, "Construct ori type for [%s] failed.", ori_type.c_str());
GELOGE(ret, "[Construct][OriType] for [%s] failed.", ori_type.c_str());
return ret;
}
GELOGI("Construct ori type : %s ", ori_type.c_str());
if (ge::PreChecker::Instance().AddOp(node, node->name(), ori_type) != SUCCESS) {
GELOGE(FAILED, "Add node_def to PreChecker failed, node name: %s.", node->name().c_str());
REPORT_CALL_ERROR("E19999", "AddOp failed, node:%s", node->name().c_str());
GELOGE(FAILED, "[Add][NodeDef] to PreChecker failed, node name: %s.", node->name().c_str());
return FAILED;
}
if (ge::PreChecker::Instance().CheckName(node) != SUCCESS) {
GELOGE(FAILED, "Check node_def name failed, node name: %s.", node->name().c_str());
REPORT_CALL_ERROR("E19999", "CheckName failed for node:%s", node->name().c_str());
GELOGE(FAILED, "[Check][Name] failed, node name: %s.", node->name().c_str());
return FAILED;
}
if (kOnnxOpMap.find(ori_type) == kOnnxOpMap.end()) {
if (ge::PreChecker::Instance().CheckType(node) != SUCCESS) {
GELOGE(FAILED, "Check node_def type failed, node name: %s.", node->name().c_str());
REPORT_CALL_ERROR("E19999", "CheckType failed for node:%s", node->name().c_str());
GELOGE(FAILED, "[Check][Type] failed, node name: %s.", node->name().c_str());
return FAILED;
}
}
@@ -575,7 +590,8 @@ Status OnnxModelParser::ParseAllNodeProto(ge::onnx::GraphProto &onnx_graph, ge::
GE_CHECK_NOTNULL(onnx_op_parser);
status = onnx_op_parser->ParseParams(node_proto, op);
if (status != SUCCESS) {
GELOGE(status, "Parse params for %s:%s failed.", node_name.c_str(), op_type.c_str());
REPORT_CALL_ERROR("E19999", "ParseParams for %s:%s failed ret:%d.", node_name.c_str(), op_type.c_str(), status);
GELOGE(status, "[Parse][Params] for %s:%s failed ret:%d.", node_name.c_str(), op_type.c_str(), status);
return status;
}

@@ -594,7 +610,8 @@ Status OnnxModelParser::ParseAllNodeProto(ge::onnx::GraphProto &onnx_graph, ge::
// 8. Construct input output relation of every node
status = ConstructInputOutputContext(node_proto);
if (status != SUCCESS) {
GELOGE(status, "Construct input output relation map failed.");
REPORT_INNER_ERROR("E19999", "ConstructInputOutputContext failed.");
GELOGE(status, "[Construct][RelationMap] to input and output failed.");
return status;
}
}
@@ -661,7 +678,7 @@ Status OnnxModelParser::GetModelFromFile(const char *file, ge::onnx::ModelProto
if (!ge::parser::ReadProtoFromBinaryFile(file, &onnx_model)) {
ErrorManager::GetInstance().ATCReportErrMessage(
"E19021", {"reason"}, {"Read onnx model file failed."});
GELOGE(PARAM_INVALID, "Read onnx model file failed.");
GELOGE(PARAM_INVALID, "[Read][ModeFile] failed.");
return FAILED;
}
return SUCCESS;
@@ -674,7 +691,7 @@ Status OnnxModelParser::GetModelFromMemory(const char *data, uint32_t size, ge::
if (!ge::parser::ReadProtoFromArray(data, size, &onnx_model)) {
ErrorManager::GetInstance().ATCReportErrMessage(
"E19021", {"reason"}, {"Read onnx model from memory failed."});
GELOGE(PARAM_INVALID, "Read onnx model from memory failed.");
GELOGE(PARAM_INVALID, "[Read][OnnxModel] from memory failed.");
return FAILED;
}
return SUCCESS;
@@ -836,7 +853,7 @@ Status OnnxModelParser::ModelParseToGraphImpl(bool is_subgraph, ge::onnx::GraphP

Status ret = ParseInput(initializer_name_tensor, is_subgraph, onnx_graph);
if (ret != SUCCESS) {
GELOGE(ret, "Parse input for onnx failed.");
GELOGE(ret, "[Parse][Input] for onnx failed.");
return ret;
}
GELOGI("The size of initializer_name_tensor is %zu after ParseInput", initializer_name_tensor.size());
@@ -844,7 +861,7 @@ Status OnnxModelParser::ModelParseToGraphImpl(bool is_subgraph, ge::onnx::GraphP
// 4. Parse Constant from graph.
ret = ParseInitializer(onnx_graph, initializer_name_tensor);
if (ret != SUCCESS) {
GELOGE(ret, "Parse initializer for onnx failed.");
GELOGE(ret, "[Parse][Initializer] for onnx failed.");
return ret;
}

@@ -857,7 +874,7 @@ Status OnnxModelParser::ModelParseToGraphImpl(bool is_subgraph, ge::onnx::GraphP
// 5. Update node name for node do not has name.
ret = UpdateAllNodeName(onnx_graph);
if (ret != SUCCESS) {
GELOGE(ret, "Update all node name for onnx failed.");
GELOGE(ret, "[Update][Name] of all node for onnx failed.");
return ret;
}

@@ -865,7 +882,7 @@ Status OnnxModelParser::ModelParseToGraphImpl(bool is_subgraph, ge::onnx::GraphP
ret = Prechecker(onnx_graph);
bool is_precheck_failed = (ret != SUCCESS) || (ge::PreChecker::Instance().HasError());
if (is_precheck_failed) {
GELOGE(FAILED, "Prechecker failed.");
GELOGE(FAILED, "[Invoke][Prechecker] failed.");
return FAILED;
}

@@ -877,7 +894,7 @@ Status OnnxModelParser::ModelParseToGraphImpl(bool is_subgraph, ge::onnx::GraphP
// 7. Construct all operator and input output tensor relation.
ret = ParseAllNodeProto(onnx_graph, graph);
if (ret != SUCCESS) {
GELOGE(ret, "Parse all node proto failed.");
GELOGE(ret, "[Parse][AllNodeProto] failed.");
return ret;
}

@@ -888,7 +905,7 @@ Status OnnxModelParser::ModelParseToGraphImpl(bool is_subgraph, ge::onnx::GraphP
// 8. Set all operator input.
ret = SetOperatorInputs();
if (ret != SUCCESS) {
GELOGE(ret, "Set operator input failed.");
GELOGE(ret, "[Set][OperatorInputs] failed.");
return ret;
}

@@ -896,7 +913,7 @@ Status OnnxModelParser::ModelParseToGraphImpl(bool is_subgraph, ge::onnx::GraphP
std::vector<ge::Operator> input_ops;
ret = GetGraphInputs(onnx_graph, input_ops);
if (ret != SUCCESS) {
GELOGE(ret, "Get graph inputs failed.");
GELOGE(ret, "[Get][GraphInputs] failed.");
return ret;
}
graph.SetInputs(input_ops);
@@ -906,7 +923,7 @@ Status OnnxModelParser::ModelParseToGraphImpl(bool is_subgraph, ge::onnx::GraphP
std::vector<std::pair<Operator, std::vector<size_t>>> output_ops;
ret = GetGraphOutputs(output_ops);
if (ret != SUCCESS) {
GELOGE(ret, "[Get][Outputs]Get graph outputs failed.");
GELOGE(ret, "[Get][Outputs] failed.");
return ret;
}
graph.SetOutputs(output_ops);
@@ -923,12 +940,12 @@ Status OnnxModelParser::Parse(const char *file, ge::Graph &graph) {
ge::onnx::ModelProto onnx_model;
Status ret = GetModelFromFile(file, onnx_model);
if (ret != SUCCESS) {
GELOGE(FAILED, "get model from file failed.");
GELOGE(FAILED, "[Get][Model] From File:%s failed.", file);
return FAILED;
}
ret = ModelParseToGraph(onnx_model, graph);
if (ret != SUCCESS) {
GELOGE(FAILED, "parse model failed.");
GELOGE(FAILED, "[Parse][Model] To Graph failed.");
return FAILED;
}
return SUCCESS;
@@ -939,12 +956,12 @@ Status OnnxModelParser::ParseFromMemory(const char *data, uint32_t size, ge::Gra
ge::onnx::ModelProto onnx_model;
Status ret = GetModelFromMemory(data, size, onnx_model);
if (ret != SUCCESS) {
GELOGE(FAILED, "get model from file failed.");
GELOGE(FAILED, "[Get][Model] From Memory failed.");
return FAILED;
}
ret = ModelParseToGraph(onnx_model, graph);
if (ret != SUCCESS) {
GELOGE(FAILED, "parse model failed.");
GELOGE(FAILED, "[Parse][Model] To Graph failed.");
return FAILED;
}
return SUCCESS;
@@ -952,17 +969,19 @@ Status OnnxModelParser::ParseFromMemory(const char *data, uint32_t size, ge::Gra

Status OnnxModelParser::ToJson(const char *model_file, const char *json_file) {
if (model_file == nullptr) {
GELOGE(FAILED, "Model file is nullptr.");
REPORT_INNER_ERROR("E19999", "param model file is nullprt, check invalid.");
GELOGE(FAILED, "[Check][Param] Model file is nullptr.");
return FAILED;
}
if (json_file == nullptr) {
GELOGE(FAILED, "Json file is nullptr.");
REPORT_INNER_ERROR("E19999", "param json file is nullptr, check invalid.");
GELOGE(FAILED, "[Check][Param]Json file is nullptr.");
return FAILED;
}

ge::onnx::ModelProto onnx_model;
GE_RETURN_WITH_LOG_IF_FALSE(ge::parser::ReadProtoFromBinaryFile(model_file, &onnx_model),
"ReadProtoFromBinaryFile failed, file:%s.", model_file);
"[Invoke][ReadProtoFromBinaryFile] failed, file:%s.", model_file);
ge::onnx::GraphProto graph_proto = onnx_model.graph();
nlohmann::json j;
ge::Pb2Json::Message2Json(graph_proto, std::set<std::string>(), j, true);


Loading…
Cancel
Save