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
0483b910
Commit
0483b910
authored
Mar 30, 2021
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
function renaming and redefination of XLeaderPS::MakeAll()
parent
2a9c6078
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
35 行增加
和
21 行删除
+35
-21
source/train/XLeader.cpp
+7
-9
source/train/XLeader.h
+5
-5
source/train/XLeaderPS.cpp
+19
-0
source/train/XLeaderPS.h
+3
-0
source/train/XTrainer.cpp
+1
-7
没有找到文件。
source/train/XLeader.cpp
查看文件 @
0483b910
...
...
@@ -317,9 +317,9 @@ void XLeader::Start()
add a number of job workers (given their device ids)
>> model - the neural network
>> n - number of the models
>>
id
s - the array of device ids
>>
devID
s - the array of device ids
*/
void
XLeader
::
AddJobWorker
(
XModel
*
model
,
int
n
,
int
*
id
s
)
void
XLeader
::
AddJobWorker
(
XModel
*
model
,
int
n
,
const
int
*
devID
s
)
{
/* we keep the input model */
if
(
n
>=
1
)
{
...
...
@@ -331,7 +331,7 @@ void XLeader::AddJobWorker(XModel * model, int n, int * ids)
/* we clone the input model */
for
(
int
i
=
1
;
i
<
n
;
i
++
)
{
XWorkerJob
*
worker
=
new
XWorkerJob
();
worker
->
SetModel
(
model
->
Clone
(
id
s
[
i
]));
worker
->
SetModel
(
model
->
Clone
(
devID
s
[
i
]));
jworkers
.
Add
(
worker
);
}
}
...
...
@@ -340,7 +340,7 @@ void XLeader::AddJobWorker(XModel * model, int n, int * ids)
add a data-collecting worker
>> mode - the data-transfer mode of the worker
*/
void
XLeader
::
Add
Job
CollectWorker
(
DATA_COLLECT_TYPE
mode
)
void
XLeader
::
AddCollectWorker
(
DATA_COLLECT_TYPE
mode
)
{
XWorkerCollect
*
worker
=
new
XWorkerCollect
();
worker
->
SetCollectMode
(
mode
);
...
...
@@ -350,17 +350,15 @@ void XLeader::AddJobCollectWorker(DATA_COLLECT_TYPE mode)
/*
add a model-update worker
>> model - the model
>> optimizer - the optimizer
*/
void
XLeader
::
Add
JobUpdateWorker
(
XModel
*
model
,
XOptimizer
*
optimizer
)
void
XLeader
::
Add
UpdateWorker
(
XModel
*
model
)
{
XWorkerUpdate
*
worker
=
new
XWorkerUpdate
();
worker
->
SetOptimizer
(
optimizer
);
uworkers
.
Add
(
worker
);
}
/* add a data-broadcasting worker */
void
XLeader
::
Add
Job
BroadcastWorker
()
void
XLeader
::
AddBroadcastWorker
()
{
XWorkerBroadcast
*
worker
=
new
XWorkerBroadcast
();
bworkers
.
Add
(
worker
);
...
...
@@ -370,7 +368,7 @@ void XLeader::AddJobBroadcastWorker()
add a parameter worker (or a pipeline)
>> n - number of parameters
*/
void
XLeader
::
Add
Job
ParamterWorker
(
int
n
)
void
XLeader
::
AddParamterWorker
(
int
n
)
{
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
XWorker
*
worker
=
new
XWorker
();
...
...
source/train/XLeader.h
查看文件 @
0483b910
...
...
@@ -160,19 +160,19 @@ public:
void
SetInstantRun
(
bool
flag
=
true
);
/* add a number of job workers (given their device ids) */
void
AddJobWorker
(
XModel
*
model
,
int
n
,
int
*
id
s
);
void
AddJobWorker
(
XModel
*
model
,
int
n
,
const
int
*
devID
s
);
/* add a data-collecting worker */
void
Add
Job
CollectWorker
(
DATA_COLLECT_TYPE
mode
=
DATA_COLLECT_P2P
);
void
AddCollectWorker
(
DATA_COLLECT_TYPE
mode
=
DATA_COLLECT_P2P
);
/* add a model-update worker */
void
Add
JobUpdateWorker
(
XModel
*
model
,
XOptimizer
*
optimizer
);
void
Add
UpdateWorker
(
XModel
*
model
);
/* add a data-broadcasting worker */
void
Add
Job
BroadcastWorker
();
void
AddBroadcastWorker
();
/* add a parameter worker (or a pipeline) */
void
Add
Job
ParamterWorker
(
int
n
);
void
AddParamterWorker
(
int
n
);
/* destroy the parameter map (and gradient map) */
void
DestroyParamMap
();
...
...
source/train/XLeaderPS.cpp
查看文件 @
0483b910
...
...
@@ -44,6 +44,25 @@ XLeaderPS::~XLeaderPS()
}
/*
create workers
>> config - configuration
>> model - the model that we run
>> devIDs - device ids of the workers (the first id is for server)
>> jobWorkerNum - number of job workers
*/
void
XLeaderPS
::
MakeAll
(
XConfig
*
config
,
XModel
*
model
,
const
int
*
devIDs
,
const
int
jobWorkerNum
)
{
Init
();
AddJobWorker
(
model
,
jobWorkerNum
,
devIDs
);
AddCollectWorker
();
AddUpdateWorker
(
model
);
AddBroadcastWorker
();
AddParamterWorker
(
model
->
paramNum
);
XLeader
::
MakeAll
(
config
,
model
);
}
/*
run the model (for one time). Basically this is a map-reduce process.
>> config - the configuration
>> dataDistributor - data distributor
...
...
source/train/XLeaderPS.h
查看文件 @
0483b910
...
...
@@ -47,6 +47,9 @@ public:
/* deconstructor */
~
XLeaderPS
();
/* create workers and other stuff used in training */
void
MakeAll
(
XConfig
*
config
,
XModel
*
model
,
const
int
*
devIDs
,
const
int
jobWorkerNum
);
/* run the model and update it (for one time) */
bool
Run
(
XConfig
*
config
,
DataDistributeBase
*
dataDistributor
,
XOptimizer
*
optimizer
);
...
...
source/train/XTrainer.cpp
查看文件 @
0483b910
...
...
@@ -113,14 +113,8 @@ void XTrainer::Run(XConfig * config, DataDistributeBase * dataDistributor,
/* create the server and workers */
XLeaderPS
leader
;
leader
.
Init
();
leader
.
AddJobWorker
(
model
,
jobNum
,
ids
);
leader
.
AddJobCollectWorker
();
leader
.
AddJobUpdateWorker
(
model
,
optimizer
);
leader
.
AddJobBroadcastWorker
();
leader
.
AddJobParamterWorker
(
model
->
paramNum
);
leader
.
MakeAll
(
config
,
model
,
ids
,
jobNum
);
//leader.SetInstantRun();
leader
.
MakeAll
(
config
,
model
);
leader
.
Start
();
/* learning rate scheduler */
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论