Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
7bcc9808
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
12 个月 前同步成功
通知
692
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
7bcc9808
编写于
6月 10, 2018
作者:
W
Wu Yi
提交者:
GitHub
6月 10, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11321 from Yancey1989/polish_sparse_update
polish sparse update logic
上级
eced9730
56964946
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
18 addition
and
21 deletion
+18
-21
paddle/fluid/operators/detail/request_handler_impl.cc
paddle/fluid/operators/detail/request_handler_impl.cc
+10
-2
paddle/fluid/operators/detail/request_handler_impl.h
paddle/fluid/operators/detail/request_handler_impl.h
+5
-0
paddle/fluid/operators/detail/rpc_server.cc
paddle/fluid/operators/detail/rpc_server.cc
+0
-13
paddle/fluid/operators/detail/rpc_server.h
paddle/fluid/operators/detail/rpc_server.h
+0
-5
paddle/fluid/operators/listen_and_serv_op.cc
paddle/fluid/operators/listen_and_serv_op.cc
+3
-1
未找到文件。
paddle/fluid/operators/detail/request_handler_impl.cc
浏览文件 @
7bcc9808
...
@@ -64,13 +64,21 @@ bool RequestSendHandler::Handle(const std::string& varname,
...
@@ -64,13 +64,21 @@ bool RequestSendHandler::Handle(const std::string& varname,
return
false
;
return
false
;
}
}
if
(
invar
->
IsType
<
framework
::
SelectedRows
>
())
{
if
(
invar
->
IsType
<
framework
::
SelectedRows
>
())
{
rpc_server_
->
RecordSparseVar
(
invar
);
std
::
unique_lock
<
std
::
mutex
>
lock
(
mutex_sparse_vars_
);
sparse_vars_
.
push_back
(
invar
);
}
}
}
}
return
true
;
return
true
;
}
}
void
RequestSendHandler
::
ResetSparseVarRecorder
()
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
mutex_sparse_vars_
);
for
(
auto
*
var
:
sparse_vars_
)
{
var
->
GetMutable
<
framework
::
SelectedRows
>
()
->
mutable_rows
()
->
clear
();
}
sparse_vars_
.
clear
();
}
bool
RequestGetHandler
::
Handle
(
const
std
::
string
&
varname
,
bool
RequestGetHandler
::
Handle
(
const
std
::
string
&
varname
,
framework
::
Scope
*
scope
,
framework
::
Scope
*
scope
,
framework
::
Variable
*
invar
,
framework
::
Variable
*
invar
,
...
...
paddle/fluid/operators/detail/request_handler_impl.h
浏览文件 @
7bcc9808
...
@@ -41,6 +41,11 @@ class RequestSendHandler final : public RequestHandler {
...
@@ -41,6 +41,11 @@ class RequestSendHandler final : public RequestHandler {
virtual
~
RequestSendHandler
()
{}
virtual
~
RequestSendHandler
()
{}
bool
Handle
(
const
std
::
string
&
varname
,
framework
::
Scope
*
scope
,
bool
Handle
(
const
std
::
string
&
varname
,
framework
::
Scope
*
scope
,
framework
::
Variable
*
var
,
framework
::
Variable
**
outvar
)
override
;
framework
::
Variable
*
var
,
framework
::
Variable
**
outvar
)
override
;
void
ResetSparseVarRecorder
();
private:
std
::
mutex
mutex_sparse_vars_
;
std
::
vector
<
framework
::
Variable
*>
sparse_vars_
;
};
};
class
RequestGetHandler
final
:
public
RequestHandler
{
class
RequestGetHandler
final
:
public
RequestHandler
{
...
...
paddle/fluid/operators/detail/rpc_server.cc
浏览文件 @
7bcc9808
...
@@ -73,19 +73,6 @@ void RPCServer::ResetBarrierCounter() {
...
@@ -73,19 +73,6 @@ void RPCServer::ResetBarrierCounter() {
t
.
second
=
0
;
t
.
second
=
0
;
}
}
}
}
void
RPCServer
::
RecordSparseVar
(
framework
::
Variable
*
sparse_var
)
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
mutex_sparse_var_recorder_
);
sparse_vars_
.
push_back
(
sparse_var
);
}
void
RPCServer
::
ResetSparseVarsRecorder
()
{
VLOG
(
3
)
<<
"RPCServer reset sparse vars recorder."
;
std
::
unique_lock
<
std
::
mutex
>
lock
(
mutex_sparse_var_recorder_
);
for
(
auto
*
var
:
sparse_vars_
)
{
var
->
GetMutable
<
framework
::
SelectedRows
>
()
->
mutable_rows
()
->
clear
();
}
sparse_vars_
.
clear
();
}
void
RPCServer
::
RegisterRPC
(
const
std
::
string
&
rpc_name
,
void
RPCServer
::
RegisterRPC
(
const
std
::
string
&
rpc_name
,
RequestHandler
*
handler
,
int
thread_num
)
{
RequestHandler
*
handler
,
int
thread_num
)
{
...
...
paddle/fluid/operators/detail/rpc_server.h
浏览文件 @
7bcc9808
...
@@ -62,8 +62,6 @@ class RPCServer {
...
@@ -62,8 +62,6 @@ class RPCServer {
void
IncreaseBatchBarrier
(
const
std
::
string
rpc_name
);
void
IncreaseBatchBarrier
(
const
std
::
string
rpc_name
);
void
ResetBarrierCounter
();
void
ResetBarrierCounter
();
void
RecordSparseVar
(
framework
::
Variable
*
sparse_var
);
void
ResetSparseVarsRecorder
();
protected:
protected:
virtual
void
ShutDownImpl
()
=
0
;
virtual
void
ShutDownImpl
()
=
0
;
...
@@ -77,9 +75,6 @@ class RPCServer {
...
@@ -77,9 +75,6 @@ class RPCServer {
std
::
atomic
<
int
>
cur_cond_
;
std
::
atomic
<
int
>
cur_cond_
;
std
::
condition_variable
rpc_cond_
;
std
::
condition_variable
rpc_cond_
;
std
::
vector
<
framework
::
Variable
*>
sparse_vars_
;
std
::
mutex
mutex_sparse_var_recorder_
;
protected:
protected:
std
::
string
bind_address_
;
std
::
string
bind_address_
;
std
::
atomic
<
int
>
exit_flag_
;
std
::
atomic
<
int
>
exit_flag_
;
...
...
paddle/fluid/operators/listen_and_serv_op.cc
浏览文件 @
7bcc9808
...
@@ -146,7 +146,9 @@ void ListenAndServOp::RunSyncLoop(framework::Executor *executor,
...
@@ -146,7 +146,9 @@ void ListenAndServOp::RunSyncLoop(framework::Executor *executor,
rpc_service_
->
SetCond
(
detail
::
kRequestGet
);
rpc_service_
->
SetCond
(
detail
::
kRequestGet
);
rpc_service_
->
WaitBarrier
(
detail
::
kRequestGet
);
rpc_service_
->
WaitBarrier
(
detail
::
kRequestGet
);
rpc_service_
->
ResetBarrierCounter
();
rpc_service_
->
ResetBarrierCounter
();
rpc_service_
->
ResetSparseVarsRecorder
();
// reset received sparse vars to avoid reuse it in the next mini-batch
dynamic_cast
<
detail
::
RequestSendHandler
*>
(
request_send_handler_
.
get
())
->
ResetSparseVarRecorder
();
}
// while(true)
}
// while(true)
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录