-
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
[IR]Lower pd op to kernel dialect #54469
[IR]Lower pd op to kernel dialect #54469
Conversation
… add_kernel_dialect
… add_kernel_dialect
… lower_pd_op_to_kernel_dialect
你的PR提交成功,感谢你对开源项目的贡献! |
❌ The PR is not created using PR's template. You can refer to this Demo. |
… lower_pd_op_to_kernel_dialect
… lower_pd_op_to_kernel_dialect
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
phi::Place cpu_place(phi::AllocationType::CPU); | ||
auto ptr = new phi::Allocation(nullptr, 0, cpu_place); | ||
|
||
std::shared_ptr<phi::Allocation> holder(ptr); |
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.
用CPUPlace fake Tensor的话是不就只能选CPU 的 kernel了?
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.
这是之前有个bug,暂时定义了一个 新的cpu place,应该用 type.place()
已经修改
… lower_pd_op_to_kernel_dialect
namespace paddle { | ||
namespace dialect { | ||
|
||
phi::DataType convetIrType2DataType(ir::Type type) { |
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.
这个函数可以和paddle/fluid/ir/dialect/utils.h中的TransToPhiDataType复用
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
… lower_pd_op_to_kernel_dialect
#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" |
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.
这个头文件应该在最前面?
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
} else if (type.isa<ir::Int32Type>()) { | ||
return phi::DataType::INT32; | ||
} else { | ||
PADDLE_THROW("not shupport type for now", type); |
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.
加报错类型
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.
加报错类型
这个代码已经移除
@@ -92,14 +94,11 @@ template <typename T> | |||
void build_context(ir::Operation* op, |
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.
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), |
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.
加报错类型
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
… lower_pd_op_to_kernel_dialect
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
PR types
Others
PR changes
Others
Description
支持将pd op lowering到 kernel dialect, 为后续打通执行器做准备
Other
Pcard-67164