Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

[Add Pass] CommonSubexpressionElimination #1166

Merged
merged 28 commits into from
Feb 16, 2023

Conversation

zrr1999
Copy link
Member

@zrr1999 zrr1999 commented Jan 30, 2023

修复 #1164 提到的两个随机错误

主要修改 cinn/hlir/pass/common_subexpression_elimination.cc 中的两处

  1. 增加如下代码判断是否候选节点是否与当前节点相同,防止当候选节点被重新加入store_nodes时导致的死循环。(232行)
if (node->id() == candidate_node->id()) continue;
  1. 删除可能导致错误的无用代码(原257行)
out_nodes.erase(node);
out_nodes.insert(candidate_node)

@luotao1
Copy link
Collaborator

luotao1 commented Jan 31, 2023

@zrr1999 请解决下冲突

@zrr1999
Copy link
Member Author

zrr1999 commented Jan 31, 2023

@zrr1999 请解决下冲突

好的,已修复

@SunNy820828449
Copy link
Collaborator

SunNy820828449 commented Feb 1, 2023

另外你这个实现的整体逻辑还是太复杂了,你把这个问题想简单一点,NodeData作为输入,后面链接几个Node,你只需要对后面Node进行去重,然后更新graph就可以了,然后循环对整个图进行这样的处理,不用建立map等这种复杂的数据结构,你再理理思路。

@zrr1999
Copy link
Member Author

zrr1999 commented Feb 1, 2023

另外你这个实现的整体逻辑还是太复杂了,你把这个问题想简单一点,NodeData作为输入,后面链接几个Node,你只需要对后面Node进行去重,然后更新graph就可以了,然后循环对整个图进行这样的处理,不用建立map等这种复杂的数据结构,你再理理思路。

因为我不太确定后期会添加的其他算子,他们的attr是什么样的,如果每个特殊新算子在attr判断等效时直接通过判断算子名称,感觉似乎会更麻烦一些

Copy link
Collaborator

@SunNy820828449 SunNy820828449 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SunNy820828449 SunNy820828449 merged commit a9630cc into PaddlePaddle:develop Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants