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]Lower pd op to kernel dialect #54469

Merged
merged 19 commits into from
Jun 13, 2023

Conversation

phlrain
Copy link
Collaborator

@phlrain phlrain commented Jun 8, 2023

PR types

Others

PR changes

Others

Description

支持将pd op lowering到 kernel dialect, 为后续打通执行器做准备

Other

Pcard-67164

@paddle-bot
Copy link

paddle-bot bot commented Jun 8, 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 Jun 8, 2023

❌ The PR is not created using PR's template. You can refer to this Demo.
Please use PR's template, it helps save our maintainers' time so that more developers get helped.

winter-wang
winter-wang previously approved these changes Jun 9, 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

Comment on lines 122 to 125
phi::Place cpu_place(phi::AllocationType::CPU);
auto ptr = new phi::Allocation(nullptr, 0, cpu_place);

std::shared_ptr<phi::Allocation> holder(ptr);
Copy link
Contributor

Choose a reason for hiding this comment

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

用CPUPlace fake Tensor的话是不就只能选CPU 的 kernel了?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

这是之前有个bug,暂时定义了一个 新的cpu place,应该用 type.place()

已经修改

Shixiaowei02
Shixiaowei02 previously approved these changes Jun 12, 2023
namespace paddle {
namespace dialect {

phi::DataType convetIrType2DataType(ir::Type type) {
Copy link
Contributor

Choose a reason for hiding this comment

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

这个函数可以和paddle/fluid/ir/dialect/utils.h中的TransToPhiDataType复用

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

raindrops2sea
raindrops2sea previously approved these changes Jun 12, 2023
@phlrain phlrain dismissed stale reviews from raindrops2sea and Shixiaowei02 via 2944ebd June 12, 2023 07:53
#include "paddle/fluid/ir/dialect/pd_attribute.h"
#include "paddle/fluid/ir/dialect/utils.h"
#include "paddle/fluid/ir/interface/op_yaml_info.h"
#include "paddle/fluid/ir/pass/pd_op_to_kernel_pass.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

这个头文件应该在最前面?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

} else if (type.isa<ir::Int32Type>()) {
return phi::DataType::INT32;
} else {
PADDLE_THROW("not shupport type for now", type);
Copy link
Contributor

Choose a reason for hiding this comment

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

加报错类型

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

加报错类型

这个代码已经移除

@@ -92,14 +94,11 @@ template <typename T>
void build_context(ir::Operation* op,
Copy link
Contributor

Choose a reason for hiding this comment

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

code style不太统一,公共函数应该都是驼峰式

.dyn_cast<paddle::dialect::AllocatedDenseTensorType>();
kernel_data_type = type.dyn_cast<dialect::DataTypeAttribute>().data();
} else {
PADDLE_ENFORCE_EQ(attr_type_map.count(slot_name),
Copy link
Contributor

Choose a reason for hiding this comment

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

加报错类型

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@zhangbo9674 zhangbo9674 left a comment

Choose a reason for hiding this comment

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

LGTM

@phlrain phlrain merged commit bb848e6 into PaddlePaddle:develop Jun 13, 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.

7 participants