Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Oneflow-Inc
oneflow
提交
c0e1504d
O
oneflow
项目概览
Oneflow-Inc
/
oneflow
上一次同步 接近 3 年
通知
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,发现更多精彩内容 >>
提交
c0e1504d
编写于
3月 24, 2019
作者:
S
ShawnXuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
branch id OK
Former-commit-id: 3a320ecf4e94cc9d2a26942a9b3375125bdf510a
上级
d28e2ad5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
42 addition
and
5 deletion
+42
-5
oneflow/core/graph/logical_graph.cpp
oneflow/core/graph/logical_graph.cpp
+42
-5
未找到文件。
oneflow/core/graph/logical_graph.cpp
浏览文件 @
c0e1504d
...
...
@@ -223,9 +223,6 @@ void LogicalGraph::SetDepthAndBranchId4Nodes() {
});
}
}
ForEachLogicalNode
<
LogicalNode
>
([
&
](
LogicalNode
*
node
)
{
LOG
(
INFO
)
<<
node
->
op_vec
().
at
(
0
)
->
op_name
()
<<
" "
<<
node
->
depth
();
});
// set branch id for nodes
// 1. get longest path
...
...
@@ -236,12 +233,51 @@ void LogicalGraph::SetDepthAndBranchId4Nodes() {
break
;
}
}
LOG
(
INFO
)
<<
"longest path size "
<<
max_depth
<<
" "
<<
longest_path_stack
.
size
();
// 2. set branch_id = 0 for ops on longest path
HashMap
<
LogicalNode
*
,
bool
>
has_branch_id
;
std
::
queue
<
LogicalNode
*>
queue4branch_id
;
while
(
!
longest_path_stack
.
empty
())
{
LogicalNode
*
node
=
longest_path_stack
.
top
();
longest_path_stack
.
pop
();
LOG
(
INFO
)
<<
node
->
op_vec
().
at
(
0
)
->
op_name
()
<<
" "
<<
node
->
depth
();
// LOG(INFO) << node->op_vec().at(0)->op_name() << " " << node->depth();
has_branch_id
[
node
]
=
true
;
}
// 3. push other nodes to queue
ForEachNode
([
&
](
LogicalNode
*
node
)
{
if
(
!
has_branch_id
[
node
])
queue4branch_id
.
push
(
node
);
});
// 4. every depth has 1 node on longest path
HashMap
<
int
,
int
>
depth2branch_num
;
for
(
int
i
=
0
;
i
<
max_depth
;
++
i
)
depth2branch_num
[
i
+
1
]
=
1
;
// 5. process other nodes
while
(
!
queue4branch_id
.
empty
())
{
LogicalNode
*
cur_node
=
queue4branch_id
.
front
();
queue4branch_id
.
pop
();
bool
should_set_branch_id
=
false
;
ForEachInNode
(
cur_node
,
[
&
](
LogicalNode
*
in_node
)
{
if
(
!
should_set_branch_id
)
should_set_branch_id
=
has_branch_id
[
in_node
];
});
ForEachOutNode
(
cur_node
,
[
&
](
LogicalNode
*
Out_node
)
{
if
(
!
should_set_branch_id
)
should_set_branch_id
=
has_branch_id
[
Out_node
];
});
if
(
should_set_branch_id
)
{
cur_node
->
set_branch_id
(
depth2branch_num
[
cur_node
->
depth
()]);
depth2branch_num
[
cur_node
->
depth
()]
++
;
has_branch_id
[
cur_node
]
=
true
;
}
else
{
queue4branch_id
.
push
(
cur_node
);
}
}
// print depth for check
ForEachLogicalNode
<
LogicalNode
>
([
&
](
LogicalNode
*
node
)
{
LOG
(
INFO
)
<<
node
->
op_vec
().
at
(
0
)
->
op_name
()
<<
" "
<<
node
->
depth
()
<<
" "
<<
node
->
branch_id
();
});
}
template
<
typename
NodeType
>
...
...
@@ -261,6 +297,7 @@ bool LogicalGraph::GetLongestPath(
if
(
!
get_it
)
longest_path_stack
.
pop
();
return
get_it
;
}
void
LogicalGraph
::
FixSharedModelNodes
(
const
HashMap
<
std
::
string
,
std
::
vector
<
LogicalNode
*>>&
op_name2nodes
)
{
HashSet
<
std
::
string
>
all_shared_model_op_names
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录