-
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
[phi] Update graph_send_recv OP #40509
[phi] Update graph_send_recv OP #40509
Conversation
✅ This PR's description meets the template requirements! |
Thanks for your contribution! |
{"pool_type", "out_size"}, | ||
{"Out", "Dst_count"}); | ||
} | ||
|
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.
前向的输入和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; |
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.
这里有个疑问,这里预置shape的目的是什么了?是否要对设置的out_size与实际的size进行检查了?
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.
预置shape的目的是希望可以动态减小输出的实际形状。比如我输入X维度为(100, 128),而实际要进行消息传递的结果只有节点编号最大为60,那我可以把输出shape设置为(61, 128),其他结果则动态去掉。
这块设置检查我是想在python端处理。或者也可以在python端函数输入一个flag来确定是否要动态压缩,然后out_size我们直接自己设置为max(dst_index) + 1.
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
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
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
![截屏2022-03-18 上午11 22 56](https://user-images.githubusercontent.com/20554008/158931589-fa1e525c-5f55-4b8b-94bb-9f953a6b57d0.png)
out_size
attribute, the model computation cost decreased. We can see the following picture for a look.