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

[geometric]Add paddle.geometric.send_u_recv API #44580

Merged

Conversation

DesmonDay
Copy link
Contributor

@DesmonDay DesmonDay commented Jul 25, 2022

PR types

Others

PR changes

APIs

Describe

  1. Add deprecated flag for paddle.incubate.graph_send_recv
  2. Add geometric directory, add paddle.geometric.send_u_recv api and corresponding unittests.
  3. Change out_size attribute from int64_t to INTArray, supporting Tensor input and number input.

Note

  1. All related Chinese documents will be revised or added later.

@paddle-bot
Copy link

paddle-bot bot commented Jul 25, 2022

你的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.

@DesmonDay DesmonDay changed the title Add paddle.geometric.send_u_recv Add paddle.geometric.send_u_recv API Jul 25, 2022
@@ -58,6 +58,10 @@ class GraphSendRecvOpMaker : public framework::OpProtoAndCheckerMaker {
"The input tensor with data type float32, float64, int32, int64.");
AddInput("Src_index", "The source index tensor.");
AddInput("Dst_index", "The destination index tensor.");
AddInput("OutSizeTensor",
Copy link
Contributor

Choose a reason for hiding this comment

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

这里的命名为什么要强调是Tensor,看看是否命名是Out_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.

改成Out_size了

@@ -58,6 +58,10 @@ class GraphSendRecvOpMaker : public framework::OpProtoAndCheckerMaker {
"The input tensor with data type float32, float64, int32, int64.");
AddInput("Src_index", "The source index tensor.");
AddInput("Dst_index", "The destination index tensor.");
AddInput("OutSizeTensor",
"(Tensor<int>, optional). The 0th dimension of the output."
Copy link
Contributor

Choose a reason for hiding this comment

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

Tensor, optional

为什么名字要加Tensor,是不是Out_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.

Tensor, optional的写法是参考其他类似的 OP,这里不改动;另外已经改成Out_size了。

@@ -886,7 +886,7 @@
backward : gelu_grad

- api : graph_send_recv
args : (Tensor x, Tensor src_index, Tensor dst_index, str pool_type = "SUM", int64_t out_size = 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

这里求解释一下,为什么不用设置默认值了

Copy link
Contributor Author

Choose a reason for hiding this comment

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

发现可以加默认值,不会报错,改好了。

Copy link
Contributor

Choose a reason for hiding this comment

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

out_size 默认 -1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

个人觉得还是默认0比较好。

const auto& src_dims = x.dims();
int64_t memset_size = 1;
if (out_size <= 0) {
for (int i = 0; i < src_dims.size(); ++i) {
memset_size *= src_dims[i];
}
} else {
// set out dim following out_size.
Copy link
Contributor

Choose a reason for hiding this comment

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

set大写

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}
out->set_dims(phi::make_ddim(dims_));
}
out->set_dims(dims);
Copy link
Contributor

Choose a reason for hiding this comment

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

这里把不定长那个维度设置成-1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

} else {
dst_count->set_dims({out_size});
}
dst_count->set_dims({dims[0]});
Copy link
Contributor

Choose a reason for hiding this comment

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

同上

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

const auto& src_dims = x.dims();
int64_t memset_size = 1;
if (out_size <= 0) {
for (int i = 0; i < src_dims.size(); ++i) {
memset_size *= src_dims[i];
}
} else {
// set out dim following out_size.
Copy link
Contributor

Choose a reason for hiding this comment

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

set -> Set

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,162 @@
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

似乎不用每个文件都要放一个函数,看看能一类放在一个文件里面

Copy link
Contributor Author

@DesmonDay DesmonDay Aug 2, 2022

Choose a reason for hiding this comment

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

把文件名改成了 send_recv.py,用来放置既有 send 也有 recv 过程的函数;后续还会有 send.py,recv.py,用来存放其他类型的函数。

[1, 4, 5]]

Args:
x (Tensor): The input tensor, and the available data type is float32, float64, int32, int64.
Copy link
Contributor

Choose a reason for hiding this comment

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

这里是不是已经支持了float16

Copy link
Contributor Author

Choose a reason for hiding this comment

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

没有支持,在另一个 PR 修改。

# TODO(daisiming): Should we add judgement for out_size: max(dst_index) + 1.

if _in_legacy_dygraph():
out_size = convert_out_size_to_list(out_size)
Copy link
Contributor

Choose a reason for hiding this comment

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

这里需要确认一下是否能动转静

Copy link
Contributor Author

Choose a reason for hiding this comment

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

找留杰确认了,动转静不走这个分支。

@DesmonDay DesmonDay force-pushed the change_graph_send_recv_outsize branch from e7f16f9 to f8fac9a Compare August 2, 2022 06:26
pool_type.upper(), out_size)

check_variable_and_dtype(x, "X", ("float32", "float64", "int32", "int64"),
"send_u_recv")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

这些地方得改成 graph_send_recv,因为 OP 的名字是这个。

@DesmonDay DesmonDay changed the title Add paddle.geometric.send_u_recv API [geometric]Add paddle.geometric.send_u_recv API Aug 8, 2022
return _C_ops.final_state_graph_send_recv(x, src_index, dst_index,
pool_type.upper(), out_size)

check_variable_and_dtype(x, "X", ("float32", "float64", "int32", "int64"),
Copy link
Contributor Author

@DesmonDay DesmonDay Aug 8, 2022

Choose a reason for hiding this comment

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

看起来float16也得加上。在下一个 PR 添加。

@PaddlePaddle PaddlePaddle locked and limited conversation to collaborators Aug 9, 2022
@PaddlePaddle PaddlePaddle unlocked this conversation Aug 9, 2022
@PaddlePaddle PaddlePaddle locked and limited conversation to collaborators Aug 9, 2022
@PaddlePaddle PaddlePaddle unlocked this conversation Aug 9, 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 34b4355 into PaddlePaddle:develop Aug 9, 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.

None yet

4 participants