@@ -130,9 +130,9 @@ target_compile_definitions(parser_graph_library_proto_obj PRIVATE | |||
) | |||
target_link_libraries(parser_graph_library_proto_obj PRIVATE ascend_protobuf $<BUILD_INTERFACE:intf_pub>) | |||
target_compile_options(parser_graph_library_proto_obj PRIVATE | |||
$<$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>:-O2 -fPIC> | |||
$<$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>:-O2 -fPIC -Wextra -Wfloat-equal> | |||
$<$<OR:$<STREQUAL:${PRODUCT_SIDE},host>,$<STREQUAL:${ENABLE_OPEN_SRC},True>>:-fexceptions> | |||
$<$<OR:$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>,$<STREQUAL:${TARGET_SYSTEM_NAME},Android>>: -Wno-deprecated-declarations -fno-common> | |||
$<$<OR:$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>,$<STREQUAL:${TARGET_SYSTEM_NAME},Android>>:-fno-common -Wextra -Wfloat-equal> | |||
$<$<AND:$<STREQUAL:${TARGET_SYSTEM_NAME},Windows>,$<STREQUAL:${CMAKE_CONFIGURATION_TYPES},Debug>>:/MTd> | |||
$<$<AND:$<STREQUAL:${TARGET_SYSTEM_NAME},Windows>,$<STREQUAL:${CMAKE_CONFIGURATION_TYPES},Release>>:/MT> | |||
) | |||
@@ -151,9 +151,9 @@ target_compile_definitions(parser_tensorflow_protos_obj PRIVATE | |||
) | |||
target_link_libraries(parser_tensorflow_protos_obj PRIVATE ascend_protobuf $<BUILD_INTERFACE:intf_pub>) | |||
target_compile_options(parser_tensorflow_protos_obj PRIVATE | |||
$<$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>:-O2 -fPIC> | |||
$<$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>:-O2 -fPIC -Wextra -Wfloat-equal> | |||
$<$<OR:$<STREQUAL:${PRODUCT_SIDE},host>,$<STREQUAL:${ENABLE_OPEN_SRC},True>>:-fexceptions> | |||
$<$<OR:$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>,$<STREQUAL:${TARGET_SYSTEM_NAME},Android>>: -Wno-deprecated-declarations -fno-common> | |||
$<$<OR:$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>,$<STREQUAL:${TARGET_SYSTEM_NAME},Android>>:-fno-common -Wextra -Wfloat-equal> | |||
$<$<AND:$<STREQUAL:${TARGET_SYSTEM_NAME},Windows>,$<STREQUAL:${CMAKE_CONFIGURATION_TYPES},Debug>>:/MTd> | |||
$<$<AND:$<STREQUAL:${TARGET_SYSTEM_NAME},Windows>,$<STREQUAL:${CMAKE_CONFIGURATION_TYPES},Release>>:/MT> | |||
) | |||
@@ -172,9 +172,9 @@ target_compile_definitions(parser_onnx_protos_obj PRIVATE | |||
) | |||
target_link_libraries(parser_onnx_protos_obj PRIVATE ascend_protobuf $<BUILD_INTERFACE:intf_pub>) | |||
target_compile_options(parser_onnx_protos_obj PRIVATE | |||
$<$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>:-O2 -fPIC> | |||
$<$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>:-O2 -fPIC -Wextra -Wfloat-equal> | |||
$<$<OR:$<STREQUAL:${PRODUCT_SIDE},host>,$<STREQUAL:${ENABLE_OPEN_SRC},True>>:-fexceptions> | |||
$<$<OR:$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>,$<STREQUAL:${TARGET_SYSTEM_NAME},Android>>: -Wno-deprecated-declarations -fno-common> | |||
$<$<OR:$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>,$<STREQUAL:${TARGET_SYSTEM_NAME},Android>>:-fno-common -Wextra -Wfloat-equal> | |||
$<$<AND:$<STREQUAL:${TARGET_SYSTEM_NAME},Windows>,$<STREQUAL:${CMAKE_CONFIGURATION_TYPES},Debug>>:/MTd> | |||
$<$<AND:$<STREQUAL:${TARGET_SYSTEM_NAME},Windows>,$<STREQUAL:${CMAKE_CONFIGURATION_TYPES},Release>>:/MT> | |||
) | |||
@@ -193,9 +193,9 @@ target_compile_definitions(parser_caffe_proto_obj PRIVATE | |||
) | |||
target_link_libraries(parser_caffe_proto_obj PRIVATE ascend_protobuf $<BUILD_INTERFACE:intf_pub>) | |||
target_compile_options(parser_caffe_proto_obj PRIVATE | |||
$<$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>:-O2 -fPIC> | |||
$<$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>:-O2 -fPIC -Wextra -Wfloat-equal> | |||
$<$<OR:$<STREQUAL:${PRODUCT_SIDE},host>,$<STREQUAL:${ENABLE_OPEN_SRC},True>>:-fexceptions> | |||
$<$<OR:$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>,$<STREQUAL:${TARGET_SYSTEM_NAME},Android>>: -Wno-deprecated-declarations -fno-common> | |||
$<$<OR:$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>,$<STREQUAL:${TARGET_SYSTEM_NAME},Android>>:-fno-common -Wextra -Wfloat-equal> | |||
$<$<AND:$<STREQUAL:${TARGET_SYSTEM_NAME},Windows>,$<STREQUAL:${CMAKE_CONFIGURATION_TYPES},Debug>>:/MTd> | |||
$<$<AND:$<STREQUAL:${TARGET_SYSTEM_NAME},Windows>,$<STREQUAL:${CMAKE_CONFIGURATION_TYPES},Release>>:/MT> | |||
) | |||
@@ -1 +1 @@ | |||
Subproject commit 8102890add03198d569205ea704b38c9b2a6d280 | |||
Subproject commit f62cba4fdf845ffe04e5c1e37ea990d22c438910 |
@@ -44,9 +44,10 @@ add_library(fmk_parser SHARED | |||
target_compile_options(fmk_parser PRIVATE | |||
-Werror | |||
-Wno-deprecated-declarations | |||
-fno-common | |||
-fvisibility=hidden | |||
-Wextra | |||
-Wfloat-equal | |||
) | |||
target_compile_definitions(fmk_parser PRIVATE | |||
@@ -136,6 +137,8 @@ add_library(fmk_parser_stub SHARED | |||
target_compile_options(fmk_parser_stub PRIVATE | |||
-O2 | |||
-fno-common | |||
-Wextra | |||
-Wfloat-equal | |||
) | |||
target_compile_definitions(fmk_parser_stub PRIVATE | |||
@@ -25,6 +25,7 @@ | |||
#include "graph/utils/graph_utils.h" | |||
#include "parser/common/op_parser_factory.h" | |||
#include "register/op_registry.h" | |||
#include "parser/common/parser_utils.h" | |||
using domi::ParseParamByOpFunc; | |||
using domi::ParseParamFunc; | |||
@@ -60,19 +61,20 @@ Status CaffeCustomParserAdapter::ParseParams(const Message *op_src, ge::OpDescPt | |||
} | |||
Status CaffeCustomParserAdapter::ParseParams(const Operator &op_src, const ge::OpDescPtr &op_dest) { | |||
GELOGI("Caffe custom op begin to params: layer name = %s, layer type= %s ", op_src.GetName().c_str(), | |||
op_src.GetOpType().c_str()); | |||
GELOGI("Caffe custom op begin to params: layer name = %s, layer type= %s ", | |||
ParserUtils::GetOperatorName(op_src).c_str(), ParserUtils::GetOperatorType(op_src).c_str()); | |||
GE_CHECK_NOTNULL(op_dest); | |||
ParseParamByOpFunc custom_op_parser = domi::OpRegistry::Instance()->GetParseParamByOperatorFunc(op_src.GetOpType()); | |||
ParseParamByOpFunc custom_op_parser = domi::OpRegistry::Instance()->GetParseParamByOperatorFunc( | |||
ParserUtils::GetOperatorType(op_src)); | |||
GE_CHECK_NOTNULL(custom_op_parser); | |||
op_dest->SetName(op_src.GetName()); | |||
op_dest->SetName(ParserUtils::GetOperatorName(op_src)); | |||
ge::Operator op = ge::OpDescUtils::CreateOperatorFromOpDesc(op_dest); | |||
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()); | |||
ParserUtils::GetOperatorName(op_src).c_str(), ParserUtils::GetOperatorType(op_src).c_str()); | |||
return SUCCESS; | |||
} | |||
@@ -25,11 +25,22 @@ using domi::caffe::BlobProto; | |||
using domi::CAFFE; | |||
namespace ge { | |||
Status CaffeOpParser::ParseParams(const Message *op_src, ge::OpDescPtr &op_dest) { return SUCCESS; } | |||
Status CaffeOpParser::ParseParams(const Message *op_src, ge::OpDescPtr &op_dest) { | |||
(void)op_src; | |||
(void)op_dest; | |||
return SUCCESS; | |||
} | |||
Status CaffeOpParser::ParseWeights(const Message *op_src, ge::NodePtr &node) { return SUCCESS; } | |||
Status CaffeOpParser::ParseWeights(const Message *op_src, ge::NodePtr &node) { | |||
(void)op_src; | |||
(void)node; | |||
return SUCCESS; | |||
} | |||
Status CaffeOpParser::AddConstInput(ge::NodePtr &node) { return SUCCESS; } | |||
Status CaffeOpParser::AddConstInput(ge::NodePtr &node) { | |||
(void)node; | |||
return SUCCESS; | |||
} | |||
void CaffeOpParser::ConvertShape(const BlobProto &proto, std::vector<int64_t> &shape) { | |||
shape.clear(); | |||
@@ -55,6 +55,8 @@ class PARSER_FUNC_VISIBILITY CaffeOpParser : public OpParser { | |||
Status ParseParams(const Message *op_src, ge::OpDescPtr &op_dest) override; | |||
Status ParseParams(const Message *op_src, ge::Operator &op_dest) override { | |||
(void)op_src; | |||
(void)op_dest; | |||
return domi::SUCCESS; | |||
} | |||
@@ -54,6 +54,7 @@ | |||
#include "register/op_registry.h" | |||
#include "register/register_fmk_types.h" | |||
#include "mmpa/mmpa_api.h" | |||
#include "parser/common/parser_utils.h" | |||
using domi::caffe::ConvolutionParameter; | |||
using domi::caffe::InnerProductParameter; | |||
@@ -106,27 +107,31 @@ graphStatus aclgrphParseCaffe(const char *model_file, const char *weights_file, | |||
// parse caffe model_file and weights_file to GE graph | |||
ge::graphStatus ret = model_parser->Parse(model_file, graph); | |||
if (ret != ge::SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "parse param:model_file %s failed, graph:%s.", model_file, graph.GetName().c_str()); | |||
GELOGE(ret, "[Parser][Param]ModelFile %s failed, graph:%s.", model_file, graph.GetName().c_str()); | |||
REPORT_CALL_ERROR("E19999", "parse param:model_file %s failed, graph:%s.", | |||
model_file, ParserUtils::GetGraphName(graph).c_str()); | |||
GELOGE(ret, "[Parser][Param]ModelFile %s failed, graph:%s.", model_file, | |||
ParserUtils::GetGraphName(graph).c_str()); | |||
return ge::FAILED; | |||
} | |||
GELOGI("Parser graph %s success.", graph.GetName().c_str()); | |||
GELOGI("Parser graph %s success.", ParserUtils::GetGraphName(graph).c_str()); | |||
auto weights_parser = domi::WeightsParserFactory::Instance()->CreateWeightsParser(domi::CAFFE); | |||
GE_CHECK_NOTNULL(weights_parser); | |||
ret = weights_parser->Parse(weights_file, graph); | |||
if (ret != ge::SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "parse param:weights_file %s failed, graph:%s", weights_file, graph.GetName().c_str()); | |||
GELOGE(ret, "[Parse][Param]WeightsFile %s failed. graph: %s", weights_file, graph.GetName().c_str()); | |||
REPORT_CALL_ERROR("E19999", "parse param:weights_file %s failed, graph:%s", | |||
weights_file, ParserUtils::GetGraphName(graph).c_str()); | |||
GELOGE(ret, "[Parse][Param]WeightsFile %s failed. graph: %s", weights_file, | |||
ParserUtils::GetGraphName(graph).c_str()); | |||
return ret; | |||
} | |||
GELOGI("Weights parse success. graph: %s", graph.GetName().c_str()); | |||
GELOGI("Weights parse success. graph: %s", ParserUtils::GetGraphName(graph).c_str()); | |||
std::map<AscendString, AscendString> parser_params; | |||
if (acl_graph_parse_util.SetOutputNodeInfo(graph, parser_params) != ge::SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "SetOutputNodeInfo failed, model file:%s graph:%s", | |||
model_file, graph.GetName().c_str()); | |||
model_file, ParserUtils::GetGraphName(graph).c_str()); | |||
GELOGE(ret, "[Invoke][SetOutputNodeInfo]Set graph %s default output node failed, model file:%s.", | |||
graph.GetName().c_str(), model_file); | |||
ParserUtils::GetGraphName(graph).c_str(), model_file); | |||
return ge::FAILED; | |||
} | |||
return ge::SUCCESS; | |||
@@ -166,15 +171,17 @@ graphStatus aclgrphParseCaffe(const char *model_file, const char *weights_file, | |||
// parse caffe model_file and weights_file to GE graph | |||
ge::graphStatus ret = model_parser->Parse(model_file, graph); | |||
if (ret != ge::SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Parse param:model_file %s failed, graph:%s", model_file, graph.GetName().c_str()); | |||
GELOGE(ret, "[Parser][Param]ModelFile %s failed, graph %s.", model_file, graph.GetName().c_str()); | |||
REPORT_CALL_ERROR("E19999", "Parse param:model_file %s failed, graph:%s", | |||
model_file, ParserUtils::GetGraphName(graph).c_str()); | |||
GELOGE(ret, "[Parser][Param]ModelFile %s failed, graph %s.", | |||
model_file, ParserUtils::GetGraphName(graph).c_str()); | |||
return ge::FAILED; | |||
} | |||
GELOGI("Parser graph %s success.", graph.GetName().c_str()); | |||
GELOGI("Parser graph %s success.", ParserUtils::GetGraphName(graph).c_str()); | |||
if (acl_graph_parse_util.ParseParamsAfterGraph(graph, parser_params) != ge::SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "ParseParamsAfterGraph failed, graph:%s.", graph.GetName().c_str()); | |||
GELOGE(ge::FAILED, "[Parser][Params] after graph failed, graph:%s.", graph.GetName().c_str()); | |||
REPORT_CALL_ERROR("E19999", "ParseParamsAfterGraph failed, graph:%s.", ParserUtils::GetGraphName(graph).c_str()); | |||
GELOGE(ge::FAILED, "[Parser][Params] after graph failed, graph:%s.", ParserUtils::GetGraphName(graph).c_str()); | |||
return ge::FAILED; | |||
} | |||
@@ -182,19 +189,21 @@ graphStatus aclgrphParseCaffe(const char *model_file, const char *weights_file, | |||
GE_CHECK_NOTNULL(weights_parser); | |||
ret = weights_parser->Parse(weights_file, graph); | |||
if (ret != ge::SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "parse param:weights_file %s failed, graph: %s", weights_file, graph.GetName().c_str()); | |||
GELOGE(ret, "[Parse][Param]WeightsFile %s failed. graph: %s", weights_file, graph.GetName().c_str()); | |||
REPORT_CALL_ERROR("E19999", "parse param:weights_file %s failed, graph: %s", | |||
weights_file, ParserUtils::GetGraphName(graph).c_str()); | |||
GELOGE(ret, "[Parse][Param]WeightsFile %s failed. graph: %s", | |||
weights_file, ParserUtils::GetGraphName(graph).c_str()); | |||
return ret; | |||
} | |||
GELOGI("Weights parse success. graph: %s", graph.GetName().c_str()); | |||
GELOGI("Weights parse success. graph: %s", ParserUtils::GetGraphName(graph).c_str()); | |||
if (acl_graph_parse_util.SetOutputNodeInfo(graph, parser_params) != ge::SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "SetOutputNodeInfo failed, graph:%s", graph.GetName().c_str()); | |||
REPORT_CALL_ERROR("E19999", "SetOutputNodeInfo failed, graph:%s", ParserUtils::GetGraphName(graph).c_str()); | |||
GELOGE(ge::FAILED, "[Invoke][SetOutputNodeInfo]Set graph %s default output node failed.", | |||
graph.GetName().c_str()); | |||
ParserUtils::GetGraphName(graph).c_str()); | |||
return ge::FAILED; | |||
} | |||
GELOGI("AclgrphParse graph %s success.", graph.GetName().c_str()); | |||
GELOGI("AclgrphParse graph %s success.", ParserUtils::GetGraphName(graph).c_str()); | |||
return ge::SUCCESS; | |||
} | |||
} // namespace ge | |||
@@ -423,6 +432,7 @@ Status CaffeModelParser::ParseNetModelByCustomProto(const char *model_path, cons | |||
Status CaffeModelParser::CustomProtoParse(const char *model_path, const string &custom_proto, | |||
const string &caffe_proto, vector<ge::Operator> &operators) { | |||
(void)caffe_proto; | |||
string custom_proto_path = ge::parser::RealPath(custom_proto.c_str()); | |||
if (custom_proto_path.empty()) { | |||
GELOGW("Valid custom proto: %s does not exist, skip parsing custom proto", custom_proto.c_str()); | |||
@@ -572,8 +582,8 @@ Status CaffeModelParser::CreateCustomOperator(string op_name, string op_type, co | |||
} | |||
GELOGI("Start to create new operator, name: %s, type: %s, index: %d.", op_name.c_str(), op_type.c_str(), index); | |||
ge::Operator ops(op_name, op_type); | |||
if (ops.GetName() != op_name) { | |||
ge::Operator ops(op_name.c_str(), op_type.c_str()); | |||
if (ParserUtils::GetOperatorName(ops) != op_name) { | |||
REPORT_INNER_ERROR("E19999", "Create Operator failed, name: %s, type: %s, index: %d.", | |||
op_name.c_str(), op_type.c_str(), index); | |||
GELOGE(FAILED, "[Create][Operator] failed, name: %s, type: %s, index: %d.", | |||
@@ -682,19 +692,22 @@ Status CaffeModelParser::AddBlobsToMap(const domi::caffe::LayerParameter &layer, | |||
} | |||
bool CaffeModelParser::IsOpAttrEmpty(const ge::Operator &op, const std::string &type) { | |||
const std::map<std::string, std::string> attrs = op.GetAllAttrNamesAndTypes(); | |||
std::map<AscendString, AscendString> attrs; | |||
(void)op.GetAllAttrNamesAndTypes(attrs); | |||
if (type == kCustom) { | |||
for (const auto &attr : attrs) { | |||
if (kCustomProtoLayerCommonField.count(attr.first) == 0) { | |||
GELOGI("Custom op[%s] attr name[%s] exists, not empty.", op.GetName().c_str(), attr.first.c_str()); | |||
if (kCustomProtoLayerCommonField.count(attr.first.GetString()) == 0) { | |||
GELOGI("Custom op[%s] attr name[%s] exists, not empty.", | |||
ParserUtils::GetOperatorName(op).c_str(), attr.first.GetString()); | |||
return false; | |||
} | |||
} | |||
} else if (type == kBuiltin) { | |||
for (const auto &attr : attrs) { | |||
if (kCaffeProtoLayerCommonField.count(attr.first) == 0) { | |||
GELOGI("Built-in op[%s] attr name[%s] exists, not empty.", op.GetName().c_str(), attr.first.c_str()); | |||
if (kCaffeProtoLayerCommonField.count(attr.first.GetString()) == 0) { | |||
GELOGI("Built-in op[%s] attr name[%s] exists, not empty.", | |||
ParserUtils::GetOperatorName(op).c_str(), attr.first.GetString()); | |||
return false; | |||
} | |||
} | |||
@@ -709,7 +722,7 @@ Status CaffeModelParser::GetCustomOp(const domi::caffe::LayerParameter &layer, v | |||
bool is_search_built_in_layer = false; | |||
for (ge::Operator &custom_op : custom_operator_) { | |||
if (custom_op.GetName() == layer.name() && custom_op.GetOpType() == op_type) { | |||
if (ParserUtils::GetOperatorName(custom_op) == layer.name() && ParserUtils::GetOperatorType(custom_op) == op_type) { | |||
if (IsOpAttrEmpty(custom_op, kCustom)) { | |||
GELOGW("Custom op attr is empty, should try to get op params from built-in layer."); | |||
is_search_built_in_layer = true; | |||
@@ -922,8 +935,8 @@ Status CaffeModelParser::AddTensorDescToOpDescByIr(ge::OpDescPtr &op_desc, const | |||
// Get opDesc by ir | |||
string layer_name = layer.name(); | |||
ge::Operator op_factory = ge::OperatorFactory::CreateOperator(layer_name, op_type); | |||
if (op_factory.GetName() != layer.name()) { | |||
ge::Operator op_factory = ge::OperatorFactory::CreateOperator(layer_name.c_str(), op_type.c_str()); | |||
if (ParserUtils::GetOperatorName(op_factory) != layer.name()) { | |||
ErrorManager::GetInstance().ATCReportErrMessage("E10501", {"opname", "optype"}, {layer_name, op_type}); | |||
GELOGE(FAILED, "[Invoke][CreateOperator]IR for op[%s] optype[%s] is not registered.", | |||
layer_name.c_str(), op_type.c_str()); | |||
@@ -1352,11 +1365,11 @@ Status CaffeModelParser::Parse(const char *model_path, ge::Graph &graph) { | |||
Status ret = Parse(model_path, compute_graph); | |||
if (ret != SUCCESS) { | |||
GELOGE(ret, "[Parser][Model] %s for graph %s failed.", model_path, graph.GetName().c_str()); | |||
GELOGE(ret, "[Parser][Model] %s for graph %s failed.", model_path, ParserUtils::GetGraphName(graph).c_str()); | |||
return ret; | |||
} | |||
GELOGI("Parser model for graph %s success.", graph.GetName().c_str()); | |||
GELOGI("Parser model for graph %s success.", ParserUtils::GetGraphName(graph).c_str()); | |||
return SUCCESS; | |||
} | |||
@@ -1675,11 +1688,11 @@ Status CaffeWeightsParser::Parse(const char *file, ge::Graph &graph) { | |||
Status ret = Parse(file, compute_graph); | |||
if (ret != SUCCESS) { | |||
GELOGE(ret, "[Parser][Weight] %s for graph %s failed.", file, graph.GetName().c_str()); | |||
GELOGE(ret, "[Parser][Weight] %s for graph %s failed.", file, ParserUtils::GetGraphName(graph).c_str()); | |||
return ret; | |||
} | |||
GELOGI("Parser weight for graph %s success.", graph.GetName().c_str()); | |||
GELOGI("Parser weight for graph %s success.", ParserUtils::GetGraphName(graph).c_str()); | |||
return SUCCESS; | |||
} | |||
@@ -2290,11 +2303,16 @@ Status CaffeWeightsParser::ConvertNetParameter(const NetParameter ¶m, ge::Co | |||
} | |||
Status CaffeModelParser::ParseProto(const google::protobuf::Message *proto, ge::ComputeGraphPtr &graph) { | |||
(void)proto; | |||
(void)graph; | |||
return SUCCESS; | |||
} | |||
Status CaffeModelParser::ParseProtoWithSubgraph(const google::protobuf::Message *root_proto, | |||
domi::GetGraphCallback callback, | |||
ge::ComputeGraphPtr &graph) { | |||
(void)root_proto; | |||
(void)callback; | |||
(void)graph; | |||
return SUCCESS; | |||
} | |||
} // namespace ge | |||
@@ -79,6 +79,9 @@ class PARSER_FUNC_VISIBILITY CaffeModelParser : public domi::ModelParser { | |||
Status ParseFromMemory(const char *data, uint32_t size, ge::ComputeGraphPtr &graph) override; | |||
Status ParseFromMemory(const char *data, uint32_t size, ge::Graph &graph) override { | |||
(void)data; | |||
(void)size; | |||
(void)graph; | |||
return domi::SUCCESS; | |||
} | |||
@@ -108,9 +111,14 @@ class PARSER_FUNC_VISIBILITY CaffeModelParser : public domi::ModelParser { | |||
* @param [in] type, datatype types of operators in CAFFE networks | |||
* @return ge::DataType | |||
*/ | |||
ge::DataType ConvertToGeDataType(const uint32_t type) override { return ge::DT_FLOAT; } | |||
ge::DataType ConvertToGeDataType(const uint32_t type) override { | |||
(void)type; | |||
return ge::DT_FLOAT; | |||
} | |||
Status ParseAllGraph(const google::protobuf::Message *root_proto, ge::ComputeGraphPtr &root_graph) override { | |||
(void)root_proto; | |||
(void)root_graph; | |||
return domi::SUCCESS; | |||
} | |||
@@ -37,8 +37,9 @@ add_dependencies(parser_common | |||
target_compile_options(parser_common PRIVATE | |||
-Werror | |||
-Wno-deprecated-declarations | |||
-fno-common | |||
-Wextra | |||
-Wfloat-equal | |||
) | |||
target_compile_definitions(parser_common PRIVATE | |||
@@ -520,6 +520,7 @@ domi::Status AclGrphParseUtil::GetDefaultOutInfo(ge::ComputeGraphPtr &compute_gr | |||
domi::Status AclGrphParseUtil::SetOutputNodeInfo(ge::Graph &graph, | |||
const std::map<AscendString, AscendString> &parser_params) { | |||
(void)parser_params; | |||
ge::ComputeGraphPtr compute_graph = ge::GraphUtils::GetComputeGraph(graph); | |||
GE_CHECK_NOTNULL(compute_graph); | |||
@@ -562,15 +563,15 @@ domi::Status AclGrphParseUtil::SetOutputNodeInfo(ge::Graph &graph, | |||
// default output node (leaf) | |||
if (user_out_nodes.empty()) { | |||
if (GetDefaultOutInfo(compute_graph, output_nodes_info) != SUCCESS) { | |||
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()); | |||
REPORT_CALL_ERROR("E19999", "GetDefaultOutInfo failed for graph:%s", compute_graph->GetName().c_str()); | |||
GELOGE(domi::FAILED, "[Invoke][GetDefaultOutInfo] failed, graph:%s.", compute_graph->GetName().c_str()); | |||
return domi::FAILED; | |||
} | |||
} | |||
CreateOutputNodesInfo(output_nodes_info, output_nodes_name); | |||
compute_graph->SetGraphOutNodesInfo(output_nodes_info); | |||
ge::GetParserContext().net_out_nodes = output_nodes_name; | |||
GELOGI("Set graph %s output node success.", graph.GetName().c_str()); | |||
GELOGI("Set graph %s output node success.", compute_graph->GetName().c_str()); | |||
return domi::SUCCESS; | |||
} | |||
@@ -726,7 +727,7 @@ static bool ReadProtoFromCodedInputStream(CodedInputStream &coded_stream, Messag | |||
REPORT_INNER_ERROR("E19999", "param proto is nullptr, check invalid"); | |||
return false, "[Check][Param] incorrect parameter. nullptr == proto"); | |||
coded_stream.SetTotalBytesLimit(kProtoReadBytesLimit, kWarningThreshold); | |||
coded_stream.SetTotalBytesLimit(kProtoReadBytesLimit); | |||
return proto->ParseFromCodedStream(&coded_stream); | |||
} | |||
@@ -130,14 +130,14 @@ Status AutoMappingSubgraphIndexByDataNodeAndOutputNodesInfo( | |||
auto ret = AutoMappingSubgraphIndexByDataNode(compute_graph, input); | |||
if (ret != SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Auto mapping graph:%s input index failed,", graph.GetName().c_str()); | |||
GELOGE(ret, "[Mapping][InputIndex] Auto mapping graph:%s input index failed,", graph.GetName().c_str()); | |||
REPORT_CALL_ERROR("E19999", "Auto mapping graph:%s input index failed,", compute_graph->GetName().c_str()); | |||
GELOGE(ret, "[Mapping][InputIndex] Auto mapping graph:%s input index failed,", compute_graph->GetName().c_str()); | |||
return ret; | |||
} | |||
ret = AutoMappingSubgraphIndexByOutputNodesInfo(compute_graph, output); | |||
if (ret != SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Auto mapping graph:%s output index failed,", graph.GetName().c_str()); | |||
GELOGE(ret, "[Mapping][OutputIndex] Auto mapping graph:%s output index failed,", graph.GetName().c_str()); | |||
REPORT_CALL_ERROR("E19999", "Auto mapping graph:%s output index failed,", compute_graph->GetName().c_str()); | |||
GELOGE(ret, "[Mapping][OutputIndex] Auto mapping graph:%s output index failed,", compute_graph->GetName().c_str()); | |||
return ret; | |||
} | |||
@@ -44,7 +44,7 @@ Status Message2Operator::ParseOperatorAttrs(const google::protobuf::Message *mes | |||
for (auto &field : field_desc) { | |||
GE_CHECK_NOTNULL(field); | |||
if (field->is_repeated()) { | |||
if (ParseRepeatedField(reflection, message, field, depth, ops) != SUCCESS) { | |||
if (ParseRepeatedField(reflection, message, field, ops) != SUCCESS) { | |||
GELOGE(FAILED, "[Parse][RepeatedField] %s failed.", field->name().c_str()); | |||
return FAILED; | |||
} | |||
@@ -67,7 +67,7 @@ Status Message2Operator::ParseField(const google::protobuf::Reflection *reflecti | |||
case google::protobuf::FieldDescriptor::CPPTYPE_##cpptype: { \ | |||
valuetype value = reflection->Get##method(*message, field); \ | |||
GELOGD("Parse result(%s : %" #logtype ")", field->name().c_str(), value); \ | |||
(void)ops.SetAttr(field->name(), value); \ | |||
(void)ops.SetAttr(field->name().c_str(), value); \ | |||
break; \ | |||
} | |||
CASE_FIELD_TYPE(INT32, Int32, int32_t, d); | |||
@@ -80,13 +80,13 @@ Status Message2Operator::ParseField(const google::protobuf::Reflection *reflecti | |||
GE_CHECK_NOTNULL(reflection->GetEnum(*message, field)); | |||
int value = reflection->GetEnum(*message, field)->number(); | |||
GELOGD("Parse result(%s : %d)", field->name().c_str(), value); | |||
(void)ops.SetAttr(field->name(), value); | |||
(void)ops.SetAttr(field->name().c_str(), value); | |||
break; | |||
} | |||
case google::protobuf::FieldDescriptor::CPPTYPE_STRING: { | |||
string value = reflection->GetString(*message, field); | |||
GELOGD("Parse result(%s : %s)", field->name().c_str(), value.c_str()); | |||
(void)ops.SetAttr(field->name(), value); | |||
(void)ops.SetAttr(field->name().c_str(), value); | |||
break; | |||
} | |||
case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE: { | |||
@@ -110,7 +110,7 @@ Status Message2Operator::ParseField(const google::protobuf::Reflection *reflecti | |||
Status Message2Operator::ParseRepeatedField(const google::protobuf::Reflection *reflection, | |||
const google::protobuf::Message *message, | |||
const google::protobuf::FieldDescriptor *field, int depth, | |||
const google::protobuf::FieldDescriptor *field, | |||
ge::Operator &ops) { | |||
GELOGD("Start to parse field: %s.", field->name().c_str()); | |||
int field_size = reflection->FieldSize(*message, field); | |||
@@ -128,7 +128,7 @@ Status Message2Operator::ParseRepeatedField(const google::protobuf::Reflection * | |||
valuetype value = reflection->GetRepeated##method(*message, field, i); \ | |||
attr_value.push_back(value); \ | |||
} \ | |||
(void)ops.SetAttr(field->name(), attr_value); \ | |||
(void)ops.SetAttr(field->name().c_str(), attr_value); \ | |||
break; \ | |||
} | |||
CASE_FIELD_TYPE_REPEATED(INT32, Int32, int32_t); | |||
@@ -154,7 +154,7 @@ Status Message2Operator::ParseRepeatedField(const google::protobuf::Reflection * | |||
GELOGE(FAILED, "[Parse][JSON]Failed to convert JSON to string."); | |||
return FAILED; | |||
} | |||
(void)ops.SetAttr(field->name(), repeated_message_str); | |||
(void)ops.SetAttr(field->name().c_str(), repeated_message_str); | |||
break; | |||
} | |||
default: { | |||
@@ -32,7 +32,7 @@ class Message2Operator { | |||
static Status ParseRepeatedField(const google::protobuf::Reflection *reflection, | |||
const google::protobuf::Message *message, | |||
const google::protobuf::FieldDescriptor *field, int depth, ge::Operator &ops); | |||
const google::protobuf::FieldDescriptor *field, ge::Operator &ops); | |||
}; | |||
} // namespace ge | |||
#endif // PARSER_MESSAGE2OPERATOR_H |
@@ -76,7 +76,7 @@ void Pb2Json::OneField2Json(const ProtobufMsg &message, const ProtobufFieldDescr | |||
switch (field->type()) { | |||
case ProtobufFieldDescriptor::TYPE_MESSAGE: { | |||
const ProtobufMsg &tmp_message = reflection->GetMessage(message, field); | |||
if (0 != tmp_message.ByteSize()) { | |||
if (0UL != tmp_message.ByteSizeLong()) { | |||
Message2Json(tmp_message, black_fields, json[field->name()], enum2str); | |||
} | |||
break; | |||
@@ -174,7 +174,7 @@ void Pb2Json::RepeatedMessage2Json(const ProtobufMsg &message, const ProtobufFie | |||
switch (field->type()) { | |||
case ProtobufFieldDescriptor::TYPE_MESSAGE: { | |||
const ProtobufMsg &tmp_message = reflection->GetRepeatedMessage(message, field, i); | |||
if (0 != tmp_message.ByteSize()) { | |||
if (0UL != tmp_message.ByteSizeLong()) { | |||
Message2Json(tmp_message, black_fields, tmp_json, enum2str); | |||
} | |||
} break; | |||
@@ -91,13 +91,15 @@ Status ParserUtils::ExpandOneToManyGraph(const Graph &graph, OutputMapping &outp | |||
Operator op = OpDescUtils::CreateOperatorFromNode(n); | |||
Status ret = parse_op_to_graph_func(op, subgraph); | |||
if (ret != SUCCESS) { | |||
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()); | |||
REPORT_CALL_ERROR("E19999", "Get one to many graph failed for op:%s.", GetOperatorName(op).c_str()); | |||
GELOGE(FAILED, "[Invoke][ParseOpToGraphFunc]Get one to many graph failed for op:%s.", | |||
GetOperatorName(op).c_str()); | |||
return FAILED; | |||
} | |||
ret = ExpandNodeToSubgraph(subgraph, n, graph, output_mapping); | |||
if (ret != SUCCESS) { | |||
GELOGE(FAILED, "[Invoke][ExpandNodeToSubgraph]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.", | |||
GetOperatorName(op).c_str()); | |||
return FAILED; | |||
} | |||
} | |||
@@ -299,4 +301,22 @@ void ParserUtils::UpdateOutputCtx(const OutputMapping &final_output_nodes, Outpu | |||
UpdateOutputNodeInfo(final_output_nodes, output_node_info); | |||
} | |||
} | |||
std::string ParserUtils::GetOperatorName(const Operator &op) { | |||
AscendString name; | |||
(void)op.GetName(name); | |||
return name.GetString() == nullptr ? "" : std::string(name.GetString()); | |||
} | |||
std::string ParserUtils::GetOperatorType(const Operator &op) { | |||
AscendString type; | |||
(void)op.GetOpType(type); | |||
return type.GetString() == nullptr ? "" : std::string(type.GetString()); | |||
} | |||
std::string ParserUtils::GetGraphName(const Graph &graph) { | |||
AscendString name; | |||
(void)graph.GetName(name); | |||
return name.GetString() == nullptr ? "" : std::string(name.GetString()); | |||
} | |||
} // namespace ge |
@@ -31,6 +31,9 @@ class ParserUtils { | |||
static string GenOutputKey(const OutputNodeInfo &node_info); | |||
static void UpdateOutputNodeInfo(const OutputMapping &final_output_nodes, OutputNodeInfo &output_node_info); | |||
static void UpdateOutputCtx(const OutputMapping &final_output_nodes, OutputMapping &tensor_to_nodes); | |||
static std::string GetOperatorName(const Operator &op); | |||
static std::string GetOperatorType(const Operator &op); | |||
static std::string GetGraphName(const Graph &graph); | |||
private: | |||
static Status ExpandNodeToSubgraph(const Graph &subgraph, const NodePtr &node, const Graph &graph, | |||
@@ -28,6 +28,13 @@ | |||
#include "parser/tensorflow/tensorflow_fusion_custom_parser_adapter.h" | |||
namespace ge { | |||
namespace { | |||
std::string GetOmOptype(const OpRegistrationData ®_data) { | |||
AscendString om_op_type; | |||
(void)reg_data.GetOmOptype(om_op_type); | |||
return om_op_type.GetString() == nullptr ? "" : std::string(om_op_type.GetString()); | |||
} | |||
} | |||
using PARSER_CREATOR_FN = std::function<std::shared_ptr<OpParser>(void)>; | |||
FMK_FUNC_HOST_VISIBILITY OpRegistrationTbe *OpRegistrationTbe::Instance() { | |||
@@ -45,16 +52,21 @@ bool OpRegistrationTbe::Finalize(const OpRegistrationData ®_data, bool is_tra | |||
if (op_map.find(reg_data.GetFrameworkType()) != op_map.end()) { | |||
std::map<std::string, std::string> *fmk_op_map = op_map[reg_data.GetFrameworkType()]; | |||
auto ori_optype_set = reg_data.GetOriginOpTypeSet(); | |||
std::set<AscendString> ori_optype_set; | |||
(void)reg_data.GetOriginOpTypeSet(ori_optype_set); | |||
for (auto &tmp : ori_optype_set) { | |||
if ((*fmk_op_map).find(tmp) != (*fmk_op_map).end()) { | |||
GELOGW("Op type does not need to be changed, om_optype:%s, orignal type:%s.", (*fmk_op_map)[tmp].c_str(), | |||
tmp.c_str()); | |||
if (tmp.GetString() == nullptr) { | |||
continue; | |||
} | |||
if ((*fmk_op_map).find(tmp.GetString()) != (*fmk_op_map).end()) { | |||
GELOGW("Op type does not need to be changed, om_optype:%s, orignal type:%s.", | |||
(*fmk_op_map)[tmp.GetString()].c_str(), tmp.GetString()); | |||
continue; | |||
} else { | |||
(*fmk_op_map)[tmp] = reg_data.GetOmOptype(); | |||
GELOGD("First register in parser initialize, original type: %s, om_optype: %s, imply type: %s.", tmp.c_str(), | |||
reg_data.GetOmOptype().c_str(), TypeUtils::ImplyTypeToSerialString(reg_data.GetImplyType()).c_str()); | |||
(*fmk_op_map)[tmp.GetString()] = GetOmOptype(reg_data); | |||
GELOGD("First register in parser initialize, original type: %s, om_optype: %s, imply type: %s.", | |||
tmp.GetString(), GetOmOptype(reg_data).c_str(), | |||
TypeUtils::ImplyTypeToSerialString(reg_data.GetImplyType()).c_str()); | |||
} | |||
} | |||
} | |||
@@ -72,9 +84,9 @@ bool OpRegistrationTbe::RegisterParser(const OpRegistrationData ®_data) { | |||
return false; | |||
} | |||
if (reg_data.GetParseParamFn() != nullptr || reg_data.GetParseParamByOperatorFn() != nullptr) { | |||
bool is_registed = factory->OpParserIsRegistered(reg_data.GetOmOptype()); | |||
bool is_registed = factory->OpParserIsRegistered(GetOmOptype(reg_data)); | |||
if (is_registed) { | |||
GELOGW("Parse param func has already register for op:%s.", reg_data.GetOmOptype().c_str()); | |||
GELOGW("Parse param func has already register for op:%s.", GetOmOptype(reg_data).c_str()); | |||
return false; | |||
} | |||
std::shared_ptr<TensorFlowCustomParserAdapter> tf_parser_adapter = | |||
@@ -85,15 +97,15 @@ bool OpRegistrationTbe::RegisterParser(const OpRegistrationData ®_data) { | |||
return false; | |||
} | |||
OpParserRegisterar registerar __attribute__((unused)) = OpParserRegisterar( | |||
domi::TENSORFLOW, reg_data.GetOmOptype(), [=]() -> std::shared_ptr<OpParser> { return tf_parser_adapter; }); | |||
domi::TENSORFLOW, GetOmOptype(reg_data), [=]() -> std::shared_ptr<OpParser> { return tf_parser_adapter; }); | |||
} | |||
if (reg_data.GetFusionParseParamFn() != nullptr || reg_data.GetFusionParseParamByOpFn() != nullptr) { | |||
bool is_registed = factory->OpParserIsRegistered(reg_data.GetOmOptype(), true); | |||
bool is_registed = factory->OpParserIsRegistered(GetOmOptype(reg_data), true); | |||
if (is_registed) { | |||
GELOGW("Parse param func has already register for fusion op:%s.", reg_data.GetOmOptype().c_str()); | |||
GELOGW("Parse param func has already register for fusion op:%s.", GetOmOptype(reg_data).c_str()); | |||
return false; | |||
} | |||
GELOGI("Register fusion custom op parser: %s", reg_data.GetOmOptype().c_str()); | |||
GELOGI("Register fusion custom op parser: %s", GetOmOptype(reg_data).c_str()); | |||
std::shared_ptr<TensorFlowFusionCustomParserAdapter> tf_fusion_parser_adapter = | |||
ge::parser::MakeShared<TensorFlowFusionCustomParserAdapter>(); | |||
if (tf_fusion_parser_adapter == nullptr) { | |||
@@ -102,7 +114,7 @@ bool OpRegistrationTbe::RegisterParser(const OpRegistrationData ®_data) { | |||
return false; | |||
} | |||
OpParserRegisterar registerar __attribute__((unused)) = OpParserRegisterar( | |||
domi::TENSORFLOW, reg_data.GetOmOptype(), | |||
domi::TENSORFLOW, GetOmOptype(reg_data), | |||
[=]() -> std::shared_ptr<OpParser> { return tf_fusion_parser_adapter; }, true); | |||
} | |||
} else { | |||
@@ -114,9 +126,9 @@ bool OpRegistrationTbe::RegisterParser(const OpRegistrationData ®_data) { | |||
TypeUtils::FmkTypeToSerialString(reg_data.GetFrameworkType()).c_str()); | |||
return false; | |||
} | |||
bool is_registed = factory->OpParserIsRegistered(reg_data.GetOmOptype()); | |||
bool is_registed = factory->OpParserIsRegistered(GetOmOptype(reg_data)); | |||
if (is_registed) { | |||
GELOGW("Parse param func has already register for op:%s.", reg_data.GetOmOptype().c_str()); | |||
GELOGW("Parse param func has already register for op:%s.", GetOmOptype(reg_data).c_str()); | |||
return false; | |||
} | |||
@@ -128,8 +140,8 @@ bool OpRegistrationTbe::RegisterParser(const OpRegistrationData ®_data) { | |||
TypeUtils::FmkTypeToSerialString(reg_data.GetFrameworkType()).c_str()); | |||
return false; | |||
} | |||
OpParserFactory::Instance(reg_data.GetFrameworkType())->RegisterCreator(reg_data.GetOmOptype(), func); | |||
GELOGD("Register custom parser adapter for op %s of fmk type %s success.", reg_data.GetOmOptype().c_str(), | |||
OpParserFactory::Instance(reg_data.GetFrameworkType())->RegisterCreator(GetOmOptype(reg_data), func); | |||
GELOGD("Register custom parser adapter for op %s of fmk type %s success.", GetOmOptype(reg_data).c_str(), | |||
TypeUtils::FmkTypeToSerialString(reg_data.GetFrameworkType()).c_str()); | |||
} | |||
return true; | |||
@@ -17,9 +17,10 @@ add_dependencies(fmk_onnx_parser | |||
target_compile_options(fmk_onnx_parser PRIVATE | |||
-Werror | |||
-Wno-deprecated-declarations | |||
-fno-common | |||
-fvisibility=hidden | |||
-Wextra | |||
-Wfloat-equal | |||
) | |||
target_compile_definitions(fmk_onnx_parser PRIVATE | |||
@@ -89,7 +89,7 @@ Status OnnxConstantParser::ParseConvertData(const ge::onnx::TensorProto &tensor_ | |||
} | |||
if (data_type == OnnxDataType::STRING) { | |||
tensor.SetData(tensor_proto.raw_data()); | |||
tensor.SetData(tensor_proto.raw_data().c_str()); | |||
} else { | |||
tensor.SetData(reinterpret_cast<const uint8_t *>(tensor_proto.raw_data().c_str()), | |||
tensor_proto.raw_data().size()); | |||
@@ -122,9 +122,9 @@ void OnnxConstantParser::ParseConvertDataElements(const ge::onnx::TensorProto &t | |||
break; | |||
// for string values | |||
case OnnxDataType::STRING: { | |||
std::vector<std::string> data; | |||
std::vector<AscendString> data; | |||
for (auto str_data : tensor_proto.string_data()) { | |||
data.emplace_back(str_data); | |||
data.emplace_back(AscendString(str_data.c_str())); | |||
} | |||
tensor.SetData(data); | |||
break; | |||
@@ -58,6 +58,16 @@ class PARSER_FUNC_VISIBILITY OnnxConstantParser : public OnnxOpParser { | |||
DataType data_type = tensor.GetTensorDesc().GetDataType(); | |||
switch (data_type) { | |||
case DT_BOOL: { | |||
unique_ptr<bool> addr_trans(new(std::nothrow) bool[count]()); | |||
GE_CHECK_NOTNULL(addr_trans); | |||
for (int32_t i = 0; i < count; i++) { | |||
*(addr_trans.get() + i) = static_cast<bool>( | |||
std::fabs(*((addr).get() + i)) > std::numeric_limits<T>::epsilon()); | |||
} | |||
(tensor).SetData(reinterpret_cast<uint8_t *>(addr_trans.get()), (count) * sizeof(bool)); | |||
break; | |||
} | |||
#define CASE_SET_DATA(dt_type, value_type, addr, count, tensor) \ | |||
case dt_type: \ | |||
{ \ | |||
@@ -75,7 +85,6 @@ class PARSER_FUNC_VISIBILITY OnnxConstantParser : public OnnxOpParser { | |||
CASE_SET_DATA(DT_INT8, int8_t, addr, count, tensor) | |||
CASE_SET_DATA(DT_UINT16, uint16_t, addr, count, tensor) | |||
CASE_SET_DATA(DT_UINT8, uint8_t, addr, count, tensor) | |||
CASE_SET_DATA(DT_BOOL, bool, addr, count, tensor) | |||
CASE_SET_DATA(DT_UINT32, uint32_t, addr, count, tensor) | |||
#undef CASE_SET_DATA | |||
default: | |||
@@ -20,6 +20,7 @@ | |||
#include "framework/common/debug/ge_log.h" | |||
#include "parser/common/op_parser_factory.h" | |||
#include "register/op_registry.h" | |||
#include "parser/common/parser_utils.h" | |||
using domi::ONNX; | |||
using domi::ParseParamByOpFunc; | |||
@@ -33,7 +34,7 @@ Status OnnxCustomParserAdapter::ParseParams(const Message *op_src, ge::Operator | |||
GELOGI("Onnx op node name = %s, op type= %s, parse params.", node_src->name().c_str(), node_src->op_type().c_str()); | |||
ParseParamFunc custom_op_parser = | |||
domi::OpRegistry::Instance()->GetParseParamFunc(op_dest.GetOpType(), node_src->op_type()); | |||
domi::OpRegistry::Instance()->GetParseParamFunc(ParserUtils::GetOperatorType(op_dest), node_src->op_type()); | |||
GE_CHECK_NOTNULL(custom_op_parser); | |||
if (custom_op_parser(op_src, op_dest) != SUCCESS) { | |||
GELOGE(FAILED, "[Invoke][Custom_Op_Parser] Custom parser params failed."); | |||
@@ -43,12 +44,13 @@ Status OnnxCustomParserAdapter::ParseParams(const Message *op_src, ge::Operator | |||
} | |||
Status OnnxCustomParserAdapter::ParseParams(const Operator &op_src, Operator &op_dest) { | |||
ParseParamByOpFunc custom_op_parser = domi::OpRegistry::Instance()->GetParseParamByOperatorFunc(op_src.GetOpType()); | |||
ParseParamByOpFunc custom_op_parser = domi::OpRegistry::Instance()->GetParseParamByOperatorFunc( | |||
ParserUtils::GetOperatorType(op_src)); | |||
GE_CHECK_NOTNULL(custom_op_parser); | |||
if (custom_op_parser(op_src, op_dest) != SUCCESS) { | |||
GELOGE(FAILED, "[Invoke][Custom_Op_Parser] failed, node name:%s, type:%s", op_src.GetName().c_str(), | |||
op_src.GetOpType().c_str()); | |||
GELOGE(FAILED, "[Invoke][Custom_Op_Parser] failed, node name:%s, type:%s", | |||
ParserUtils::GetOperatorName(op_src).c_str(), ParserUtils::GetOperatorType(op_src).c_str()); | |||
return FAILED; | |||
} | |||
@@ -21,6 +21,7 @@ | |||
#include "parser/common/op_parser_factory.h" | |||
#include "framework/omg/parser/parser_inner_ctx.h" | |||
#include "parser/onnx/onnx_util.h" | |||
#include "parser/common/parser_utils.h" | |||
using domi::ONNX; | |||
using namespace ge::parser; | |||
@@ -32,7 +33,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", ParserUtils::GetOperatorName(op_def).c_str()); | |||
return FAILED; | |||
} | |||
// Subgraph data operator don't need parse input shape | |||
@@ -42,7 +43,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", ParserUtils::GetOperatorName(op_def).c_str()); | |||
return FAILED; | |||
} | |||
@@ -50,12 +51,12 @@ Status OnnxDataParser::ParseParams(const Message *op_src, ge::Operator &op_def) | |||
tensor_desc.SetShape(ge::Shape(user_input_dims_v_)); | |||
tensor_desc.SetOriginShape(ge::Shape(user_input_dims_v_)); | |||
int64_t type = 1; | |||
(void)op_def.GetAttr(ge::DATA_ATTR_NAME_DATA_TYPE, type); | |||
(void)op_def.GetAttr(ge::DATA_ATTR_NAME_DATA_TYPE.c_str(), type); | |||
tensor_desc.SetDataType(static_cast<DataType>(type)); | |||
auto op_desc = ge::OpDescUtils::GetOpDescFromOperator(op_def); | |||
op_def.UpdateInputDesc(op_desc->GetInputNameByIndex(0), tensor_desc); | |||
op_def.UpdateOutputDesc(op_desc->GetOutputNameByIndex(0), tensor_desc); | |||
op_def.UpdateInputDesc(op_desc->GetInputNameByIndex(0).c_str(), tensor_desc); | |||
op_def.UpdateOutputDesc(op_desc->GetOutputNameByIndex(0).c_str(), tensor_desc); | |||
return SUCCESS; | |||
} | |||
@@ -90,7 +91,7 @@ Status OnnxDataParser::ParseInputFromModel(const Message *op_src, ge::Operator & | |||
} | |||
} | |||
op_def.SetAttr(ge::ATTR_NAME_INDEX, index); | |||
op_def.SetAttr(ge::ATTR_NAME_INDEX.c_str(), index); | |||
if (IsSubgraphDataOp()) { | |||
return SUCCESS; | |||
} | |||
@@ -102,7 +103,7 @@ Status OnnxDataParser::ParseInputFromModel(const Message *op_src, ge::Operator & | |||
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)); | |||
op_def.SetAttr(ge::DATA_ATTR_NAME_DATA_TYPE.c_str(), static_cast<int64_t>(type)); | |||
return SUCCESS; | |||
} | |||
@@ -110,7 +111,7 @@ Status OnnxDataParser::ParseInputFromModel(const Message *op_src, ge::Operator & | |||
Status OnnxDataParser::ParseInputFromUser(const ge::Operator &op_def) { | |||
std::map<std::string, std::vector<int64_t>> input_dims = GetParserContext().input_dims; | |||
// User not designate the input_shape | |||
std::string name = op_def.GetName(); | |||
std::string name = ParserUtils::GetOperatorName(op_def); | |||
if (input_dims.count(name) == 0) { | |||
GELOGI("input shape of node %s is not designated ,need parse from model", name.c_str()); | |||
for (uint32_t i = 0; i < model_input_dims_v_.size(); i++) { | |||
@@ -49,6 +49,8 @@ class PARSER_FUNC_VISIBILITY OnnxOpParser : public OpParser { | |||
/// @return SUCCESS parse success | |||
/// @return FAILED Parse failed | |||
Status ParseParams(const Message *op_src, ge::OpDescPtr &op_dest) override { | |||
(void)op_src; | |||
(void)op_dest; | |||
return domi::SUCCESS; | |||
} | |||
@@ -58,6 +60,8 @@ class PARSER_FUNC_VISIBILITY OnnxOpParser : public OpParser { | |||
/// @return SUCCESS parse success | |||
/// @return FAILED Parse failed | |||
Status ParseParams(const Message *op_src, ge::Operator &op_dest) override { | |||
(void)op_src; | |||
(void)op_dest; | |||
return domi::SUCCESS; | |||
} | |||
@@ -67,6 +71,8 @@ class PARSER_FUNC_VISIBILITY OnnxOpParser : public OpParser { | |||
/// @return SUCCESS parsing success | |||
/// @return FAILED parsing failed | |||
Status ParseWeights(const Message *op_src, ge::NodePtr &node) override { | |||
(void)op_src; | |||
(void)node; | |||
return domi::SUCCESS; | |||
} | |||
}; | |||
@@ -88,7 +88,8 @@ graphStatus HandleAfterParse(AclGrphParseUtil &acl_graph_parse_util, | |||
if (acl_graph_parse_util.SetOutputNodeInfo(graph, parser_params) != ge::SUCCESS) { | |||
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()); | |||
GELOGE(ge::FAILED, "[Update][NodeInfo] Set graph %s default output node failed.", | |||
ParserUtils::GetGraphName(graph).c_str()); | |||
return ge::FAILED; | |||
} | |||
return ge::SUCCESS; | |||
@@ -110,18 +111,19 @@ 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) { | |||
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()); | |||
REPORT_CALL_ERROR("E19999", "parse modelfile %s failed, graph:%s", | |||
model_file, ParserUtils::GetGraphName(graph).c_str()); | |||
GELOGE(ret, "[Parse][ModelFile] %s failed, graph %s.", model_file, ParserUtils::GetGraphName(graph).c_str()); | |||
return ge::FAILED; | |||
} | |||
GELOGI("Parser graph %s success.", graph.GetName().c_str()); | |||
GELOGI("Parser graph %s success.", ParserUtils::GetGraphName(graph).c_str()); | |||
if (HandleAfterParse(acl_graph_parse_util, parser_params, graph) != ge::SUCCESS) { | |||
GELOGE(ge::FAILED, "[Invoke][HandleAfterParse] failed."); | |||
return ge::FAILED; | |||
} | |||
GELOGI("AclgrphParse graph %s success.", graph.GetName().c_str()); | |||
GELOGI("AclgrphParse graph %s success.", ParserUtils::GetGraphName(graph).c_str()); | |||
return ge::SUCCESS; | |||
} | |||
@@ -141,16 +143,16 @@ graphStatus aclgrphParseONNXFromMem(const char *buffer, size_t size, | |||
ge::graphStatus ret = model_parser->ParseFromMemory(buffer, (uint32_t)size, graph); | |||
if (ret != ge::SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "ParseFromMemory failed"); | |||
GELOGE(ret, "[Parser][Graph] %s failed.", graph.GetName().c_str()); | |||
GELOGE(ret, "[Parser][Graph] %s failed.", ParserUtils::GetGraphName(graph).c_str()); | |||
return ge::FAILED; | |||
} | |||
GELOGI("Parser graph %s success.", graph.GetName().c_str()); | |||
GELOGI("Parser graph %s success.", ParserUtils::GetGraphName(graph).c_str()); | |||
if (HandleAfterParse(acl_graph_parse_util, parser_params, graph) != ge::SUCCESS) { | |||
GELOGE(ge::FAILED, "[Invoke][HandleAfterParse] failed."); | |||
return ge::FAILED; | |||
} | |||
GELOGI("AclgrphParse graph %s success.", graph.GetName().c_str()); | |||
GELOGI("AclgrphParse graph %s success.", ParserUtils::GetGraphName(graph).c_str()); | |||
return ge::SUCCESS; | |||
} | |||
} // namespace ge | |||
@@ -444,8 +446,8 @@ Status OnnxModelParser::TransNodeToOperator(const ge::onnx::NodeProto *node_prot | |||
const string &op_type) { | |||
GE_CHECK_NOTNULL(node_proto); | |||
string node_name = node_proto->name(); | |||
op = ge::OperatorFactory::CreateOperator(node_name, op_type); | |||
if (op.GetName() != node_name) { | |||
op = ge::OperatorFactory::CreateOperator(node_name.c_str(), op_type.c_str()); | |||
if (ParserUtils::GetOperatorName(op) != node_name) { | |||
REPORT_INPUT_ERROR("E10501", std::vector<std::string>({"opname", "optype"}), | |||
std::vector<std::string>({node_name, op_type})); | |||
GELOGE(INTERNAL_ERROR, "[Creat][Op] IR for op[%s] optype[%s] is not registered.", | |||
@@ -453,8 +455,9 @@ Status OnnxModelParser::TransNodeToOperator(const ge::onnx::NodeProto *node_prot | |||
return INTERNAL_ERROR; | |||
} | |||
GELOGI("After create operator, op[%s]: type[%s] have input size: %zu, output size: %zu", op.GetName().c_str(), | |||
op.GetOpType().c_str(), op.GetInputsSize(), op.GetOutputsSize()); | |||
GELOGI("After create operator, op[%s]: type[%s] have input size: %zu, output size: %zu", | |||
ParserUtils::GetOperatorName(op).c_str(), ParserUtils::GetOperatorType(op).c_str(), | |||
op.GetInputsSize(), op.GetOutputsSize()); | |||
return SUCCESS; | |||
} | |||
@@ -509,14 +512,15 @@ Status OnnxModelParser::SetOperatorInputs() { | |||
auto src_op = output_op_iter->second; | |||
int dst_index = input_node_index.second; | |||
int src_index = out_node_index.second; | |||
GELOGI("Start add output:%d of op:%s as input:%d of op:%s.", src_index, src_op.GetName().c_str(), dst_index, | |||
dst_op.GetName().c_str()); | |||
GELOGI("Start add output:%d of op:%s as input:%d of op:%s.", src_index, | |||
ParserUtils::GetOperatorName(src_op).c_str(), dst_index, | |||
ParserUtils::GetOperatorName(dst_op).c_str()); | |||
auto dst_op_desc = ge::OpDescUtils::GetOpDescFromOperator(dst_op); | |||
GE_CHECK_NOTNULL(dst_op_desc); | |||
auto src_op_desc = ge::OpDescUtils::GetOpDescFromOperator(src_op); | |||
GE_CHECK_NOTNULL(src_op_desc); | |||
dst_op.SetInput(dst_op_desc->GetInputNameByIndex(dst_index), src_op, | |||
src_op_desc->GetOutputNameByIndex(src_index)); | |||
dst_op.SetInput(dst_op_desc->GetInputNameByIndex(dst_index).c_str(), src_op, | |||
src_op_desc->GetOutputNameByIndex(src_index).c_str()); | |||
} | |||
} | |||
} | |||
@@ -566,7 +570,7 @@ Status OnnxModelParser::ParseOpParam(const ge::onnx::NodeProto *node_proto, ge:: | |||
if (parse_param_func == nullptr) { | |||
status = op_parser->ParseParams(node_proto, op); | |||
} else { | |||
ge::Operator op_src(node_proto->name(), op_type); | |||
ge::Operator op_src(node_proto->name().c_str(), op_type.c_str()); | |||
status = Message2Operator::ParseOperatorAttrs(node_proto, 1, op_src); | |||
if (status != SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Auto mapping node:%s(%s) to operator failed", | |||
@@ -626,16 +630,17 @@ Status OnnxModelParser::ParseAllNodeProto(ge::onnx::GraphProto &onnx_graph, ge:: | |||
return status; | |||
} | |||
GELOGI("After ParseParams, op[%s]: type[%s] have input size: %zu, output size: %zu", op.GetName().c_str(), | |||
op.GetOpType().c_str(), op.GetInputsSize(), op.GetOutputsSize()); | |||
GELOGI("After ParseParams, op[%s]: type[%s] have input size: %zu, output size: %zu", | |||
ParserUtils::GetOperatorName(op).c_str(), ParserUtils::GetOperatorType(op).c_str(), | |||
op.GetInputsSize(), op.GetOutputsSize()); | |||
ge::graphStatus graph_status = graph.AddOp(op); | |||
if (graph_status != ge::GRAPH_SUCCESS) { | |||
GELOGE(FAILED, "[Add][Op] Add op:%s to graph failed.", op.GetName().c_str()); | |||
REPORT_CALL_ERROR("E19999", "Add op:%s to graph failed.", op.GetName().c_str()); | |||
GELOGE(FAILED, "[Add][Op] Add op:%s to graph failed.", ParserUtils::GetOperatorName(op).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Add op:%s to graph failed.", ParserUtils::GetOperatorName(op).c_str()); | |||
return FAILED; | |||
} | |||
name_operator_[op.GetName()] = op; | |||
name_operator_[ParserUtils::GetOperatorName(op)] = op; | |||
// 8. Construct input output relation of every node | |||
status = ConstructInputOutputContext(node_proto); | |||
@@ -669,7 +674,7 @@ Status OnnxModelParser::GetGraphInputs(ge::onnx::GraphProto &onnx_graph, std::ve | |||
return PARAM_INVALID; | |||
} | |||
input_ops.emplace_back(in_op->second); | |||
GELOGI("Model assigned input node name: %s", in_op->second.GetName().c_str()); | |||
GELOGI("Model assigned input node name: %s", ParserUtils::GetOperatorName(in_op->second).c_str()); | |||
} | |||
return SUCCESS; | |||
} | |||
@@ -800,7 +805,8 @@ Status OnnxModelParser::ModelParseToGraph(const ge::onnx::ModelProto &onnx_model | |||
domain_verseion_[it.domain()] = it.version(); | |||
GELOGI("Domain: %s, Version: %ld ", it.domain().c_str(), it.version()); | |||
} | |||
std::string root_graph_name = root_graph.GetName().empty() ? "default_graph" : root_graph.GetName(); | |||
std::string root_graph_name = ParserUtils::GetGraphName(root_graph).empty() ? "default_graph" : | |||
ParserUtils::GetGraphName(root_graph); | |||
tasks.push_back({&root_onnx_graph, nullptr, root_graph_name, 0}); | |||
while (!tasks.empty()) { | |||
@@ -819,7 +825,7 @@ Status OnnxModelParser::ModelParseToGraph(const ge::onnx::ModelProto &onnx_model | |||
} | |||
ge::onnx::GraphProto *onnx_graph = arg.onnx_graph; | |||
ge::Graph tmp_graph(arg.graph_name); | |||
ge::Graph tmp_graph(arg.graph_name.c_str()); | |||
ret = ModelParseToGraphImpl(is_subgraph, *onnx_graph, tmp_graph); | |||
if (ret != SUCCESS) { | |||
GELOGE(ret, "[Parse][Model] Model parse to graph failed, graph name:%s.", arg.graph_name.c_str()); | |||
@@ -927,7 +933,7 @@ Status OnnxModelParser::ModelParseToGraphImpl(bool is_subgraph, ge::onnx::GraphP | |||
return ret; | |||
} | |||
std::vector<string> op_names; | |||
std::vector<AscendString> op_names; | |||
graph.GetAllOpName(op_names); | |||
GELOGI("After trans node to operator, graph has the size of operator is %zu.", op_names.size()); | |||
@@ -968,7 +974,7 @@ Status OnnxModelParser::ModelParseToGraphImpl(bool is_subgraph, ge::onnx::GraphP | |||
if (!is_subgraph) { | |||
ret = SetOutputsInfo(final_output_nodes, out_tensor_to_nodes); | |||
if (ret != SUCCESS) { | |||
GELOGE(ret, "[Set][OutputsInfo] Graph:%s.", graph.GetName().c_str()); | |||
GELOGE(ret, "[Set][OutputsInfo] Graph:%s.", ParserUtils::GetGraphName(graph).c_str()); | |||
return ret; | |||
} | |||
} | |||
@@ -52,20 +52,32 @@ class PARSER_FUNC_VISIBILITY OnnxModelParser : public domi::ModelParser { | |||
ge::DataType ConvertToGeDataType(const uint32_t type) override; | |||
Status ParseFromMemory(const char *data, uint32_t size, ge::ComputeGraphPtr &graph) override { return domi::SUCCESS; } | |||
Status ParseFromMemory(const char *data, uint32_t size, ge::ComputeGraphPtr &graph) override { | |||
(void)data; | |||
(void)size; | |||
(void)graph; | |||
return domi::SUCCESS; | |||
} | |||
Status ParseFromMemory(const char *data, uint32_t size, ge::Graph &graph) override; | |||
Status ParseProto(const google::protobuf::Message *proto, ge::ComputeGraphPtr &graph) override { | |||
(void)proto; | |||
(void)graph; | |||
return domi::SUCCESS; | |||
} | |||
Status ParseProtoWithSubgraph(const google::protobuf::Message *root_proto, domi::GetGraphCallback callback, | |||
ge::ComputeGraphPtr &graph) override { | |||
(void)root_proto; | |||
(void)callback; | |||
(void)graph; | |||
return domi::SUCCESS; | |||
} | |||
Status ParseAllGraph(const google::protobuf::Message *root_proto, ge::ComputeGraphPtr &root_graph) override { | |||
(void)root_proto; | |||
(void)root_graph; | |||
return domi::SUCCESS; | |||
} | |||
@@ -136,9 +148,18 @@ class PARSER_FUNC_VISIBILITY OnnxModelParser : public domi::ModelParser { | |||
class PARSER_FUNC_VISIBILITY OnnxWeightsParser : public domi::WeightsParser { | |||
public: | |||
Status Parse(const char *file, ge::Graph &graph) override { return domi::SUCCESS; } | |||
Status Parse(const char *file, ge::Graph &graph) override { | |||
(void)file; | |||
(void)graph; | |||
return domi::SUCCESS; | |||
} | |||
Status ParseFromMemory(const char *data, uint32_t size, ge::ComputeGraphPtr &graph) override { return domi::SUCCESS; } | |||
Status ParseFromMemory(const char *data, uint32_t size, ge::ComputeGraphPtr &graph) override { | |||
(void)data; | |||
(void)size; | |||
(void)graph; | |||
return domi::SUCCESS; | |||
} | |||
}; | |||
} // namespace domi | |||
#endif // PARSER_ONNX_ONNX_PARSER_H_ |
@@ -50,6 +50,9 @@ class PARSER_FUNC_VISIBILITY SubgraphAdapter { | |||
virtual domi::Status AdaptAndFindAllSubgraphs(ge::onnx::NodeProto *parent_op, | |||
std::vector<ge::onnx::GraphProto *> &onnx_graphs, | |||
std::map<std::string, ge::onnx::GraphProto *> &name_to_onnx_graph) { | |||
(void)parent_op; | |||
(void)onnx_graphs; | |||
(void)name_to_onnx_graph; | |||
return domi::SUCCESS; | |||
} | |||
}; | |||
@@ -22,7 +22,8 @@ | |||
#include "parser/common/op_parser_factory.h" | |||
#include "register/op_registry.h" | |||
#include "register/register.h" | |||
#include "register/register_utils.h" | |||
#include "parser/common/parser_utils.h" | |||
using domi::TENSORFLOW; | |||
using namespace ge::parser; | |||
@@ -51,9 +52,9 @@ Status TensorFlowAutoMappingParserAdapter::ParseParams(const Message *op_src, ge | |||
} | |||
ge::Operator op = ge::OpDescUtils::CreateOperatorFromOpDesc(op_dest); | |||
Status ret = domi::AutoMappingFn(op_src, op); | |||
Status ret = domi::OperatorAutoMapping(op_src, op); | |||
if (ret != SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "call auto mapping failed for node:%s", op.GetName().c_str()); | |||
REPORT_CALL_ERROR("E19999", "call auto mapping failed for node:%s", ParserUtils::GetOperatorName(op).c_str()); | |||
GELOGE(FAILED, "Tensorflow auto mapping parser params failed"); | |||
return FAILED; | |||
} | |||
@@ -19,6 +19,7 @@ | |||
#include "framework/common/debug/ge_log.h" | |||
#include "parser/common/op_parser_factory.h" | |||
#include "register/op_registry.h" | |||
#include "parser/common/parser_utils.h" | |||
using domi::ParseParamFunc; | |||
using domi::ParseParamByOpFunc; | |||
@@ -49,19 +50,22 @@ Status TensorFlowCustomParserAdapter::ParseParams(const Message *op_src, ge::OpD | |||
Status TensorFlowCustomParserAdapter::ParseParams(const Operator &op_src, ge::OpDescPtr &op_dest) { | |||
GELOGI("Tensorflow custom op begin to parse params: op node name = %s, op type = %s.", | |||
op_src.GetName().c_str(), op_src.GetOpType().c_str()); | |||
ParserUtils::GetOperatorName(op_src).c_str(), ParserUtils::GetOperatorType(op_src).c_str()); | |||
GE_CHECK_NOTNULL(op_dest); | |||
ParseParamByOpFunc custom_op_parser = domi::OpRegistry::Instance()->GetParseParamByOperatorFunc(op_src.GetOpType()); | |||
ParseParamByOpFunc custom_op_parser = domi::OpRegistry::Instance()->GetParseParamByOperatorFunc( | |||
ParserUtils::GetOperatorType(op_src)); | |||
if (custom_op_parser == nullptr) { | |||
REPORT_CALL_ERROR("E19999", "No ParseParamByOperatorFunc of node:%s exist in OpRegistry", op_src.GetName().c_str()); | |||
GELOGE(FAILED, "No ParseParamByOperatorFunc of node:%s exist in OpRegistry", op_src.GetName().c_str()); | |||
REPORT_CALL_ERROR("E19999", "No ParseParamByOperatorFunc of node:%s exist in OpRegistry", | |||
ParserUtils::GetOperatorName(op_src).c_str()); | |||
GELOGE(FAILED, "No ParseParamByOperatorFunc of node:%s exist in OpRegistry", | |||
ParserUtils::GetOperatorName(op_src).c_str()); | |||
return FAILED; | |||
} | |||
ge::Operator op = ge::OpDescUtils::CreateOperatorFromOpDesc(op_dest); | |||
GE_CHK_BOOL_RET_STATUS(custom_op_parser(op_src, op) == SUCCESS, FAILED, "Custom parser params failed or node:%s", | |||
op_src.GetName().c_str()); | |||
ParserUtils::GetOperatorName(op_src).c_str()); | |||
op_src.BreakConnect(); | |||
return SUCCESS; | |||
@@ -76,10 +76,16 @@ Status TensorFlowFusionOpParser::GetTensorFromNode(const NodeDef *node_def, Tens | |||
} | |||
Status TensorFlowFusionOpParser::ParseParams(const std::vector<const NodeDef *> &v_input_const, NodePtr &op_dest) { | |||
(void)v_input_const; | |||
(void)op_dest; | |||
return SUCCESS; | |||
} | |||
Status TensorFlowFusionOpParser::ParseParams(const Message *op_src, OpDescPtr &op_dest) { return SUCCESS; } | |||
Status TensorFlowFusionOpParser::ParseParams(const Message *op_src, OpDescPtr &op_dest) { | |||
(void)op_src; | |||
(void)op_dest; | |||
return SUCCESS; | |||
} | |||
Status TensorFlowFusionOpParser::ParseParamFromConst(const NodeDef *node_def, int32_t ¶m) { | |||
GE_CHECK_NOTNULL(node_def); | |||
@@ -79,6 +79,8 @@ class PARSER_FUNC_VISIBILITY TensorFlowOpParser : public OpParser { | |||
* | |||
*/ | |||
Status ParseParams(const Message *op_src, ge::OpDescPtr &op_dest) override { | |||
(void)op_src; | |||
(void)op_dest; | |||
return domi::SUCCESS; | |||
} | |||
@@ -92,6 +94,8 @@ class PARSER_FUNC_VISIBILITY TensorFlowOpParser : public OpParser { | |||
* | |||
*/ | |||
Status ParseParams(const Message *op_src, ge::Operator &op_dest) override { | |||
(void)op_src; | |||
(void)op_dest; | |||
return domi::SUCCESS; | |||
} | |||
@@ -105,6 +109,8 @@ class PARSER_FUNC_VISIBILITY TensorFlowOpParser : public OpParser { | |||
* | |||
*/ | |||
Status ParseWeights(const Message *op_src, ge::NodePtr &node) final { | |||
(void)op_src; | |||
(void)node; | |||
return domi::SUCCESS; | |||
} | |||
}; | |||
@@ -51,6 +51,7 @@ | |||
#include "parser/tensorflow/tensorflow_op_parser.h" | |||
#include "parser/tensorflow/tensorflow_util.h" | |||
#include "register/op_registry.h" | |||
#include "register/register_utils.h" | |||
#include "register/scope/scope_pass_registry_impl.h" | |||
#include "parser/common/auto_mapping_subgraph_io_index_func.h" | |||
@@ -118,16 +119,16 @@ graphStatus aclgrphParseTensorFlow(const char *model_file, ge::Graph &graph) { | |||
// parse tensorflow 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()); | |||
GELOGE(ret, "Parser graph %s failed.", ParserUtils::GetGraphName(graph).c_str()); | |||
return ge::FAILED; | |||
} | |||
std::map<AscendString, AscendString> parser_params; | |||
if (acl_graph_parse_util.SetOutputNodeInfo(graph, parser_params) != ge::SUCCESS) { | |||
GELOGE(ret, "Set graph %s default output node failed.", graph.GetName().c_str()); | |||
GELOGE(ret, "Set graph %s default output node failed.", ParserUtils::GetGraphName(graph).c_str()); | |||
return ge::FAILED; | |||
} | |||
GELOGI("Parser graph %s success.", graph.GetName().c_str()); | |||
GELOGI("Parser graph %s success.", ParserUtils::GetGraphName(graph).c_str()); | |||
return ge::SUCCESS; | |||
} | |||
@@ -172,7 +173,7 @@ graphStatus aclgrphParseTensorFlow(const char *model_file, const std::map<Ascend | |||
// parse tensorflow 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()); | |||
GELOGE(ret, "Parser graph %s failed.", ParserUtils::GetGraphName(graph).c_str()); | |||
return ge::FAILED; | |||
} | |||
@@ -182,10 +183,10 @@ graphStatus aclgrphParseTensorFlow(const char *model_file, const std::map<Ascend | |||
} | |||
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()); | |||
GELOGE(ge::FAILED, "Set graph %s default output node failed.", ParserUtils::GetGraphName(graph).c_str()); | |||
return ge::FAILED; | |||
} | |||
GELOGI("AclgrphParse graph %s success.", graph.GetName().c_str()); | |||
GELOGI("AclgrphParse graph %s success.", ParserUtils::GetGraphName(graph).c_str()); | |||
return ge::SUCCESS; | |||
} | |||
} // namespace ge | |||
@@ -313,9 +314,9 @@ Status MappingAndAddSubGraph(const NodePtr &node, const Graph &graph, const Comp | |||
}); | |||
if (status != SUCCESS) { | |||
GELOGE(INTERNAL_ERROR, "[Mapping][Subgraph]node:%s, sub graph name:%s.", node->GetName().c_str(), | |||
graph.GetName().c_str()); | |||
ParserUtils::GetGraphName(graph).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to map sub graph input and output, node:%s, sub graph name:%s.", | |||
node->GetName().c_str(), graph.GetName().c_str()); | |||
node->GetName().c_str(), ParserUtils::GetGraphName(graph).c_str()); | |||
return INTERNAL_ERROR; | |||
} | |||
@@ -407,8 +408,8 @@ Status TensorFlowModelParser::TransNodeToOpDesc(const domi::tensorflow::NodeDef | |||
const string &op_type) { | |||
GE_CHECK_NOTNULL(node_def); | |||
string node_name = node_def->name(); | |||
ge::Operator op_factory = ge::OperatorFactory::CreateOperator(node_name, op_type); | |||
if (op_factory.GetName() != node_name || op_type == ge::parser::DATA) { | |||
ge::Operator op_factory = ge::OperatorFactory::CreateOperator(node_name.c_str(), op_type.c_str()); | |||
if (ParserUtils::GetOperatorName(op_factory) != node_name || op_type == ge::parser::DATA) { | |||
if (std::find(kMakeOperatorNotByIr.begin(), kMakeOperatorNotByIr.end(), op_type) != kMakeOperatorNotByIr.end()) { | |||
op = ge::parser::MakeShared<ge::OpDesc>(node_name, op_type); | |||
GE_CHECK_NOTNULL(op); | |||
@@ -455,8 +456,8 @@ Status TensorFlowModelParser::ParseOpParams(const domi::tensorflow::NodeDef *nod | |||
return status; | |||
} | |||
} else { | |||
ge::Operator op_src(node_def->name(), node_def->op()); | |||
status = domi::AutoMappingFn(node_def, op_src); | |||
ge::Operator op_src(node_def->name().c_str(), node_def->op().c_str()); | |||
status = domi::OperatorAutoMapping(node_def, op_src); | |||
if (status != SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Auto mapping node_def:%s(%s) to operator failed", node_def->name().c_str(), | |||
node_def->op().c_str()); | |||
@@ -468,7 +469,7 @@ Status TensorFlowModelParser::ParseOpParams(const domi::tensorflow::NodeDef *nod | |||
GE_CHECK_NOTNULL(tf_custom_op_parser); | |||
status = tf_custom_op_parser->ParseParams(op_src, op); | |||
if (status != SUCCESS) { | |||
GELOGE(status, "Parse params for node[%s] failed", op_src.GetName().c_str()); | |||
GELOGE(status, "Parse params for node[%s] failed", ParserUtils::GetOperatorName(op_src).c_str()); | |||
return status; | |||
} | |||
} | |||
@@ -501,7 +502,7 @@ Status TensorFlowModelParser::AddNode(const domi::tensorflow::NodeDef *node_def, | |||
GE_RETURN_IF_ERROR(TransNodeToOpDesc(node_def, op_desc, node_op)); | |||
ge::Operator op = ge::OpDescUtils::CreateOperatorFromOpDesc(op_desc); | |||
GE_CHK_STATUS(domi::AutoMappingFn(node_def, op)); | |||
GE_CHK_STATUS(domi::OperatorAutoMapping(node_def, op)); | |||
op.BreakConnect(); | |||
ge::NodePtr node = nullptr; | |||
@@ -938,8 +939,8 @@ Status TensorFlowModelParser::ParseNodeDef(TensorFlowModelParser *parser, ge::Co | |||
// Construct operator by IR | |||
ge::OpDescPtr op; | |||
ge::Operator op_factory = ge::OperatorFactory::CreateOperator(node_name, op_type); | |||
if (op_factory.GetName() != node_name) { | |||
ge::Operator op_factory = ge::OperatorFactory::CreateOperator(node_name.c_str(), op_type.c_str()); | |||
if (ParserUtils::GetOperatorName(op_factory) != node_name) { | |||
if (std::find(kMakeOperatorNotByIr.begin(), kMakeOperatorNotByIr.end(), op_type) != kMakeOperatorNotByIr.end()) { | |||
op = ge::parser::MakeShared<ge::OpDesc>(node_name, op_type); | |||
GE_CHECK_NOTNULL(op); | |||
@@ -947,7 +948,7 @@ Status TensorFlowModelParser::ParseNodeDef(TensorFlowModelParser *parser, ge::Co | |||
GE_RETURN_IF_ERROR(parser->DefunToPartitionedCall(node_def, op)); | |||
GE_CHECK_NOTNULL(op); | |||
ge::Operator op_tmp = ge::OpDescUtils::CreateOperatorFromOpDesc(op); | |||
GE_CHK_STATUS(domi::AutoMappingFn(node_def, op_tmp)); | |||
GE_CHK_STATUS(domi::OperatorAutoMapping(node_def, op_tmp)); | |||
op_tmp.BreakConnect(); | |||
ge::NodePtr node; | |||
{ | |||
@@ -1321,11 +1322,11 @@ Status TensorFlowModelParser::Parse(const char *file, ge::Graph &graph) { | |||
Status ret = Parse(file, root_graph); | |||
if (ret != SUCCESS) { | |||
GELOGE(ret, "Parser graph %s failed.", graph.GetName().c_str()); | |||
GELOGE(ret, "Parser graph %s failed.", ParserUtils::GetGraphName(graph).c_str()); | |||
return ret; | |||
} | |||
GELOGI("Parser graph %s success.", graph.GetName().c_str()); | |||
GELOGI("Parser graph %s success.", ParserUtils::GetGraphName(graph).c_str()); | |||
return SUCCESS; | |||
} | |||
@@ -2206,10 +2207,15 @@ Status TensorFlowModelParser::ToJson(const char *model_file, const char *json_fi | |||
} | |||
Status TensorFlowWeightsParser::ParseFromMemory(const char *data, uint32_t size, ge::ComputeGraphPtr &graph) { | |||
(void)data; | |||
(void)size; | |||
(void)graph; | |||
return SUCCESS; | |||
} | |||
Status TensorFlowWeightsParser::Parse(const char *file, ge::Graph &graph) { | |||
(void)file; | |||
(void)graph; | |||
return SUCCESS; | |||
} | |||
@@ -2225,7 +2231,6 @@ Status TensorFlowModelParser::ParseProto(const google::protobuf::Message *proto, | |||
// Make a copy for operation without modifying the original graph def. | |||
domi::tensorflow::GraphDef graph_def_operation = *graph_def_in; | |||
domi::tensorflow::GraphDef *graph_def = &graph_def_operation; | |||
GELOGI("[TF Parser] graph def version:%d", graph_def->version()); | |||
GE_RETURN_WITH_LOG_IF_ERROR(ProtoTypePassManager::Instance().Run(graph_def, domi::TENSORFLOW), | |||
"Run ProtoType Pass Failed"); | |||
@@ -3278,8 +3283,8 @@ Status TensorFlowModelParser::FusionNodeParseParams(shared_ptr<OpParser> &op_par | |||
} else { | |||
vector<ge::Operator> op_src_vec; | |||
for (const auto &node_def_src : node_def_v) { | |||
ge::Operator op_src(node_def_src->name(), node_def_src->op()); | |||
status = domi::AutoMappingFn(node_def_src, op_src); | |||
ge::Operator op_src(node_def_src->name().c_str(), node_def_src->op().c_str()); | |||
status = domi::OperatorAutoMapping(node_def_src, op_src); | |||
if (status != SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Auto mapping node_def:%s(%s) to operator failed", node_def_src->name().c_str(), | |||
node_def_src->op().c_str()); | |||
@@ -3615,7 +3620,7 @@ Status TensorFlowModelParser::RecordFusionResult(const std::shared_ptr<ge::Scope | |||
std::vector<std::string> original_names; | |||
auto nodes = fusion_result->Nodes(); | |||
std::transform(nodes.begin(), nodes.end(), std::back_inserter(original_names), | |||
[](ge::OperatorPtr n) -> std::string { return n->GetName(); }); | |||
[](ge::OperatorPtr n) -> std::string { return ParserUtils::GetOperatorName(*n); }); | |||
GELOGI("Op %s original_names size = %zu.", op_desc->GetName().c_str(), original_names.size()); | |||
bool ret = ge::AttrUtils::SetListStr(op_desc, ge::ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, original_names); | |||
@@ -4062,7 +4067,7 @@ Status TensorFlowModelParser::AddExternalGraph(const ComputeGraphPtr &root_graph | |||
return INTERNAL_ERROR; | |||
} | |||
Graph graph = model.GetGraph(); | |||
GELOGD("Get subgraph[%s] from model[%s].", graph.GetName().c_str(), node->GetName().c_str()); | |||
GELOGD("Get subgraph[%s] from model[%s].", ParserUtils::GetGraphName(graph).c_str(), node->GetName().c_str()); | |||
Status ret = MappingAndAddSubGraph(node, graph, root_graph); | |||
if (ret != SUCCESS) { | |||
GELOGE(INTERNAL_ERROR, "[Mapping][Subgraph]Node:%s.", node->GetName().c_str()); | |||
@@ -102,6 +102,9 @@ class PARSER_FUNC_VISIBILITY TensorFlowModelParser : public domi::ModelParser { | |||
Status ParseFromMemory(const char *data, uint32_t size, ge::ComputeGraphPtr &graph) override; | |||
Status ParseFromMemory(const char *data, uint32_t size, ge::Graph &graph) override { | |||
(void)data; | |||
(void)size; | |||
(void)graph; | |||
return domi::SUCCESS; | |||
} | |||
@@ -77,10 +77,14 @@ Status TensorFlowRefSwitchParser::ParseParams(const Message *op_src, ge::OpDescP | |||
// AUTO GEN PLEASE DO NOT MODIFY IT | |||
Status TensorFlowRefSwitchParser::PreParseParams(const domi::tensorflow::NodeDef *node, RefSwitchOperator *op) { | |||
(void)node; | |||
(void)op; | |||
return SUCCESS; | |||
} | |||
Status TensorFlowRefSwitchParser::PostParseParams(const domi::tensorflow::NodeDef *node, RefSwitchOperator *op) { | |||
(void)node; | |||
(void)op; | |||
return SUCCESS; | |||
} | |||
@@ -155,10 +155,14 @@ Status TensorFlowShapeNParser::ParseParams(const Message *op_src, ge::OpDescPtr | |||
// AUTO GEN PLEASE DO NOT MODIFY IT | |||
Status TensorFlowShapeNParser::PreParseParams(const domi::tensorflow::NodeDef *node, ShapeNOperator *op) { | |||
(void)node; | |||
(void)op; | |||
return SUCCESS; | |||
} | |||
Status TensorFlowShapeNParser::PostParseParams(const domi::tensorflow::NodeDef *node, ShapeNOperator *op) { | |||
(void)node; | |||
(void)op; | |||
return SUCCESS; | |||
} | |||