Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
d85a9dc4
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
d85a9dc4
编写于
1月 19, 2018
作者:
H
helinwang
提交者:
GitHub
1月 19, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7621 from helinwang/remote_optimize
Recv OP: use BlockDesc* instread of ProgramDesc proto as Attribute
上级
c8e7d108
e92fe9e6
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
10 addition
and
13 deletion
+10
-13
paddle/operators/recv_op.cc
paddle/operators/recv_op.cc
+7
-7
paddle/operators/send_recv_op_test.cc
paddle/operators/send_recv_op_test.cc
+1
-4
python/paddle/v2/fluid/distribute_transpiler.py
python/paddle/v2/fluid/distribute_transpiler.py
+1
-1
python/paddle/v2/fluid/distribute_transpiler_simple.py
python/paddle/v2/fluid/distribute_transpiler_simple.py
+1
-1
未找到文件。
paddle/operators/recv_op.cc
浏览文件 @
d85a9dc4
...
@@ -34,6 +34,7 @@ limitations under the License. */
...
@@ -34,6 +34,7 @@ limitations under the License. */
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
constexpr
char
kOptimizeBlock
[]
=
"OptimizeBlock"
;
constexpr
int
kCondStart
=
0
;
constexpr
int
kCondStart
=
0
;
constexpr
int
kCondRunning
=
1
;
constexpr
int
kCondRunning
=
1
;
constexpr
int
kCondDone
=
2
;
constexpr
int
kCondDone
=
2
;
...
@@ -99,10 +100,8 @@ class RecvOp : public framework::OperatorBase {
...
@@ -99,10 +100,8 @@ class RecvOp : public framework::OperatorBase {
auto
fan_in
=
Attr
<
int
>
(
"Fanin"
);
auto
fan_in
=
Attr
<
int
>
(
"Fanin"
);
size_t
param_count
=
param_list
.
size
();
size_t
param_count
=
param_list
.
size
();
std
::
string
program_str
=
Attr
<
std
::
string
>
(
"OptimizeProgram"
);
auto
*
block
=
Attr
<
framework
::
BlockDesc
*>
(
kOptimizeBlock
);
framework
::
proto
::
ProgramDesc
program_desc
;
auto
*
program
=
block
->
Program
();
program_desc
.
ParseFromString
(
program_str
);
framework
::
ProgramDesc
program
(
program_desc
);
framework
::
Executor
executor
(
dev_place
);
framework
::
Executor
executor
(
dev_place
);
// TODO(typhoonzero): change this to a while_op for every cluster-batch.
// TODO(typhoonzero): change this to a while_op for every cluster-batch.
...
@@ -142,8 +141,9 @@ class RecvOp : public framework::OperatorBase {
...
@@ -142,8 +141,9 @@ class RecvOp : public framework::OperatorBase {
if
(
exit_flag
)
{
if
(
exit_flag
)
{
break
;
break
;
}
}
try
{
try
{
executor
.
Run
(
program
,
&
recv_scope
,
0
,
/*global_block*/
executor
.
Run
(
*
program
,
&
recv_scope
,
block
->
ID
()
,
/*global_block*/
false
/*create_local_scope*/
,
false
/*create_vars*/
);
false
/*create_local_scope*/
,
false
/*create_vars*/
);
}
catch
(
std
::
exception
&
e
)
{
}
catch
(
std
::
exception
&
e
)
{
LOG
(
ERROR
)
<<
"run sub program error "
<<
e
.
what
();
LOG
(
ERROR
)
<<
"run sub program error "
<<
e
.
what
();
...
@@ -175,8 +175,8 @@ This operator will recv tensor from send_op
...
@@ -175,8 +175,8 @@ This operator will recv tensor from send_op
"IP address to listen on."
)
"IP address to listen on."
)
.
SetDefault
(
"127.0.0.1:6164"
)
.
SetDefault
(
"127.0.0.1:6164"
)
.
AddCustomChecker
([](
const
std
::
string
&
ip
)
{
return
!
ip
.
empty
();
});
.
AddCustomChecker
([](
const
std
::
string
&
ip
)
{
return
!
ip
.
empty
();
});
AddAttr
<
std
::
string
>
(
"OptimizeProgram"
,
"type string"
,
AddAttr
<
framework
::
BlockDesc
*>
(
"Serialized ProgramDesc string for recv to run."
);
kOptimizeBlock
,
"Serialized ProgramDesc string for recv to run."
);
AddAttr
<
std
::
vector
<
std
::
string
>>
(
AddAttr
<
std
::
vector
<
std
::
string
>>
(
"ParamList"
,
"type list of string"
,
"ParamList"
,
"type list of string"
,
"grad->param name mapping to find which param to optimize."
)
"grad->param name mapping to find which param to optimize."
)
...
...
paddle/operators/send_recv_op_test.cc
浏览文件 @
d85a9dc4
...
@@ -130,10 +130,7 @@ void StartServerNet(bool is_sparse) {
...
@@ -130,10 +130,7 @@ void StartServerNet(bool is_sparse) {
attrs
.
insert
({
"endpoint"
,
std
::
string
(
"127.0.0.1:6174"
)});
attrs
.
insert
({
"endpoint"
,
std
::
string
(
"127.0.0.1:6174"
)});
attrs
.
insert
({
"ParamList"
,
std
::
vector
<
std
::
string
>
({
"Out"
})});
attrs
.
insert
({
"ParamList"
,
std
::
vector
<
std
::
string
>
({
"Out"
})});
attrs
.
insert
({
"GradList"
,
std
::
vector
<
std
::
string
>
({
"x1"
})});
attrs
.
insert
({
"GradList"
,
std
::
vector
<
std
::
string
>
({
"x1"
})});
std
::
string
program_proto
;
attrs
.
insert
({
"OptimizeBlock"
,
block
});
PADDLE_ENFORCE
(
program
.
Proto
()
->
SerializeToString
(
&
program_proto
));
attrs
.
insert
({
"OptimizeProgram"
,
program_proto
});
recv_op
=
f
::
OpRegistry
::
CreateOp
(
"recv"
,
{{
"RX"
,
{
"x1"
}}},
{},
attrs
);
recv_op
=
f
::
OpRegistry
::
CreateOp
(
"recv"
,
{{
"RX"
,
{
"x1"
}}},
{},
attrs
);
recv_op
->
Run
(
scope
,
place
);
recv_op
->
Run
(
scope
,
place
);
}
}
...
...
python/paddle/v2/fluid/distribute_transpiler.py
浏览文件 @
d85a9dc4
...
@@ -452,7 +452,7 @@ class DistributeTranspiler:
...
@@ -452,7 +452,7 @@ class DistributeTranspiler:
},
# grads to recv
},
# grads to recv
outputs
=
{},
outputs
=
{},
attrs
=
{
attrs
=
{
"Optimize
Program"
:
optimize_sub_program
.
desc
,
"Optimize
Block"
:
optimize_sub_program
.
global_block
()
,
"endpoint"
:
endpoint
,
"endpoint"
:
endpoint
,
"ParamList"
:
[
"ParamList"
:
[
p
.
name
p
.
name
...
...
python/paddle/v2/fluid/distribute_transpiler_simple.py
浏览文件 @
d85a9dc4
...
@@ -243,7 +243,7 @@ class SimpleDistributeTranspiler:
...
@@ -243,7 +243,7 @@ class SimpleDistributeTranspiler:
self
.
param_grad_map
[
endpoint
][
"grads"
]},
# grads to recv
self
.
param_grad_map
[
endpoint
][
"grads"
]},
# grads to recv
outputs
=
{},
outputs
=
{},
attrs
=
{
attrs
=
{
"Optimize
Program"
:
optimize_sub_program
.
desc
,
"Optimize
Block"
:
optimize_sub_program
.
global_block
()
,
"endpoint"
:
endpoint
,
"endpoint"
:
endpoint
,
"ParamList"
:
"ParamList"
:
[
p
.
name
for
p
in
self
.
param_grad_map
[
endpoint
][
"params"
]],
[
p
.
name
for
p
in
self
.
param_grad_map
[
endpoint
][
"params"
]],
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录