From 3c820064defc0ef2e24439f3674b7d1f34269436 Mon Sep 17 00:00:00 2001 From: tangwei12 Date: Mon, 14 May 2018 23:14:06 +0800 Subject: [PATCH] remove overwrite judge to test load --- paddle/fluid/operators/checkpoint_save_op.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/operators/checkpoint_save_op.cc b/paddle/fluid/operators/checkpoint_save_op.cc index 1e621a00e..94a1cc05c 100644 --- a/paddle/fluid/operators/checkpoint_save_op.cc +++ b/paddle/fluid/operators/checkpoint_save_op.cc @@ -30,6 +30,9 @@ namespace operators { // TODO(sidgoyal78): These function are needed by other files (save_op), move // them to paddle::filesystem namespace. (as noted by yuyang18 in save_op). constexpr char kSEP = '/'; +// write empty file named _SUCCESS +const char SUCCESS[] = "_SUCCESS"; + static bool FileExists(const std::string &filepath) { struct stat buffer; return (stat(filepath.c_str(), &buffer) == 0); @@ -73,8 +76,11 @@ class CheckpointSaveOp : public framework::OperatorBase { bool is_present = FileExists(dir); if (is_present && !overwrite) { - PADDLE_THROW("%s exists!, cannot save_combine to it when overwrite=false", - dir, overwrite); + return; + // todo(tangwei) judge the folder is exist + // PADDLE_THROW("%s exists!, cannot save_combine to it when + // overwrite=false", + // dir, overwrite); } MkDirRecursively(dir.c_str()); @@ -108,6 +114,13 @@ class CheckpointSaveOp : public framework::OperatorBase { framework::SerializeToStream(fout, tensor, dev_ctx); fout.close(); } + + std::string success; + success.append(dir); + success.append("/"); + success.append(SUCCESS); + std::ofstream fout(success); + fout.close(); } }; -- GitLab