Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Oneflow-Inc
oneflow
提交
a49e738f
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,发现更多精彩内容 >>
提交
a49e738f
编写于
2月 26, 2018
作者:
X
Xinqi Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
split registers into two catagory: splited or cloned
Former-commit-id: bd8f19466c91b5d21d10657371e493fe51ff9bd9
上级
62ad745a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
54 addition
and
8 deletion
+54
-8
oneflow/core/auto_placement/demo_chain_graph.cpp
oneflow/core/auto_placement/demo_chain_graph.cpp
+27
-0
oneflow/core/auto_placement/demo_chain_graph.h
oneflow/core/auto_placement/demo_chain_graph.h
+12
-8
oneflow/core/auto_placement/demo_chain_graph_test.cpp
oneflow/core/auto_placement/demo_chain_graph_test.cpp
+15
-0
未找到文件。
oneflow/core/auto_placement/demo_chain_graph.cpp
浏览文件 @
a49e738f
...
...
@@ -283,5 +283,32 @@ DemoChainGraph::CalcChainRegstId2PathChainNodeIds(
return
ret
;
}
std
::
vector
<
std
::
vector
<
int64_t
>>
DemoChainGraph
::
SplitedRegstIds
()
const
{
std
::
vector
<
std
::
vector
<
int64_t
>>
ret
;
for
(
const
auto
&
regst
:
regsts_
)
{
if
(
!
regst
->
IsRegstCloned
())
{
ret
.
push_back
(
std
::
vector
<
int64_t
>
{
regst
->
chain_regst_id
()});
}
}
return
ret
;
}
std
::
vector
<
std
::
vector
<
int64_t
>>
DemoChainGraph
::
ClonedRegstIds
()
const
{
std
::
vector
<
std
::
vector
<
int64_t
>>
ret
;
for
(
const
auto
&
regst
:
regsts_
)
{
if
(
regst
->
IsRegstCloned
())
{
ret
.
push_back
(
std
::
vector
<
int64_t
>
{
regst
->
chain_regst_id
()});
}
}
return
ret
;
}
bool
DemoChainRegst
::
IsRegstCloned
()
const
{
return
producer
()
->
task_type
()
==
TaskType
::
kMdDiffAcc
||
producer
()
->
task_type
()
==
TaskType
::
kMdUpdt
||
(
consumers
().
size
()
==
1
&&
consumers
().
front
()
->
task_type
()
==
TaskType
::
kMdDiffAcc
);
}
}
// namespace df
}
// namespace oneflow
oneflow/core/auto_placement/demo_chain_graph.h
浏览文件 @
a49e738f
...
...
@@ -24,10 +24,12 @@ class DemoChainRegst final {
void
HandleDiff
(
DemoChainRegst
*
regst
)
const
{
diff_handler_
(
regst
);
}
bool
IsRegstCloned
()
const
;
// Getters
int64_t
chain_regst_id
()
const
{
return
chain_regst_id_
;
}
const
DemoChainNode
*
producer
()
const
{
return
producer_
;
}
const
std
::
unordered_se
t
<
const
DemoChainNode
*>&
consumers
()
const
{
const
std
::
lis
t
<
const
DemoChainNode
*>&
consumers
()
const
{
return
consumers_
;
}
...
...
@@ -38,14 +40,14 @@ class DemoChainRegst final {
diff_handler_
=
diff_handler
;
}
void
AddConsumer
(
const
DemoChainNode
*
consumer
)
{
consumers_
.
insert
(
consumer
);
consumers_
.
push_back
(
consumer
);
}
private:
DemoChainNode
*
producer_
;
int64_t
chain_regst_id_
;
std
::
function
<
void
(
DemoChainRegst
*
)
>
diff_handler_
;
std
::
unordered_se
t
<
const
DemoChainNode
*>
consumers_
;
std
::
lis
t
<
const
DemoChainNode
*>
consumers_
;
};
class
DemoChainEdge
;
...
...
@@ -80,10 +82,9 @@ class DemoChainNode final : public Node<DemoChainNode, DemoChainEdge> {
class
DemoChainNodeSubGraph
final
{
public:
OF_DISALLOW_COPY_AND_MOVE
(
DemoChainNodeSubGraph
);
DemoChainNodeSubGraph
(
const
DemoChainNode
*
start_node
,
const
std
::
unordered_set
<
const
DemoChainNode
*>&
end_nodes
,
const
IsReachablePredicator
&
is_reachable
)
DemoChainNodeSubGraph
(
const
DemoChainNode
*
start_node
,
const
std
::
list
<
const
DemoChainNode
*>&
end_nodes
,
const
IsReachablePredicator
&
is_reachable
)
:
start_node_
(
start_node
),
end_nodes_
(
end_nodes
),
is_reachable_
(
&
is_reachable
)
{}
...
...
@@ -108,7 +109,7 @@ class DemoChainNodeSubGraph final {
bool
IsReachableToEndNode
(
const
DemoChainNode
*
node
)
const
;
const
DemoChainNode
*
start_node_
;
std
::
unordered_se
t
<
const
DemoChainNode
*>
end_nodes_
;
std
::
lis
t
<
const
DemoChainNode
*>
end_nodes_
;
const
IsReachablePredicator
*
is_reachable_
;
};
...
...
@@ -143,6 +144,9 @@ class DemoChainGraph final : public Graph<DemoChainNode, DemoChainEdge> {
[](
int64_t
)
->
double
{
return
1
;
});
}
std
::
vector
<
std
::
vector
<
int64_t
>>
SplitedRegstIds
()
const
;
std
::
vector
<
std
::
vector
<
int64_t
>>
ClonedRegstIds
()
const
;
private:
friend
class
DemoChainGraphBuilder
;
void
InitIsReachable
();
...
...
oneflow/core/auto_placement/demo_chain_graph_test.cpp
浏览文件 @
a49e738f
...
...
@@ -24,6 +24,13 @@ TEST(DemoChainGraph, simple_without_model) {
std
::
vector
<
std
::
vector
<
int64_t
>>
expected_path
{
{
0
,
2
,
3
,
5
},
{
1
,
2
,
3
,
4
},
{
2
,
3
},
{
2
,
3
},
{
3
,
4
},
{
3
,
5
}};
ASSERT_TRUE
(
graph
.
CalcChainRegstId2PathChainNodeIds
()
==
expected_path
);
std
::
vector
<
std
::
vector
<
int64_t
>>
expected_splited_regst_ids
{{
0
},
{
1
},
{
2
},
{
3
},
{
4
},
{
5
}};
ASSERT_TRUE
(
graph
.
SplitedRegstIds
()
==
expected_splited_regst_ids
);
std
::
vector
<
std
::
vector
<
int64_t
>>
expected_cloned_regst_ids
{};
ASSERT_TRUE
(
graph
.
ClonedRegstIds
()
==
expected_cloned_regst_ids
);
}
TEST
(
DemoChainGraph
,
simple_with_model
)
{
...
...
@@ -45,6 +52,14 @@ TEST(DemoChainGraph, simple_with_model) {
std
::
vector
<
std
::
vector
<
int64_t
>>
expected_path
{
{
0
,
1
,
2
,
5
},
{
4
,
1
,
2
},
{
1
,
2
},
{
1
,
2
},
{
2
,
3
},
{
3
,
4
},
{
2
,
5
}};
ASSERT_TRUE
(
graph
.
CalcChainRegstId2PathChainNodeIds
()
==
expected_path
);
std
::
vector
<
std
::
vector
<
int64_t
>>
expected_splited_regst_ids
{
{
0
},
{
2
},
{
3
},
{
6
}};
ASSERT_TRUE
(
graph
.
SplitedRegstIds
()
==
expected_splited_regst_ids
);
std
::
vector
<
std
::
vector
<
int64_t
>>
expected_cloned_regst_ids
{{
1
},
{
4
},
{
5
}};
ASSERT_TRUE
(
graph
.
ClonedRegstIds
()
==
expected_cloned_regst_ids
);
}
}
// namespace test
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录