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] Refine PhiKernelOp attributes name and delete some unused code #54891

Merged

Conversation

zhangbo9674
Copy link
Contributor

@zhangbo9674 zhangbo9674 commented Jun 26, 2023

PR types

Function optimization

PR changes

APIs

Description

本 pr 完善了 IR 多个遗留问题,包括:

  • 规范 PdOpLowerToKernelPass 中 PhiKernelOp 的定义,属性采用 op_name、kernel_name、kernel_key
  • 完善 BuildScope:修复处理 pd.feed 逻辑中重复向 name_map 插入元素的问题;支持算子输出类型为 VectorType 的场景
  • 规范 infer shape 为 infer meta
  • 添加 elementwise_add 算子定义到 legacy_op.yaml 中,该算子用于支持存在 axis 且不为 -1 的 add 算子(todo:convert 模块适配)
  • 删除 test/cpp/ir/core/phi_kernel_adaptor.h 文件
  • 删除废弃单测 ir_phi_kernel_op_test

Others

Pcard-67164

@paddle-bot
Copy link

paddle-bot bot commented Jun 26, 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.

Copy link
Contributor

@XieYunshen XieYunshen left a comment

Choose a reason for hiding this comment

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

LGTM
单测删除

}

const std::string PhiKernelOp::op_name() {
return operation()
Copy link
Contributor

Choose a reason for hiding this comment

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

这儿直接调用 attributes()就可以。没必要加 operation()吧。后面的类似。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#54944 完成修改

@@ -26,6 +27,9 @@ class PhiKernelOp : public ir::Op<PhiKernelOp> {
static const char *name() { return "phi.kernel"; }
static constexpr uint32_t attributes_num = 3;
static const char *attributes_name[attributes_num];
const std::string op_name();
Copy link
Contributor

Choose a reason for hiding this comment

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

要么返回 const string& ,要么返回string。 返回const string感觉没啥意义。后面类似。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#54944 完成修改

@@ -143,7 +143,7 @@ class {op_name} : public ir::Op<{op_name}{interfaces}{traits}> {{
}}
"""
OP_INFER_SHAPE_TEMPLATE = """
void {op_name}::InferShape( phi::InferMetaContext *infer_meta ) {{
Copy link
Contributor

Choose a reason for hiding this comment

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

InferMeta的生成逻辑是不是可以类似verify, 单独抽一个python文件出来? 感觉op_gen.py里面内容有点太多了。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#54944 完成修改

@zhangbo9674 zhangbo9674 merged commit 9137adb into PaddlePaddle:develop Jun 28, 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.

4 participants