Browse Source

!13276 modify export mindir log

From: @changzherui
Reviewed-by: @zhoufeng54
Signed-off-by:
tags/v1.2.0-rc1
mindspore-ci-bot Gitee 4 years ago
parent
commit
06fc4e9819
2 changed files with 5 additions and 5 deletions
  1. +3
    -3
      mindspore/core/load_mindir/load_model.cc
  2. +2
    -2
      mindspore/train/serialization.py

+ 3
- 3
mindspore/core/load_mindir/load_model.cc View File

@@ -127,7 +127,7 @@ std::shared_ptr<FuncGraph> LoadMindIR(const std::string &file_name, bool is_lite
mind_ir::ModelProto origin_model; mind_ir::ModelProto origin_model;


if (!input_graph || !origin_model.ParseFromIstream(&input_graph)) { if (!input_graph || !origin_model.ParseFromIstream(&input_graph)) {
MS_LOG(ERROR) << "Load MindIR file failed.";
MS_LOG(ERROR) << "Load MindIR file failed, please check the correctness of the file.";
return nullptr; return nullptr;
} }


@@ -143,7 +143,7 @@ std::shared_ptr<FuncGraph> LoadMindIR(const std::string &file_name, bool is_lite
string path = abs_path; string path = abs_path;
get_all_files(path, &files); get_all_files(path, &files);
} else { } else {
MS_LOG(ERROR) << "MindIR graph has not variable path, load failed";
MS_LOG(ERROR) << "Load graph's variable folder failed, please check the correctness of variable folder.";
return nullptr; return nullptr;
} }


@@ -153,7 +153,7 @@ std::shared_ptr<FuncGraph> LoadMindIR(const std::string &file_name, bool is_lite
std::fstream input_param(files[file_index], std::ios::in | std::ios::binary); std::fstream input_param(files[file_index], std::ios::in | std::ios::binary);
mind_ir::GraphProto param_graph; mind_ir::GraphProto param_graph;
if (!input_param || !param_graph.ParseFromIstream(&input_param)) { if (!input_param || !param_graph.ParseFromIstream(&input_param)) {
MS_LOG(ERROR) << "Load param proto file failed.";
MS_LOG(ERROR) << "Load variable file failed, please check the correctness of mindir's variable file.";
return nullptr; return nullptr;
} }




+ 2
- 2
mindspore/train/serialization.py View File

@@ -721,7 +721,7 @@ def _save_mindir(net, file_name, *inputs):
if data_size > TOTAL_SAVE: if data_size > TOTAL_SAVE:
data_file_name = data_path + "/" + "data_" + str(index) data_file_name = data_path + "/" + "data_" + str(index)
with open(data_file_name, "ab") as f: with open(data_file_name, "ab") as f:
os.chmod(file_name, stat.S_IRUSR | stat.S_IWUSR)
os.chmod(data_file_name, stat.S_IRUSR | stat.S_IWUSR)
f.write(graphproto.SerializeToString()) f.write(graphproto.SerializeToString())
index += 1 index += 1
data_size = 0 data_size = 0
@@ -730,7 +730,7 @@ def _save_mindir(net, file_name, *inputs):
if graphproto.parameter: if graphproto.parameter:
data_file_name = data_path + "/" + "data_" + str(index) data_file_name = data_path + "/" + "data_" + str(index)
with open(data_file_name, "ab") as f: with open(data_file_name, "ab") as f:
os.chmod(file_name, stat.S_IRUSR | stat.S_IWUSR)
os.chmod(data_file_name, stat.S_IRUSR | stat.S_IWUSR)
f.write(graphproto.SerializeToString()) f.write(graphproto.SerializeToString())


# save graph # save graph


Loading…
Cancel
Save