-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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): parse compute of python dsl #57731
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
5424e3f
to
08ebb0c
Compare
08ebb0c
to
5ca9351
Compare
5ca9351
to
bf34e78
Compare
Sorry to inform you that bf34e78's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
else: | ||
raise Exception("Current Only support compile from CinnLowerLevelIrJit") | ||
|
||
if just_convert: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this code?
It looks like just return llir_func
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later PR will insert code here to convert llir_func to the RunTime Module
of CINN. As follows
if just_convert:
return llir_func
rt_module = llir_to_runtime_module(
llir_func, kwargs["target"], fn.__name__, kwargs["arg_names"]
)
return rt_module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please send me the PR immediately after this PR.
if is_node_parsed_in_schedule(node.value): | ||
return | ||
res = ExprExecutor(self.variables_table.get()).exec(node.value) | ||
if res is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we simply line 244-249?
if res is not None and isinstance(res, ir.Expr):
ir.link_to_parent_context(res)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
拆分新特性: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的变量表。
拆分新特性: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的变量表。
拆分新特性: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的变量表。
PR types
Others
PR changes
Others
Description
Pcard-72423
拆分新特性: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中定义的变量,主要是下面两个功能。