Browse Source

add ret

pull/242/head
wjm 5 years ago
parent
commit
cc5425b0a0
3 changed files with 11 additions and 9 deletions
  1. +3
    -3
      atc/parse_graph.cc
  2. +5
    -4
      parser/common/convert/pb2json.cc
  3. +3
    -2
      parser/common/convert/pb2json.h

+ 3
- 3
atc/parse_graph.cc View File

@@ -893,7 +893,7 @@ FMK_FUNC_HOST_VISIBILITY Status ConvertOm(const char *model_file, const char *js

if (is_covert_to_json) {
GetGroupName(model_def);
Pb2Json::ToJson(model_def, kOmBlackFields, json_file, true);
ret = Pb2Json::ToJson(model_def, kOmBlackFields, json_file, true);
} else {
PrintModelInfo(&model_def);
}
@@ -917,8 +917,8 @@ FMK_FUNC_HOST_VISIBILITY Status ConvertPbtxtToJson(const char *model_file, const
}

GetGroupName(model_def);
Pb2Json::ToJson(model_def, kOmBlackFields, json_file, true);
return SUCCESS;
ret = Pb2Json::ToJson(model_def, kOmBlackFields, json_file, true);
return ret;
} catch (const std::exception &e) {
ErrorManager::GetInstance().ATCReportErrMessage("E19021", {"reason"},
{"Convert pbtxt to json failed, exception message[" + std::string(e.what()) + "]"});


+ 5
- 4
parser/common/convert/pb2json.cc View File

@@ -33,13 +33,14 @@ namespace {
const int kSignificantDigits = 10;
}

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void Pb2Json::ToJson(const ProtobufMsg &message,
const set<string> &black_fields,
const char *json_file, bool enum2str) {
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status Pb2Json::ToJson(const ProtobufMsg &message,
const set<string> &black_fields,
const char *json_file, bool enum2str) {
Json j;
Message2Json(message, black_fields, j, enum2str);
ge::parser::ModelSaver::SaveJsonToFile(json_file, j);
return ge::parser::ModelSaver::SaveJsonToFile(json_file, j);
}

// JSON parses non utf8 character throwing exceptions, so some fields need to be shielded through black fields
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void Pb2Json::Message2Json(const ProtobufMsg &message,
const set<string> &black_fields, Json &json,


+ 3
- 2
parser/common/convert/pb2json.h View File

@@ -23,6 +23,7 @@
#include <memory>
#include <set>
#include <string>
#include "ge/ge_api_error_codes.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/message.h"
#include "nlohmann/json.hpp"
@@ -51,8 +52,8 @@ class Pb2Json {
const ProtobufReflection *reflection, const std::set<std::string> &black_fields,
Json &json, bool enum2str);

static void ToJson(const ProtobufMsg &message, const std::set<std::string> &black_fields, const char *json_file,
bool enum2str = false);
static Status ToJson(const ProtobufMsg &message, const std::set<std::string> &black_fields, const char *json_file,
bool enum2str = false);

protected:
static void Enum2Json(const ProtobufEnumValueDescriptor *enum_value_desc, const ProtobufFieldDescriptor *field,


Loading…
Cancel
Save