Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
0bf799a5
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0bf799a5
编写于
4月 10, 2018
作者:
T
typhoonzero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip testing
上级
b9c28df9
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
16 addition
and
17 deletion
+16
-17
paddle/fluid/framework/details/CMakeLists.txt
paddle/fluid/framework/details/CMakeLists.txt
+1
-1
paddle/fluid/framework/details/multi_devices_graph_builder.cc
...le/fluid/framework/details/multi_devices_graph_builder.cc
+4
-6
paddle/fluid/framework/details/multi_devices_graph_builder.h
paddle/fluid/framework/details/multi_devices_graph_builder.h
+2
-5
paddle/fluid/framework/parallel_executor.h
paddle/fluid/framework/parallel_executor.h
+2
-2
paddle/fluid/operators/detail/serde_test.cc
paddle/fluid/operators/detail/serde_test.cc
+1
-1
paddle/fluid/pybind/pybind.cc
paddle/fluid/pybind/pybind.cc
+1
-0
python/paddle/fluid/parallel_executor.py
python/paddle/fluid/parallel_executor.py
+5
-2
未找到文件。
paddle/fluid/framework/details/CMakeLists.txt
浏览文件 @
0bf799a5
...
@@ -16,7 +16,7 @@ else()
...
@@ -16,7 +16,7 @@ else()
set
(
multi_devices_graph_builder_deps
)
set
(
multi_devices_graph_builder_deps
)
endif
()
endif
()
cc_library
(
multi_devices_graph_builder SRCS multi_devices_graph_builder.cc DEPS ssa_graph_builder computation_op_handle
cc_library
(
multi_devices_graph_builder SRCS multi_devices_graph_builder.cc DEPS ssa_graph_builder computation_op_handle
scale_loss_grad_op_handle
${
multi_devices_graph_builder_deps
}
)
scale_loss_grad_op_handle
send_op_handle
${
multi_devices_graph_builder_deps
}
)
cc_library
(
ssa_graph_executor SRCS ssa_graph_executor.cc DEPS ssa_graph framework_proto
)
cc_library
(
ssa_graph_executor SRCS ssa_graph_executor.cc DEPS ssa_graph framework_proto
)
cc_library
(
threaded_ssa_graph_executor SRCS threaded_ssa_graph_executor.cc DEPS fetch_op_handle ssa_graph_executor scope
cc_library
(
threaded_ssa_graph_executor SRCS threaded_ssa_graph_executor.cc DEPS fetch_op_handle ssa_graph_executor scope
simple_threadpool device_context
)
simple_threadpool device_context
)
paddle/fluid/framework/details/multi_devices_graph_builder.cc
浏览文件 @
0bf799a5
...
@@ -35,22 +35,20 @@ MultiDevSSAGraphBuilder::MultiDevSSAGraphBuilder(
...
@@ -35,22 +35,20 @@ MultiDevSSAGraphBuilder::MultiDevSSAGraphBuilder(
const
std
::
string
&
loss_var_name
,
const
std
::
string
&
loss_var_name
,
const
std
::
unordered_set
<
std
::
string
>
&
params
,
const
std
::
unordered_set
<
std
::
string
>
&
params
,
const
std
::
vector
<
Scope
*>
&
local_scopes
,
const
std
::
vector
<
Scope
*>
&
local_scopes
,
platform
::
NCCLContextMap
*
nccl_ctxs
,
bool
distributed
)
platform
::
NCCLContextMap
*
nccl_ctxs
)
:
loss_var_name_
(
loss_var_name
),
:
loss_var_name_
(
loss_var_name
),
places_
(
places
),
places_
(
places
),
local_scopes_
(
local_scopes
),
local_scopes_
(
local_scopes
),
distributed_
(
distributed
),
nccl_ctxs_
(
nccl_ctxs
)
{
nccl_ctxs_
(
nccl_ctxs
)
{
#else
#else
MultiDevSSAGraphBuilder
::
MultiDevSSAGraphBuilder
(
MultiDevSSAGraphBuilder
::
MultiDevSSAGraphBuilder
(
const
std
::
vector
<
platform
::
Place
>
&
places
,
const
std
::
vector
<
platform
::
Place
>
&
places
,
const
std
::
string
&
loss_var_name
,
const
std
::
string
&
loss_var_name
,
const
std
::
unordered_set
<
std
::
string
>
&
params
,
const
std
::
unordered_set
<
std
::
string
>
&
params
,
const
std
::
vector
<
Scope
*>
&
local_scopes
,
bool
distributed
)
const
std
::
vector
<
Scope
*>
&
local_scopes
)
:
loss_var_name_
(
loss_var_name
),
:
loss_var_name_
(
loss_var_name
),
places_
(
places
),
places_
(
places
),
local_scopes_
(
local_scopes
),
local_scopes_
(
local_scopes
)
{
distributed_
(
distributed
)
{
#endif
#endif
for
(
auto
&
p
:
params
)
{
for
(
auto
&
p
:
params
)
{
grad_names_
.
insert
(
GradVarName
(
p
));
grad_names_
.
insert
(
GradVarName
(
p
));
...
@@ -99,7 +97,7 @@ std::unique_ptr<SSAGraph> MultiDevSSAGraphBuilder::Build(
...
@@ -99,7 +97,7 @@ std::unique_ptr<SSAGraph> MultiDevSSAGraphBuilder::Build(
// append send op if program is distributed trainer main program.
// append send op if program is distributed trainer main program.
// always use the first device
// always use the first device
if
(
is_forwarding
&&
distributed_
&&
op
->
Type
()
==
"send"
)
{
if
(
!
is_forwarding
&&
op
->
Type
()
==
"send"
)
{
auto
&
p
=
places_
[
0
];
auto
&
p
=
places_
[
0
];
auto
*
s
=
local_scopes_
[
0
];
auto
*
s
=
local_scopes_
[
0
];
size_t
i
=
0
;
size_t
i
=
0
;
...
...
paddle/fluid/framework/details/multi_devices_graph_builder.h
浏览文件 @
0bf799a5
...
@@ -34,14 +34,12 @@ class MultiDevSSAGraphBuilder : public SSAGraphBuilder {
...
@@ -34,14 +34,12 @@ class MultiDevSSAGraphBuilder : public SSAGraphBuilder {
const
std
::
string
&
loss_var_name
,
const
std
::
string
&
loss_var_name
,
const
std
::
unordered_set
<
std
::
string
>
&
params
,
const
std
::
unordered_set
<
std
::
string
>
&
params
,
const
std
::
vector
<
Scope
*>
&
local_scopes
,
const
std
::
vector
<
Scope
*>
&
local_scopes
,
platform
::
NCCLContextMap
*
nccl_ctxs
,
platform
::
NCCLContextMap
*
nccl_ctxs
);
bool
distributed
=
false
);
#else
#else
MultiDevSSAGraphBuilder
(
const
std
::
vector
<
platform
::
Place
>
&
places
,
MultiDevSSAGraphBuilder
(
const
std
::
vector
<
platform
::
Place
>
&
places
,
const
std
::
string
&
loss_var_name
,
const
std
::
string
&
loss_var_name
,
const
std
::
unordered_set
<
std
::
string
>
&
params
,
const
std
::
unordered_set
<
std
::
string
>
&
params
,
const
std
::
vector
<
Scope
*>
&
local_scopes
,
const
std
::
vector
<
Scope
*>
&
local_scopes
);
bool
distributed
=
false
);
#endif
#endif
std
::
unique_ptr
<
SSAGraph
>
Build
(
const
ProgramDesc
&
program
)
const
override
;
std
::
unique_ptr
<
SSAGraph
>
Build
(
const
ProgramDesc
&
program
)
const
override
;
...
@@ -55,7 +53,6 @@ class MultiDevSSAGraphBuilder : public SSAGraphBuilder {
...
@@ -55,7 +53,6 @@ class MultiDevSSAGraphBuilder : public SSAGraphBuilder {
const
std
::
vector
<
platform
::
Place
>
&
places_
;
const
std
::
vector
<
platform
::
Place
>
&
places_
;
const
std
::
vector
<
Scope
*>
&
local_scopes_
;
const
std
::
vector
<
Scope
*>
&
local_scopes_
;
std
::
unordered_set
<
std
::
string
>
grad_names_
;
std
::
unordered_set
<
std
::
string
>
grad_names_
;
bool
distributed_
;
#ifdef PADDLE_WITH_CUDA
#ifdef PADDLE_WITH_CUDA
platform
::
NCCLContextMap
*
nccl_ctxs_
;
platform
::
NCCLContextMap
*
nccl_ctxs_
;
...
...
paddle/fluid/framework/parallel_executor.h
浏览文件 @
0bf799a5
...
@@ -48,13 +48,13 @@ class ParallelExecutor {
...
@@ -48,13 +48,13 @@ class ParallelExecutor {
const
std
::
string
&
fetched_var_name
,
const
std
::
string
&
fetched_var_name
,
const
std
::
unordered_map
<
std
::
string
,
LoDTensor
>&
feed_tensors
);
const
std
::
unordered_map
<
std
::
string
,
LoDTensor
>&
feed_tensors
);
void
BCastParamsToGPUs
(
const
std
::
unordered_set
<
std
::
string
>&
vars
)
const
;
private:
private:
void
SplitTensorToPlaces
(
void
SplitTensorToPlaces
(
const
std
::
unordered_map
<
std
::
string
,
LoDTensor
>&
feed_tensors
);
const
std
::
unordered_map
<
std
::
string
,
LoDTensor
>&
feed_tensors
);
ParallelExecutorPrivate
*
member_
;
ParallelExecutorPrivate
*
member_
;
void
BCastParamsToGPUs
(
const
std
::
unordered_set
<
std
::
string
>&
vars
)
const
;
};
};
}
// namespace framework
}
// namespace framework
...
...
paddle/fluid/operators/detail/serde_test.cc
浏览文件 @
0bf799a5
...
@@ -107,7 +107,7 @@ void RunSerdeTestSelectedRows(platform::Place place) {
...
@@ -107,7 +107,7 @@ void RunSerdeTestSelectedRows(platform::Place place) {
for
(
int
i
=
0
;
i
<
tensor_numel
;
++
i
)
{
for
(
int
i
=
0
;
i
<
tensor_numel
;
++
i
)
{
EXPECT_FLOAT_EQ
(
tensor_data2
[
i
],
32.7
);
EXPECT_FLOAT_EQ
(
tensor_data2
[
i
],
32.7
);
}
}
for
(
int64
_t
i
=
0
;
i
<
rows2
->
size
();
++
i
)
{
for
(
size
_t
i
=
0
;
i
<
rows2
->
size
();
++
i
)
{
EXPECT_EQ
(
rows_data2
[
i
],
i
);
EXPECT_EQ
(
rows_data2
[
i
],
i
);
}
}
EXPECT_EQ
(
slr2
->
height
(),
1000
);
EXPECT_EQ
(
slr2
->
height
(),
1000
);
...
...
paddle/fluid/pybind/pybind.cc
浏览文件 @
0bf799a5
...
@@ -554,6 +554,7 @@ All parameter, weight, gradient are variables in Paddle.
...
@@ -554,6 +554,7 @@ All parameter, weight, gradient are variables in Paddle.
bcast_vars
,
main_program
,
loss_var_name
,
bcast_vars
,
main_program
,
loss_var_name
,
scope
,
local_scopes
,
allow_op_delay
);
scope
,
local_scopes
,
allow_op_delay
);
})
})
.
def
(
"bcast_params"
,
&
ParallelExecutor
::
BCastParamsToGPUs
)
.
def
(
"local_scopes"
,
.
def
(
"local_scopes"
,
[](
ParallelExecutor
&
self
)
->
std
::
vector
<
Scope
*>
*
{
[](
ParallelExecutor
&
self
)
->
std
::
vector
<
Scope
*>
*
{
return
&
self
.
GetLocalScopes
();
return
&
self
.
GetLocalScopes
();
...
...
python/paddle/fluid/parallel_executor.py
浏览文件 @
0bf799a5
...
@@ -99,7 +99,7 @@ class ParallelExecutor(object):
...
@@ -99,7 +99,7 @@ class ParallelExecutor(object):
local_scopes
=
share_vars_from
.
executor
.
local_scopes
(
local_scopes
=
share_vars_from
.
executor
.
local_scopes
(
)
if
share_vars_from
else
[]
)
if
share_vars_from
else
[]
persistable_vars
=
[
self
.
persistable_vars
=
[
v
.
name
v
.
name
for
v
in
filter
(
lambda
var
:
var
.
persistable
,
main
.
list_vars
())
for
v
in
filter
(
lambda
var
:
var
.
persistable
,
main
.
list_vars
())
]
]
...
@@ -112,7 +112,7 @@ class ParallelExecutor(object):
...
@@ -112,7 +112,7 @@ class ParallelExecutor(object):
p
.
name
for
p
in
main
.
global_block
().
iter_parameters
()
p
.
name
for
p
in
main
.
global_block
().
iter_parameters
()
if
not
p
.
stop_gradient
if
not
p
.
stop_gradient
]),
]),
set
(
persistable_vars
),
set
(
self
.
persistable_vars
),
main
.
desc
,
main
.
desc
,
loss_name
if
loss_name
else
''
,
loss_name
if
loss_name
else
''
,
scope
,
scope
,
...
@@ -142,3 +142,6 @@ class ParallelExecutor(object):
...
@@ -142,3 +142,6 @@ class ParallelExecutor(object):
self
.
executor
.
run
(
fetch_list
,
fetch_var_name
,
feed_tensor_dict
)
self
.
executor
.
run
(
fetch_list
,
fetch_var_name
,
feed_tensor_dict
)
arr
=
self
.
scope
.
find_var
(
fetch_var_name
).
get_lod_tensor_array
()
arr
=
self
.
scope
.
find_var
(
fetch_var_name
).
get_lod_tensor_array
()
return
[
arr
[
i
]
for
i
in
range
(
len
(
arr
))]
return
[
arr
[
i
]
for
i
in
range
(
len
(
arr
))]
def
bcast_params
(
self
):
self
.
executor
.
bcast_params
(
set
(
self
.
persistable_vars
))
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录