Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
60b7bf6f
P
Paddle
项目概览
Crayon鑫
/
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看板
提交
60b7bf6f
编写于
3月 28, 2019
作者:
D
dongdaxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add infer_from_dataset for inference
上级
030c7e7e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
37 addition
and
6 deletion
+37
-6
paddle/fluid/framework/device_worker.h
paddle/fluid/framework/device_worker.h
+2
-0
paddle/fluid/framework/hogwild_worker.cc
paddle/fluid/framework/hogwild_worker.cc
+26
-2
python/paddle/fluid/device_worker.py
python/paddle/fluid/device_worker.py
+3
-0
python/paddle/fluid/executor.py
python/paddle/fluid/executor.py
+5
-3
python/paddle/fluid/trainer_desc.py
python/paddle/fluid/trainer_desc.py
+1
-1
未找到文件。
paddle/fluid/framework/device_worker.h
浏览文件 @
60b7bf6f
...
...
@@ -147,6 +147,8 @@ class HogwildWorker : public CPUWorkerBase {
std
::
vector
<
std
::
string
>
op_names_
;
std
::
vector
<
OperatorBase
*>
ops_
;
Scope
*
thread_scope_
;
HogwildWorkerParameter
param_
;
std
::
vector
<
std
::
string
>
skip_ops_
;
};
class
DownpourWorker
:
public
HogwildWorker
{
...
...
paddle/fluid/framework/hogwild_worker.cc
浏览文件 @
60b7bf6f
...
...
@@ -22,6 +22,12 @@ namespace framework {
void
HogwildWorker
::
Initialize
(
const
TrainerDesc
&
desc
)
{
fetch_config_
=
desc
.
fetch_config
();
param_
=
desc
.
hogwild_param
();
skip_ops_
.
resize
(
param_
.
skip_ops_size
());
LOG
(
WARNING
)
<<
"skip op size: "
<<
skip_ops_
.
size
();
for
(
size_t
i
=
0
;
i
<
param_
.
skip_ops_size
();
++
i
)
{
skip_ops_
[
i
]
=
param_
.
skip_ops
(
i
);
}
}
void
HogwildWorker
::
CreateThreadOperators
(
const
ProgramDesc
&
program
)
{
...
...
@@ -92,9 +98,18 @@ void HogwildWorker::TrainFilesWithProfiler() {
read_time
+=
timeline
.
ElapsedSec
();
total_time
+=
timeline
.
ElapsedSec
();
for
(
size_t
i
=
0
;
i
<
ops_
.
size
();
++
i
)
{
bool
need_skip
=
false
;
for
(
auto
t
=
0u
;
t
<
skip_ops_
.
size
();
++
t
)
{
if
(
ops_
[
i
]
->
Type
().
find
(
skip_ops_
[
t
])
!=
std
::
string
::
npos
)
{
need_skip
=
true
;
break
;
}
}
timeline
.
Start
();
VLOG
(
3
)
<<
"Going to run op "
<<
op_name
[
i
];
ops_
[
i
]
->
Run
(
*
thread_scope_
,
place_
);
if
(
!
need_skip
)
{
ops_
[
i
]
->
Run
(
*
thread_scope_
,
place_
);
}
VLOG
(
3
)
<<
"Op "
<<
op_name
[
i
]
<<
" Finished"
;
timeline
.
Pause
();
op_total_time
[
i
]
+=
timeline
.
ElapsedSec
();
...
...
@@ -127,7 +142,16 @@ void HogwildWorker::TrainFiles() {
int
cur_batch
;
while
((
cur_batch
=
device_reader_
->
Next
())
>
0
)
{
for
(
auto
&
op
:
ops_
)
{
op
->
Run
(
*
thread_scope_
,
place_
);
bool
need_skip
=
false
;
for
(
auto
t
=
0u
;
t
<
skip_ops_
.
size
();
++
t
)
{
if
(
op
->
Type
().
find
(
skip_ops_
[
t
])
!=
std
::
string
::
npos
)
{
need_skip
=
true
;
break
;
}
}
if
(
!
need_skip
)
{
op
->
Run
(
*
thread_scope_
,
place_
);
}
}
PrintFetchVars
();
...
...
python/paddle/fluid/device_worker.py
浏览文件 @
60b7bf6f
...
...
@@ -89,6 +89,9 @@ class Hogwild(DeviceWorker):
trainer_desc(TrainerDesc): a TrainerDesc object
"""
trainer_desc
.
device_worker_name
=
"HogwildWorker"
if
self
.
infer_
:
# just ignore feed op for inference model
trainer_desc
.
hogwild_param
.
skip_ops
.
extend
([
"feed"
])
class
DownpourSGD
(
DeviceWorker
):
...
...
python/paddle/fluid/executor.py
浏览文件 @
60b7bf6f
...
...
@@ -659,10 +659,12 @@ class Executor(object):
def
infer_from_dataset
(
self
,
program
=
None
,
dataset
=
None
,
fetch_list
=
None
,
scope
=
None
,
thread
=
0
,
opt_info
=
None
):
debug
=
False
,
fetch_list
=
None
,
fetch_info
=
None
,
print_period
=
100
):
"""
The document of infer_from_dataset is almost the same as
train_from_dataset, except that in distributed training,
...
...
@@ -711,8 +713,8 @@ class Executor(object):
fetch_list
=
fetch_list
,
fetch_info
=
fetch_info
,
print_period
=
print_period
)
trainer
.
_gen_trainer_desc
()
trainer
.
_set_infer
(
True
)
trainer
.
_gen_trainer_desc
()
dataset
.
_prepare_to_run
()
if
debug
:
self
.
_dump_debug_info
(
program
=
program
,
trainer
=
trainer
)
...
...
python/paddle/fluid/trainer_desc.py
浏览文件 @
60b7bf6f
...
...
@@ -98,7 +98,7 @@ class DistMultiTrainer(TrainerDesc):
super
(
DistMultiTrainer
,
self
).
_gen_trainer_desc
()
self
.
proto_desc
.
class_name
=
"DistMultiTrainer"
if
self
.
program_
==
None
:
print
(
"None p
rogram"
)
raise
RuntimeError
(
"None P
rogram"
)
self
.
device_worker_
.
_set_infer
(
self
.
infer_
)
self
.
device_worker_
.
_set_program
(
self
.
program_
)
self
.
device_worker_
.
_gen_worker_desc
(
self
.
proto_desc
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录