Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
N
NiuTrans.Tensor
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
8
Issues
8
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
NiuTrans
NiuTrans.Tensor
Commits
78307f09
Commit
78307f09
authored
Mar 22, 2021
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updates with bugs
parent
726f5e21
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
85 行增加
和
0 行删除
+85
-0
source/train/XLeader.cpp
+85
-0
没有找到文件。
source/train/XLeader.cpp
查看文件 @
78307f09
...
...
@@ -482,6 +482,91 @@ void XLeader::RunUpdate(XConfig * config, XOptimizer * optimizer, const int * ac
}
if
(
1
){
int
finished
=
0
;
for
(
int
j
=
0
;
j
<
serverModel
.
paramNum
;
j
++
)
serverModel
.
params
[
j
].
flag
=
PARAM_STATE_NOT_READY
;
/* check */
for
(
int
i
=
0
;
i
<
membersAll
.
count
;
i
++
)
{
XModel
*
source
=
(
XModel
*
)
membersAll
.
GetItem
(
i
);
CheckNTErrors
(
source
->
paramNum
==
serverModel
.
paramNum
,
"Incompatiable models!"
);
}
for
(
int
i
=
0
;
i
<
members
.
count
;
i
++
)
{
XModel
*
source
=
(
XModel
*
)
members
.
GetItem
(
i
);
CheckNTErrors
(
source
->
paramNum
==
serverModel
.
paramNum
,
"Incompatiable models!"
);
}
CheckNTErrors
(
jobQueues
.
count
==
serverModel
.
paramNum
,
"Incompatiable model!"
);
/* counts how many member models are collect for each parameters */
int
*
finishedCount
=
new
int
[
serverModel
.
paramNum
];
memset
(
finishedCount
,
0
,
sizeof
(
int
)
*
serverModel
.
paramNum
);
/* This is a simple implementation of the wait-and-collect process. But
there is a risk that some models are not available, that is, the
loop would never stop. A solution might be that we force the loop
to break after waiting for a short time. */
while
(
1
)
{
for
(
int
j
=
0
;
j
<
serverModel
.
paramNum
;
j
++
)
{
XParamKeeper
&
paramServer
=
serverModel
.
params
[
j
];
/* tp[j]->isGradFinished is true only if the model finishes the computation
(in another process) */
if
(
paramServer
.
flag
!=
PARAM_STATE_NOT_READY
||
!
paramServer
.
param
->
isGradFinished
)
continue
;
/* check if all the models (or part of them) are ready */
for
(
int
i
=
0
;
i
<
members
.
count
;
i
++
)
{
XModel
*
source
=
(
XModel
*
)
members
.
GetItem
(
i
);
XParamKeeper
&
paramSource
=
source
->
params
[
j
];
/* sp[j]->isGradFinished is true only if the model finishes the computation
(in another process) */
if
(
paramSource
.
flag
==
PARAM_STATE_NOT_READY
&&
paramSource
.
param
->
isGradFinished
)
{
/* data transmit */
CollectP2P
(
paramSource
.
param
->
grad
,
paramServer
.
param
->
grad
);
/* reset the flag */
paramSource
.
flag
=
PARAM_STATE_COLLECTED
;
finished
++
;
finishedCount
[
j
]
++
;
/* we call model update (in another thread) and then
broadcast the new parameters to member models
(in another thread) */
if
(
finishedCount
[
j
]
==
memberActive
->
count
)
{
paramServer
.
flag
=
PARAM_STATE_COLLECTED
;
if
(
updater
!=
NULL
)
{
XQueue
*
jobQueue
=
(
XQueue
*
)
jobQueues
->
GetItem
(
j
);
/* update the parameters */
updater
->
AddJobUpdate
(
jobQueue
,
server
,
j
,
optimizer
);
updater
->
AddJobEnqueueFinished
(
jobQueue
);
/* broadcast the new parameter to other models*/
broadcaster
->
AddJobBroadcastSingle
(
jobQueue
,
server
,
memberAll
,
j
);
broadcaster
->
AddJobEnqueueFinished
(
jobQueue
);
}
}
else
if
(
finishedCount
[
j
]
>
memberActive
->
count
)
{
ShowNTErrors
(
"Something is wrong with finishedCount!"
);
}
}
}
}
/* the collection finishes if all data tensors are processed */
if
(
finished
==
server
->
paramNum
*
memberActive
->
count
)
break
;
XSleep
(
sleepTime
);
}
delete
[]
finishedCount
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论