fix serial number

shanyi15-patch-3
tangwei12 7 years ago
parent cd98f2b7e0
commit dbd023771f

@ -176,7 +176,7 @@ to a file on disk.
AddAttr<std::string>(
"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(); });
}

@ -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);

Loading…
Cancel
Save