Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Oneflow-Inc
oneflow
提交
87db4f65
O
oneflow
项目概览
Oneflow-Inc
/
oneflow
上一次同步 2 年多
通知
13
Star
2733
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oneflow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
87db4f65
编写于
7月 09, 2017
作者:
L
Liu Guo
提交者:
Jingwu Chen
7月 09, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine copy actors and mode diff actor (#189)
* refine copy actors and model diff acc actor * use set_num_of_not_eord
上级
74acbc55
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
31 deletion
+31
-31
oneflow/core/actor/copy_comm_net_actor.cpp
oneflow/core/actor/copy_comm_net_actor.cpp
+10
-10
oneflow/core/actor/copy_hd_actor.cpp
oneflow/core/actor/copy_hd_actor.cpp
+11
-11
oneflow/core/actor/model_diff_accumulate_actor.cpp
oneflow/core/actor/model_diff_accumulate_actor.cpp
+10
-10
未找到文件。
oneflow/core/actor/copy_comm_net_actor.cpp
浏览文件 @
87db4f65
...
...
@@ -8,6 +8,8 @@ void CopyCommNetActor::Init(const TaskProto& task_proto,
const
ThreadCtx
&
thread_ctx
)
{
Actor
::
Init
(
task_proto
,
thread_ctx
);
CHECK
(
thread_ctx
.
cpu_stream
);
set_num_of_not_eord
(
1
);
mut_num_of_read_empty
()
=
1
;
mut_device_ctx
().
reset
(
new
CpuDeviceCtx
(
thread_ctx
.
cpu_stream
));
OF_SET_MSG_HANDLE
(
&
CopyCommNetActor
::
HandleNormal
);
}
...
...
@@ -15,16 +17,19 @@ void CopyCommNetActor::Init(const TaskProto& task_proto,
int
CopyCommNetActor
::
HandleNormal
(
const
ActorMsg
&
msg
)
{
if
(
msg
.
msg_type
()
==
ActorMsgType
::
kCmdMsg
)
{
CHECK_EQ
(
msg
.
actor_cmd
(),
ActorCmd
::
kEORD
);
OF_SET_MSG_HANDLE
(
&
CopyCommNetActor
::
HandleWaitUntilNoReadableRegst
);
ProcessEord
(
);
}
else
if
(
msg
.
msg_type
()
==
ActorMsgType
::
kRegstMsg
)
{
auto
regst_wp
=
msg
.
regst_wrapper
();
if
(
TryUpdtStateAsProducedRegst
(
regst_wp
->
regst_raw_ptr
())
!=
0
)
{
mut_num_of_read_empty
()
=
0
;
CHECK
(
piece_id2waiting_in_regst_
.
emplace
(
regst_wp
->
piece_id
(),
regst_wp
)
.
second
);
}
else
{
// do nothing
}
ActUntilFail
();
}
ActUntilFail
();
return
0
;
return
msg_handle
()
==
nullptr
;
}
int
CopyCommNetActor
::
HandleWaitUntilNoReadableRegst
(
const
ActorMsg
&
msg
)
{
...
...
@@ -33,13 +38,7 @@ int CopyCommNetActor::HandleWaitUntilNoReadableRegst(const ActorMsg& msg) {
ActUntilFail
();
if
(
piece_id2waiting_in_regst_
.
empty
())
{
AsyncSendEORDMsgForAllProducedRegstDesc
();
if
(
total_reading_cnt
()
==
0
)
{
OF_SET_MSG_HANDLE
(
nullptr
);
return
1
;
}
else
{
OF_SET_MSG_HANDLE
(
&
CopyCommNetActor
::
HandleWaitUntilReadingCntEqualZero
);
return
0
;
}
OF_SET_MSG_HANDLE
(
&
CopyCommNetActor
::
HandleWaitUntilReadingCntEqualZero
);
}
return
0
;
}
...
...
@@ -64,6 +63,7 @@ void CopyCommNetActor::Act() {
});
AsyncSendRegstMsgToProducer
(
regst_wp
);
piece_id2waiting_in_regst_
.
erase
(
next_regst_it
);
mut_num_of_read_empty
()
=
piece_id2waiting_in_regst_
.
empty
();
}
REGISTER_ACTOR
(
kCopyCommNetTask
,
true
,
CopyCommNetActor
);
...
...
oneflow/core/actor/copy_hd_actor.cpp
浏览文件 @
87db4f65
...
...
@@ -10,36 +10,35 @@ void CopyHdActor::Init(const TaskProto& task_proto,
CHECK
(
thread_ctx
.
copy_hd_cuda_stream
);
mut_device_ctx
().
reset
(
new
CudaDeviceCtx
(
thread_ctx
.
copy_hd_cuda_stream
,
nullptr
,
nullptr
));
set_num_of_not_eord
(
1
);
mut_num_of_read_empty
()
=
1
;
OF_SET_MSG_HANDLE
(
&
CopyHdActor
::
HandleNormal
);
}
int
CopyHdActor
::
HandleNormal
(
const
ActorMsg
&
msg
)
{
if
(
msg
.
msg_type
()
==
ActorMsgType
::
kCmdMsg
)
{
CHECK_EQ
(
msg
.
actor_cmd
(),
ActorCmd
::
kEORD
);
OF_SET_MSG_HANDLE
(
&
CopyHdActor
::
HandleWaitUntilNoReadableRegst
);
ProcessEord
(
);
}
else
if
(
msg
.
msg_type
()
==
ActorMsgType
::
kRegstMsg
)
{
if
(
TryUpdtStateAsProducedRegst
(
msg
.
regst_wrapper
()
->
regst_raw_ptr
())
!=
0
)
{
mut_num_of_read_empty
()
=
0
;
waiting_in_regst_
.
push
(
msg
.
regst_wrapper
());
}
else
{
// do nothing
}
ActUntilFail
();
}
ActUntilFail
();
return
0
;
return
msg_handle
()
==
nullptr
;
}
int
CopyHdActor
::
HandleWaitUntilNoReadableRegst
(
const
ActorMsg
&
msg
)
{
CHECK_EQ
(
TryUpdtStateAsProducedRegst
(
msg
.
regst_wrapper
()
->
regst_raw_ptr
()),
0
);
ActUntilFail
();
if
(
waiting_in_regst_
.
empty
())
{
if
(
mut_num_of_read_
empty
())
{
AsyncSendEORDMsgForAllProducedRegstDesc
();
if
(
total_reading_cnt
()
==
0
)
{
OF_SET_MSG_HANDLE
(
nullptr
);
return
1
;
}
else
{
OF_SET_MSG_HANDLE
(
&
CopyHdActor
::
HandleWaitUntilReadingCntEqualZero
);
return
0
;
}
OF_SET_MSG_HANDLE
(
&
CopyHdActor
::
HandleWaitUntilReadingCntEqualZero
);
}
return
0
;
}
...
...
@@ -64,6 +63,7 @@ void CopyHdActor::Act() {
});
AsyncSendRegstMsgToProducer
(
regst_wp
);
waiting_in_regst_
.
pop
();
mut_num_of_read_empty
()
=
waiting_in_regst_
.
empty
();
}
REGISTER_ACTOR
(
kCopyHdTask
,
true
,
CopyHdActor
);
...
...
oneflow/core/actor/model_diff_accumulate_actor.cpp
浏览文件 @
87db4f65
...
...
@@ -14,6 +14,8 @@ void MdDiffAccActor::Init(const TaskProto& task_proto,
cuda_handle_
.
cublas_handle
(),
cuda_handle_
.
cudnn_handle
()));
}
set_num_of_not_eord
(
1
);
mut_num_of_read_empty
()
=
1
;
OF_SET_MSG_HANDLE
(
&
MdDiffAccActor
::
HandleNormal
);
ForEachCurWriteableRegst
(
[
this
](
Regst
*
regst
)
{
model_diff_acc_cnt_
[
regst
]
=
0
;
});
...
...
@@ -22,15 +24,18 @@ void MdDiffAccActor::Init(const TaskProto& task_proto,
int
MdDiffAccActor
::
HandleNormal
(
const
ActorMsg
&
msg
)
{
if
(
msg
.
msg_type
()
==
ActorMsgType
::
kCmdMsg
)
{
CHECK_EQ
(
msg
.
actor_cmd
(),
ActorCmd
::
kEORD
);
OF_SET_MSG_HANDLE
(
&
MdDiffAccActor
::
HandleWaitUntilNoReadableRegst
);
ProcessEord
(
);
}
else
if
(
msg
.
msg_type
()
==
ActorMsgType
::
kRegstMsg
)
{
if
(
TryUpdtStateAsProducedRegst
(
msg
.
regst_wrapper
()
->
regst_raw_ptr
())
!=
0
)
{
mut_num_of_read_empty
()
=
0
;
waiting_in_regst_
.
push
(
msg
.
regst_wrapper
());
}
else
{
// do nothing
}
ActUntilFail
();
}
ActUntilFail
();
return
0
;
return
msg_handle
()
==
nullptr
;
}
int
MdDiffAccActor
::
HandleWaitUntilNoReadableRegst
(
const
ActorMsg
&
msg
)
{
...
...
@@ -39,13 +44,7 @@ int MdDiffAccActor::HandleWaitUntilNoReadableRegst(const ActorMsg& msg) {
ActUntilFail
();
if
(
waiting_in_regst_
.
empty
())
{
AsyncSendEORDMsgForAllProducedRegstDesc
();
if
(
total_reading_cnt
()
==
0
)
{
OF_SET_MSG_HANDLE
(
nullptr
);
return
1
;
}
else
{
OF_SET_MSG_HANDLE
(
&
MdDiffAccActor
::
HandleWaitUntilReadingCntEqualZero
);
return
0
;
}
OF_SET_MSG_HANDLE
(
&
MdDiffAccActor
::
HandleWaitUntilReadingCntEqualZero
);
}
return
0
;
}
...
...
@@ -81,6 +80,7 @@ void MdDiffAccActor::Act() {
});
AsyncSendRegstMsgToProducer
(
regst_wp
);
waiting_in_regst_
.
pop
();
mut_num_of_read_empty
()
=
waiting_in_regst_
.
empty
();
}
}
// namespace oneflow
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录