Browse Source

misra

pull/473/head
lzl 3 years ago
parent
commit
47341bfc21
14 changed files with 59 additions and 57 deletions
  1. +2
    -2
      parser/caffe/caffe_data_parser.cc
  2. +11
    -10
      parser/caffe/caffe_parser.cc
  3. +5
    -4
      parser/common/acl_graph_parser_util.cc
  4. +5
    -5
      parser/common/op_parser_factory.cc
  5. +2
    -2
      parser/common/pre_checker.cc
  6. +2
    -2
      parser/common/proto_file_parser.cc
  7. +1
    -1
      parser/common/tbe_plugin_loader.cc
  8. +1
    -1
      parser/onnx/onnx_constant_parser.cc
  9. +7
    -7
      parser/onnx/onnx_parser.cc
  10. +1
    -1
      parser/onnx/subgraph_adapter/if_subgraph_adapter.cc
  11. +1
    -1
      parser/onnx/subgraph_adapter/subgraph_adapter_factory.cc
  12. +4
    -4
      parser/tensorflow/graph_functiondef.cc
  13. +2
    -2
      parser/tensorflow/graph_optimizer.cc
  14. +15
    -15
      parser/tensorflow/tensorflow_parser.cc

+ 2
- 2
parser/caffe/caffe_data_parser.cc View File

