-
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
[NewIR]refactor pd op to kernel pass #56984
[NewIR]refactor pd op to kernel pass #56984
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
❌ The PR is not created using PR's template. You can refer to this Demo. |
… refactor_pd_op_to_kernel_pass
… refactor_pd_op_to_kernel_pass
… refactor_pd_op_to_kernel_pass
… refactor_pd_op_to_kernel_pass
… refactor_pd_op_to_kernel_pass
@@ -255,7 +101,7 @@ bool NeedFallBackCpu(const pir::Operation* op, | |||
|
|||
phi::Backend GetDstBackend(const std::string& op_name, | |||
phi::Place place, | |||
OpYamlInfoParser* op_yaml_info_parser, | |||
const OpYamlInfoParser* op_yaml_info_parser, |
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.
phi::Backend GetDstBackend(const std::string& op_name,
const phi::Place& place,
const OpYamlInfoParser* op_yaml_info_parser,
const phi::Backend& kernel_def_backend,
size_t input_index) {
对于const的变量,相对于指针类型,我们更推荐引用,应为引用永远是「合法的」。
std::stringstream ss; | ||
prog->Print(ss); | ||
VLOG(2) << "Program after lowering to kernel pass : " << ss.str(); | ||
if (op->name() == "pd_op.load_combine") { |
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.
对于op name 我们更推荐使用 paddle::dialect::LoadCombineOp::name()
。其实更好的方式是: op->isa<LoadCombineOp>()
const pir::Value cur_in, | ||
const std::unordered_map<pir::Value, pir::OpResult>& map_value_pair, | ||
const int index, | ||
const std::string op_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.
const std::string op_name) { | |
const std::string& op_name) { |
std::unordered_map<pir::Value, pir::OpResult>* map_value_pair) { | ||
std::vector<pir::OpResult> vec_inputs; | ||
std::vector<pir::Type> op_output_types; | ||
if (op_item->name() == "builtin.combine") { |
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.
同上
|
||
if (NeedFallBackFromGPUDNN2GPU(op_item, kernel_key)) { | ||
kernel_key.set_backend(phi::Backend::GPU); | ||
pir::OpInfo op_info = ctx->GetRegisteredOpInfo(op_item->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.
pir::OpInfo op_info = ctx->GetRegisteredOpInfo(op_item->name()); | |
pir::OpInfo& op_info = ctx->GetRegisteredOpInfo(op_item->name()); |
std::vector<pir::Type> op_output_types; | ||
auto phi_kernel = phi::KernelFactory::Instance().SelectKernelWithGPUDNN( | ||
kernel_fn_str, kernel_key); | ||
auto args_def = phi_kernel.args_def(); |
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.
auto args_def = phi_kernel.args_def(); | |
auto& args_def = phi_kernel.args_def(); |
auto phi_kernel = phi::KernelFactory::Instance().SelectKernelWithGPUDNN( | ||
kernel_fn_str, kernel_key); | ||
auto args_def = phi_kernel.args_def(); | ||
auto output_defs = args_def.output_defs(); |
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.
auto output_defs = args_def.output_defs(); | |
auto& output_defs = args_def.output_defs(); |
pir::Operation* op_item, | ||
const std::string& kernel_fn_str, | ||
const phi::KernelKey& kernel_key, | ||
const phi::Place place, |
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.
const phi::Place place, | |
const phi::Place& place, |
|
||
// get input args def type | ||
auto args_def = kernel.args_def(); | ||
auto input_defs = args_def.input_defs(); |
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.
auto input_defs = args_def.input_defs(); | |
auto& input_defs = args_def.input_defs(); |
std::unordered_map<pir::Operation*, pir::Operation*>* map_op_pair, | ||
std::unordered_map<pir::Value, pir::OpResult>* map_value_pair) { | ||
bool feed_op_add_shadow_feed = | ||
(op_item->name() == "pd_op.feed") && platform::is_gpu_place(place); |
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.
op_item->isa<FeedOp>()
* refactor pd op to kernel pass * fix bug * update * add code * fix merge bug * fix bug * update * fix bug * polish code
PR types
Others
PR changes
Others
Description
对于pd op to kernel pass 做代码结构的调整,进行模块化划分,方便控制流的接入
Pcard-67164