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
c0bcb78b
Commit
c0bcb78b
authored
Mar 30, 2021
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updates of XLeader
parent
0483b910
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
62 行增加
和
47 行删除
+62
-47
source/train/XLeader.cpp
+0
-41
source/train/XLeader.h
+0
-3
source/train/XLeaderAllReduce.cpp
+0
-0
source/train/XLeaderAllReduce.h
+15
-0
source/train/XLeaderPS.cpp
+44
-3
source/train/XLeaderPS.h
+3
-0
没有找到文件。
source/train/XLeader.cpp
查看文件 @
c0bcb78b
...
...
@@ -184,47 +184,6 @@ void XLeader::MakeAll(XConfig * config, XModel * model)
MakeParamMap
();
}
/*
wait for finished states (i.e., all workers finish their jobs)
>> activeJobWorkers - indicates whether each job worker is active
>> isToUpdate - indicates whether the model is updated
*/
void
XLeader
::
WaitForFinishing
(
const
int
*
activeJobWorkers
,
const
int
isToUpdate
)
{
int
activeCount
=
0
;
for
(
int
i
=
0
;
i
<
jworkers
.
count
;
i
++
)
{
if
(
activeJobWorkers
[
i
]
>
0
)
{
XWorker
*
worker
=
(
XWorker
*
)
jworkers
[
i
];
worker
->
DequeueFinishedJob
();
activeCount
++
;
CheckNTErrors
(
worker
->
GetFinishedNumInQueue
()
==
0
,
"Incorrect job number!"
);
}
}
if
(
activeCount
>
0
&&
isToUpdate
)
{
for
(
int
i
=
0
;
i
<
cworkers
.
count
;
i
++
)
{
XWorker
*
worker
=
(
XWorker
*
)
cworkers
[
i
];
for
(
int
j
=
0
;
j
<
serverModel
.
paramNum
*
activeCount
;
j
++
)
worker
->
DequeueFinishedJob
();
CheckNTErrors
(
worker
->
GetFinishedNumInQueue
()
==
0
,
"Incorrect job number!"
);
}
for
(
int
i
=
0
;
i
<
uworkers
.
count
;
i
++
)
{
XWorker
*
worker
=
(
XWorker
*
)
uworkers
[
i
];
for
(
int
j
=
0
;
j
<
serverModel
.
paramNum
;
j
++
)
worker
->
DequeueFinishedJob
();
CheckNTErrors
(
worker
->
GetFinishedNumInQueue
()
==
0
,
"Incorrect job number!"
);
}
for
(
int
i
=
0
;
i
<
bworkers
.
count
;
i
++
)
{
XWorker
*
worker
=
(
XWorker
*
)
bworkers
[
i
];
for
(
int
j
=
0
;
j
<
serverModel
.
paramNum
;
j
++
)
worker
->
DequeueFinishedJob
();
CheckNTErrors
(
worker
->
GetFinishedNumInQueue
()
==
0
,
"Incorrect job number!"
);
}
}
}
/* get loss */
float
XLeader
::
GetLoss
()
{
...
...
source/train/XLeader.h
查看文件 @
c0bcb78b
...
...
@@ -138,9 +138,6 @@ public:
/* prepare for running */
void
MakeAll
(
XConfig
*
config
,
XModel
*
model
);
/* wait for finished states (i.e., all workers finish their jobs) */
void
WaitForFinishing
(
const
int
*
activeJobWorkers
,
const
int
isToUpdate
);
/* get loss */
float
GetLoss
();
...
...
source/train/XLeaderAllReduce.cpp
查看文件 @
c0bcb78b
差异被折叠。
点击展开。
source/train/XLeaderAllReduce.h
查看文件 @
c0bcb78b
...
...
@@ -49,6 +49,21 @@ public:
/* deconstructor */
~
XLeaderAllReduce
();
/* create workers and other stuff used in training */
void
MakeAll
(
XConfig
*
config
,
XModel
*
model
,
const
int
*
devIDs
,
const
int
jobWorkerNum
);
/* wait for finished states (i.e., all workers finish their jobs) */
void
WaitForFinishing
(
const
int
*
activeJobWorkers
,
const
int
isToUpdate
);
/* run the model and update it (for one time) */
bool
Run
(
XConfig
*
config
,
DataDistributeBase
*
dataDistributor
,
XOptimizer
*
optimizer
);
/* run the model */
int
RunModel
(
XConfig
*
config
,
DataDistributeBase
*
dataDistributor
,
int
*
active
);
/* update the model */
void
RunUpdate
(
XConfig
*
config
,
XOptimizer
*
optimizer
,
const
int
*
active
);
};
}
...
...
source/train/XLeaderPS.cpp
查看文件 @
c0bcb78b
...
...
@@ -44,7 +44,7 @@ XLeaderPS::~XLeaderPS()
}
/*
create workers
create workers
and other stuff
>> config - configuration
>> model - the model that we run
>> devIDs - device ids of the workers (the first id is for server)
...
...
@@ -63,6 +63,47 @@ void XLeaderPS::MakeAll(XConfig * config, XModel * model, const int * devIDs, co
}
/*
wait for finished states (i.e., all workers finish their jobs)
>> activeJobWorkers - indicates whether each job worker is active
>> isToUpdate - indicates whether the model is updated
*/
void
XLeaderPS
::
WaitForFinishing
(
const
int
*
activeJobWorkers
,
const
int
isToUpdate
)
{
int
activeCount
=
0
;
for
(
int
i
=
0
;
i
<
jworkers
.
count
;
i
++
)
{
if
(
activeJobWorkers
[
i
]
>
0
)
{
XWorker
*
worker
=
(
XWorker
*
)
jworkers
[
i
];
worker
->
DequeueFinishedJob
();
activeCount
++
;
CheckNTErrors
(
worker
->
GetFinishedNumInQueue
()
==
0
,
"Incorrect job number!"
);
}
}
if
(
activeCount
>
0
&&
isToUpdate
)
{
for
(
int
i
=
0
;
i
<
cworkers
.
count
;
i
++
)
{
XWorker
*
worker
=
(
XWorker
*
)
cworkers
[
i
];
for
(
int
j
=
0
;
j
<
serverModel
.
paramNum
*
activeCount
;
j
++
)
worker
->
DequeueFinishedJob
();
CheckNTErrors
(
worker
->
GetFinishedNumInQueue
()
==
0
,
"Incorrect job number!"
);
}
for
(
int
i
=
0
;
i
<
uworkers
.
count
;
i
++
)
{
XWorker
*
worker
=
(
XWorker
*
)
uworkers
[
i
];
for
(
int
j
=
0
;
j
<
serverModel
.
paramNum
;
j
++
)
worker
->
DequeueFinishedJob
();
CheckNTErrors
(
worker
->
GetFinishedNumInQueue
()
==
0
,
"Incorrect job number!"
);
}
for
(
int
i
=
0
;
i
<
bworkers
.
count
;
i
++
)
{
XWorker
*
worker
=
(
XWorker
*
)
bworkers
[
i
];
for
(
int
j
=
0
;
j
<
serverModel
.
paramNum
;
j
++
)
worker
->
DequeueFinishedJob
();
CheckNTErrors
(
worker
->
GetFinishedNumInQueue
()
==
0
,
"Incorrect job number!"
);
}
}
}
/*
run the model (for one time). Basically this is a map-reduce process.
>> config - the configuration
>> dataDistributor - data distributor
...
...
@@ -133,8 +174,8 @@ int XLeaderPS::RunModel(XConfig* config, DataDistributeBase* dataDistributor, in
/* job in queue 1: run the model */
worker
->
AddJobNeuralNet
(
jmodel
,
worker
->
GetInput
(),
worker
->
GetOutput
(),
worker
->
GetGold
(),
worker
->
GetLoss
());
worker
->
GetInput
(),
worker
->
GetOutput
(),
worker
->
GetGold
(),
worker
->
GetLoss
());
/* job in queue 1: make a record of the run */
worker
->
AddJobRecord
(
&
serverRecord
);
...
...
source/train/XLeaderPS.h
查看文件 @
c0bcb78b
...
...
@@ -50,6 +50,9 @@ public:
/* create workers and other stuff used in training */
void
MakeAll
(
XConfig
*
config
,
XModel
*
model
,
const
int
*
devIDs
,
const
int
jobWorkerNum
);
/* wait for finished states (i.e., all workers finish their jobs) */
void
WaitForFinishing
(
const
int
*
activeJobWorkers
,
const
int
isToUpdate
);
/* run the model and update it (for one time) */
bool
Run
(
XConfig
*
config
,
DataDistributeBase
*
dataDistributor
,
XOptimizer
*
optimizer
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论