@@ -95,7 +95,7 @@ Status CaffeDataParser::ParseParamsForInput(const domi::caffe::LayerParameter *l
std::map<std::string, std::vector<int64_t>> input_dims = ctx.input_dims;
string name = layer->name();
std::map<std::string, std::vector<int64_t>>::const_iterator search = input_dims.find(name);
if (search == input_dims.end()) {
if (search == input_dims.cend()) {
REPORT_INPUT_ERROR("E11005", std::vector<std::string>({"input"}), std::vector<std::string>({layer->name()}));
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].",
@@ -140,7 +140,7 @@ Status CaffeDataParser::ParseParamsForDummyData(const domi::caffe::LayerParamete
std::map<std::string, std::vector<int64_t>> input_dims = ctx.input_dims;
string name = layer->name();
std::map<std::string, std::vector<int64_t>>::const_iterator search = input_dims.find(name);
if (search == input_dims.end()) {
if (search == input_dims.cend()) {
REPORT_INPUT_ERROR("E11005", std::vector<std::string>({"input"}), std::vector<std::string>({layer->name()}));
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].",


+ 11
- 10
parser/caffe/caffe_parser.cc View File

@@ -617,8 +617,9 @@ Status CaffeModelParser::CreateCustomOperator(string op_name, string op_type, co
}

void CaffeModelParser::AddOutputInfoToContext(string layer_name, int32_t top_index) const {
auto iter_node_name = ge::GetParserContext().out_nodes_map.find(layer_name);
if (iter_node_name != ge::GetParserContext().out_nodes_map.end()) {
std::map<std::string, std::vector<int32_t>>::const_iterator iter_node_name =
ge::GetParserContext().out_nodes_map.find(layer_name);
if (iter_node_name != ge::GetParserContext().out_nodes_map.cend()) {
iter_node_name->second.emplace_back(top_index);
} else {
std::vector<int32_t> index_v;
@@ -1028,7 +1029,7 @@ Status CaffeModelParser::AddEdges(ge::ComputeGraphPtr &graph) {
// Find the layer for this input
std::map<std::string, ge::NodePtr>::const_iterator bottom_node_iter =
node_map.find(bottom_blob_layer_pair.first);
if (top_node_iter != node_map.end() && bottom_node_iter != node_map.end()) {
if (top_node_iter != node_map.cend() && bottom_node_iter != node_map.cend()) {
// Output node top_node_iter->second,
// Output index top_blob_layer_pair.second
// input node bottom_node_iter->second
@@ -1099,7 +1100,7 @@ Status CaffeModelParser::AddUserOutNodesTop() {
for (const auto &out_pair : user_out_nodes) {
std::map<std::string, std::vector<std::string>>::const_iterator layer_iter = layer_tops_map_.find(out_pair.first);
GELOGI("Add to output, node name: %s", out_pair.first.c_str());
if (layer_iter != layer_tops_map_.end()) {
if (layer_iter != layer_tops_map_.cend()) {
if (static_cast<uint32_t>(out_pair.second) >= (layer_iter->second).size()) {
ErrorManager::GetInstance().ATCReportErrMessage(
"E11016", {"opname", "outputindex", "totlaloutputindex", "inputindex", "totlalinputindex"},
@@ -1113,7 +1114,7 @@ Status CaffeModelParser::AddUserOutNodesTop() {

string top_name = layer_iter->second[out_pair.second];
std::map<std::string, ge::NodePtr>::const_iterator top_node_iter = node_map.find(out_pair.first);
if (top_node_iter != node_map.end()) {
if (top_node_iter != node_map.cend()) {
ge::GetParserContext().out_tensor_names.push_back(top_name);
GELOGI("The top of out node [%s] is [%s]", out_pair.first.c_str(), top_name.c_str());
}
@@ -1147,7 +1148,7 @@ Status CaffeModelParser::AddOutputTop(const domi::caffe::NetParameter &proto_mes
std::map<std::string, std::vector<std::pair<std::string, int32_t>>>::const_iterator t_iter =
top_blobs_map_.find(top);

GE_RETURN_WITH_LOG_IF_FALSE(t_iter != top_blobs_map_.end(),
GE_RETURN_WITH_LOG_IF_FALSE(t_iter != top_blobs_map_.cend(),
"[Check][Param]Failed to find top: %s, layer name:%s", top.c_str(),
layer.name().c_str());

@@ -1161,7 +1162,7 @@ Status CaffeModelParser::AddOutputTop(const domi::caffe::NetParameter &proto_mes
// Find the layer for this output
std::map<std::string, ge::NodePtr>::const_iterator top_node_iter = node_map.find(layer.name());
GELOGI("output in top_blob: %s", layer.name().c_str());
if (top_node_iter != node_map.end()) {
if (top_node_iter != node_map.cend()) {
ge::GetParserContext().out_tensor_names.push_back(top_origin);
ge::GetParserContext().default_out_nodes.push_back(std::make_pair(layer.name(), i));
GELOGI("The top of out node [%s] is [%s]", layer.name().c_str(), top_origin.c_str());
@@ -1396,7 +1397,7 @@ void CaffeModelParser::SaveOrigionLayerTops(domi::caffe::LayerParameter &layer)
tops.push_back(top);
}
std::map<std::string, std::vector<std::string>>::const_iterator it = layer_tops_map_.find(name);
if (it == layer_tops_map_.end()) {
if (it == layer_tops_map_.cend()) {
layer_tops_map_[name] = tops;
}
return;
@@ -2163,7 +2164,7 @@ Status CaffeWeightsParser::ConvertLayerParameter(const google::protobuf::Message

// The weight processing also needs to judge the duplicate operator, which is reserved here and processed later.
std::map<std::string, std::string>::const_iterator iter = caffe_op_map.find(layer_type);
if (iter == caffe_op_map.end()) {
if (iter == caffe_op_map.cend()) {
GELOGW("Unrecognized layer type %s , layer name: %s, layer ignored.", layer_type.c_str(), layer_name.c_str());
continue;
}
@@ -2289,7 +2290,7 @@ Status CaffeWeightsParser::ConvertNetParameter(const NetParameter &param, ge::Co

// The weight processing also needs to judge the duplicate operator, which is reserved here and processed later.
std::map<std::string, std::string>::const_iterator iter = caffe_op_map.find(layer.type());
if (iter == caffe_op_map.end()) {
if (iter == caffe_op_map.cend()) {
GELOGW("Unrecognized layer type %s , layer name: %s, layer ignored.", layer.type().c_str(), layer_name.c_str());
continue;
}


+ 5
- 4
parser/common/acl_graph_parser_util.cc View File

@@ -309,10 +309,11 @@ domi::Status AclGrphParseUtil::ParseAclOutputNodes(const string &out_nodes) {
return PARAM_INVALID;
}

auto iter = ge::GetParserContext().out_nodes_map.find(key_value_v[0]);
std::map<std::string, std::vector<int32_t>>::const_iterator iter =
ge::GetParserContext().out_nodes_map.find(key_value_v[0]);
int32_t index = stoi(StringUtils::Trim(key_value_v[1]));
GELOGD("Get output info: node[%s] and index[%d]", key_value_v[0].c_str(), index);
if (iter != ge::GetParserContext().out_nodes_map.end()) {
if (iter != ge::GetParserContext().out_nodes_map.cend()) {
iter->second.emplace_back(index);
} else {
std::vector<int32_t> index_v;
@@ -587,8 +588,8 @@ domi::Status AclGrphParseUtil::CheckOptions(const std::map<AscendString, AscendS
}

string key_str = key_ascend;
auto it = ge::ir_option::ir_parser_suppported_options.find(key_str);
if (it == ge::ir_option::ir_parser_suppported_options.end()) {
std::set<std::string>::const_iterator it = ge::ir_option::ir_parser_suppported_options.find(key_str);
if (it == ge::ir_option::ir_parser_suppported_options.cend()) {
ErrorManager::GetInstance().ATCReportErrMessage("E10016", {"parameter", "opname"}, {"parser_params", key_str});
GELOGE(PARAM_INVALID, "[Check][Param] Input options include unsupported option(%s).Please check!", key_ascend);
return PARAM_INVALID;


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

@@ -51,7 +51,7 @@ FMK_FUNC_HOST_VISIBILITY std::shared_ptr<OpParserFactory> OpParserFactory::Insta
static std::map<domi::FrameworkType, std::shared_ptr<OpParserFactory>> instances;

std::map<domi::FrameworkType, std::shared_ptr<OpParserFactory>>::const_iterator iter = instances.find(framework);
if (iter == instances.end()) {
if (iter == instances.cend()) {
std::shared_ptr<OpParserFactory> instance(new (std::nothrow) OpParserFactory());
if (instance == nullptr) {
REPORT_CALL_ERROR("E19999", "create OpParserFactory failed");
@@ -68,7 +68,7 @@ FMK_FUNC_HOST_VISIBILITY std::shared_ptr<OpParserFactory> OpParserFactory::Insta
FMK_FUNC_HOST_VISIBILITY std::shared_ptr<OpParser> OpParserFactory::CreateOpParser(const std::string &op_type) {
// First look for CREATOR_FUN based on OpType, then call CREATOR_FUN to create OpParser.
std::map<std::string, CREATOR_FUN>::const_iterator iter = op_parser_creator_map_.find(op_type);
if (iter != op_parser_creator_map_.end()) {
if (iter != op_parser_creator_map_.cend()) {
return iter->second();
}
REPORT_INNER_ERROR("E19999", "param op_type invalid, Not supported type: %s", op_type.c_str());
@@ -79,7 +79,7 @@ FMK_FUNC_HOST_VISIBILITY std::shared_ptr<OpParser> OpParserFactory::CreateOpPars
FMK_FUNC_HOST_VISIBILITY std::shared_ptr<OpParser> OpParserFactory::CreateFusionOpParser(const std::string &op_type) {
// First look for CREATOR_FUN based on OpType, then call CREATOR_FUN to create OpParser.
std::map<std::string, CREATOR_FUN>::const_iterator iter = fusion_op_parser_creator_map_.find(op_type);
if (iter != fusion_op_parser_creator_map_.end()) {
if (iter != fusion_op_parser_creator_map_.cend()) {
return iter->second();
}
REPORT_INNER_ERROR("E19999", "param op_type invalid, Not supported fusion op type: %s", op_type.c_str());
@@ -103,12 +103,12 @@ FMK_FUNC_HOST_VISIBILITY void OpParserFactory::RegisterCreator(const std::string
FMK_FUNC_HOST_VISIBILITY bool OpParserFactory::OpParserIsRegistered(const std::string &op_type, bool is_fusion_op) {
if (is_fusion_op) {
std::map<std::string, CREATOR_FUN>::const_iterator iter = fusion_op_parser_creator_map_.find(op_type);
if (iter != fusion_op_parser_creator_map_.end()) {
if (iter != fusion_op_parser_creator_map_.cend()) {
return true;
}
} else {
std::map<std::string, CREATOR_FUN>::const_iterator iter = op_parser_creator_map_.find(op_type);
if (iter != op_parser_creator_map_.end()) {
if (iter != op_parser_creator_map_.cend()) {
return true;
}
}


+ 2
- 2
parser/common/pre_checker.cc View File

@@ -218,8 +218,8 @@ 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, "[Check][Param] don't find this op.");
map<OpId, Info>::const_iterator iter = op_map_.find(id);
GE_CHK_BOOL_RET_STATUS(iter != op_map_.cend(), FAILED, "[Check][Param] don't find this op.");
Info &info = iter->second;

// Initialization operator general information


+ 2
- 2
parser/common/proto_file_parser.cc View File

@@ -426,7 +426,7 @@ void ProtoFileParser::CheckConflictOp(const char *caffe_proto_file, const char *
std::map<std::string, std::pair<int, string>> &caffe_op_identifier_map,
std::map<std::string, std::pair<int, string>> &custom_op_identifier_map) {
std::map<std::string, std::pair<int, string>>::const_iterator iter = custom_op_identifier_map.begin();
for (; iter != custom_op_identifier_map.end(); ++iter) {
for (; iter != custom_op_identifier_map.cend(); ++iter) {
if (caffe_op_identifier_map.count(iter->first) > 0) {
string message_name = iter->first;
auto caffe_pair = caffe_op_identifier_map[iter->first];
@@ -454,7 +454,7 @@ void ProtoFileParser::CheckConflictIdentifier(const char *caffe_proto_file, cons
std::map<int, std::pair<string, string>> caffe_identifier_op_map,
std::map<int, std::pair<string, string>> custom_identifier_op_map) {
std::map<int, std::pair<string, string>>::const_iterator iter = custom_identifier_op_map.begin();
for (; iter != custom_identifier_op_map.end(); ++iter) {
for (; iter != custom_identifier_op_map.cend(); ++iter) {
if (caffe_identifier_op_map.count(iter->first) > 0) {
int identifier = iter->first;
auto caffe_pair = caffe_identifier_op_map[iter->first];


+ 1
- 1
parser/common/tbe_plugin_loader.cc View File

@@ -106,7 +106,7 @@ void TBEPluginLoader::GetCustomOpPath(std::string &customop_path) {
std::string fmk_type;
domi::FrameworkType type = domi::TENSORFLOW;
std::map<string, string>::const_iterator it = options_.find(FRAMEWORK_TYPE);
if (it != options_.end()) {
if (it != options_.cend()) {
type = static_cast<domi::FrameworkType>(std::strtol(it->second.c_str(), nullptr, 10));
}
fmk_type = ge::TypeUtils::FmkTypeToSerialString(type);


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

@@ -72,7 +72,7 @@ Status OnnxConstantParser::ParseConvertData(const ge::onnx::TensorProto &tensor_

int32_t datatype_val_size = 0;
std::map<uint32_t, int32_t>::const_iterator iter = datatype_val_size_map.find(data_type);
if (iter != datatype_val_size_map.end()) {
if (iter != datatype_val_size_map.cend()) {
datatype_val_size = iter->second;
} else {
REPORT_INNER_ERROR("E19999", "data_type %ld not support.", data_type);


+ 7
- 7
parser/onnx/onnx_parser.cc View File

@@ -385,7 +385,7 @@ Status OnnxModelParser::ConstructOriType(const ge::onnx::NodeProto *node_proto,
int64_t version = 0;
if (!domain.empty()) {
std::map<std::string, int64_t>::const_iterator it = domain_verseion_.find(domain);
if (it != domain_verseion_.end()) {
if (it != domain_verseion_.cend()) {
version = it->second;
} else {
REPORT_INNER_ERROR("E19999", "The opset of domain[%s] has no responding version.", domain.c_str());
@@ -494,14 +494,14 @@ Status OnnxModelParser::SetOperatorInputs() {
for (auto input_node_index : input_node_indexs) {
for (auto out_node_index : output_node_indexs) {
std::map<std::string, ge::Operator>::const_iterator input_op_iter = name_operator_.find(input_node_index.first);
if (input_op_iter == name_operator_.end()) {
if (input_op_iter == name_operator_.cend()) {
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;
}
std::map<std::string, ge::Operator>::const_iterator output_op_iter = name_operator_.find(out_node_index.first);
if (output_op_iter == name_operator_.end()) {
if (output_op_iter == name_operator_.cend()) {
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());
@@ -666,7 +666,7 @@ Status OnnxModelParser::GetGraphInputs(ge::onnx::GraphProto &onnx_graph, std::ve
}
for (auto in_name : input_node_names_) {
std::map<std::string, ge::Operator>::const_iterator in_op = name_operator_.find(in_name);
if (in_op == name_operator_.end()) {
if (in_op == name_operator_.cend()) {
GELOGE(PARAM_INVALID, "[Get][Inputs] Model assigned input node name: %s can not find in graph.",
in_name.c_str());
REPORT_INNER_ERROR("E19999", "Model assigned input node name: %s can not find in graph.",
@@ -684,7 +684,7 @@ Status OnnxModelParser::GetGraphOutputs(std::vector<std::pair<Operator, std::vec
for (auto output_name : output_node_names_) {
std::map<std::string, std::vector<std::pair<std::string, int>>>::const_iterator itr =
outputs_map_.find(output_name);
if (itr == outputs_map_.end()) {
if (itr == outputs_map_.cend()) {
GELOGE(PARAM_INVALID, "[Get][Outputs] Can not find output:%s in graph.", output_name.c_str());
REPORT_INNER_ERROR("E19999", "[Get][Outputs] Can not find output:%s in graph.", output_name.c_str());
return PARAM_INVALID;
@@ -694,7 +694,7 @@ Status OnnxModelParser::GetGraphOutputs(std::vector<std::pair<Operator, std::vec
for (const auto &node_name_index : node_names_indexes) {
auto node_name = node_name_index.first;
std::map<std::string, ge::Operator>::const_iterator out_op_itr = name_operator_.find(node_name);
if (out_op_itr == name_operator_.end()) {
if (out_op_itr == name_operator_.cend()) {
GELOGE(PARAM_INVALID, "[Get][Operator] Can not find operator: %s in graph.", node_name.c_str());
REPORT_INNER_ERROR("E19999", "Can not find operator: %s in graph.", node_name.c_str());
return PARAM_INVALID;
@@ -817,7 +817,7 @@ Status OnnxModelParser::ModelParseToGraph(const ge::onnx::ModelProto &onnx_model

if (arg.onnx_graph == nullptr) {
std::map<std::string, ge::onnx::GraphProto *>::const_iterator itr = name_to_onnx_graph.find(arg.graph_name);
if (itr == name_to_onnx_graph.end()) {
if (itr == name_to_onnx_graph.cend()) {
GELOGE(FAILED, "[Find][OnnxGraph] Can not find onnx graph, graph:%s.", arg.graph_name.c_str());
REPORT_INNER_ERROR("E19999", "Can not find onnx graph, graph:%s.", arg.graph_name.c_str());
return FAILED;


+ 1
- 1
parser/onnx/subgraph_adapter/if_subgraph_adapter.cc View File

@@ -105,7 +105,7 @@ domi::Status IfSubgraphAdapter::GetSubgraphsAllInputs(ge::onnx::GraphProto &onnx

for (const auto &input : graph_inputs) {
std::set<std::string>::const_iterator out_iter = graph_outputs.find(input);
if (out_iter == graph_outputs.end()) {
if (out_iter == graph_outputs.cend()) {
// Record input node need to be constructed
all_inputs.emplace(input);
}


+ 1
- 1
parser/onnx/subgraph_adapter/subgraph_adapter_factory.cc View File

@@ -27,7 +27,7 @@ std::shared_ptr<SubgraphAdapter> SubgraphAdapterFactory::CreateSubgraphAdapter(
const std::string &op_type) {
// First look for CREATOR_FUN based on OpType, then call CREATOR_FUN to create SubgraphAdapter.
std::map<std::string, CREATOR_FUN>::const_iterator iter = subgraph_adapter_creator_map_.find(op_type);
if (iter != subgraph_adapter_creator_map_.end()) {
if (iter != subgraph_adapter_creator_map_.cend()) {
return iter->second();
}



+ 4
- 4
parser/tensorflow/graph_functiondef.cc View File

@@ -203,9 +203,9 @@ domi::Status RemapFunctionDef(FunctionDef *fdef, const string &name, NameMapHelp
ret_name.c_str(), return_value.c_str(), name.c_str());
return domi::INTERNAL_ERROR);

const auto iter = tensor_renaming.find(return_value);
const std::map<string, string>::const_iterator iter = tensor_renaming.find(return_value);

GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(iter == tensor_renaming.end(),
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(iter == tensor_renaming.cend(),
REPORT_INNER_ERROR("E19999", "can not find value[%s] in tensor_renaming map",
return_value.c_str());
return domi::INTERNAL_ERROR,
@@ -228,7 +228,7 @@ domi::Status GraphToFunctionDef::RecordResult(ge::ComputeGraphPtr graph,
GE_CHECK_NOTNULL(anchor->GetOwnerNode()->GetOpDesc());
int32_t type = anchor->GetOwnerNode()->GetOpDesc()->GetOutputDesc(anchor->GetIdx()).GetDataType();
std::map<int32_t, int32_t>::const_iterator iter = GE_TENSORFLOW_DATA_TYPE_MAP.find(type);
GE_IF_BOOL_EXEC(iter == GE_TENSORFLOW_DATA_TYPE_MAP.end(),
GE_IF_BOOL_EXEC(iter == GE_TENSORFLOW_DATA_TYPE_MAP.cend(),
REPORT_INNER_ERROR("E19999", "datatype:%d of output:%d in node:%s:%s is not supported",
type, anchor->GetIdx(), anchor->GetOwnerNode()->GetName().c_str(),
anchor->GetOwnerNode()->GetName().c_str());
@@ -305,7 +305,7 @@ domi::Status GraphToFunctionDef::RecordArg(ge::ComputeGraphPtr graph, const vect

int32_t type = tensor_desc_ptr->GetDataType();
std::map<int32_t, int32_t>::const_iterator iter = GE_TENSORFLOW_DATA_TYPE_MAP.find(type);
GE_IF_BOOL_EXEC(iter == GE_TENSORFLOW_DATA_TYPE_MAP.end(),
GE_IF_BOOL_EXEC(iter == GE_TENSORFLOW_DATA_TYPE_MAP.cend(),
REPORT_INNER_ERROR("E19999", "datatype:%d of input:%d in node:%s:%s is not supported",
type, anchor->GetIdx(), anchor->GetOwnerNode()->GetName().c_str(),
anchor->GetOwnerNode()->GetName().c_str());


+ 2
- 2
parser/tensorflow/graph_optimizer.cc View File

@@ -383,7 +383,7 @@ Status ParserGraphOptimizer::RebuildOutputAnchors(vector<ge::OutDataAnchorPtr> &
ge::DataType data_type = src_out_desc.GetDataType();
const std::map<int32_t, int32_t>::const_iterator iter = GE_TENSORFLOW_DATA_TYPE_MAP.find((int32_t)data_type);
GE_IF_BOOL_EXEC(
iter == GE_TENSORFLOW_DATA_TYPE_MAP.end(),
iter == GE_TENSORFLOW_DATA_TYPE_MAP.cend(),
REPORT_INNER_ERROR("E19999", "datatype:%d of output:%d in node:%s:%s is not supported",
data_type, out_anchor->GetIdx(), src_node->GetName().c_str(), src_node->GetName().c_str());
GELOGE(PARAM_INVALID, "data_type %s not supported", ge::TypeUtils::DataTypeToSerialString(data_type).c_str());
@@ -419,7 +419,7 @@ Status ParserGraphOptimizer::RebuildInputAnchors(vector<ge::InDataAnchorPtr> &in
ge::DataType data_type = tensorDescPtr->GetDataType();
const std::map<int32_t, int32_t>::const_iterator iter = GE_TENSORFLOW_DATA_TYPE_MAP.find((int32_t)data_type);
GE_IF_BOOL_EXEC(
iter == GE_TENSORFLOW_DATA_TYPE_MAP.end(),
iter == GE_TENSORFLOW_DATA_TYPE_MAP.cend(),
REPORT_INNER_ERROR("E19999", "datatype:%d of input:%d in node:%s:%s is not supported",
data_type, in_anchor->GetIdx(), dst_node->GetName().c_str(), dst_node->GetName().c_str());
GELOGE(PARAM_INVALID, "data_type %s not supported", ge::TypeUtils::DataTypeToSerialString(data_type).c_str());


+ 15
- 15
parser/tensorflow/tensorflow_parser.cc View File

@@ -496,7 +496,7 @@ Status TensorFlowModelParser::AddNode(const domi::tensorflow::NodeDef *node_def,
string node_name = node_def->name();
string node_op = node_def->op();
std::map<std::string, std::string>::const_iterator type_it = tensorflow_op_map.find(node_op);
if (type_it == tensorflow_op_map.end()) {
if (type_it == tensorflow_op_map.cend()) {
GELOGI("Can not find,maybe this node has no plugin node_name is %s, node_op is %s ", node_name.c_str(),
node_op.c_str());
ge::OpDescPtr op_desc;
@@ -555,7 +555,7 @@ Status TensorFlowModelParser::AddNode(const domi::tensorflow::NodeDef *node_def,
GE_CHECK_NOTNULL(fusion_op_parser);
// Find all children of the fusion operator
std::map<string, vector<const NodeDef *>>::const_iterator iter = fusion_op_nodedef_map_.find(node_def->name());
if (iter == fusion_op_nodedef_map_.end()) {
if (iter == fusion_op_nodedef_map_.cend()) {
REPORT_INNER_ERROR("E19999", "FusionOp node %s has no children node, check invalid", node_name.c_str());
GELOGE(FAILED, "FusionOp node %s has no children node!", node_name.c_str());
return INTERNAL_ERROR;
@@ -760,7 +760,7 @@ Status TensorFlowModelParser::AddEdges(ge::ComputeGraphPtr &graph) {
std::map<std::string, std::vector<std::pair<int32_t, int32_t>>>::const_iterator
input_iter = dest_input_map.find(src_op_name);
// Find output and input
if (input_iter == dest_input_map.end()) {
if (input_iter == dest_input_map.cend()) {
continue;
}
auto iter = node_map_.find(src_op_name);
@@ -923,7 +923,7 @@ Status TensorFlowModelParser::ParseNodeDef(TensorFlowModelParser *parser, ge::Co

std::map<std::string, std::string>::const_iterator iterator = parser->adaptedOpTypeMap_.find(node_name);
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(
iterator == parser->adaptedOpTypeMap_.end(),
iterator == parser->adaptedOpTypeMap_.cend(),
REPORT_INNER_ERROR("E19999", "get adapted op type failed, node name = %s", node_name.c_str());
return FAILED, "get adapted op type failed, node name = %s", node_name.c_str());

@@ -1378,7 +1378,7 @@ Status TensorFlowModelParser::Parse(const char *model_path, ge::ComputeGraphPtr

const std::map<std::string, domi::tensorflow::GraphDef>::const_iterator
iter = function_name_to_graphdef.find(arg.function_name);
if (iter == function_name_to_graphdef.end()) {
if (iter == function_name_to_graphdef.cend()) {
ErrorManager::GetInstance().ATCReportErrMessage("E12013", {"functionname"}, {arg.function_name});
GELOGE(FAILED, "Failed to get subgraph by function name %s", arg.function_name.c_str());
return FAILED;
@@ -1871,7 +1871,7 @@ Status TensorFlowModelParser::UpdateAllNodeOpContext(shared_ptr<ge::ScopeGraph>
// This node is a fusion operator
const std::map<std::string, OpNodeContext>::const_iterator
fusion_iter = tmp_fusion_op_node_context_map.find(info.fusion_node_name);
if (fusion_iter == tmp_fusion_op_node_context_map.end()) {
if (fusion_iter == tmp_fusion_op_node_context_map.cend()) {
OpNodeContext op_node_context;
tmp_fusion_op_node_context_map[info.fusion_node_name] = op_node_context;
tmp_op_node_name_list.push_back(info.fusion_node_name);
@@ -2121,7 +2121,7 @@ Status TensorFlowModelParser::NormalizeInputOrOutputMap(

string name = to_string(pair.first) + ":" + to_string(pair.second);
const std::set<std::string>::const_iterator compare_iter = compare_set.find(name);
if (compare_iter != compare_set.end()) {
if (compare_iter != compare_set.cend()) {
// pair<from,to> repeat, ignore
continue;
}
@@ -2160,7 +2160,7 @@ void TensorFlowModelParser::SaveEdgesControlInfo(const string &node_name, const

void TensorFlowModelParser::UpdateEdgesControlInfo(const ge::ScopeFusionOpInfo &info) {
const std::map<std::string, std::vector<int32_t>>::const_iterator iter = edges_control_map.find(info.node_name);
if (iter != edges_control_map.end()) {
if (iter != edges_control_map.cend()) {
// Delete the original fusion operator node information and add the fusion operator control edge information
edges_control_map.erase(iter);
edges_control_map[info.fusion_node_name].push_back(kControlSlot);
@@ -2485,7 +2485,7 @@ Status TensorFlowModelParser::OptimizeIdentityByOutput(map<string, NodeDef *> &n

const std::map<std::string, NodeDef *>::const_iterator node_def_iter = nodedef_map.find(curr_node_name);
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(
(node_def_iter == nodedef_map.end()),
(node_def_iter == nodedef_map.cend()),
REPORT_INNER_ERROR("E19999", "Node:%s can't find in nodedef_map, check invalid", curr_node_name.c_str());
return INTERNAL_ERROR, "Can't find nodedef");
domi::tensorflow::NodeDef *curr_node_def = node_def_iter->second;
@@ -2508,7 +2508,7 @@ Status TensorFlowModelParser::OptimizeIdentityByOutput(map<string, NodeDef *> &n
// Deal with non _Retval output operator of Identity.
if (has_out_retval) {
std::map<std::string, std::vector<std::pair<int32_t, int32_t>>>::const_iterator output_iter = output_map.begin();
for (; output_iter != output_map.end(); ++output_iter) {
for (; output_iter != output_map.cend(); ++output_iter) {
const string &output_node_name = output_iter->first;
domi::tensorflow::NodeDef *output_node_def = nodedef_map[output_node_name];
GE_CHECK_NOTNULL(output_node_def);
@@ -3757,8 +3757,8 @@ void TensorFlowModelParser::UpdateInnerInputMap(const string &fusion_op_name, Op
op_node_context.input_map.insert(tmp_input_map.begin(), tmp_input_map.end());
// update output map of pre node
for (const auto &in_iter : op_node_context.input_map) {
auto src_iter = op_node_context_map_.find(in_iter.first);
if (src_iter != op_node_context_map_.end()) {
unordered_map<string, OpNodeContext>::const_iterator src_iter = op_node_context_map_.find(in_iter.first);
if (src_iter != op_node_context_map_.cend()) {
std::vector<std::pair<int32_t, int32_t>> input_pairs = in_iter.second;
OpNodeContext &src_context = src_iter->second;
src_context.output_map[node_name].assign(input_pairs.begin(), input_pairs.end());
@@ -3806,8 +3806,8 @@ void TensorFlowModelParser::UpdateInnerOutputMap(const string &fusion_op_name, O
op_node_context.output_map.insert(tmp_output_map.begin(), tmp_output_map.end());
// update input map of pre node
for (const auto &out_iter : op_node_context.output_map) {
auto dst_iter = op_node_context_map_.find(out_iter.first);
if (dst_iter != op_node_context_map_.end()) {
unordered_map<string, OpNodeContext>::const_iterator dst_iter = op_node_context_map_.find(out_iter.first);
if (dst_iter != op_node_context_map_.cend()) {
std::vector<std::pair<int32_t, int32_t>> output_pairs = out_iter.second;
OpNodeContext &dst_context = dst_iter->second;
dst_context.input_map[node_name].assign(output_pairs.begin(), output_pairs.end());
@@ -3905,7 +3905,7 @@ Status TensorFlowModelParser::AddFusionNodeDef(shared_ptr<ge::ScopeGraph> &scope
for (size_t i = 0; i < op_node_list_size; ++i) {
const string op_node_name = node_name_list[i];
std::map<string, vector<const NodeDef *>>::const_iterator iter = fusion_op_nodedef_map_.find(op_node_name);
if (iter != fusion_op_nodedef_map_.end()) {
if (iter != fusion_op_nodedef_map_.cend()) {
vector<string> fusion_op_info = fusion_op_type_map_[op_node_name];
if (fusion_op_info[0] != ge::kScopeToMultiNodes) {
NodeDef *node_def = new (std::nothrow) NodeDef();


Loading…
Cancel
Save