Browse Source

add onnx model parse api

pull/134/head
baker 5 years ago
parent
commit
266e78792e
1 changed files with 3 additions and 4 deletions
  1. +3
    -4
      parser/onnx/onnx_parser.cc

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

@@ -506,7 +506,6 @@ Status OnnxModelParser::GetModelFromFile(const char *file, ge::onnx::ModelProto
GELOGI("File path is %s.", file);

// 1. Get graph from onnx model file.
ge::onnx::ModelProto onnx_model;
if (!ge::parser::ReadProtoFromBinaryFile(file, onnx_model)) {
ErrorManager::GetInstance().ATCReportErrMessage(
"E19021", {"reason"}, {"Read onnx model file failed."});
@@ -520,11 +519,10 @@ Status OnnxModelParser::GetModelFromMemory(const char *data, uint32_t size, ge::
GE_CHECK_NOTNULL(data);

// 1. Get graph from onnx model file.
ge::onnx::ModelProto onnx_model;
if (!ge::parser::ReadProtoFromArray(file, onnx_model)) {
if (!ge::parser::ReadProtoFromArray(data, onnx_model)) {
ErrorManager::GetInstance().ATCReportErrMessage(
"E19021", {"reason"}, {"Read onnx model from memory failed."});
GELOGE(PARAM_INVALID, "Read onnx model file failed.");
GELOGE(PARAM_INVALID, "Read onnx model from memory failed.");
return FAILED;
}
return SUCCESS;
@@ -652,6 +650,7 @@ Status OnnxModelParser::ParseFromMemory(const char *data, uint32_t size, ge::Gra
return FAILED;
}
}

Status OnnxModelParser::ToJson(const char *model_file, const char *json_file) {
if (model_file == nullptr) {
GELOGE(FAILED, "Model file is nullptr.");


Loading…
Cancel
Save