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

[SOT][Faster Guard] adapt to faster guard for more variables #69411

Merged
merged 3 commits into from
Nov 15, 2024

Conversation

zrr1999
Copy link
Member

@zrr1999 zrr1999 commented Nov 14, 2024

PR Category

Execute Infrastructure

PR Types

Performance

Description

  • 实现 AttributeMatchGuard and RangeMatchGuard
  • 适配 VariableBase,LayerVariable, ContainerLayerVari

Copy link

paddle-bot bot commented Nov 14, 2024

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

@paddle-bot paddle-bot bot added the contributor External developers label Nov 14, 2024
@zrr1999 zrr1999 changed the title [SOT][Faster Guard] adapt to [SOT][Faster Guard] adapt to faster guard for more variables Nov 14, 2024
Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

LGTMeow 🐾

@@ -148,6 +148,19 @@ class ShapeMatchGuard : public GuardBase {
std::vector<std::optional<int64_t>> expected_;
};

class AttributeMatchGuard : public GuardBase {
Copy link
Member

Choose a reason for hiding this comment

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

AttributeMatchGuard(v, "attr").check(x) 会比 ValueMatchGuard(v).check(x.attr) 快一些是么?

这里我的一个考虑是,如果 IR 表示(表达式树)上包含的是 value_guard_1(x.attr) and value_guard_2(x.attr) 是可以消除公共子表达式的,而 attr_guard_1(x, attr) and attr_guard_2(x, attr) 则是相对来说会更难优化的,这在后续设计时可以考虑下

如果 AttributeMatchGuard 是有优化的,这里可以考虑在最开始 build 的 Guard 树上不体现 AttributeMatchGuard,以确保公共子表达式消除等优化是可以作用的,最后通过 Pass 将 value_guard_1(x.attr) fuse 成 attr_guard_1(x, attr)

有点组合算子的意思,IR 上最开始生成的以及后续 Pass 处理的是基础 Guard,经过图变换、融合生成高性能的组合 Guard

@zrr1999 zrr1999 changed the title [SOT][Faster Guard] adapt to faster guard for more variables [SOT][3.13][Faster Guard] adapt to faster guard for more variables Nov 15, 2024
@SigureMo SigureMo changed the title [SOT][3.13][Faster Guard] adapt to faster guard for more variables [SOT][Faster Guard] adapt to faster guard for more variables Nov 15, 2024
@SigureMo SigureMo merged commit 3030a46 into PaddlePaddle:develop Nov 15, 2024
27 of 28 checks passed
@zrr1999 zrr1999 deleted the faster_guard branch November 24, 2024 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants