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
53c5f571
Commit
53c5f571
authored
Mar 01, 2021
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fixes
parent
d39baab3
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
23 行增加
和
18 行删除
+23
-18
source/train/XWorkerCollect.cpp
+21
-16
source/train/XWorkerJob.cpp
+2
-2
没有找到文件。
source/train/XWorkerCollect.cpp
查看文件 @
53c5f571
...
...
@@ -58,6 +58,9 @@ void XWorkerCollect::CollectData(XList * sourceList, XModel * target, long sleep
{
TensorList
&
tp
=
target
->
params
;
int
finished
=
0
;
for
(
int
j
=
0
;
j
<
tp
.
count
;
j
++
)
target
->
flags
[
j
]
=
PARAM_STATE_NOT_READY
;
/* check */
for
(
int
i
=
0
;
i
<
sourceList
->
count
;
i
++
)
{
...
...
@@ -73,9 +76,9 @@ void XWorkerCollect::CollectData(XList * sourceList, XModel * target, long sleep
if
(
collectMode
==
DATA_COLLECT_P2P
)
{
for
(
int
j
=
0
;
j
<
tp
.
count
;
j
++
)
{
/* t
arget->flags[j] is ready only if
model finishes the computation
/* t
p[j]->isGradFinished is true only if the
model finishes the computation
(in another process) */
if
(
target
->
flags
[
j
]
!=
PARAM_STATE_READY
)
if
(
target
->
flags
[
j
]
==
PARAM_STATE_COLLECTED
||
!
tp
[
j
]
->
isGradFinished
)
continue
;
/* check if all the models (or part of them) are ready */
...
...
@@ -83,9 +86,9 @@ void XWorkerCollect::CollectData(XList * sourceList, XModel * target, long sleep
XModel
*
source
=
(
XModel
*
)
sourceList
->
GetItem
(
i
);
TensorList
&
sp
=
source
->
params
;
/* s
ource->flags[j] is ready only if
model finishes the computation
/* s
p[j]->isGradFinished is true only if the
model finishes the computation
(in another process) */
if
(
source
->
flags
[
j
]
==
PARAM_STATE_READY
)
{
if
(
source
->
flags
[
j
]
!=
PARAM_STATE_COLLECTED
&&
sp
[
j
]
->
isGradFinished
)
{
/* data transmit */
CollectP2P
(
sp
.
GetItem
(
j
),
tp
.
GetItem
(
j
));
...
...
@@ -103,9 +106,9 @@ void XWorkerCollect::CollectData(XList * sourceList, XModel * target, long sleep
bool
ready
=
true
;
/* t
arget->flags[j] is ready only if
model finishes the computation
(in another process) */
if
(
target
->
flags
[
j
]
!=
PARAM_STATE_READY
)
/* t
p[j]->isGradFinished is true only if the
model finishes the computation
(in another process) */
if
(
target
->
flags
[
j
]
==
PARAM_STATE_COLLECTED
||
!
tp
[
j
]
->
isGradFinished
)
continue
;
/* check if all the models (or part of them) are ready */
...
...
@@ -113,12 +116,16 @@ void XWorkerCollect::CollectData(XList * sourceList, XModel * target, long sleep
XModel
*
source
=
(
XModel
*
)
sourceList
->
GetItem
(
i
);
TensorList
&
sp
=
source
->
params
;
/* s
ource->flags[j] is ready only if
model finishes the computation
(in another process) */
if
(
source
->
flags
[
j
]
!=
PARAM_STATE_READY
)
{
/* s
p[j]->isGradFinished is true only if the
model finishes the computation
(in another process) */
if
(
source
->
flags
[
j
]
==
PARAM_STATE_COLLECTED
||
!
sp
[
j
]
->
isGradFinished
)
{
ready
=
false
;
break
;
}
else
if
(
source
->
flags
[
j
]
==
PARAM_STATE_NOT_READY
){
source
->
flags
[
j
]
=
PARAM_STATE_READY
;
}
}
if
(
ready
)
{
...
...
@@ -152,14 +159,13 @@ void XWorkerCollect::CollectData(XList * sourceList, XModel * target, long sleep
break
;
/* reset the flags */
for
(
int
i
=
0
;
i
<
tp
.
count
;
i
++
)
{
target
->
flags
[
i
]
=
PARAM_STATE_COLLECTED
;
}
for
(
int
j
=
0
;
j
<
tp
.
count
;
j
++
)
target
->
flags
[
j
]
=
PARAM_STATE_COLLECTED
;
#ifdef _WIN32
Sleep
((
DWORD
)
sleepTime
);
#else
sleep
(
sleepTime
/
1000
);
sleep
(
(
unsigned
)
sleepTime
/
1000
);
#endif
}
}
...
...
@@ -230,4 +236,4 @@ void XWorkerCollect::CollectAllReduce(XList * all)
ShowNTErrors
(
"TODO!"
);
}
}
\ No newline at end of file
}
source/train/XWorkerJob.cpp
查看文件 @
53c5f571
...
...
@@ -89,7 +89,7 @@ bool XWorkerJob::AddJobRefresh(XModel * myModel)
XList
args
(
1
);
args
.
Add
(
myModel
);
queue
.
EnqueueJob
(
XModel
::
Refresh
,
&
args
);
queue
.
EnqueueJob
(
(
void
*
)(
char
*
)
XModel
::
Refresh
,
&
args
);
return
true
;
}
...
...
@@ -112,7 +112,7 @@ bool XWorkerJob::AddJobNeuralNet(XModel * myModel, XList * inputs, XList * outpu
args
.
AddList
(
inputs
);
args
.
AddList
(
outputs
);
queue
.
EnqueueJob
(
XModel
::
Run
,
&
args
);
queue
.
EnqueueJob
(
(
void
*
)(
char
*
)
XModel
::
Run
,
&
args
);
return
true
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论