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

[IR] Program & Parameter & PaddleDialect #53557

Merged
merged 14 commits into from
May 17, 2023

Conversation

zhangbo9674
Copy link
Contributor

@zhangbo9674 zhangbo9674 commented May 6, 2023

PR types

New features

PR changes

Others

Description

本 PR 主要包括:(1)新 IR 核心数据结构:Program, Parameter, DialectInterface;(2)定义 Paddle Dialect

1. Program

Program 是对模型结构的抽象,包括一个算子列表和参数哈希表,核心内容见:class Program。(在后续高阶特性阶段,会对控制流算子进行详细设计,并引入基本块、闭包、函数等概念,不断完善 Program对计算图的表示能力)

2. Parameter

参数(或权重)沿用 Paddle 之前的做法,将权重单独存储,在模型中通过参数名字对参数值进行获取、保存,核心数据结构见:class Parameter
对于模型中参数的使用,定义了两个内置算子:GetParameterOp、SetParameterOp,见 builtin_op

  • 获取:GetParameterOp 接受一个字符串作为属性,意义是从该模型的哈希表中加载该字符串对应的权重,并将其转换为输出。
  • 更新:SetParameterOp 接受一个字符串作为属性,一个张量类型的输入,没有输出。 表示用该属性和张量组成的键值对更新模型权重哈希表

3. DialectInterface

Dialect Interface 通常适用于想要对一组 attribute/operation/type 进行分析或转换,这些 attribute/operation/type 可以在不同的 dialect 中定义。

这些 Interface 通常涉及所有种类的 Dialect,并且仅用于少数的分析或转换,在这些情况下,在每个 operation 上直接注册接口过于复杂和繁琐,因此定义了 DialecInterface 数据结构,按需注册到对应的 Dialect 中。

本 PR 实现了 Dialect Interface 核心功能,并在 Paddle Dialect 中定义及注册了 ParameterConvertInterface,用于实现 ir::Parameter 与 paddle::framework::Variable 之间的转换。

4. Paddle Dialect

核心内容包括:

Other

Pcard-67164

@paddle-bot
Copy link

paddle-bot bot commented May 6, 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.

@zhangbo9674 zhangbo9674 changed the title [IR] Program & Parameter & Dialect_Interface [IR] Program & Parameter & PaddleDialect May 8, 2023
paddle/ir/operation.cc Outdated Show resolved Hide resolved
Shixiaowei02
Shixiaowei02 previously approved these changes May 10, 2023
Copy link
Contributor

@Shixiaowei02 Shixiaowei02 left a comment

Choose a reason for hiding this comment

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

LGTM

winter-wang
winter-wang previously approved these changes May 11, 2023
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

zhiqiu
zhiqiu previously approved these changes May 15, 2023
Copy link
Contributor

@zhiqiu zhiqiu left a comment

Choose a reason for hiding this comment

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

LGTM

winter-wang
winter-wang previously approved these changes May 15, 2023
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

@zhangbo9674 zhangbo9674 dismissed stale reviews from winter-wang and zhiqiu via 8d199e2 May 16, 2023 02:56
winter-wang
winter-wang previously approved these changes May 16, 2023
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

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

Copy link
Contributor

@zhiqiu zhiqiu 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

@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

@zhangbo9674 zhangbo9674 merged commit 78967ad into PaddlePaddle:develop May 17, 2023
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