-
Notifications
You must be signed in to change notification settings - Fork 275
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
【Hackathon 6th No.9】Add cartesian_prod API to Paddle #833
Conversation
PR描述部分有误,达到可以review的状态请及时告知 |
已修改 |
|
||
## 1、相关背景 | ||
|
||
计算给定Tensor的长度为r的组合 |
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.
背景这句不太容易理解,r代表什么?
|
||
目前paddle缺少相关功能实现。 | ||
|
||
# 三、业内方案调研 |
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设计为`paddle.cartesian_prod(*tensors, 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.
API的参数,*tensors
->*args
?
类似paddle.meshgrid(*args, **kargs)
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设计为
paddle.cartesian_prod(*tensors, name)
@Patrick-Star125 经过讨论:API设计为paddle.cartesian_prod(x, name)
,类似 paddle.stack
https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/stack_cn.html#stack
即输入 x 是多个 Tensor,打包成一个list或者tuple传进去
参数 | ||
::::::::: | ||
|
||
- tensors (Tensor|list(Tensor)) - 输入的一个至多个 1-D Tensor,`x` 的数据类型可以是 float32,float64,int32,int64 |
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.
数据类型可以是 float32,float64,int32,int64
其他数据类型能否支持?默认都要支持 fp16/bf16/complex64/complex128
如果是组合API不支持的,需要增强API的功能,如增强paddle.meshgrid
的数据类型
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.
四种数据类型都需要支持吗,这样的话 meshgrid
、flatten
、stack
的支持类型都需要扩充
return paddle.stack(grids, axis=1) | ||
~~~ | ||
|
||
因为 paddle.flatten 并不支持当shape中有0存在的情况,因此对该情况做特殊处理 |
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.
torch.flatten
是否支持当shape中有0存在的情况?
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.
支持,是否需要扩展 paddle.flatten
在该场景下的功能
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.
fp16/bf16/complex64/complex128
四种数据类型都需要,可以扩充meshgrid
、flatten
、stack
的支持类型- 需要扩展
paddle.flatten
在支持shape中有0存在的功能。 - 可以分别提单独的PR来解决上述问题。如果遇到比较大的难度,可以再进行沟通或调整星级🌟。
close due to the following PR is merged: |
新增 cartesian_prod API 设计文档,和 PaddlePaddle/Paddle#62939 同步修改