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

[NewIR]Split PaddleDialect and KernelDialect and Implement Layered Compailation #56442

Merged
merged 9 commits into from
Aug 21, 2023

Conversation

Aurelius84
Copy link
Contributor

@Aurelius84 Aurelius84 commented Aug 18, 2023

PR types

Others

PR changes

Others

Description

Pcard-67164

此 PR 为推理库裁剪的前置 PR:#56352

What's New?

1. 拆分了Dialect

  • fluid/ir/dialect 目录文件拆分为paddle_dialectpaddle_kernel_dialect
  • traitinterface 目录移动到 paddle_dialect

2. 独立中间组件

  • 独立编译出 pd_dialect_core,包含 dialect 相关的 type, attribute, trait,interface
image
  • 独立编译出 pd_dialect_op 包含 Operation 定义,但不包含 VJP 的 static 实现,以解决与prim的循环依赖
  • 独立编译出 pd_dialect_api 包含 API C++ 定义,提供给 prim vjp 使用
image
  • 最终编译出 pd_dialect,前三者并外加算子的 VJP static 实现
image

3. 效果

对于与 dialect 平层级的其他组件,可以按需依赖 pd_dialect_core 、或pd_dialect_api、或pd_dialect_op,而不必依赖pd_dialect这个大的target.

对于上层组件,如执行器层面,可以直接依赖 pd_dialect,而不必关心细节 target

NOTE

1. 如何解决 pd_op.cc/.h 对于 prim/vjpprimitive_vjp_experimental 的依赖的?

虽然 pd_op.h 中定义了 vjp 的 static 类方法,但其实不影响每个Op class 的大小。只需要两步处理:

  • 将 vjp static 函数独立一个文件 xxx.cc,在编译pd_dialect_op 时不添加此 xxx.cc 作为 SRCS,则DEPS 中就不会有 primitive_vjp_experimental,此处为第一处「断依赖边」
  • primitive_vjp_experimental 只依赖于pd_dialect_api,所以在编译 pd_dialect 时额外加上 xxx.cc 即可保证对外的算子定义是完整。

@paddle-bot
Copy link

paddle-bot bot commented Aug 18, 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.

@Aurelius84 Aurelius84 requested a review from zhangbo9674 August 21, 2023 02:04
YuanRisheng
YuanRisheng previously approved these changes Aug 21, 2023
Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

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

LGTM

@Aurelius84 Aurelius84 merged commit ca8f955 into PaddlePaddle:develop Aug 21, 2023
@Aurelius84 Aurelius84 deleted the split_dialect branch August 22, 2023 01:42
BeingGod pushed a commit to BeingGod/Paddle that referenced this pull request Sep 9, 2023
…mpailation (PaddlePaddle#56442)

* [NewIR]Split PaddleDialect and KernelDialect and Implement Layered Compailation

* remove ir_core DEPS

* fix header files

* fix conflict

* ignore test_assert UT

* fix code style

* fix UT
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.

5 participants