Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
a1aae040
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
a1aae040
编写于
8月 26, 2021
作者:
W
Wilber
提交者:
GitHub
8月 26, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Inference] Replace unordered_map with map to support subgraph stability (#35147)
上级
e4a8815d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
4 addition
and
4 deletion
+4
-4
paddle/fluid/framework/ir/subgraph_detector.cc
paddle/fluid/framework/ir/subgraph_detector.cc
+3
-3
python/paddle/fluid/tests/unittests/ir/test_ir_fusion_group_pass.py
...dle/fluid/tests/unittests/ir/test_ir_fusion_group_pass.py
+1
-1
未找到文件。
paddle/fluid/framework/ir/subgraph_detector.cc
浏览文件 @
a1aae040
...
@@ -117,7 +117,7 @@ void SubgraphDetector::MarkNodesInsideSubGraph() {
...
@@ -117,7 +117,7 @@ void SubgraphDetector::MarkNodesInsideSubGraph() {
// Use the Union Find(UF) algorithm to find fully connected sub-graphs, if node
// Use the Union Find(UF) algorithm to find fully connected sub-graphs, if node
// a's output is node b, that is a and b is in the same sub-graph. The UF
// a's output is node b, that is a and b is in the same sub-graph. The UF
// algorithm will group them to the same cluster.
// algorithm will group them to the same cluster.
using
node_map_t
=
std
::
unordered_
map
<
int
,
Node
*>
;
using
node_map_t
=
std
::
map
<
int
,
Node
*>
;
// Find the ancestor id of a node.
// Find the ancestor id of a node.
int
UnionFindGetAncestor
(
const
node_map_t
&
node_map
,
size_t
id
)
{
int
UnionFindGetAncestor
(
const
node_map_t
&
node_map
,
size_t
id
)
{
int
tmp
=
id
;
int
tmp
=
id
;
...
@@ -155,7 +155,7 @@ struct BriefNode {
...
@@ -155,7 +155,7 @@ struct BriefNode {
// 3. change all the dst's inputs and outputs
// 3. change all the dst's inputs and outputs
// corresponding inlinks and outlinks to src node.
// corresponding inlinks and outlinks to src node.
// 4. delete all dst's inlinks and outlinks.
// 4. delete all dst's inlinks and outlinks.
void
UnionContractedNodes
(
const
std
::
unordered_
map
<
int
,
BriefNode
*>
&
node_map
,
void
UnionContractedNodes
(
const
std
::
map
<
int
,
BriefNode
*>
&
node_map
,
int
src_id
,
int
dst_id
)
{
int
src_id
,
int
dst_id
)
{
// merge the two adjacent nodes into one node.
// merge the two adjacent nodes into one node.
BriefNode
*
src_node
=
node_map
.
at
(
src_id
);
BriefNode
*
src_node
=
node_map
.
at
(
src_id
);
...
@@ -262,7 +262,7 @@ std::vector<std::vector<Node *>> SubgraphDetector::ExtractSubGraphs() {
...
@@ -262,7 +262,7 @@ std::vector<std::vector<Node *>> SubgraphDetector::ExtractSubGraphs() {
std
::
vector
<
Node
*>
marked_nodes
;
std
::
vector
<
Node
*>
marked_nodes
;
// We use brief_node_map to represent the original graph in order to avoid
// We use brief_node_map to represent the original graph in order to avoid
// changing the original graph.
// changing the original graph.
std
::
unordered_
map
<
int
,
BriefNode
*>
brief_node_map
;
std
::
map
<
int
,
BriefNode
*>
brief_node_map
;
std
::
unordered_set
<
int32_t
>
valid_node_ids
;
std
::
unordered_set
<
int32_t
>
valid_node_ids
;
for
(
auto
*
node
:
graph_
->
Nodes
())
{
for
(
auto
*
node
:
graph_
->
Nodes
())
{
...
...
python/paddle/fluid/tests/unittests/ir/test_ir_fusion_group_pass.py
浏览文件 @
a1aae040
...
@@ -167,7 +167,7 @@ class FusionGroupPassSumTest(FusionGroupPassTest):
...
@@ -167,7 +167,7 @@ class FusionGroupPassSumTest(FusionGroupPassTest):
self
.
append_gradients
(
tmp_3
)
self
.
append_gradients
(
tmp_3
)
self
.
num_fused_ops
=
4
self
.
num_fused_ops
=
3
self
.
fetch_list
=
[
tmp_3
,
self
.
grad
(
tmp_0
)]
self
.
fetch_list
=
[
tmp_3
,
self
.
grad
(
tmp_0
)]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录