From dbd023771f82cb69574b374bea30836f3804015a Mon Sep 17 00:00:00 2001 From: tangwei12 Date: Fri, 18 May 2018 19:37:49 +0800 Subject: [PATCH] fix serial number --- paddle/fluid/operators/checkpoint_load_op.cc | 2 +- paddle/fluid/operators/checkpoint_save_op.cc | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/paddle/fluid/operators/checkpoint_load_op.cc b/paddle/fluid/operators/checkpoint_load_op.cc index 82a40e18d5c..c18edf63062 100644 --- a/paddle/fluid/operators/checkpoint_load_op.cc +++ b/paddle/fluid/operators/checkpoint_load_op.cc @@ -176,7 +176,7 @@ to a file on disk. AddAttr( "dir", "(string)" - "The \"file_path\" where the LoDTensor variables will be saved.") + "The \"dir\" where the checkpoint files will be loaded.") .AddCustomChecker( [](const std::string &path) { return !path.empty(); }); } diff --git a/paddle/fluid/operators/checkpoint_save_op.cc b/paddle/fluid/operators/checkpoint_save_op.cc index 790fd4ea685..1832c5792a1 100644 --- a/paddle/fluid/operators/checkpoint_save_op.cc +++ b/paddle/fluid/operators/checkpoint_save_op.cc @@ -94,10 +94,16 @@ class CheckpointSaveOp : public framework::OperatorBase { VLOG(1) << "CheckpointSaveOp get " << SERIAL_VAR << " value: " << serial_num; - if (serial_num->empty()) { - serial_num->append("0"); + int serials = 0; + if (!serial_num->empty()) { + std::string::size_type sz; + serials = std::stoi(serial_num->data, &sz); + serials += 1; } + serial_num->clear(); + serial_num->append(std::to_string(serials)); + std::string dir = GenePath(ck_dir, serial_num->c_str()); VLOG(1) << "CheckpointSaveOp current dir: " << dir; bool is_present = FileExists(dir); -- GitLab