Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ShapeAnalysisMgr #59254

Merged
merged 6 commits into from
Nov 27, 2023
Merged

Add ShapeAnalysisMgr #59254

merged 6 commits into from
Nov 27, 2023

Conversation

zhangbopd
Copy link
Contributor

PR types

Others

PR changes

Others

Description

  • 新增 ShapeAnalysisMgr

Other

Pcard-67164

Copy link

paddle-bot bot commented Nov 22, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

class IR_API ShapeAnalysisManager {
public:
static ShapeAnalysisManager& Instance();
ShapeConstraintIRAnalysis& GetShapeConstraintIRAnalysis(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ShapeConstraintIRAnalysis& GetShapeConstraintIRAnalysis(
ShapeConstraintIRAnalysis& Get(

Get是不是就可以了,简洁易用

Copy link
Contributor Author

Choose a reason for hiding this comment

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


private:
ShapeAnalysisManager() {}
std::unordered_map<pir::Program*, ShapeConstraintIRAnalysis> tables_;
Copy link
Contributor

Choose a reason for hiding this comment

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

如之前沟通,在一些单测文件中,可能会包含很多个单测单元。在执行时,由于具有「时间连续性」,可能会出现A 测试单元的program 分配的地址是 0x123,执行完后回收资源;紧接着执行 B 测试单元,给新program分配的地址依旧是 0x123,导致此时从ShapeAnalysisManager查询得到的是A 中对应的 ShapeConstraintIRAnalysis,出现了「错位」,引发各种奇怪的错误

Copy link
Contributor Author

Choose a reason for hiding this comment

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

经过讨论,通过在 program 中 d module op 加 id 解决

Aurelius84
Aurelius84 previously approved these changes Nov 24, 2023
Copy link
Contributor

@Aurelius84 Aurelius84 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@winter-wang winter-wang left a comment

Choose a reason for hiding this comment

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

LGTM

return instance;
}

ShapeConstraintIRAnalysis& ShapeAnalysisManager::Get(pir::Program* program) {
Copy link
Contributor

Choose a reason for hiding this comment

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

参数用 const Progran&会不会更好一点? 不用担心指针为空的风险。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK,下一个PR可以修改一下

@zhangbopd zhangbopd merged commit f4be32e into PaddlePaddle:develop Nov 27, 2023
SecretXV pushed a commit to SecretXV/Paddle that referenced this pull request Nov 28, 2023
* ShapeAnalysisMgr

* singleton

* UT

* Werror=reorder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants