Skip to content

Commit

Permalink
Merge pull request PaddlePaddle#15112 from wopeizl/windows/fixsaveand…
Browse files Browse the repository at this point in the history
…loadops

fix save and load ops on windows test=develop
  • Loading branch information
wopeizl committed Jan 2, 2019
2 parents 5f9c888 + b368810 commit 7305fc2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions paddle/fluid/operators/load_combine_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ class LoadCombineOp : public framework::OperatorBase {
static_cast<int>(out_var_names.size()), 0,
"The number of output variables should be greater than 0.");
if (!model_from_memory) {
std::ifstream fin(filename);
std::ifstream fin(filename, std::ios::binary);
PADDLE_ENFORCE(static_cast<bool>(fin),
"Cannot open file %s for load_combine op", filename);
LoadParamsFromBuffer(scope, place, &fin, load_as_fp16, out_var_names);
} else {
PADDLE_ENFORCE(!filename.empty(), "Cannot load file from memory");
std::stringstream fin(filename);
std::stringstream fin(filename, std::ios::in | std::ios::binary);
LoadParamsFromBuffer(scope, place, &fin, load_as_fp16, out_var_names);
}
}
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/load_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class LoadOp : public framework::OperatorBase {
// FIXME(yuyang18): We save variable to local file now, but we should change
// it to save an output stream.
auto filename = Attr<std::string>("file_path");
std::ifstream fin(filename);
std::ifstream fin(filename, std::ios::binary);
PADDLE_ENFORCE(static_cast<bool>(fin), "Cannot open file %s for load op",
filename);

Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/save_combine_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SaveCombineOp : public framework::OperatorBase {
}

MkDirRecursively(DirName(filename).c_str());
std::ofstream fout(filename);
std::ofstream fout(filename, std::ios::binary);
PADDLE_ENFORCE(static_cast<bool>(fout), "Cannot open %s to write",
filename);

Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/operators/save_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class SaveOp : public framework::OperatorBase {

// FIXME(yuyang18): We save variable to local file now, but we should change
// it to save an output stream.
std::ofstream fout(filename);
std::ofstream fout(filename, std::ios::binary);
PADDLE_ENFORCE(static_cast<bool>(fout), "Cannot open %s to write",
filename);

Expand Down Expand Up @@ -122,7 +122,7 @@ class SaveOp : public framework::OperatorBase {

// FIXME(yuyang18): We save variable to local file now, but we should change
// it to save an output stream.
std::ofstream fout(filename);
std::ofstream fout(filename, std::ios::binary);
PADDLE_ENFORCE(static_cast<bool>(fout), "Cannot open %s to write",
filename);
framework::SerializeToStream(fout, selectedRows, dev_ctx);
Expand Down

0 comments on commit 7305fc2

Please sign in to comment.