-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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] Python DSL of CINN IR #56393
[CINN] Python DSL of CINN IR #56393
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
✅ This PR's description meets the template requirements! |
483ef5f
to
daaa0d4
Compare
paddle/cinn/ir/ir.cc
Outdated
@@ -268,6 +268,27 @@ Expr For::Make(Var loop_var, | |||
|
|||
return Expr(node); | |||
} | |||
Expr For::Make(Var loop_var, Expr min, Expr extent, Expr body) { | |||
auto node = make_shared<For>(); | |||
CHECK(loop_var.defined()); |
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 add message for CHECK failure. Now we would like every error message can be user-friendly.
Reference: https://github.com/PaddlePaddle/Paddle/wiki/Paddle-Error-Message-Writing-Specification
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
paddle/cinn/ir/ir.cc
Outdated
BindInfo bind_info = BindInfo(); | ||
node->set_bind_info(BindInfo()); | ||
|
||
if (node->is_vectorized()) CHECK(node->vectorize_info().valid()); |
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.
Line 286\287, put any controlled statements inside blocks (i.e. use curly braces).
Reference: https://google.github.io/styleguide/cppguide.html#Formatting_Looping_Branching
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
paddle/cinn/ir/lowered_func.h
Outdated
//! kInput: arg is input | ||
//! kOutput: arg is output | ||
//! kUnknown: arg maybe input or output | ||
enum class IO { kInput = 0, kOutput = 1, kUnknown = 2 }; |
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.
Is IO a good name? Because IO is also related to print\file\hardware\network, can we name it as InputOutputType
? ArgInOutType
or something else?
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.
Indeed, this name is not very good, but so many modules of the current CINN have relied on this IO. It is too troublesome to modify. This is an enum property in ir::Argument, the ambiguity doesn't seem too serious.
paddle/cinn/ir/tensor.cc
Outdated
const std::vector<Expr> &shape, | ||
const std::vector<Expr> &domain, | ||
const std::vector<Var> &reduce_axis) { | ||
CHECK(!name.empty()) << "Tensor name is set empty"; |
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.
"Cannot set empty Tensor name in Tensor::Make"
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
python/cinn/runtime/cinn_jit.py
Outdated
T = TypeVar('T') | ||
|
||
|
||
class CINNLowerLevelIRJIT(Generic[T]): |
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.
CinnLowerLevelIrJit is a better name
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
python/cinn/runtime/data_array.py
Outdated
|
||
|
||
class DataArray: | ||
""" """ |
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 is here empty comment?
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
), f"{node.id} is not defined in context" | ||
return self.local_variables[node.id] | ||
|
||
def visit_BinOp(self, node): |
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.
Is this a temporary function?
I asked because it only handled Add here, and BinOp can potentially not only Load. So I guess it may not be correct?
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.
The code about visit_XXX
will be re-written by new commit
llir_var_expr = ir.Expr(llir_var) | ||
self.set_value(node.target.id, llir_var_expr) | ||
|
||
llir_for_min = ir.Expr(ast_min) |
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.
I guess LLIR For doesn't support step
? Should we report error to users if user has step
in for range?
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.
step
has already been checked in the previous code, almost at line 109.
assert (
len(iter_args) <= 2
), "CINN Low Level IR does not support setting the range step"
Sorry to inform you that da6b637's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
|
liuchao seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
8950eaf
to
f293535
Compare
拆分新特性:CINN Python DSL 单测和e2e测试在主开发PR上,详细见主开发PR描述 #56393 修改了IRCompare,支持对比IR的结构是否相同 封装了一些需要上下文信息才能构建的IR。 封装为IRContext类,开放出C++接口给Python层调用。包括下面的IR
此PR封装了Python DSL需要的C++和Python层的接口 单测和e2e测试见主PR: #56393
Sorry to inform you that 0f87e8c's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
拆分新特性: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的变量表。
拆分新特性:CINN Python DSL, 主PR和单测见:#56393 此PR只负责 解析python dsl中的schedule定义
拆分新特性:CINN Python DSL 单测和e2e测试在主开发PR上,详细见主开发PR描述 PaddlePaddle#56393 修改了IRCompare,支持对比IR的结构是否相同 封装了一些需要上下文信息才能构建的IR。 封装为IRContext类,开放出C++接口给Python层调用。包括下面的IR
此PR封装了Python DSL需要的C++和Python层的接口 单测和e2e测试见主PR: PaddlePaddle#56393
拆分新特性: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中的schedule定义
拆分新特性:CINN Python DSL 单测和e2e测试在主开发PR上,详细见主开发PR描述 PaddlePaddle#56393 修改了IRCompare,支持对比IR的结构是否相同 封装了一些需要上下文信息才能构建的IR。 封装为IRContext类,开放出C++接口给Python层调用。包括下面的IR
此PR封装了Python DSL需要的C++和Python层的接口 单测和e2e测试见主PR: PaddlePaddle#56393
拆分新特性: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中的schedule定义
拆分新特性:CINN Python DSL, 主PR和单测见:#56393 此PR只负责 给python dsl封装cinn ir的Runtime
拆分新特性:CINN Python DSL, 主PR和单测见:PaddlePaddle#56393 此PR只负责 给python dsl封装cinn ir的Runtime
拆分新特性:CINN Python DSL 单测和e2e测试在主开发PR上,详细见主开发PR描述 PaddlePaddle#56393 修改了IRCompare,支持对比IR的结构是否相同 封装了一些需要上下文信息才能构建的IR。 封装为IRContext类,开放出C++接口给Python层调用。包括下面的IR
此PR封装了Python DSL需要的C++和Python层的接口 单测和e2e测试见主PR: PaddlePaddle#56393
拆分新特性: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中的schedule定义
拆分新特性:CINN Python DSL, 主PR和单测见:PaddlePaddle#56393 此PR只负责 给python dsl封装cinn ir的Runtime
PR types
Others
PR changes
Others
Description
Pcard-72423
支持通过Python DSL定制CINN Lower Level IR的主PR。
单测目录:
test/cinn/ir/
e2e测试目录:
test/cinn/runtime
以element wise add为例