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

cinn(py-dsl): add ir context used in python dsl #57515

Merged
merged 3 commits into from Sep 22, 2023

Conversation

6clc
Copy link
Contributor

@6clc 6clc commented Sep 20, 2023

PR types

Others

PR changes

Others

Description

Pcard-72423

拆分新特性:CINN Python DSL
单测和e2e测试在主开发PR上,详细见主开发PR描述 #56393

  1. 修改了IRCompare,支持对比IR的结构是否相同
  2. 封装了一些需要上下文信息才能构建的IR。 封装为IRContext类,开放出C++接口给Python层调用。包括下面的IR
ScheduleBlockContext
ForContextNode
LowerFuncContextNode
IfContextNode
ThenContextNode
ElseContextNode

@paddle-bot
Copy link

paddle-bot bot commented Sep 20, 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.

@paddle-bot
Copy link

paddle-bot bot commented Sep 20, 2023

✅ This PR's description meets the template requirements!
Please wait for other CI results.

paddle/cinn/ir/utils/ir_compare.h Outdated Show resolved Hide resolved
paddle/cinn/pybind/ir/ir_context.h Show resolved Hide resolved
@@ -54,6 +54,8 @@ void Module::Builder::Clear() {
module_->submodules.clear();
}

Target::Arch Module::Builder::GetTarget() { return module_->target.arch; }
Copy link
Member

Choose a reason for hiding this comment

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

GetTaget or GetTargetArch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

static constexpr char* __type_info__ = "IRContextNode";
};

