Skip to content

[CINN]backend support stmt to expr visitor and run on func body #70739

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

Merged
merged 1 commit into from
Jan 10, 2025

Conversation

Hongqing-work
Copy link
Contributor

PR Category

CINN

PR Types

Improvements

Description

pcard-67164
This PR Improves CINN backend IR in the following part:

  • add stmt to expr default visitor
  • allow expr inplace modify
  • allow func pass only run on func body

Copy link

paddle-bot bot commented Jan 9, 2025

你的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.

Comment on lines +84 to +87
class ExprPass : public Pass<ir::Expr*> {
public:
explicit ExprPass(const std::string& name) : Pass(PassKind::PK_STMT, name) {}
virtual LogicalResult Run(ir::Expr expr) = 0;
virtual LogicalResult Run(ir::Expr* expr) = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Expr本身已经是一个指针类型了,为什么要换成Expr*类型?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

因为现有的对Expr的操作是允许inplace替换的,直接把这个指针改成新的指针了,要兼容这种替换必须用Expr*,否则底层对Expr的Visitor也需要全部升级改造重写允许返回值

Copy link
Contributor

@zyfncg zyfncg Jan 10, 2025

Choose a reason for hiding this comment

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

允许返回值的Visitor的问题是什么?为什么不选用这个方式

Copy link
Contributor Author

Choose a reason for hiding this comment

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

成本问题,需要把对所有Expr的访问再升级改造

@Hongqing-work Hongqing-work merged commit 2b7aac9 into PaddlePaddle:develop Jan 10, 2025
30 of 31 checks passed
@Hongqing-work Hongqing-work deleted the add-expr-visitor branch February 13, 2025 10:19
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.

2 participants