Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
7b6c0abf
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7b6c0abf
编写于
5月 17, 2018
作者:
T
tangwei12
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify variable point
上级
8430c8d7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
13 deletion
+31
-13
paddle/fluid/operators/checkpoint_load_op.cc
paddle/fluid/operators/checkpoint_load_op.cc
+16
-8
paddle/fluid/operators/checkpoint_save_op.cc
paddle/fluid/operators/checkpoint_save_op.cc
+15
-5
未找到文件。
paddle/fluid/operators/checkpoint_load_op.cc
浏览文件 @
7b6c0abf
...
@@ -108,15 +108,22 @@ class CheckpointLoadOp : public framework::OperatorBase {
...
@@ -108,15 +108,22 @@ class CheckpointLoadOp : public framework::OperatorBase {
void
RunImpl
(
const
framework
::
Scope
&
scope
,
void
RunImpl
(
const
framework
::
Scope
&
scope
,
const
platform
::
Place
&
place
)
const
override
{
const
platform
::
Place
&
place
)
const
override
{
std
::
string
dir
=
Attr
<
std
::
string
>
(
"dir"
);
std
::
string
dir
=
Attr
<
std
::
string
>
(
"dir"
);
int
serial_num
=
Attr
<
int
>
(
"Serial"
);
std
::
string
serial_num
=
Attr
<
std
::
string
>
(
"Serial"
);
std
::
string
serial_var_name
=
std
::
string
(
SERIAL_VAR
);
auto
*
serial_var
=
scope
.
FindVar
(
serial_var_name
);
auto
*
serial_num
;
if
(
serial_var
==
nullptr
)
{
*
serial_var
=
scope
.
Var
(
serial_var_name
);
*
serial_num
=
serial_var
->
GetMutable
<
std
::
string
>
();
serial_num
->
append
(
"0"
);
}
auto
*
serial_var
=
scope
.
FindVar
(
SERIAL_VAR
);
*
serial_num
=
serial_var
->
GetMutable
<
std
::
string
>
();
serial_var
=
serial_num
;
VLOG
(
1
)
<<
"CheckpointLoadOp set "
<<
SERIAL_NUMBER
VLOG
(
1
)
<<
"CheckpointLoadOp set "
<<
SERIAL_NUMBER
<<
" value: "
<<
serial_num
;
<<
" value: "
<<
serial_num
;
std
::
string
success
;
std
::
string
success
=
GenePath
(
dir
,
serial_num
);
=
GenePath
(
dir
,
std
::
to_string
(
serial_num
));
VLOG
(
3
)
<<
"Load checkpoint from dir: "
<<
success
;
VLOG
(
3
)
<<
"Load checkpoint from dir: "
<<
success
;
success
=
GenePath
(
success
,
SUCCESS
);
success
=
GenePath
(
success
,
SUCCESS
);
bool
is_present
=
FileExists
(
success
);
bool
is_present
=
FileExists
(
success
);
...
@@ -157,9 +164,10 @@ This operator will serialize and write a list of input LoDTensor variables
...
@@ -157,9 +164,10 @@ This operator will serialize and write a list of input LoDTensor variables
to a file on disk.
to a file on disk.
)DOC"
);
)DOC"
);
AddAttr
<
int
>
(
"Serial"
,
AddAttr
<
std
::
string
>
(
"(int)"
"Serial"
,
"The serial number of the checkpoint will to be load."
);
"(std::string)"
"The serial number of the checkpoint will to be load."
);
AddAttr
<
std
::
string
>
(
AddAttr
<
std
::
string
>
(
"dir"
,
"dir"
,
"(string)"
"(string)"
...
...
paddle/fluid/operators/checkpoint_save_op.cc
浏览文件 @
7b6c0abf
...
@@ -82,13 +82,23 @@ class CheckpointSaveOp : public framework::OperatorBase {
...
@@ -82,13 +82,23 @@ class CheckpointSaveOp : public framework::OperatorBase {
auto
dir
=
Attr
<
std
::
string
>
(
"dir"
);
auto
dir
=
Attr
<
std
::
string
>
(
"dir"
);
auto
overwrite
=
Attr
<
bool
>
(
"overwrite"
);
auto
overwrite
=
Attr
<
bool
>
(
"overwrite"
);
auto
serial_num
=
scope
.
FindVar
(
SERIAL_VAR
);
std
::
string
serial_var_name
=
std
::
string
(
SERIAL_VAR
);
if
(
serial_num
==
nullptr
)
{
auto
*
serial_var
=
scope
.
FindVar
(
serial_var_name
);
serial_num
=
scope
.
Var
(
SERIAL_VAR
);
auto
*
serial_num
;
if
(
serial_var
==
nullptr
)
{
*
serial_var
=
scope
.
Var
(
serial_var_name
);
*
serial_num
=
serial_var
->
GetMutable
<
std
::
string
>
();
serial_num
->
append
(
"0"
);
}
}
serial_num
=
serial_num
+
1
;
dir
=
GenePath
(
dir
,
std
::
to_string
(
serial_num
));
*
serial_num
=
serial_var
->
GetMutable
<
std
::
string
>
();
VLOG
(
1
)
<<
"CheckpointSaveOp get "
<<
SERIAL_NUMBER
<<
" value: "
<<
serial_num
;
auto
*
serial_num
=
serial_var
->
GetMutable
<
std
::
string
>
();
serial_num
->
append
(
"1"
);
dir
=
GenePath
(
dir
,
serial_num
);
bool
is_present
=
FileExists
(
dir
);
bool
is_present
=
FileExists
(
dir
);
if
(
is_present
&&
!
overwrite
)
{
if
(
is_present
&&
!
overwrite
)
{
PADDLE_THROW
(
"%s exists!, checkpoint save cannot to overwrite it"
,
dir
,
PADDLE_THROW
(
"%s exists!, checkpoint save cannot to overwrite it"
,
dir
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录