| @@ -19,6 +19,7 @@ | |||
| #include "parser/common/op_parser_factory.h" | |||
| #include "common/util/error_manager/error_manager.h" | |||
| #include "framework/omg/parser/parser_types.h" | |||
| #include "graph/def_types.h" | |||
| using namespace ge::parser; | |||
| using domi::caffe::BlobProto; | |||
| @@ -107,7 +108,7 @@ Status CaffeOpParser::ParseWeightType(const BlobProto &proto, const ge::GeShape | |||
| for (int i = 0; i < size; ++i) { | |||
| buf[i] = proto.double_data(i); | |||
| } | |||
| GE_IF_BOOL_EXEC(weight->SetData(reinterpret_cast<uint8_t *>(buf.get()), size * sizeof(float)) != ge::GRAPH_SUCCESS, | |||
| GE_IF_BOOL_EXEC(weight->SetData(PtrToPtr<float, uint8_t>(buf.get()), size * sizeof(float)) != ge::GRAPH_SUCCESS, | |||
| GELOGW("SetData failed for GeTensor.");); // no need to return | |||
| } else if (proto.int8_data().length() > 0) { | |||
| if (size != static_cast<int>(proto.int8_data().length())) { | |||
| @@ -121,7 +122,7 @@ Status CaffeOpParser::ParseWeightType(const BlobProto &proto, const ge::GeShape | |||
| const char *data_ptr = proto.int8_data().data(); | |||
| GE_CHECK_NOTNULL(data_ptr); | |||
| GE_IF_BOOL_EXEC( | |||
| weight->SetData(reinterpret_cast<const uint8_t *>(data_ptr), size * sizeof(int8_t)) != ge::GRAPH_SUCCESS, | |||
| weight->SetData(PtrToPtr<const char, const uint8_t>(data_ptr), size * sizeof(int8_t)) != ge::GRAPH_SUCCESS, | |||
| GELOGW("SetData failed for GeTensor.");); // no need to return | |||
| dtype = ge::DT_INT8; | |||
| } else if (proto.int32_data_size() > 0) { | |||
| @@ -139,7 +140,7 @@ Status CaffeOpParser::ParseWeightType(const BlobProto &proto, const ge::GeShape | |||
| int32_weight_buf[i] = proto.int32_data(i); | |||
| } | |||
| GE_IF_BOOL_EXEC( | |||
| weight->SetData(reinterpret_cast<uint8_t *>(int32_weight_buf.get()), size * sizeof(int32_t)) != ge::GRAPH_SUCCESS, | |||
| weight->SetData(PtrToPtr<int32_t, uint8_t>(int32_weight_buf.get()), size * sizeof(int32_t)) != ge::GRAPH_SUCCESS, | |||
| GELOGW("SetData failed for GeTensor.");); // no need to return | |||
| dtype = ge::DT_INT32; | |||
| } else if (proto.uint64_data_size() > 0) { | |||
| @@ -156,7 +157,7 @@ Status CaffeOpParser::ParseWeightType(const BlobProto &proto, const ge::GeShape | |||
| for (int i = 0; i < size; ++i) { | |||
| uint64_weight_buf[i] = proto.uint64_data(i); | |||
| } | |||
| GE_IF_BOOL_EXEC(weight->SetData(reinterpret_cast<uint8_t *>(uint64_weight_buf.get()), size * sizeof(uint64_t)) != | |||
| GE_IF_BOOL_EXEC(weight->SetData(PtrToPtr<uint64_t, uint8_t>(uint64_weight_buf.get()), size * sizeof(uint64_t)) != | |||
| ge::GRAPH_SUCCESS, | |||
| GELOGW("SetData failed for GeTensor.");); // no need to return | |||
| dtype = ge::DT_UINT64; | |||
| @@ -173,7 +174,7 @@ Status CaffeOpParser::ParseWeightType(const BlobProto &proto, const ge::GeShape | |||
| const float *data_ptr = proto.data().data(); | |||
| GE_CHECK_NOTNULL(data_ptr); | |||
| GE_IF_BOOL_EXEC( | |||
| weight->SetData(reinterpret_cast<const uint8_t *>(data_ptr), size * sizeof(float)) != ge::GRAPH_SUCCESS, | |||
| weight->SetData(PtrToPtr<const float, const uint8_t>(data_ptr), size * sizeof(float)) != ge::GRAPH_SUCCESS, | |||
| GELOGW("SetData failed for GeTensor.");); // no need to return | |||
| } | |||
| ge::GeTensorDesc weight_desc = ge::GeTensorDesc(); | |||
| @@ -1920,7 +1920,7 @@ Status CaffeWeightsParser::ParseLayerField(const google::protobuf::Reflection *r | |||
| const google::protobuf::FieldDescriptor *field, | |||
| google::protobuf::Message *layer) { | |||
| GELOGD("Start to parse field: %s.", field->name().c_str()); | |||
| domi::caffe::LayerParameter *layer_proto = reinterpret_cast<domi::caffe::LayerParameter *>(layer); | |||
| domi::caffe::LayerParameter *layer_proto = PtrToPtr<google::protobuf::Message, domi::caffe::LayerParameter>(layer); | |||
| string filed_name = field->name(); | |||
| #define CASE_FIELD_NAME(kName, method) \ | |||
| if (filed_name == kField##kName) { \ | |||
| @@ -1976,7 +1976,7 @@ Status CaffeWeightsParser::ConvertBlobsProto(const google::protobuf::Message *me | |||
| vector<const google::protobuf::FieldDescriptor *> field_desc; | |||
| blobs_reflection->ListFields(*message, &field_desc); | |||
| domi::caffe::BlobProto *blobs_proto = reinterpret_cast<domi::caffe::BlobProto *>(blobs); | |||
| domi::caffe::BlobProto *blobs_proto = PtrToPtr<google::protobuf::Message, domi::caffe::BlobProto>(blobs); | |||
| for (auto &field : field_desc) { | |||
| GE_CHECK_NOTNULL(field); | |||
| @@ -2025,7 +2025,7 @@ Status CaffeWeightsParser::ConvertBlobShapeProto(const google::protobuf::Message | |||
| vector<const google::protobuf::FieldDescriptor *> field_desc; | |||
| reflection->ListFields(*message, &field_desc); | |||
| domi::caffe::BlobShape *shape_proto = reinterpret_cast<domi::caffe::BlobShape *>(dest_message); | |||
| domi::caffe::BlobShape *shape_proto = PtrToPtr<google::protobuf::Message, domi::caffe::BlobShape>(dest_message); | |||
| for (auto &field : field_desc) { | |||
| if (field->name() != kFieldDim) { | |||
| @@ -2048,7 +2048,7 @@ Status CaffeWeightsParser::ConvertConvParamProto(const google::protobuf::Message | |||
| reflection->ListFields(*message, &field_desc); | |||
| domi::caffe::ConvolutionParameter *conv_param_proto = | |||
| reinterpret_cast<domi::caffe::ConvolutionParameter *>(dest_message); | |||
| PtrToPtr<google::protobuf::Message, domi::caffe::ConvolutionParameter>(dest_message); | |||
| for (auto &field : field_desc) { | |||
| if (field->name() != kFieldBiasTerm) { | |||
| @@ -2068,7 +2068,7 @@ Status CaffeWeightsParser::ConvertInnerProdcutProto(const google::protobuf::Mess | |||
| reflection->ListFields(*message, &field_desc); | |||
| domi::caffe::InnerProductParameter *inner_product_proto = | |||
| reinterpret_cast<domi::caffe::InnerProductParameter *>(dest_message); | |||
| PtrToPtr<google::protobuf::Message, domi::caffe::InnerProductParameter>(dest_message); | |||
| for (auto &field : field_desc) { | |||
| if (field->name() != kFieldBiasTerm) { | |||
| @@ -2125,7 +2125,8 @@ Status CaffeWeightsParser::CheckLayersSize(const google::protobuf::Message *mess | |||
| Status CaffeWeightsParser::ConvertLayerParameter(const google::protobuf::Message *layer_message, | |||
| ge::ComputeGraphPtr &graph) { | |||
| vector<string> need_share_layers; | |||
| const domi::caffe::LayerParameter *layer = reinterpret_cast<const domi::caffe::LayerParameter *>(layer_message); | |||
| const domi::caffe::LayerParameter *layer = | |||
| PtrToPtr<google::protobuf::Message, domi::caffe::LayerParameter>(layer_message); | |||
| const string &shared_layer_name = layer->name(); | |||
| const string &layer_type = layer->type(); | |||
| for (auto p_iter = params_share_map.begin(); p_iter != params_share_map.end(); ++p_iter) { | |||
| @@ -128,7 +128,7 @@ Status CaffeReshapeParser::AddConstInput(ge::NodePtr &node) { | |||
| data[i] = attr_shape[i]; | |||
| } | |||
| GE_IF_BOOL_EXEC( | |||
| constTensor->SetData(reinterpret_cast<uint8_t *>(data.get()), dims_size * sizeof(int64_t)) != ge::GRAPH_SUCCESS, | |||
| constTensor->SetData(PtrToPtr<int64_t, uint8_t>(data.get()), dims_size * sizeof(int64_t)) != ge::GRAPH_SUCCESS, | |||
| GELOGW("SetData failed for GeTensor.");); // no need to return | |||
| // construct const node and add edge | |||
| @@ -820,7 +820,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromArray(const v | |||
| "or size is 0, check invalid"); return false, | |||
| "[Check][Param]incorrect parameter. proto is nullptr || data is nullptr || size is 0"); | |||
| google::protobuf::io::CodedInputStream coded_stream(reinterpret_cast<uint8_t *>(const_cast<void *>(data)), size); | |||
| google::protobuf::io::CodedInputStream coded_stream(PtrToPtr<void, uint8_t>(const_cast<void *>(data)), size); | |||
| return ReadProtoFromCodedInputStream(coded_stream, proto); | |||
| } | |||
| @@ -901,7 +901,7 @@ Status GetOriginalType(const ge::NodePtr &node, string &type) { | |||
| return SUCCESS; | |||
| } | |||
| FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &str, const std::string &mode) { | |||
| FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &filePath, const std::string &mode) { | |||
| char ebuff[kMaxBuffSize]; | |||
| regex_t reg; | |||
| int cflags = REG_EXTENDED | REG_NOSUB; | |||
| @@ -913,7 +913,7 @@ FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &str, const std::str | |||
| return true; | |||
| } | |||
| ret = regexec(®, str.c_str(), 0, nullptr, 0); | |||
| ret = regexec(®, filePath.c_str(), 0, nullptr, 0); | |||
| if (ret) { | |||
| regerror(ret, ®, ebuff, kMaxBuffSize); | |||
| GELOGE(ge::PARAM_INVALID, "[Invoke][RegExec] failed, reason: %s", ebuff); | |||
| @@ -60,7 +60,7 @@ class DataOpParser { | |||
| * @param [in] 4D shape information (dimensions) | |||
| * @param [out] Save converted shap information | |||
| */ | |||
| static Status Init5DInputTensor(const std::vector<int64_t> &shape, ge::GeTensorDesc &tensorDesc); | |||
| static Status Init5DInputTensor(const std::vector<int64_t> &shape, ge::GeTensorDesc &tensor_desc); | |||
| /** | |||
| * @ingroup domi_omg | |||
| @@ -98,7 +98,7 @@ class DataOpParser { | |||
| * @return SUCCESS Convert success | |||
| * @return FAILED Convert failed | |||
| */ | |||
| static Status InitNDTensor(const std::vector<int64_t> &shape, ge::DataType data_type, ge::GeTensorDesc &desc); | |||
| static Status InitNDTensor(const std::vector<int64_t> &shape, ge::DataType data_type, ge::GeTensorDesc &tensor_desc); | |||
| }; | |||
| } // namespace ge | |||
| @@ -114,7 +114,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY domi::Status ConvertToOpDesc(co | |||
| if (op_attr_pair.second.value_.value_case() == domi::AttrDef::kBt) { | |||
| auto &buffer = op_attr_pair.second.value_.bt(); | |||
| (void)ge::AttrUtils::SetZeroCopyBytes(op_def, op_attr_pair.first, | |||
| ge::Buffer::CopyFrom(reinterpret_cast<uint8_t *>(const_cast<char *>(buffer.data())), buffer.size())); | |||
| ge::Buffer::CopyFrom(PtrToPtr<void, uint8_t>(const_cast<char *>(buffer.data())), buffer.size())); | |||
| } | |||
| if (op_attr_pair.second.value_.value_case() == domi::AttrDef::kS) { | |||
| @@ -62,7 +62,7 @@ public: | |||
| /// @return others optimized failed | |||
| /// @author | |||
| /// | |||
| static Status Run(const ge::ComputeGraphPtr &graph, std::vector<std::pair<std::string, GraphPass *>> &passes); | |||
| static Status Run(const ge::ComputeGraphPtr &graph, std::vector<std::pair<std::string, GraphPass *>> &names_to_passes); | |||
| ~PassManager(); | |||
| @@ -91,7 +91,7 @@ Status OnnxConstantParser::ParseConvertData(const ge::onnx::TensorProto &tensor_ | |||
| if (data_type == OnnxDataType::STRING) { | |||
| tensor.SetData(tensor_proto.raw_data().c_str()); | |||
| } else { | |||
| tensor.SetData(reinterpret_cast<const uint8_t *>(tensor_proto.raw_data().c_str()), | |||
| tensor.SetData(PtrToPtr<const char_t, const uint8_t>(tensor_proto.raw_data().c_str()), | |||
| tensor_proto.raw_data().size()); | |||
| } | |||
| GELOGD("Raw data size is : %zu", tensor_proto.raw_data().size()); | |||
| @@ -65,7 +65,7 @@ class PARSER_FUNC_VISIBILITY OnnxConstantParser : public OnnxOpParser { | |||
| *(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)); | |||
| (tensor).SetData(PtrToPtr<bool, uint8_t>(addr_trans.get()), (count) * sizeof(bool)); | |||
| break; | |||
| } | |||
| #define CASE_SET_DATA(dt_type, value_type, addr, count, tensor) \ | |||
| @@ -96,7 +96,7 @@ class PARSER_FUNC_VISIBILITY OnnxModelParser : public domi::ModelParser { | |||
| Status ConstructOriType(const ge::onnx::NodeProto *node_proto, std::string &ori_type); | |||
| Status AdapterOpType(const ge::onnx::NodeProto *node_proto, std::string &ori_type, std::string &om_type); | |||
| Status AdapterOpType(const ge::onnx::NodeProto *node_proto, std::string &ori_type, std::string &op_type); | |||
| Status TransNodeToOperator(const ge::onnx::NodeProto *node_proto, ge::Operator &op, const string &op_type) const; | |||
| @@ -106,7 +106,7 @@ class PARSER_FUNC_VISIBILITY OnnxModelParser : public domi::ModelParser { | |||
| Status GetGraphInputs(ge::onnx::GraphProto &onnx_graph, std::vector<ge::Operator> &input_ops); | |||
| Status GetGraphOutputs(std::vector<std::pair<Operator, std::vector<size_t>>> &outputs, | |||
| Status GetGraphOutputs(std::vector<std::pair<Operator, std::vector<size_t>>> &output_ops, | |||
| ParserUtils::OutputMapping &out_tensor_to_nodes); | |||
| Status Prechecker(ge::onnx::GraphProto &onnx_graph); | |||
| @@ -115,7 +115,7 @@ class PARSER_FUNC_VISIBILITY OnnxModelParser : public domi::ModelParser { | |||
| Status GetModelFromMemory(const char *data, uint32_t size, ge::onnx::ModelProto &onnx_model) const; | |||
| Status ModelParseToGraph(const ge::onnx::ModelProto &onnx_model, ge::Graph &graph); | |||
| Status ModelParseToGraph(const ge::onnx::ModelProto &onnx_model, ge::Graph &root_graph); | |||
| Status ModelParseToGraphImpl(bool is_subgraph, ge::onnx::GraphProto &onnx_graph, ge::Graph &graph); | |||
| @@ -24,7 +24,7 @@ | |||
| namespace ge { | |||
| class PARSER_FUNC_VISIBILITY IfSubgraphAdapter : public SubgraphAdapter { | |||
| public: | |||
| domi::Status AdaptAndFindAllSubgraphs(ge::onnx::NodeProto *parent_op, | |||
| domi::Status AdaptAndFindAllSubgraphs(ge::onnx::NodeProto *parent_node, | |||
| std::vector<ge::onnx::GraphProto *> &onnx_graphs, | |||
| std::map<std::string, ge::onnx::GraphProto *> &name_to_onnx_graph) override; | |||
| @@ -52,7 +52,7 @@ class GraphToFunctionDef { | |||
| const string &name, FunctionDef *fdef); | |||
| static domi::Status BuildFunctionDef(ge::ComputeGraphPtr &graph, | |||
| const string &nme_in, | |||
| const string &name_in, | |||
| FunctionDefLibrary *library, | |||
| NodeDef *call_node_def, | |||
| vector<ge::InDataAnchorPtr> &in_anchor, | |||
| @@ -178,7 +178,7 @@ Status CollectNodeFuncs(vector<ge::NodePtr> &nodes, FunctionDefLibrary *library) | |||
| GE_IF_BOOL_EXEC( | |||
| AttrUtils::GetBytes(opDef, ge::ATTR_NAME_FRAMEWORK_FUNC_DEF, funcDefBytes), FunctionDefLibrary funcLib; | |||
| GE_CHECK_NOTNULL(funcDefBytes.GetData()); | |||
| string str(reinterpret_cast<char *>(funcDefBytes.GetData()), funcDefBytes.GetSize()); | |||
| string str(PtrToPtr<uint8_t, char_t>(funcDefBytes.GetData()), funcDefBytes.GetSize()); | |||
| GELOGI("FUNCDEF: Get function -> %s.", str.c_str()); GE_IF_BOOL_EXEC( | |||
| funcLib.ParseFromArray(funcDefBytes.GetData(), funcDefBytes.GetSize()), library->MergeFrom(funcLib))); | |||
| } | |||
| @@ -250,10 +250,10 @@ Status ParserGraphOptimizer::UpdateGraph(vector<NodePtr> &nodes) { | |||
| (void)AttrUtils::SetZeroCopyBytes( | |||
| fusion_node_opdef, ge::ATTR_NAME_FRAMEWORK_FUNC_DEF, | |||
| Buffer::CopyFrom(reinterpret_cast<const uint8_t *>(funcdefStr.data()), funcdefStr.length())); | |||
| Buffer::CopyFrom(PtrToPtr<const char_t, const uint8_t>(funcdefStr.data()), funcdefStr.length())); | |||
| (void)AttrUtils::SetZeroCopyBytes( | |||
| fusion_node_opdef, ge::ATTR_NAME_FRAMEWORK_NODE_DEF, | |||
| Buffer::CopyFrom(reinterpret_cast<const uint8_t *>(nodefStr.data()), nodefStr.length())); | |||
| Buffer::CopyFrom(PtrToPtr<const char_t, const uint8_t>(nodefStr.data()), nodefStr.length())); | |||
| (void)AttrUtils::SetInt(fusion_node_opdef, ge::ATTR_NAME_FRAMEWORK_FWK_TYPE, ge::GetParserContext().type); | |||
| @@ -130,7 +130,7 @@ Status TensorFlowAutoMappingParserAdapter::ParseParams(const Message *op_src, ge | |||
| (void)AttrUtils::SetZeroCopyBytes( | |||
| op_dest, ge::ATTR_NAME_FRAMEWORK_NODE_DEF, | |||
| Buffer::CopyFrom(reinterpret_cast<const uint8_t *>(serialized_node.data()), serialized_node.length())); | |||
| Buffer::CopyFrom(PtrToPtr<const char_t, const uint8_t>(serialized_node.data()), serialized_node.length())); | |||
| GELOGI("node_def of %s is %s.", op_dest->GetName().c_str(), serialized_node.c_str()); | |||
| } | |||
| @@ -44,7 +44,7 @@ class PARSER_FUNC_VISIBILITY TensorFlowFusionOpParser : public TensorFlowOpParse | |||
| * @return SUCCESS Parsing success | |||
| * @return FAILED Parsing failed | |||
| */ | |||
| virtual Status ParseParams(const std::vector<const NodeDef *> &v_input_const, ge::NodePtr &node) const; | |||
| virtual Status ParseParams(const std::vector<const NodeDef *> &v_input_const, ge::NodePtr &op_dest) const; | |||
| /** | |||
| * @ingroup domi_omg | |||
| @@ -54,6 +54,7 @@ | |||
| #include "register/register_utils.h" | |||
| #include "register/scope/scope_pass_registry_impl.h" | |||
| #include "parser/common/auto_mapping_subgraph_io_index_func.h" | |||
| #include "graph/def_types.h" | |||
| using ge::OpParserFactory; | |||
| using ge::Pb2Json; | |||
| @@ -2415,7 +2416,7 @@ Status TensorFlowModelParser::ParseProto(const std::string &serialized_proto, ge | |||
| GELOGE(FAILED, "Proto object GraphDef parse serialized proto failed"); | |||
| return FAILED; | |||
| } | |||
| return ParseProto(reinterpret_cast<const google::protobuf::Message *>(&graph_def), graph); | |||
| return ParseProto(ge::PtrToPtr<domi::tensorflow::GraphDef, const google::protobuf::Message>(&graph_def), graph); | |||
| } | |||
| Status TensorFlowModelParser::ParseProtoWithSubgraph(const std::string &root_proto, domi::GetGraphCallbackV2 callback, | |||
| @@ -4059,7 +4060,7 @@ Status TensorFlowModelParser::AddExternalGraph(const ComputeGraphPtr &root_graph | |||
| std::string model_data; | |||
| if (AttrUtils::GetStr(node->GetOpDesc(), kExternalModel, model_data) && !model_data.empty()) { | |||
| ge::Model model; | |||
| auto load_ret = ge::Model::Load(reinterpret_cast<const uint8_t *>(model_data.data()), model_data.size(), model); | |||
| auto load_ret = ge::Model::Load(ge::PtrToPtr<char_t, const uint8_t>(model_data.data()), model_data.size(), model); | |||
| if (load_ret != GRAPH_SUCCESS) { | |||
| GELOGE(INTERNAL_ERROR, "[Parse][ExternalModel]Node:%s.", node->GetName().c_str()); | |||
| REPORT_CALL_ERROR("E19999", "Failed to parse external model, node:%s.", node->GetName().c_str()); | |||
| @@ -130,7 +130,7 @@ class PARSER_FUNC_VISIBILITY TensorFlowModelParser : public domi::ModelParser { | |||
| Status ParseProtoWithSubgraph(const google::protobuf::Message *root_proto, | |||
| domi::GetGraphCallback callback, | |||
| ge::ComputeGraphPtr &graph) override; | |||
| ge::ComputeGraphPtr &root_graph) override; | |||
| /* | |||
| * @ingroup domi_omg | |||
| @@ -34,7 +34,7 @@ class PARSER_FUNC_VISIBILITY TensorFlowReshapeParser : public TensorFlowOpParser | |||
| * @return FAILED parse failed | |||
| * @author | |||
| */ | |||
| Status ParseParams(const Message *op_src, ge::OpDescPtr &op_dest) override; | |||
| Status ParseParams(const Message *op_src, ge::OpDescPtr &op) override; | |||
| }; | |||
| } // namespace ge | |||
| @@ -22,7 +22,7 @@ | |||
| namespace ge { | |||
| class PARSER_FUNC_VISIBILITY TensorFlowSqueezeParser : public TensorFlowOpParser { | |||
| public: | |||
| Status ParseParams(const Message *op_src, ge::OpDescPtr &op_dest) override; | |||
| Status ParseParams(const Message *op_src, ge::OpDescPtr &op) override; | |||
| private: | |||
| static Status ParseDesc(const domi::tensorflow::AttrValue &attr_value, ge::GeTensorDesc &ge_desc); | |||