class IRContext {
Copy link
Member

Choose a reason for hiding this comment

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

Add comment about the IRContext

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

@zhhsplendid zhhsplendid left a comment

Choose a reason for hiding this comment

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

LGTM

@zhhsplendid zhhsplendid merged commit 92f9249 into PaddlePaddle:develop Sep 22, 2023
27 checks passed
zhhsplendid pushed a commit that referenced this pull request Oct 9, 2023
拆分新特性:CINN Python DSL, 主PR和单测见:#56393

此PR只负责 解析python dsl中的compute定义

1. 装饰器@to_cinn_ir封装cinn的function kernel:

CinnLowerLevelIrJit支持从Jit运行时中数据类型、target类型、python ast。后续解析compute的信息都会从CinnLowerLevelIrJit这个类中获取。

CinnLowerLevelIrJit也支持静态获取上述信息,通过python的annotation来填充。

2. compute 语义解析
将整个AST分为三种类型:

stmts: Function, For, If, With ,对应封装上下文IR的PR: #57515

Assign: 表达式"lhs = rhs"的类型,Assign类型构成了stmts。
python/cinn/compiler/expr_executor.py中的exec_expr方法将rhs解析成cinn ir Expr
python/cinn/compiler/expr_executor.py中的exec_assign方法,将lhs=rhs表达的assign语义存储在局部变量表中。

Expr:组成Assign中的rhs。

3. 变量管理

python/cinn/compiler/utils.py中的class VariableTable:用于管理Python DSL中定义的变量,主要是下面两个功能。

每次Enter新的Context,会复制当前的变量表
每次Exit Context,会删除当前Context增加的变量,恢复上一轮Context的变量表。
Frida-a pushed a commit to Frida-a/Paddle that referenced this pull request Oct 14, 2023
拆分新特性:CINN Python DSL
单测和e2e测试在主开发PR上,详细见主开发PR描述 PaddlePaddle#56393

修改了IRCompare,支持对比IR的结构是否相同
封装了一些需要上下文信息才能构建的IR。 封装为IRContext类,开放出C++接口给Python层调用。包括下面的IR
Frida-a pushed a commit to Frida-a/Paddle that referenced this pull request Oct 14, 2023
拆分新特性:CINN Python DSL, 主PR和单测见:PaddlePaddle#56393

此PR只负责 解析python dsl中的compute定义

1. 装饰器@to_cinn_ir封装cinn的function kernel:

CinnLowerLevelIrJit支持从Jit运行时中数据类型、target类型、python ast。后续解析compute的信息都会从CinnLowerLevelIrJit这个类中获取。

CinnLowerLevelIrJit也支持静态获取上述信息,通过python的annotation来填充。

2. compute 语义解析
将整个AST分为三种类型:

stmts: Function, For, If, With ,对应封装上下文IR的PR: PaddlePaddle#57515

Assign: 表达式"lhs = rhs"的类型,Assign类型构成了stmts。
python/cinn/compiler/expr_executor.py中的exec_expr方法将rhs解析成cinn ir Expr
python/cinn/compiler/expr_executor.py中的exec_assign方法,将lhs=rhs表达的assign语义存储在局部变量表中。

Expr:组成Assign中的rhs。

3. 变量管理

python/cinn/compiler/utils.py中的class VariableTable:用于管理Python DSL中定义的变量,主要是下面两个功能。

每次Enter新的Context,会复制当前的变量表
每次Exit Context,会删除当前Context增加的变量,恢复上一轮Context的变量表。
jiahy0825 pushed a commit to jiahy0825/Paddle that referenced this pull request Oct 16, 2023
拆分新特性:CINN Python DSL
单测和e2e测试在主开发PR上,详细见主开发PR描述 PaddlePaddle#56393

修改了IRCompare,支持对比IR的结构是否相同
封装了一些需要上下文信息才能构建的IR。 封装为IRContext类,开放出C++接口给Python层调用。包括下面的IR
jiahy0825 pushed a commit to jiahy0825/Paddle that referenced this pull request Oct 16, 2023
拆分新特性:CINN Python DSL, 主PR和单测见:PaddlePaddle#56393

此PR只负责 解析python dsl中的compute定义

1. 装饰器@to_cinn_ir封装cinn的function kernel:

CinnLowerLevelIrJit支持从Jit运行时中数据类型、target类型、python ast。后续解析compute的信息都会从CinnLowerLevelIrJit这个类中获取。

CinnLowerLevelIrJit也支持静态获取上述信息,通过python的annotation来填充。

2. compute 语义解析
将整个AST分为三种类型:

stmts: Function, For, If, With ,对应封装上下文IR的PR: PaddlePaddle#57515

Assign: 表达式"lhs = rhs"的类型,Assign类型构成了stmts。
python/cinn/compiler/expr_executor.py中的exec_expr方法将rhs解析成cinn ir Expr
python/cinn/compiler/expr_executor.py中的exec_assign方法,将lhs=rhs表达的assign语义存储在局部变量表中。

Expr:组成Assign中的rhs。

3. 变量管理

python/cinn/compiler/utils.py中的class VariableTable:用于管理Python DSL中定义的变量,主要是下面两个功能。

每次Enter新的Context,会复制当前的变量表
每次Exit Context,会删除当前Context增加的变量,恢复上一轮Context的变量表。
danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 2023
拆分新特性:CINN Python DSL
单测和e2e测试在主开发PR上,详细见主开发PR描述 PaddlePaddle#56393

修改了IRCompare,支持对比IR的结构是否相同
封装了一些需要上下文信息才能构建的IR。 封装为IRContext类,开放出C++接口给Python层调用。包括下面的IR
danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 2023
拆分新特性:CINN Python DSL, 主PR和单测见:PaddlePaddle#56393

此PR只负责 解析python dsl中的compute定义

1. 装饰器@to_cinn_ir封装cinn的function kernel:

CinnLowerLevelIrJit支持从Jit运行时中数据类型、target类型、python ast。后续解析compute的信息都会从CinnLowerLevelIrJit这个类中获取。

CinnLowerLevelIrJit也支持静态获取上述信息,通过python的annotation来填充。

2. compute 语义解析
将整个AST分为三种类型:

stmts: Function, For, If, With ,对应封装上下文IR的PR: PaddlePaddle#57515

Assign: 表达式"lhs = rhs"的类型,Assign类型构成了stmts。
python/cinn/compiler/expr_executor.py中的exec_expr方法将rhs解析成cinn ir Expr
python/cinn/compiler/expr_executor.py中的exec_assign方法,将lhs=rhs表达的assign语义存储在局部变量表中。

Expr:组成Assign中的rhs。

3. 变量管理

python/cinn/compiler/utils.py中的class VariableTable:用于管理Python DSL中定义的变量,主要是下面两个功能。

每次Enter新的Context,会复制当前的变量表
每次Exit Context,会删除当前Context增加的变量,恢复上一轮Context的变量表。
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.

None yet

2 participants