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

New ir support data transfer #54763

Merged
merged 71 commits into from
Jun 27, 2023

Conversation

phlrain
Copy link
Collaborator

@phlrain phlrain commented Jun 19, 2023

PR types

Others

PR changes

Others

Description

支持data transfer,当前仅支持place的transfer

Others

Pcard-67164

phlrain added 30 commits June 7, 2023 10:28
@paddle-bot
Copy link

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

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


if (op->name() == "pd.uniform") {
// try to process uniform, use shape to determin backend
// TODO(phlrain): shuold support other initilize op
Copy link
Contributor

Choose a reason for hiding this comment

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

这里的TODO意思是我们要单独处理其他的初始化op?

@@ -166,6 +194,7 @@ std::unique_ptr<ir::Program> PdOpLowerToKernelPass(ir::Program* prog) {
phi::Place cpu_place(phi::AllocationType::CPU);

ir::IrContext* ctx = ir::IrContext::Instance();
ctx->GetOrRegisterDialect<paddle::dialect::PaddleDialect>();
Copy link
Contributor

Choose a reason for hiding this comment

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

这里Dialect的MayBe注册逻辑放到这里感觉有点违和?IrContext 是个单例,我们期望是在某个地方统一注册所有的Dialect,还是说在某个模块用到了,就增量注册下?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

我理解是按需添加

paddle::dialect::OpYamlInfoInterface op_info_interface =
(*it)->dyn_cast<paddle::dialect::OpYamlInfoInterface>();
std::string kernel_fn_str;
std::vector<paddle::dialect::OpInputInfo> input_info;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
std::vector<paddle::dialect::OpInputInfo> input_info;
std::vector<paddle::dialect::OpInputInfo> input_infos;


if ((i < input_info.size()) &&
(!input_info[i].is_mutable_attribute) &&
(place != phi::TransToPhiPlace(kernel_key.backend()))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

一般我们建议超过2个的条件join操作,使用一个单独的类似 bool need_transform = xxxx && xxx && xxx; 来提升代码可读性

// build memcopy op
auto copy_kernel_key = kernel_key;
copy_kernel_key.set_backend(phi::Backend::GPU);
std::unordered_map<std::string, ir::Attribute> op1_attribute{
Copy link
Contributor

Choose a reason for hiding this comment

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

这里的op1_attribute为什么带了一个数字1的后缀,有什么特殊含义么?以及下面的 op1 变量命名?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

这是个不好的习惯,我修正下

@@ -118,5 +118,22 @@ void TransDataBackend(const phi::SelectedRows* tensor,
Backend target_backend,
phi::SelectedRows* out);

inline bool NeedTransformPlace(const phi::Place& input,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
inline bool NeedTransformPlace(const phi::Place& input,
inline bool NeedTransformPlace(const phi::Place& src_place,

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

5 participants