提交 dbd02377 编写于 作者: T tangwei12

fix serial number

上级 cd98f2b7
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册