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

[phi] Update graph_send_recv OP #40509

Merged
merged 11 commits into from
Mar 22, 2022

Conversation

DesmonDay
Copy link
Contributor

@DesmonDay DesmonDay commented Mar 14, 2022

PR types

Function optimization

PR changes

OPs

Describe

Add out_size attribute for graph_send_recv. After adding this attribute, we can set the shape of output according to actual need, which can bring us less computation cost. Take PGL GraphSage model on Reddit dataset as an example. After using this out_size attribute, the model computation cost decreased. We can see the following picture for a look.
截屏2022-03-18 上午11 22 56

@paddle-bot-old
Copy link

paddle-bot-old bot commented Mar 14, 2022

✅ This PR's description meets the template requirements!
Please wait for other CI results.

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@DesmonDay DesmonDay changed the title [phi]Update graph_send_recv OP [phi] Update graph_send_recv OP Mar 14, 2022
@PaddlePaddle PaddlePaddle locked and limited conversation to collaborators Mar 14, 2022
@PaddlePaddle PaddlePaddle unlocked this conversation Mar 14, 2022
{"pool_type", "out_size"},
{"Out", "Dst_count"});
}

Copy link
Contributor

Choose a reason for hiding this comment

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

前向的输入和API输入的顺序一致,这里就不用注册

@@ -32,15 +32,23 @@ void GraphSendRecvOpCUDAKernelLaunchHelper(const Context& ctx,
const DenseTensor& src_index,
const DenseTensor& dst_index,
const std::string& pool_type,
int64_t out_size,
DenseTensor* out,
DenseTensor* dst_count = nullptr) {
const int& index_size = src_index.dims()[0];
ctx.template Alloc<T>(out);
T* p_output = out->data<T>();
const auto& src_dims = x.dims();
int64_t memset_size = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

这里有个疑问,这里预置shape的目的是什么了?是否要对设置的out_size与实际的size进行检查了?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

预置shape的目的是希望可以动态减小输出的实际形状。比如我输入X维度为(100, 128),而实际要进行消息传递的结果只有节点编号最大为60,那我可以把输出shape设置为(61, 128),其他结果则动态去掉。

这块设置检查我是想在python端处理。或者也可以在python端函数输入一个flag来确定是否要动态压缩,然后out_size我们直接自己设置为max(dst_index) + 1.

@PaddlePaddle PaddlePaddle locked and limited conversation to collaborators Mar 17, 2022
@PaddlePaddle PaddlePaddle unlocked this conversation Mar 17, 2022
Copy link
Contributor

@wawltor wawltor left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@ZeyuChen ZeyuChen left a comment

Choose a reason for hiding this comment

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

LGTM

@ZeyuChen ZeyuChen merged commit 67b46e4 into PaddlePaddle:develop Mar 22, 2022
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.

3 participants