From 8a4dbc9424095ea6576a9b43587dec4843b1aff9 Mon Sep 17 00:00:00 2001 From: baker Date: Wed, 9 Dec 2020 21:59:24 +0800 Subject: [PATCH 1/3] add onnx parse api --- inc/framework/common/ge_types.h | 1 + inc/framework/omg/parser/model_parser.h | 11 +++++++++++ inc/framework/omg/parser/parser_inner_ctx.h | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/inc/framework/common/ge_types.h b/inc/framework/common/ge_types.h index fb1f0be1..254dbada 100644 --- a/inc/framework/common/ge_types.h +++ b/inc/framework/common/ge_types.h @@ -37,6 +37,7 @@ enum FrameworkType { MINDSPORE = 1, TENSORFLOW = 3, ANDROID_NN, + ONNX, FRAMEWORK_RESERVED, }; diff --git a/inc/framework/omg/parser/model_parser.h b/inc/framework/omg/parser/model_parser.h index 20bfcef4..bb3a04b9 100644 --- a/inc/framework/omg/parser/model_parser.h +++ b/inc/framework/omg/parser/model_parser.h @@ -65,6 +65,17 @@ class ModelParser { virtual Status ParseFromMemory(const char *data, uint32_t size, ge::ComputeGraphPtr &graph) = 0; /** + * @ingroup domi_omg + * @brief Parse relevant data from memory and save it to graph + * @param [in] input Model file memory data + * @param [in|out] graph A graph for saving the model information after analysis + * @return SUCCESS + * @return FAILED + * @author + */ + virtual Status ParseFromMemory(const char *data, uint32_t size, ge::Graph &graph) = 0; + + /** * @ingroup domi_omg * @brief Analyze network model data * @param [in] proto network model diff --git a/inc/framework/omg/parser/parser_inner_ctx.h b/inc/framework/omg/parser/parser_inner_ctx.h index f24e2639..5d91bd46 100644 --- a/inc/framework/omg/parser/parser_inner_ctx.h +++ b/inc/framework/omg/parser/parser_inner_ctx.h @@ -59,7 +59,7 @@ struct ParserContext { bool train_flag = false; domi::domiTensorFormat_t format = domi::DOMI_TENSOR_ND; domi::FrameworkType type = domi::FRAMEWORK_RESERVED; - RunMode run_mode = ONLY_PRE_CHECK; + RunMode run_mode = GEN_OM_MODEL; // save caffe custom proto path, used by caffe parse std::string custom_proto_path; // save caffe proto path, used by caffe parse From e1228324ffceb0c089a7f0ee8c238e74860c23e6 Mon Sep 17 00:00:00 2001 From: baker Date: Wed, 9 Dec 2020 22:00:26 +0800 Subject: [PATCH 2/3] add onnx parse api --- inc/framework/omg/parser/model_parser.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/framework/omg/parser/model_parser.h b/inc/framework/omg/parser/model_parser.h index bb3a04b9..021985c3 100644 --- a/inc/framework/omg/parser/model_parser.h +++ b/inc/framework/omg/parser/model_parser.h @@ -67,7 +67,7 @@ class ModelParser { /** * @ingroup domi_omg * @brief Parse relevant data from memory and save it to graph - * @param [in] input Model file memory data + * @param [in] input Model file memory data and size * @param [in|out] graph A graph for saving the model information after analysis * @return SUCCESS * @return FAILED From 65b377cf7f447e78c27fe859ddc827b334704b74 Mon Sep 17 00:00:00 2001 From: baker Date: Thu, 10 Dec 2020 11:08:50 +0800 Subject: [PATCH 3/3] add onnx model parse api --- inc/framework/omg/parser/model_parser.h | 42 ++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/inc/framework/omg/parser/model_parser.h b/inc/framework/omg/parser/model_parser.h index 021985c3..7ce7795e 100644 --- a/inc/framework/omg/parser/model_parser.h +++ b/inc/framework/omg/parser/model_parser.h @@ -54,25 +54,25 @@ class ModelParser { virtual Status Parse(const char *file, ge::Graph &graph) = 0; /** - * @ingroup domi_omg - * @brief Parse relevant data from memory and save it to graph - * @param [in] input Model file memory data - * @param [in|out] graph A graph for saving the model information after analysis - * @return SUCCESS - * @return FAILED - * @author - */ + * @ingroup domi_omg + * @brief Parse relevant data from memory and save it to graph + * @param [in] input Model file memory data + * @param [in|out] graph A graph for saving the model information after analysis + * @return SUCCESS + * @return FAILED + * @author + */ virtual Status ParseFromMemory(const char *data, uint32_t size, ge::ComputeGraphPtr &graph) = 0; /** - * @ingroup domi_omg - * @brief Parse relevant data from memory and save it to graph - * @param [in] input Model file memory data and size - * @param [in|out] graph A graph for saving the model information after analysis - * @return SUCCESS - * @return FAILED - * @author - */ + * @ingroup domi_omg + * @brief Parse relevant data from memory and save it to graph + * @param [in] input Model file memory data and size + * @param [in|out] graph A graph for saving the model information after analysis + * @return SUCCESS + * @return FAILED + * @author + */ virtual Status ParseFromMemory(const char *data, uint32_t size, ge::Graph &graph) = 0; /** @@ -108,11 +108,11 @@ class ModelParser { virtual Status ToJson(const char *model_file, const char *json_file) { return domi::SUCCESS; } /* - * @ingroup domi_omg - * @brief Convert network data type - * @param [in] type Data type to be converted - * @return ge::DataType - */ + * @ingroup domi_omg + * @brief Convert network data type + * @param [in] type Data type to be converted + * @return ge::DataType + */ virtual ge::DataType ConvertToGeDataType(const uint32_t type) = 0; virtual Status ParseAllGraph(const google::protobuf::Message *root_proto, ge::ComputeGraphPtr &root_graph) = 0;